Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert svn logs into ChangeLog (up to r7858 for now)
[simgrid.git] / src / xbt_synchro_unit.c
1 /*******************************/
2 /* GENERATED FILE, DO NOT EDIT */
3 /*******************************/
4
5 #include <stdio.h>
6 #include "xbt.h"
7 /*******************************/
8 /* GENERATED FILE, DO NOT EDIT */
9 /*******************************/
10
11 #line 66 "xbt/xbt_synchro.c" 
12 #define NB_ELEM 50
13 #include "xbt/synchro.h"
14
15 XBT_LOG_EXTERNAL_CATEGORY(xbt_dyn);
16 XBT_LOG_DEFAULT_CATEGORY(xbt_dyn);
17
18 static void add100(int rank, void *data)
19 {
20   //INFO2("Thread%d: Add 100 to %d",rank,*(int*)data);
21   *(int *) data += 100;
22 }
23
24 XBT_TEST_UNIT("dopar", test_dynar_dopar, "do parallel on dynars of integers")
25 {
26   xbt_dynar_t d;
27   int i, cpt;
28   unsigned int cursor;
29
30   xbt_test_add1
31       ("==== Push %d int, add 100 to each of them in parallel and check the results",
32        NB_ELEM);
33   d = xbt_dynar_new(sizeof(int), NULL);
34   for (cpt = 0; cpt < NB_ELEM; cpt++) {
35     xbt_dynar_push_as(d, int, cpt);     /* This is faster (and possible only with scalars) */
36     xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
37   }
38   xbt_dynar_dopar(d, add100);
39   cpt = 100;
40   xbt_dynar_foreach(d, cursor, i) {
41     xbt_test_assert2(i == cpt,
42                      "The retrieved value is not the expected one (%d!=%d)",
43                      i, cpt);
44     cpt++;
45   }
46   xbt_dynar_free(&d);
47 }
48
49 /*******************************/
50 /* GENERATED FILE, DO NOT EDIT */
51 /*******************************/
52