Skip to content

Commit

Permalink
Merge pull request #1795 from McStasMcXtrace/various-minor-comp-instr…
Browse files Browse the repository at this point in the history
…-fixes

Various minor comp instr fixes
  • Loading branch information
willend authored Dec 9, 2024
2 parents f239fca + edb59ef commit dedcb05
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions mcstas-comps/misc/MCPL_input_once.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -208,15 +209,19 @@ 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:
if (ptr == NULL) {
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;
Expand Down
3 changes: 2 additions & 1 deletion mcstas-comps/union/Union_abs_logger_1D_space_event.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion mcstas-comps/union/Union_abs_logger_event.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dedcb05

Please sign in to comment.