-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][USM] Enable per-context USM behavior. #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,35 +24,35 @@ namespace usm { | |
|
||
class CLUSM { | ||
public: | ||
static bool Create(CLUSM *&pCLUSM); | ||
static void Delete(CLUSM *&pCLUSM); | ||
CLUSM() = default; | ||
~CLUSM() = default; | ||
|
||
void initExtensions(cl_platform_id platform); | ||
void initExtensions(cl_context Context, cl_platform_id Platform); | ||
|
||
void *hostMemAlloc(cl_context context, cl_mem_properties_intel *properties, | ||
size_t size, cl_uint alignment, cl_int *errcode_ret); | ||
void *deviceMemAlloc(cl_context context, cl_device_id device, | ||
cl_mem_properties_intel *properties, size_t size, | ||
cl_uint alignment, cl_int *errcode_ret); | ||
void *sharedMemAlloc(cl_context context, cl_device_id device, | ||
cl_mem_properties_intel *properties, size_t size, | ||
cl_uint alignment, cl_int *errcode_ret); | ||
void *hostMemAlloc(cl_context Context, cl_mem_properties_intel *Properties, | ||
size_t Size, cl_uint Alignment, cl_int *Errcode_ret); | ||
void *deviceMemAlloc(cl_context Context, cl_device_id Device, | ||
cl_mem_properties_intel *Properties, size_t Size, | ||
cl_uint Alignment, cl_int *Errcode_ret); | ||
void *sharedMemAlloc(cl_context Context, cl_device_id Device, | ||
cl_mem_properties_intel *Properties, size_t Size, | ||
cl_uint Alignment, cl_int *Errcode_ret); | ||
|
||
cl_int memFree(cl_context context, const void *ptr); | ||
cl_int memFree(cl_context Context, const void *Ptr); | ||
|
||
cl_int getMemAllocInfoINTEL(cl_context context, const void *ptr, | ||
cl_mem_info_intel param_name, | ||
size_t param_value_size, void *param_value, | ||
size_t *param_value_size_ret); | ||
cl_int getMemAllocInfoINTEL(cl_context Context, const void *Ptr, | ||
cl_mem_info_intel Param_name, | ||
size_t Param_value_size, void *Param_value, | ||
size_t *Param_value_size_ret); | ||
|
||
cl_int setKernelExecInfo(cl_kernel kernel, cl_kernel_exec_info param_name, | ||
size_t param_value_size, const void *param_value); | ||
cl_int setKernelExecInfo(cl_kernel Kernel, cl_kernel_exec_info Param_name, | ||
size_t Param_value_size, const void *Param_value); | ||
|
||
cl_int setKernelIndirectUSMExecInfo(cl_command_queue queue, cl_kernel kernel); | ||
cl_int setKernelIndirectUSMExecInfo(cl_command_queue Queue, cl_kernel Kernel); | ||
|
||
template <class T> | ||
cl_int writeParamToMemory(size_t param_value_size, T param, | ||
size_t *param_value_size_ret, T *pointer) const; | ||
cl_int writeParamToMemory(size_t Param_value_size, T Param, | ||
size_t *Param_value_size_ret, T *Pointer) const; | ||
|
||
bool useCLUSM() { return mEnableCLUSM; } | ||
|
||
|
@@ -63,9 +63,6 @@ class CLUSM { | |
bool mInitialized = false; | ||
std::mutex mLock; | ||
|
||
CLUSM() = default; | ||
~CLUSM() = default; | ||
|
||
struct SUSMAllocInfo { | ||
SUSMAllocInfo() = default; | ||
|
||
|
@@ -108,23 +105,25 @@ class CLUSM { | |
} // namespace usm | ||
|
||
namespace cliext { | ||
bool initializeExtensions(cl_platform_id platform); | ||
bool initializeExtensions(cl_context context, cl_platform_id platform); | ||
} // namespace cliext | ||
|
||
} // namespace detail | ||
} // namespace sycl | ||
} // namespace cl | ||
|
||
__SYCL_EXPORTED extern cl::sycl::detail::usm::CLUSM *gCLUSM; | ||
inline cl::sycl::detail::usm::CLUSM *GetCLUSM() { | ||
if (gCLUSM == nullptr) { | ||
cl::sycl::detail::usm::CLUSM::Create(gCLUSM); | ||
__SYCL_EXPORTED extern std::map<cl_context, cl::sycl::detail::usm::CLUSM *> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you store pointer to CLUSM in the context object? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. Wasn't sure if you guys preferred it to be that invasive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually - not sure I can really do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See below in the opencl_shim part. |
||
gCLUSM; | ||
inline cl::sycl::detail::usm::CLUSM *GetCLUSM(cl_context ctxt) { | ||
if (!cl::sycl::detail::pi::piUseBackend( | ||
cl::sycl::detail::pi::PiBackend::SYCL_BE_PI_OPENCL)) { | ||
// Bail if we're not using a CL backend. CLUSM is not relevant. | ||
return nullptr; | ||
} | ||
|
||
cl::sycl::detail::usm::CLUSM *retVal = nullptr; | ||
if (cl::sycl::detail::pi::piUseBackend( | ||
cl::sycl::detail::pi::PiBackend::SYCL_BE_PI_OPENCL)) { | ||
retVal = gCLUSM; | ||
cl::sycl::detail::usm::CLUSM *&retVal = gCLUSM[ctxt]; | ||
if (retVal == nullptr) { | ||
retVal = new cl::sycl::detail::usm::CLUSM(); | ||
} | ||
return retVal; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, follow llvm coding guidelines. name variables starting from big letter, functions from small.