Skip to content

Commit

Permalink
Save WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-rowe committed Jun 6, 2024
1 parent 792ce16 commit c73fe5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backends/sycl/ceed-sycl-compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <libprtc/prtc.h>

using SyclModule_t = std::shared_ptr<prtc::DynamicLibrary>;
using SyclKernel_t = void*; // Revisit
using SyclKernel_t = void*; // Revisit this

CEED_INTERN int CeedBuildModule_Sycl(Ceed ceed, const std::string &kernel_source, SyclModule_t *sycl_module,
const std::map<std::string, CeedInt> &constants = {});
Expand Down
18 changes: 13 additions & 5 deletions backends/sycl/ceed-sycl-compile.sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <ceed/jit-tools.h>
#include <level_zero/ze_api.h>

#include <cstdlib>
#include <map>
#include <sstream>
#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -67,18 +68,25 @@ static inline int CeedJitGetFlags_Sycl(std::vector<std::string> &flags) {

//------------------------------------------------------------------------------
// Compile sycl source to a shared library
// TODO: Check if source, module, etc. already exists
//------------------------------------------------------------------------------
static inline int CeedJitCompileSource_Sycl(Ceed ceed, const sycl::device &sycl_device, const std::string &kernel_source, std::string& output_path,
const std::vector<std::string> &flags = {}) {

// Q: Should we write the kernel source string to a file here
// or handle this in a separarte function;

// Should outputfile name be generated here?
// Get cache path from env variable
const char* cache_path = std::getenv("CEED_CACHE_DIR");

// Generate kernel hash
// E.g., see https://intel.github.io/llvm-docs/design/KernelProgramCache.html
// An example of directory structure can be found here:
// https://intel.github.io/llvm-docs/design/KernelProgramCache.html#persistent-cache-storage-structure

// Write source string to file
std::string source_path;

// TODO: Get compiler-path and flags from env or some other means
prtc::ShellCompiler compiler("icpx","-o","-c","-fPIC","-shared");
const auto [success, message] = compiler.compileAndLink(kernel_source,output_path,flags);
const auto [success, message] = compiler.compileAndLink(source_path,output_path,flags);
// Q: Should we always output the compiler output in verbose/debug mode?
if (!success) return CeedError((ceed), CEED_ERROR_BACKEND, message);
return CEED_ERROR_SUCCESS;
Expand Down

0 comments on commit c73fe5d

Please sign in to comment.