From 939af32e692f4c2642cd7b4b8a61449fb3da7e15 Mon Sep 17 00:00:00 2001 From: aquileia Date: Tue, 24 Jun 2014 06:01:13 +0200 Subject: [PATCH] Fix openMP build Tested to compile on VC12 with openMP activated. With two loops over the same unit list, 'guided' scheduling (as done before the second loop was introduced) isn't optimal. [ci skip] --- src/display.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index d0b9af0ae9e3..f60b505fd327 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -3098,13 +3098,12 @@ void display::invalidate_animations() open_mp_list.push_back(u); } - #pragma omp parallel shared(chunks) - { - #pragma omp for - for(size_t i = 0; i < open_mp_list.size(); ++i) - open_mp_list[i]->anim_comp().refresh(); + // openMP can't iterate over size_t + const int omp_iterations = open_mp_list.size(); + #pragma omp parallel for shared(open_mp_list) + for (int i = 0; i < omp_iterations; i++) { + open_mp_list[i]->anim_comp().refresh(); } -} #endif @@ -3119,14 +3118,12 @@ void display::invalidate_animations() new_inval |= u->anim_comp().invalidate(*this); } #else - #pragma omp parallel shared(chunks) - { - #pragma omp for - for(size_t i = 0; i < open_mp_list.size(); ++i) + #pragma omp parallel for reduction(|:new_inval) shared(open_mp_list) + for (int i = 0; i < omp_iterations; i++) { new_inval |= open_mp_list[i]->anim_comp().invalidate(*this); } #endif - }while(new_inval); + } while (new_inval); } void display::add_arrow(arrow& arrow)