Skip to content

Commit

Permalink
changes to make shared ptr usage consistent and adding template defin…
Browse files Browse the repository at this point in the history
…ition to header file
  • Loading branch information
uumesh committed Oct 15, 2024
1 parent 627aa8d commit dcd4af6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion backends/sycl-ref/ceed-sycl-ref-qfunction.sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int CeedQFunctionDestroy_Sycl(CeedQFunction qf) {
CeedCallBackend(CeedQFunctionGetData(qf, &impl));
CeedCallBackend(CeedQFunctionGetCeed(qf, &ceed));
delete impl->QFunction;
delete impl->sycl_module;
// delete impl->sycl_module;
CeedCallBackend(CeedFree(&impl));
return CEED_ERROR_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion backends/sycl-ref/ceed-sycl-ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ typedef struct {
using SyclQfunctionKernel_t = std::function<void(sycl::queue&, sycl::nd_range<1>, void*, CeedInt, Fields_Sycl*)>;

typedef struct {
SyclModule_t *sycl_module;
SyclModule_t sycl_module;
const char *qfunction_name;
const char *qfunction_source;
SyclQfunctionKernel_t *QFunction;
Expand Down
11 changes: 9 additions & 2 deletions backends/sycl/ceed-sycl-compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
using SyclModule_t = std::shared_ptr<prtc::DynamicLibrary>;
using SyclBundle_t = sycl::kernel_bundle<sycl::bundle_state::executable>;

CEED_INTERN int CeedBuildModule_Sycl(Ceed ceed, const std::string &kernel_source, SyclModule_t *sycl_module,
CEED_INTERN int CeedBuildModule_Sycl(Ceed ceed, const std::string &kernel_source, SyclModule_t sycl_module,
const std::map<std::string, CeedInt> &constants = {});

template <class SyclKernel_t>
int CeedGetKernel_Sycl(Ceed ceed, const SyclModule_t *sycl_module, const std::string &kernel_name, SyclKernel_t **sycl_kernel);
int CeedGetKernel_Sycl(Ceed ceed, const SyclModule_t sycl_module, const std::string &kernel_name, SyclKernel_t *sycl_kernel) {
try {
*sycl_kernel = sycl_module->getFunction<SyclKernel_t>(kernel_name);
} catch (const std::exception& e) {
return CeedError((ceed), CEED_ERROR_BACKEND, e.what());
}
return CEED_ERROR_SUCCESS;
}

template <class SyclKernel_t>
int CeedRunKernelDimSharedSycl(Ceed ceed, SyclKernel_t *kernel, const int grid_size, const int block_size_x, const int block_size_y,
Expand Down
24 changes: 12 additions & 12 deletions backends/sycl/ceed-sycl-compile.sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ static inline int CeedJitCompileSource_Sycl(Ceed ceed, const sycl::device &sycl_
// Load (compile) SPIR-V source and wrap in sycl kernel_bundle
// ------------------------------------------------------------------------------
static int CeedLoadModule_Sycl(Ceed ceed, const sycl::context &sycl_context, const sycl::device &sycl_device, const std::string& path,
SyclModule_t *sycl_module) {
SyclModule_t sycl_module) {
try {
*sycl_module = prtc::DynamicLibrary::open(path);
sycl_module = prtc::DynamicLibrary::open(path);
} catch (const std::exception& e) {
return CeedError((ceed), CEED_ERROR_BACKEND, e.what());
}
Expand All @@ -148,7 +148,7 @@ static int CeedLoadModule_Sycl(Ceed ceed, const sycl::context &sycl_context, con
// ------------------------------------------------------------------------------
// Compile kernel source to a shared library
// ------------------------------------------------------------------------------
int CeedBuildModule_Sycl(Ceed ceed, const std::string &kernel_source, SyclModule_t *sycl_module, const std::map<std::string, CeedInt> &constants) {
int CeedBuildModule_Sycl(Ceed ceed, const std::string &kernel_source, SyclModule_t sycl_module, const std::map<std::string, CeedInt> &constants) {
Ceed_Sycl *data;
std::string jit_source;
std::string module_path;
Expand All @@ -168,15 +168,15 @@ int CeedBuildModule_Sycl(Ceed ceed, const std::string &kernel_source, SyclModule
// ------------------------------------------------------------------------------
// Get a sycl kernel from an existing module
// ------------------------------------------------------------------------------
template <class SyclKernel_t>
int CeedGetKernel_Sycl(Ceed ceed, const SyclModule_t sycl_module, const std::string &kernel_name, SyclKernel_t *sycl_kernel) {
try {
*sycl_kernel = sycl_module->getFunction<SyclKernel_t>(kernel_name);
} catch (const std::exception& e) {
return CeedError((ceed), CEED_ERROR_BACKEND, e.what());
}
return CEED_ERROR_SUCCESS;
}
// template <class SyclKernel_t>
// int CeedGetKernel_Sycl(Ceed ceed, const SyclModule_t sycl_module, const std::string &kernel_name, SyclKernel_t *sycl_kernel) {
// try {
// *sycl_kernel = sycl_module->getFunction<SyclKernel_t>(kernel_name);
// } catch (const std::exception& e) {
// return CeedError((ceed), CEED_ERROR_BACKEND, e.what());
// }
// return CEED_ERROR_SUCCESS;
// }

//------------------------------------------------------------------------------
// Run SYCL kernel for spatial dimension with shared memory
Expand Down

0 comments on commit dcd4af6

Please sign in to comment.