@@ -205,13 +205,20 @@ enum {FALSE_WIN = 0};
205205#include <utility>
206206#endif
207207
208- // Convenient macro to define pragma.
208+ // Portable macro to define ' pragma' .
209209#ifdef _MSC_VER
210210#define cimg_pragma(x) __pragma(x)
211211#else
212212#define cimg_pragma(x) _Pragma(#x)
213213#endif
214214
215+ // Portable macro to define '__restrict'.
216+ #if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) || defined(__INTEL_COMPILER)
217+ #define cimg_restrict __restrict
218+ #else
219+ #define cimg_restrict
220+ #endif
221+
215222// Define own datatypes to ensure portability.
216223// ( 'sizeof(cimg_ulong/cimg_long) = sizeof(void*)' ).
217224#define cimg_uint8 unsigned char
@@ -34857,8 +34864,10 @@ namespace cimg_library {
3485734864 if (mode&4) cimg_rofX(*this,x) mp(x,y,z,0);
3485834865 else cimg_rofX(*this,x) {
3485934866 mp(x,y,z,0,res._data);
34860- const double *ptrs = res._data;
34861- T *_ptrd = ptrd--; for (unsigned int n = N; n>0; --n) { *_ptrd = (T)(*ptrs++); _ptrd+=whd; }
34867+ const double *const cimg_restrict ptrs = res._data;
34868+ T *cimg_restrict _ptrd = ptrd--;
34869+ cimg_pragma_openmp(simd)
34870+ for (unsigned int n = 0; n<N; ++n) _ptrd[n*whd] = (T)ptrs[n];
3486234871 }
3486334872 }
3486434873 mp.end_t();
@@ -34871,8 +34880,10 @@ namespace cimg_library {
3487134880 if (mode&4) cimg_forX(*this,x) mp(x,y,z,0);
3487234881 else cimg_forX(*this,x) {
3487334882 mp(x,y,z,0,res._data);
34874- const double *ptrs = res._data;
34875- T *_ptrd = ptrd++; for (unsigned int n = N; n>0; --n) { *_ptrd = (T)(*ptrs++); _ptrd+=whd; }
34883+ const double *const cimg_restrict ptrs = res._data;
34884+ T *cimg_restrict _ptrd = ptrd++;
34885+ cimg_pragma_openmp(simd)
34886+ for (unsigned int n = 0; n<N; ++n) _ptrd[n*whd] = (T)ptrs[n];
3487634887 }
3487734888 }
3487834889 mp.end_t();
@@ -34900,9 +34911,10 @@ namespace cimg_library {
3490034911 const ulongT off = (ulongT)_off; \
3490134912 cimg_for##_X(*this,_x) { \
3490234913 lmp(x,y,z,0,res._data); \
34903- const double *ptrs = res._data; \
34904- T *_ptrd = __ptrd; \
34905- for (unsigned int n = N; n>0; --n) { *_ptrd = (T)(*ptrs++); _ptrd+=whd; } \
34914+ const double *const cimg_restrict ptrs = res._data; \
34915+ T *cimg_restrict _ptrd = __ptrd; \
34916+ cimg_pragma_openmp(simd) \
34917+ for (unsigned int n = 0; n<N; ++n) _ptrd[n*whd] = (T)ptrs[n]; \
3490634918 __ptrd+=off; \
3490734919 } \
3490834920 } \
@@ -34920,17 +34932,33 @@ namespace cimg_library {
3492034932 }
3492134933
3492234934 } else { // Scalar-valued expression
34923- T *ptrd = *expression=='<'?end() - 1 :_data;
34935+ T *cimg_restrict ptrd = *expression=='<'?end() - _width :_data;
3492434936 if (*expression=='<') {
3492534937 mp.begin_t();
34926- if (mode&4) cimg_rofYZC(*this,y,z,c) { cimg_abort_test; cimg_rofX(*this,x) mp(x,y,z,c); }
34927- else cimg_rofYZC(*this,y,z,c) { cimg_abort_test; cimg_rofX(*this,x) *(ptrd--) = (T)mp(x,y,z,c); }
34938+ if (mode&4) cimg_rofYZC(*this,y,z,c) {
34939+ cimg_abort_test;
34940+ cimg_rofX(*this,x) mp(x,y,z,c);
34941+ }
34942+ else cimg_rofYZC(*this,y,z,c) {
34943+ cimg_abort_test;
34944+ cimg_pragma_openmp(simd)
34945+ cimg_rofX(*this,x) ptrd[x] = (T)mp(x,y,z,c);
34946+ ptrd-=_width;
34947+ }
3492834948 mp.end_t();
3492934949
3493034950 } else if (*expression=='>' || *expression=='+' || !is_parallelizable) {
3493134951 mp.begin_t();
34932- if (mode&4) cimg_forYZC(*this,y,z,c) { cimg_abort_test; cimg_forX(*this,x) mp(x,y,z,c); }
34933- else cimg_forYZC(*this,y,z,c) { cimg_abort_test; cimg_forX(*this,x) *(ptrd++) = (T)mp(x,y,z,c); }
34952+ if (mode&4) cimg_forYZC(*this,y,z,c) {
34953+ cimg_abort_test;
34954+ cimg_forX(*this,x) mp(x,y,z,c);
34955+ }
34956+ else cimg_forYZC(*this,y,z,c) {
34957+ cimg_abort_test;
34958+ cimg_pragma_openmp(simd)
34959+ cimg_forX(*this,x) ptrd[x] = (T)mp(x,y,z,c);
34960+ ptrd+=_width;
34961+ }
3493434962 mp.end_t();
3493534963
3493634964 } else {
@@ -34951,9 +34979,10 @@ namespace cimg_library {
3495134979 cimg_abort_test; \
3495234980 if (mode&4) cimg_for##_X(*this,_x) lmp(x,y,z,c); \
3495334981 else { \
34954- T *_ptrd = data(_sx,_sy,_sz,_sc); \
34982+ T *cimg_restrict _ptrd = data(_sx,_sy,_sz,_sc); \
3495534983 const ulongT off = (ulongT)_off; \
34956- cimg_for##_X(*this,_x) { *_ptrd = (T)lmp(x,y,z,c); _ptrd+=off; } \
34984+ cimg_pragma_openmp(simd) \
34985+ cimg_for##_X(*this,_x) _ptrd[_x*off] = (T)lmp(x,y,z,c); \
3495734986 } \
3495834987 } _cimg_abort_catch_openmp _cimg_abort_catch_fill_openmp
3495934988
0 commit comments