From: Tom Cornebize Date: Thu, 6 Apr 2017 08:03:12 +0000 (+0200) Subject: More complex test. X-Git-Tag: v3.16~353^2~1^2~12 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/66e1b04b3ca7d398c5edac42ff58b1695fcde97b?hp=6371a022a209c56be6442c83aa80a267fa4632d7 More complex test. --- diff --git a/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c b/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c index 6a21001c17..aeac4b81b3 100644 --- a/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c +++ b/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c @@ -4,31 +4,36 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -/* This example should be instructive to learn about SMPI_SHARED_CALL */ - #include #include #include #include -// Return the number of occurences of the given value between buf[start] and buf[stop-1]. +// Set the elements between buf[start] and buf[stop-1] to (i+value)%256 +void set(uint8_t *buf, int start, int stop, uint8_t value) { + for(int i = start; i < stop; i++) { + buf[i] = (i+value)%256; + } +} + +// Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1]. int count_all(uint8_t *buf, int start, int stop, uint8_t value) { int occ = 0; for(int i = start ; i < stop ; i++) { - if(buf[i] == value) { + if(buf[i] == (i+value)%256) { occ ++; } } return occ; } -// Return true iff the values from buf[start] to buf[stop-1] are all equal to value. +// Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256. int check_all(uint8_t *buf, int start, int stop, uint8_t value) { int occ = count_all(buf, start, stop, value); return occ == stop-start; } -// Return true iff "enough" occurences of the given value are between buf[start] and buf[stop-1]. +// Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1]. int check_enough(uint8_t *buf, int start, int stop, uint8_t value) { int page_size = 0x1000; int size = stop-start; @@ -58,7 +63,7 @@ int main(int argc, char *argv[]) //Let's Allocate a shared memory buffer uint8_t *buf; buf = SMPI_PARTIAL_SHARED_MALLOC(mem_size, shared_blocks, nb_blocks); - memset(buf, 0, mem_size); + set(buf, 0, mem_size, 0); MPI_Barrier(MPI_COMM_WORLD); // Process 0 write in shared blocks @@ -66,7 +71,7 @@ int main(int argc, char *argv[]) for(int i = 0; i < nb_blocks; i++) { int start = shared_blocks[2*i]; int stop = shared_blocks[2*i+1]; - memset(buf+start, 42, stop-start); + set(buf, start, stop, 42); } } MPI_Barrier(MPI_COMM_WORLD);