Skip to content

Commit 52a6ad5

Browse files
author
Sergey Kanaev
committed
Address review comments
Signed-off-by: Sergey Kanaev <[email protected]>
1 parent a020c33 commit 52a6ad5

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

sycl/plugins/opencl/pi_opencl.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,24 @@ struct ExtFuncsPerContextT {
111111
};
112112

113113
namespace detail {
114-
#define _EXT_FUNCTION_INTEL(t_pfx) \
115-
template <> \
116-
std::pair<t_pfx##INTEL_fn &, bool &> get<t_pfx##Name, t_pfx##INTEL_fn>( \
117-
ExtFuncsPerContextT & Funcs) { \
118-
using FPtrT = t_pfx##INTEL_fn; \
119-
std::pair<FPtrT &, bool &> Ret{Funcs.t_pfx##Func, \
120-
Funcs.t_pfx##Initialized}; \
121-
return Ret; \
122-
}
123114

124-
#define _EXT_FUNCTION(t_pfx) \
115+
#define _EXT_FUNCTION_COMMON(t_pfx, t_pfx_suff) \
125116
template <> \
126-
std::pair<t_pfx##_fn &, bool &> get<t_pfx##Name, t_pfx##_fn>( \
117+
std::pair<t_pfx_suff##_fn &, bool &> get<t_pfx##Name, t_pfx_suff##_fn>( \
127118
ExtFuncsPerContextT & Funcs) { \
128-
using FPtrT = t_pfx##_fn; \
119+
using FPtrT = t_pfx_suff##_fn; \
129120
std::pair<FPtrT &, bool &> Ret{Funcs.t_pfx##Func, \
130121
Funcs.t_pfx##Initialized}; \
131122
return Ret; \
132123
}
124+
#define _EXT_FUNCTION_INTEL(t_pfx) _EXT_FUNCTION_COMMON(t_pfx, t_pfx##INTEL)
125+
#define _EXT_FUNCTION(t_pfx) _EXT_FUNCTION_COMMON(t_pfx, t_pfx)
133126

134127
#include "ext_functions.inc"
135128

136129
#undef _EXT_FUNCTION
137130
#undef _EXT_FUNCTION_INTEL
131+
#undef _EXT_FUNCTION_COMMON
138132
} // namespace detail
139133

140134
struct ExtFuncsCachesT {
@@ -196,15 +190,16 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) {
196190
T FuncPtr =
197191
(T)clGetExtensionFunctionAddressForPlatform(curPlatform, FuncName);
198192

193+
// We're about to store the cached value. Mark this cache entry initialized.
194+
FuncInitialized.second = true;
195+
199196
if (!FuncPtr) {
200197
// Cache that the extension is not available
201198
FuncInitialized.first = nullptr;
202-
FuncInitialized.second = true;
203199
return PI_INVALID_VALUE;
204200
}
205201

206202
FuncInitialized.first = FuncPtr;
207-
FuncInitialized.second = true;
208203
*fptr = FuncPtr;
209204

210205
return cast<pi_result>(ret_err);

0 commit comments

Comments
 (0)