Skip to content

Commit

Permalink
jit - I include JiT source dirs set
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylt committed Oct 16, 2024
1 parent daaf13a commit fead0bb
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
13 changes: 12 additions & 1 deletion backends/cuda/ceed-cuda-compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,18 @@ int CeedCompile_Cuda(Ceed ceed, const char *source, CUmodule *module, const Ceed
+ std::to_string(prop.major) + std::to_string(prop.minor);
opts[1] = arch_arg.c_str();
opts[2] = "-Dint32_t=int";
opts[3] = "-I/home/jeremy/Dev/libCEED/include/ceed/jit-source/"
{
const char **jit_source_dirs;
CeedInt num_jit_source_dirs;
std::ostringstream include_dirs_arg;

CeedCallBackend(CeedGetJitSourceRoots(ceed, &num_jit_source_dirs, &jit_source_dirs));
for (CeedInt i = 0; i < num_jit_source_dirs; i++) {
include_dirs_arg << "-I" << jit_source_dirs[i] << " ";
}
CeedCallBackend(CeedRestoreJitSourceRoots(ceed, &jit_source_dirs));
opts[3] = include_dirs_arg.str().c_str();
}

// Add string source argument provided in call
code << source;
Expand Down
14 changes: 13 additions & 1 deletion backends/hip/ceed-hip-compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int CeedCompile_Hip(Ceed ceed, const char *source, hipModule_t *module, const Ce
size_t ptx_size;
char *jit_defs_source, *ptx;
const char *jit_defs_path;
const int num_opts = 3;
const int num_opts = 4;
const char *opts[num_opts];
int runtime_version;
hiprtcProgram prog;
Expand Down Expand Up @@ -90,6 +90,18 @@ int CeedCompile_Hip(Ceed ceed, const char *source, hipModule_t *module, const Ce
std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName);
opts[1] = arch_arg.c_str();
opts[2] = "-munsafe-fp-atomics";
{
const char **jit_source_dirs;
CeedInt num_jit_source_dirs;
std::ostringstream include_dirs_arg;

CeedCallBackend(CeedGetJitSourceRoots(ceed, &num_jit_source_dirs, &jit_source_dirs));
for (CeedInt i = 0; i < num_jit_source_dirs; i++) {
include_dirs_arg << "-I" << jit_source_dirs[i] << " ";
}
CeedCallBackend(CeedRestoreJitSourceRoots(ceed, &jit_source_dirs));
opts[3] = include_dirs_arg.str().c_str();
}

// Add string source argument provided in call
code << source;
Expand Down
2 changes: 2 additions & 0 deletions include/ceed/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ CEED_EXTERN int CeedSetData(Ceed ceed, void *data);
CEED_EXTERN int CeedReference(Ceed ceed);
CEED_EXTERN int CeedGetWorkVector(Ceed ceed, CeedSize len, CeedVector *vec);
CEED_EXTERN int CeedRestoreWorkVector(Ceed ceed, CeedVector *vec);
CEED_EXTERN int CeedGetJitSourceRoots(Ceed ceed, CeedInt *num_source_roots, const char ***jit_source_roots);
CEED_EXTERN int CeedRestoreJitSourceRoots(Ceed ceed, const char ***jit_source_roots);

CEED_EXTERN int CeedVectorHasValidArray(CeedVector vec, bool *has_valid_array);
CEED_EXTERN int CeedVectorHasBorrowedArrayOfType(CeedVector vec, CeedMemType mem_type, bool *has_borrowed_array_of_type);
Expand Down
34 changes: 34 additions & 0 deletions interface/ceed.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,40 @@ int CeedRestoreWorkVector(Ceed ceed, CeedVector *vec) {
// LCOV_EXCL_STOP
}

/**
@brief Retrieve list ofadditional JiT source roots from `Ceed` context.
Note: The caller is responsible for restoring `jit_source_roots` with @ref CeedRestoreJitSourceRoots().
@param[in] ceed `Ceed` context
@param[out] num_source_roots Number of JiT source directories
@param[out] jit_source_roots Absolute paths to additional JiT source directories
@return An error code: 0 - success, otherwise - failure
@ref Backend
**/
int CeedGetJitSourceRoots(Ceed ceed, CeedInt *num_source_roots, const char ***jit_source_roots) {
*num_source_roots = ceed->num_jit_source_roots;
*jit_source_roots = (const char **)ceed->jit_source_roots;
return CEED_ERROR_SUCCESS;
}

/**
@brief Restore list of additional JiT source roots from with @ref CeedGetJitSourceRoots()
@param[in] ceed `Ceed` context
@param[out] jit_source_roots Absolute paths to additional JiT source directories
@return An error code: 0 - success, otherwise - failure
@ref Backend
**/
int CeedRestoreJitSourceRoots(Ceed ceed, const char ***jit_source_roots) {
*jit_source_roots = NULL;
return CEED_ERROR_SUCCESS;
}

/// @}

/// ----------------------------------------------------------------------------
Expand Down

0 comments on commit fead0bb

Please sign in to comment.