Skip to content

Commit 3aaa7dd

Browse files
committed
Partial GPU support
1 parent 0bd90b8 commit 3aaa7dd

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

mcstas-comps/examples/Prototypes/ODIN_TOF_train4/ESS_butterfly.comp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,19 +549,20 @@ TRACE
549549
vx = v*dx/r;
550550

551551
int train_index;
552+
553+
long tmp;
552554

553555
if (total_N_sent == 0) {
554-
#pragma acc atomic
555-
adaptive_N = N_trains;
556+
tmp = N_trains;
556557
} else {
557-
long tmp = ceil(target_tsplit*total_N_sent/total_arrived);
558-
#pragma acc atomic
559-
adaptive_N = tmp;
560-
if (adaptive_N > N_trains) {
561-
#pragma acc atomic
562-
adaptive_N = N_trains;
558+
tmp = ceil(target_tsplit*total_N_sent/total_arrived);
559+
if (tmp > N_trains) {
560+
tmp = N_trains;
563561
}
564562
}
563+
564+
#pragma acc atomic write
565+
adaptive_N = tmp;
565566

566567
for (train_index=0; train_index<adaptive_N; train_index++) {
567568

mcstas-comps/examples/Prototypes/ODIN_TOF_train4/ODIN_TOF_train4.instr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ int adaptive_N;
107107
long total_arrived;
108108
long total_N_sent;
109109
long total_rays_sent;
110+
#pragma acc declare create(adaptive_N,total_arrived,total_N_sent,total_rays_sent)
110111
%}
111112

112113
USERVARS
@@ -141,7 +142,8 @@ adaptive_N=NTOF;
141142
total_arrived=0;
142143
total_N_sent=0;
143144
total_rays_sent=0;
144-
145+
#pragma acc update device(adaptive_N,total_arrived,total_N_sent,total_rays_sent)
146+
145147
// Don't measure time on windows, CLOCK_REALTIME
146148
// macro is unknown...
147149
// It is indicated in this oagehttps://learn.microsoft.com/en-us/answers/questions/2147256/clock-realtime-is-undefined-in-visual-studio-but-c that it might work to add a high enough _POSIX_C_SOURCE define, i.e.

0 commit comments

Comments
 (0)