diff --git a/mcstas-comps/misc/MCPL_input_once.comp b/mcstas-comps/misc/MCPL_input_once.comp index 8c9c074ff3..805eb56939 100644 --- a/mcstas-comps/misc/MCPL_input_once.comp +++ b/mcstas-comps/misc/MCPL_input_once.comp @@ -179,6 +179,7 @@ TRACE if (current_index >= maximum_index){ // go back to the start of this worker's particles, rather than accessing out-of-range data + #pragma acc atomic write current_index = 0; #ifndef OPENACC if (!preload){ @@ -208,8 +209,11 @@ TRACE if (!times_replayed) used_neutrons++; } else { #endif - ptr = particles + current_index++; -#ifndef OPENACC + ptr = particles + (_particle->_uid % maximum_index); +#ifdef OPENACC + #pragma acc atomic + current_index++; // track how many particles have been accessed, to ensure we don't exceed our slice of the file +#else OPENACC } #endif // copy from the component particle struct to the particle ray struct: @@ -217,6 +221,7 @@ TRACE fprintf(stderr, "ERROR (%s): component particle struct pointer not set! Crash before out-of-bounds memory access.\n", NAME_CURRENT_COMP); exit(-1); } + #pragma acc atomic emitted_neutrons++; // this could be done via memcpy if we ensure equal memory layout with the ray's struct x = ptr->_x; diff --git a/mcstas-comps/union/Union_abs_logger_1D_space_event.comp b/mcstas-comps/union/Union_abs_logger_1D_space_event.comp index d02bdc34db..f1dd0f332a 100644 --- a/mcstas-comps/union/Union_abs_logger_1D_space_event.comp +++ b/mcstas-comps/union/Union_abs_logger_1D_space_event.comp @@ -101,7 +101,8 @@ SHARE #error "The Union_init component must be included before this Union_abs_logger_1D_space_event component" #endif -%include "monitor_nd-lib" // Internally avoids double import +// Internally avoids double import +%include "monitor_nd-lib" struct temp_abs_1D_event_data_element_struct { double x_pos; diff --git a/mcstas-comps/union/Union_abs_logger_event.comp b/mcstas-comps/union/Union_abs_logger_event.comp index d0315068c1..d3e5fb6ac6 100644 --- a/mcstas-comps/union/Union_abs_logger_event.comp +++ b/mcstas-comps/union/Union_abs_logger_event.comp @@ -85,7 +85,8 @@ SHARE #error "The Union_init component must be included before this Union_abs_logger_event component" #endif -%include "monitor_nd-lib" // Internally avoids double import +// Internally avoids double import +%include "monitor_nd-lib" struct temp_abs_event_data_element_struct { double x_pos;