From 9df73e99b9b64083bd73c361c528cbdcfe08d132 Mon Sep 17 00:00:00 2001 From: Brandon Myers Date: Sat, 12 Apr 2014 16:20:09 -0700 Subject: [PATCH 1/3] probably fix issue #157 --- system/ParallelLoop.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/ParallelLoop.hpp b/system/ParallelLoop.hpp index c20106f42..d9982ef37 100644 --- a/system/ParallelLoop.hpp +++ b/system/ParallelLoop.hpp @@ -35,6 +35,8 @@ #include "Collective.hpp" #include "function_traits.hpp" +#include + /// 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; From b8e8e70c62413db71b00716aaeeba57271b8e71b Mon Sep 17 00:00:00 2001 From: Brandon Myers Date: Sun, 13 Apr 2014 21:12:04 -0700 Subject: [PATCH 2/3] failing test --- system/New_loop_tests.cpp | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/system/New_loop_tests.cpp b/system/New_loop_tests.cpp index 3903630df..a333da3e3 100644 --- a/system/New_loop_tests.cpp +++ b/system/New_loop_tests.cpp @@ -125,6 +125,50 @@ void test_forall_here() { } +struct OneBlock { + int64_t x; +} GRAPPA_BLOCK_ALIGNED; +struct TwoBlocks { + char stuff[BLOCK_SIZE-1]; // test strange alignment + 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 = 23; + auto arr = global_alloc(c); + // initialize + forall(arr, c, [] (int64_t i, OneBlock& two) { + two.a = 10*i; + }); + + // check without forall + for (int i=0; i(c); + // initialize + forall(arr, c, [] (int64_t i, TwoBlocks& two) { + two.a = 10*i; + two.b = 1000*i; + }); + + // check without forall + for (int i=0; i Date: Mon, 14 Apr 2014 07:04:20 -0700 Subject: [PATCH 3/3] testing more things (wip) --- system/New_loop_tests.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/system/New_loop_tests.cpp b/system/New_loop_tests.cpp index a333da3e3..ddffa05d5 100644 --- a/system/New_loop_tests.cpp +++ b/system/New_loop_tests.cpp @@ -129,18 +129,19 @@ struct OneBlock { int64_t x; } GRAPPA_BLOCK_ALIGNED; struct TwoBlocks { - char stuff[BLOCK_SIZE-1]; // test strange alignment + 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 = 23; + size_t c = 7; auto arr = global_alloc(c); // initialize forall(arr, c, [] (int64_t i, OneBlock& two) { - two.a = 10*i; + two.x = 10*i; }); // check without forall @@ -150,19 +151,32 @@ void test_forall_large_data() { } } { - size_t c = 23; + size_t c = 7; auto arr = global_alloc(c); // initialize +/* forall(arr, c, [] (int64_t i, TwoBlocks& two) { + two.y = i; two.a = 10*i; - two.b = 1000*i; + two.b = 100*i; + two.c = 1000*i; + two.d = 10000*i; }); + */ + + for (int i=0; i