Skip to content

Commit ace45c6

Browse files
author
abergeron
authored
Merge pull request #534 from jvesely/opencl_extensions
Check for available OpenCL extensions
2 parents 4461ad8 + 4285e20 commit ace45c6

File tree

2 files changed

+460
-433
lines changed

2 files changed

+460
-433
lines changed

src/cluda_opencl.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
#define ga_long long
3434
#define ga_ulong ulong
3535
#define ga_float float
36+
#ifdef cl_khr_fp64
37+
#pragma OPENCL EXTENSION cl_khr_fp64: enable
3638
#define ga_double double
39+
#endif
3740
#define ga_size ulong
3841
#define ga_ssize long
3942
#define GA_DECL_SHARED_PARAM(type, name) , __local type *name
@@ -109,6 +112,14 @@ static inline ga_half ga_float2half(ga_float f) {
109112
#define atom_add_Il(a, b) atomic_add(a, b)
110113
#define atom_xchg_Ig(a, b) atomic_xchg(a, b)
111114
#define atom_xchg_Il(a, b) atomic_xchg(a, b)
115+
/* ga_float */
116+
gen_atom32_add(atom_add_fg, ga_float, global)
117+
gen_atom32_add(atom_add_fl, ga_float, local)
118+
#define atom_xchg_fg(a, b) atomic_xchg(a, b)
119+
#define atom_xchg_fl(a, b) atomic_xchg(a, b)
120+
121+
#ifdef cl_khr_int64_base_atomics
122+
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
112123
/* ga_long */
113124
#define atom_add_lg(a, b) atom_add(a, b)
114125
#define atom_add_ll(a, b) atom_add(a, b)
@@ -119,16 +130,14 @@ static inline ga_half ga_float2half(ga_float f) {
119130
#define atom_add_Ll(a, b) atom_add(a, b)
120131
#define atom_xchg_Lg(a, b) atom_xchg(a, b)
121132
#define atom_xchg_Ll(a, b) atom_xchg(a, b)
122-
/* ga_float */
123-
gen_atom32_add(atom_add_fg, ga_float, global)
124-
gen_atom32_add(atom_add_fl, ga_float, local)
125-
#define atom_xchg_fg(a, b) atomic_xchg(a, b)
126-
#define atom_xchg_fl(a, b) atomic_xchg(a, b)
127133
/* ga_double */
134+
#ifdef cl_khr_fp64
128135
gen_atom64_add(atom_add_dg, ga_double, global)
129136
gen_atom64_add(atom_add_dl, ga_double, local)
130137
gen_atom64_xchg(atom_xchg_dg, ga_double, global)
131138
gen_atom64_xchg(atom_xchg_dl, ga_double, local)
139+
#endif
140+
#endif
132141
/* ga_half */
133142
#define gen_atomh_add(name, aspace) \
134143
ga_half name(volatile aspace ga_half *addr, ga_half val); \

0 commit comments

Comments
 (0)