Skip to content

Commit 6878a50

Browse files
author
Sergey Kanaev
committed
Stylistic change
Signed-off-by: Sergey Kanaev <[email protected]>
1 parent eeff988 commit 6878a50

File tree

1 file changed

+44
-41
lines changed

1 file changed

+44
-41
lines changed

sycl/plugins/opencl/pi_opencl.cpp

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *clSetProgramSpecializationConstant_fn)(
8686
// There's another way. A mapping of context to collection of function pointers.
8787
// Though, the former design allows for simultaneous access for different
8888
// function pointer for different contexts.
89-
template <const char *FuncName, typename FuncT>
90-
struct ExtFuncCache {
89+
template <const char *FuncName, typename FuncT> struct ExtFuncCache {
9190
std::map<pi_context, FuncT> Cache;
9291
// FIXME Use spin-lock to make lock/unlock faster and w/o context switching
9392
std::mutex Mtx;
@@ -96,8 +95,8 @@ struct ExtFuncCache {
9695
struct ExtFuncCacheCollection;
9796

9897
namespace detail {
99-
template <const char *FuncName, typename FuncT>
100-
ExtFuncCache<FuncName, FuncT> &get(::ExtFuncCacheCollection &);
98+
template <const char *FuncName, typename FuncT>
99+
ExtFuncCache<FuncName, FuncT> &get(::ExtFuncCacheCollection &);
101100
} // namespace detail
102101

103102
struct ExtFuncCacheCollection {
@@ -106,10 +105,9 @@ struct ExtFuncCacheCollection {
106105
return detail::get<FuncName, FuncT>(*this);
107106
}
108107

109-
#define DEFINE_INTEL(t_pfx) \
110-
ExtFuncCache<t_pfx ## Name, t_pfx ## INTEL_fn> t_pfx ## _Cache
111-
#define DEFINE(t_pfx) \
112-
ExtFuncCache<t_pfx ## Name, t_pfx ## _fn> t_pfx ## _Cache
108+
#define DEFINE_INTEL(t_pfx) \
109+
ExtFuncCache<t_pfx##Name, t_pfx##INTEL_fn> t_pfx##_Cache
110+
#define DEFINE(t_pfx) ExtFuncCache<t_pfx##Name, t_pfx##_fn> t_pfx##_Cache
113111

114112
DEFINE_INTEL(clHostMemAlloc);
115113
DEFINE_INTEL(clDeviceMemAlloc);
@@ -128,27 +126,31 @@ struct ExtFuncCacheCollection {
128126
};
129127

130128
namespace detail {
131-
#define DEFINE_GETTER_INTEL(t_pfx) \
132-
template<> ExtFuncCache<t_pfx ## Name, t_pfx ## INTEL_fn> &get<t_pfx ## Name, t_pfx ## INTEL_fn>(::ExtFuncCacheCollection &C) { \
133-
return C.t_pfx ## _Cache; \
129+
#define DEFINE_GETTER_INTEL(t_pfx) \
130+
template <> \
131+
ExtFuncCache<t_pfx##Name, t_pfx##INTEL_fn> \
132+
&get<t_pfx##Name, t_pfx##INTEL_fn>(::ExtFuncCacheCollection & C) { \
133+
return C.t_pfx##_Cache; \
134134
}
135-
#define DEFINE_GETTER(t_pfx) \
136-
template<> ExtFuncCache<t_pfx ## Name, t_pfx ## _fn> &get<t_pfx ## Name, t_pfx ## _fn>(::ExtFuncCacheCollection &C) { \
137-
return C.t_pfx ## _Cache; \
135+
#define DEFINE_GETTER(t_pfx) \
136+
template <> \
137+
ExtFuncCache<t_pfx##Name, t_pfx##_fn> &get<t_pfx##Name, t_pfx##_fn>( \
138+
::ExtFuncCacheCollection & C) { \
139+
return C.t_pfx##_Cache; \
138140
}
139141

140-
DEFINE_GETTER_INTEL(clHostMemAlloc)
141-
DEFINE_GETTER_INTEL(clDeviceMemAlloc)
142-
DEFINE_GETTER_INTEL(clSharedMemAlloc)
143-
DEFINE_GETTER_INTEL(clCreateBufferWithProperties)
144-
DEFINE_GETTER_INTEL(clMemBlockingFree)
145-
DEFINE_GETTER_INTEL(clMemFree)
146-
DEFINE_GETTER_INTEL(clSetKernelArgMemPointer)
147-
DEFINE_GETTER_INTEL(clEnqueueMemset)
148-
DEFINE_GETTER_INTEL(clEnqueueMemcpy)
149-
DEFINE_GETTER_INTEL(clGetMemAllocInfo)
150-
DEFINE_GETTER(clGetDeviceFunctionPointer)
151-
DEFINE_GETTER(clSetProgramSpecializationConstant)
142+
DEFINE_GETTER_INTEL(clHostMemAlloc)
143+
DEFINE_GETTER_INTEL(clDeviceMemAlloc)
144+
DEFINE_GETTER_INTEL(clSharedMemAlloc)
145+
DEFINE_GETTER_INTEL(clCreateBufferWithProperties)
146+
DEFINE_GETTER_INTEL(clMemBlockingFree)
147+
DEFINE_GETTER_INTEL(clMemFree)
148+
DEFINE_GETTER_INTEL(clSetKernelArgMemPointer)
149+
DEFINE_GETTER_INTEL(clEnqueueMemset)
150+
DEFINE_GETTER_INTEL(clEnqueueMemcpy)
151+
DEFINE_GETTER_INTEL(clGetMemAllocInfo)
152+
DEFINE_GETTER(clGetDeviceFunctionPointer)
153+
DEFINE_GETTER(clSetProgramSpecializationConstant)
152154
#undef DEFINE_GETTER
153155
#undef DEFINE_GETTER_INTEL
154156
} // namespace detail
@@ -1470,24 +1472,25 @@ pi_result piTearDown(void *PluginParameter) {
14701472
}
14711473

14721474
pi_result piContextRelease(pi_context Context) {
1473-
#define RELEASE_EXT_FUNCS_CACHE_INTEL(t_pfx) \
1474-
{ \
1475-
ExtFuncCache<t_pfx ## Name, t_pfx ## INTEL_fn> &Cache = ExtFuncCaches->get<t_pfx ## Name, t_pfx ## INTEL_fn>(); \
1476-
std::lock_guard<std::mutex> CacheLock{Cache.Mtx}; \
1477-
auto It = Cache.Cache.find(Context); \
1478-
if (It != Cache.Cache.end()) \
1479-
Cache.Cache.erase(It); \
1475+
#define RELEASE_EXT_FUNCS_CACHE_INTEL(t_pfx) \
1476+
{ \
1477+
ExtFuncCache<t_pfx##Name, t_pfx##INTEL_fn> &Cache = \
1478+
ExtFuncCaches->get<t_pfx##Name, t_pfx##INTEL_fn>(); \
1479+
std::lock_guard<std::mutex> CacheLock{Cache.Mtx}; \
1480+
auto It = Cache.Cache.find(Context); \
1481+
if (It != Cache.Cache.end()) \
1482+
Cache.Cache.erase(It); \
14801483
}
1481-
#define RELEASE_EXT_FUNCS_CACHE(t_pfx) \
1482-
{ \
1483-
ExtFuncCache<t_pfx ## Name, t_pfx ## _fn> &Cache = ExtFuncCaches->get<t_pfx ## Name, t_pfx ## _fn>(); \
1484-
std::lock_guard<std::mutex> CacheLock{Cache.Mtx}; \
1485-
auto It = Cache.Cache.find(Context); \
1486-
if (It != Cache.Cache.end()) \
1487-
Cache.Cache.erase(It); \
1484+
#define RELEASE_EXT_FUNCS_CACHE(t_pfx) \
1485+
{ \
1486+
ExtFuncCache<t_pfx##Name, t_pfx##_fn> &Cache = \
1487+
ExtFuncCaches->get<t_pfx##Name, t_pfx##_fn>(); \
1488+
std::lock_guard<std::mutex> CacheLock{Cache.Mtx}; \
1489+
auto It = Cache.Cache.find(Context); \
1490+
if (It != Cache.Cache.end()) \
1491+
Cache.Cache.erase(It); \
14881492
}
14891493

1490-
14911494
RELEASE_EXT_FUNCS_CACHE_INTEL(clHostMemAlloc);
14921495
RELEASE_EXT_FUNCS_CACHE_INTEL(clDeviceMemAlloc);
14931496
RELEASE_EXT_FUNCS_CACHE_INTEL(clSharedMemAlloc);

0 commit comments

Comments
 (0)