Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtschump committed Jul 12, 2023
2 parents a7ff63a + e777f2e commit ff183f8
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -16954,7 +16954,7 @@ namespace cimg_library {

unsigned int mempos, mem_img_median, mem_img_norm, mem_img_index, debug_indent,
result_dim, result_end_dim, break_type, constcache_size;
bool is_parallelizable, is_noncritical_run, is_end_code, is_fill, return_new_comp, need_input_copy;
bool is_parallelizable, is_noncritical_run, is_end_code, is_fill, need_input_copy, return_new_comp;
double *result, *result_end;
cimg_uint64 rng;
const char *const calling_function, *s_op, *ss_op;
Expand Down Expand Up @@ -17131,7 +17131,8 @@ namespace cimg_library {
imgin(CImg<T>::const_empty()),imgout(CImg<T>::empty()),imglist(CImgList<T>::empty()),
img_stats(_img_stats),list_stats(_list_stats),list_median(_list_median),list_norm(_list_norm),debug_indent(0),
result_dim(0),result_end_dim(0),break_type(0),constcache_size(0),is_parallelizable(true),
is_noncritical_run(false),is_fill(false),need_input_copy(false),result_end(0),rng(0),calling_function(0) {
is_noncritical_run(false),is_fill(false),need_input_copy(false),
result_end(0),rng(0),calling_function(0) {
mem.assign(1 + _cimg_mp_slot_c,1,1,1,0); // Allow to skip 'is_empty?' test in operator()()
result = mem._data;
}
Expand Down Expand Up @@ -21895,9 +21896,7 @@ namespace cimg_library {
#ifdef cimg_mp_func_run
if (!std::strncmp(ss,"run(",4)) { // Run external command
_cimg_mp_op("Function 'run()'");
if (!is_inside_critical && !is_inside_begin && !is_inside_end) {
is_parallelizable = false; is_noncritical_run = true;
}
if (!is_inside_critical && !is_inside_begin && !is_inside_end) is_noncritical_run = true;
CImg<ulongT>::vector((ulongT)mp_run,0,0).move_to(l_opcode);
pos = 1;
for (s = ss4; s<se; ++s) {
Expand Down Expand Up @@ -27312,7 +27311,12 @@ namespace cimg_library {
}
CImg(1,1,1,1,0).move_to(_str);
CImg<charT> str = _str>'x';
cimg_mp_func_run(str._data);
#if cimg_use_openmp==0
const unsigned int n_thread = 0;
#else
const unsigned int n_thread = omp_get_thread_num();
#endif
cimg_mp_func_run(str._data,n_thread && mp.is_noncritical_run);
return cimg::type<double>::nan();
}
#endif
Expand Down Expand Up @@ -32747,16 +32751,8 @@ namespace cimg_library {
}

bool is_parallelizable = false;
#if cimg_use_openmp!=0
if (mp.is_noncritical_run && (*expression=='*' || *expression==':'))
throw CImgArgumentException(_cimg_instance
"%s(): Cannot evaluate expression '%s' in parallel, "
"as 'run()' is used outside a 'critical()' section.",
cimg_instance,calling_function,expression);
cimg_openmp_if(!mp.is_noncritical_run &&
(*expression=='*' || *expression==':' || (mp.is_parallelizable && M1>=2 && M1*M2>=16)))
cimg_openmp_if(*expression=='*' || *expression==':' || (mp.is_parallelizable && M1>=2 && M1*M2>=16))
is_parallelizable = true;
#endif

if (mp.result_dim) { // Vector-valued expression
const unsigned int N = std::min(mp.result_dim,_spectrum);
Expand Down

0 comments on commit ff183f8

Please sign in to comment.