Skip to content

Commit 47898d9

Browse files
committed
Added tunable parameters to the example.
1 parent da2fe05 commit 47898d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/directives/histogram_c_openacc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ def histogram(vector, hist):
2121
#define VECTOR_SIZE 1000000
2222
2323
#pragma tuner start histogram vector(int*:VECTOR_SIZE) hist(int*:HIST_SIZE)
24+
#if enable_reduction == 1
25+
#pragma acc parallel num_gangs(ngangs) vector_length(nthreads) reduction(+:hist[:HIST_SIZE])
26+
#else
2427
#pragma acc parallel num_gangs(ngangs) vector_length(nthreads)
28+
#endif
2529
#pragma acc loop independent
2630
for ( int i = 0; i < VECTOR_SIZE; i++ ) {
31+
#if enable_atomic == 1
2732
#pragma acc atomic update
33+
#endif
2834
hist[vector[i]] += 1;
2935
}
3036
#pragma tuner stop
@@ -37,6 +43,9 @@ def histogram(vector, hist):
3743
tune_params = dict()
3844
tune_params["ngangs"] = [2**i for i in range(1, 11)]
3945
tune_params["nthreads"] = [32 * i for i in range(1, 33)]
46+
tune_params["enable_reduction"] = [0, 1]
47+
tune_params["enable_atomic"] = [0, 1]
48+
constraints = ["enable_reduction != enable_atomic"]
4049
metrics = dict()
4150
metrics["GB/s"] = (
4251
lambda x: ((2 * 4 * len(kernel_args["histogram"][0])) + (4 * len(kernel_args["histogram"][0])))
@@ -56,6 +65,7 @@ def histogram(vector, hist):
5665
0,
5766
kernel_args["histogram"],
5867
tune_params,
68+
restrictions=constraints,
5969
metrics=metrics,
6070
answer=answer,
6171
compiler="nvc++",

0 commit comments

Comments
 (0)