diff --git a/system/New_loop_tests.cpp b/system/New_loop_tests.cpp index 3903630df..ddffa05d5 100644 --- a/system/New_loop_tests.cpp +++ b/system/New_loop_tests.cpp @@ -125,6 +125,64 @@ void test_forall_here() { } +struct OneBlock { + int64_t x; +} GRAPPA_BLOCK_ALIGNED; +struct TwoBlocks { + int64_t y; + char stuff[BLOCK_SIZE-sizeof(int64_t)]; + int64_t a,b,c,d; +} GRAPPA_BLOCK_ALIGNED; + +void test_forall_large_data() { + BOOST_MESSAGE("Testing forall on array of large structs"); + { + size_t c = 7; + auto arr = global_alloc(c); + // initialize + forall(arr, c, [] (int64_t i, OneBlock& two) { + two.x = 10*i; + }); + + // check without forall + for (int i=0; i(c); + // initialize +/* + forall(arr, c, [] (int64_t i, TwoBlocks& two) { + two.y = i; + two.a = 10*i; + two.b = 100*i; + two.c = 1000*i; + two.d = 10000*i; + }); + */ + + for (int i=0; i + /// Flag: loop_threshold /// /// Iterations of `forall` loops *may* be run in parallel. A complete loop is decomposed into @@ -333,7 +335,7 @@ namespace Grappa { auto end = base+nelem; if (nelem > 0) { fc = 1; } - size_t block_elems = block_size / sizeof(T); + size_t block_elems = std::max(1, block_size / sizeof(T)); int64_t nfirstcore = base.block_max() - base; int64_t n = nelem - nfirstcore;