Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a Vivaldi network model, coded live during SUD'10 ;)
[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 # 58 "/home/navarrop/Developments/simgrid/src/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   //INFO2("Thread%d: Add 100 to %d",rank,*(int*)data);
20   *(int*)data +=100;
21 }
22
23 XBT_TEST_UNIT("dopar", test_dynar_dopar, "do parallel on dynars of integers")
24 {
25   xbt_dynar_t d;
26   int i, cpt;
27   unsigned int cursor;
28
29   xbt_test_add1("==== Push %d int, add 100 to each of them in parallel and check the results", NB_ELEM);
30   d = xbt_dynar_new(sizeof(int), NULL);
31   for (cpt = 0; cpt < NB_ELEM; cpt++) {
32     xbt_dynar_push_as(d, int, cpt);     /* This is faster (and possible only with scalars) */
33     xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
34   }
35   xbt_dynar_dopar(d,add100);
36   cpt = 100;
37   xbt_dynar_foreach(d, cursor, i) {
38     xbt_test_assert2(i == cpt,
39                      "The retrieved value is not the expected one (%d!=%d)",
40                      i, cpt);
41     cpt++;
42   }
43   xbt_dynar_free(&d);
44 }
45
46 /*******************************/
47 /* GENERATED FILE, DO NOT EDIT */
48 /*******************************/
49