Skip to content

Commit

Permalink
Merge pull request #937 from CEED/jeremy/parent-source-root
Browse files Browse the repository at this point in the history
ceed - add JiT source root to topmost parent
  • Loading branch information
jeremylt authored Apr 8, 2022
2 parents 18562a3 + 6155f12 commit dc78211
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 5 additions & 3 deletions interface/ceed-jit-tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,24 @@ int CeedGetJitRelativePath(const char *absolute_file_path,
int CeedGetJitAbsolutePath(Ceed ceed, const char *relative_file_path,
char **absolute_file_path) {
int ierr;
Ceed ceed_parent;

// Debug
CeedDebug256(ceed, 1, "---------- Ceed JiT ----------\n");
CeedDebug256(ceed, 1, "Relative JiT source file: ");
CeedDebug256(ceed, 255, "%s\n", relative_file_path);


for (CeedInt i = 0; i < ceed->num_jit_source_roots; i++) {
ierr = CeedGetParent(ceed, &ceed_parent); CeedChk(ierr);
for (CeedInt i = 0; i < ceed_parent->num_jit_source_roots; i++) {
bool is_valid;

// Debug
CeedDebug256(ceed, 1, "Checking JiT root: ");
CeedDebug256(ceed, 255, "%s\n", ceed->jit_source_roots[i]);
CeedDebug256(ceed, 255, "%s\n", ceed_parent->jit_source_roots[i]);

// Build and check absolute path with current root
ierr = CeedPathConcatenate(ceed, ceed->jit_source_roots[i],
ierr = CeedPathConcatenate(ceed, ceed_parent->jit_source_roots[i],
relative_file_path, absolute_file_path);
CeedChk(ierr);
ierr = CeedCheckFilePath(ceed, *absolute_file_path, &is_valid); CeedChk(ierr);
Expand Down
15 changes: 10 additions & 5 deletions interface/ceed.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,8 @@ int CeedInit(const char *resource, Ceed *ceed) {
CeedChk(ierr);

// Set default JiT source root
// Note: there will always be the default root for every Ceed
// but all additional paths are added to the top-most parent
ierr = CeedAddJitSourceRoot(*ceed, (char *)CeedJitSourceRootDefault);
CeedChk(ierr);

Expand Down Expand Up @@ -1014,14 +1016,17 @@ int CeedIsDeterministic(Ceed ceed, bool *is_deterministic) {
**/
int CeedAddJitSourceRoot(Ceed ceed, const char *jit_source_root) {
int ierr;
Ceed ceed_parent;

CeedInt index = ceed->num_jit_source_roots;
ierr = CeedGetParent(ceed, &ceed_parent); CeedChk(ierr);

CeedInt index = ceed_parent->num_jit_source_roots;
size_t path_length = strlen(jit_source_root);
ierr = CeedRealloc(index + 1, &ceed->jit_source_roots); CeedChk(ierr);
ierr = CeedCalloc(path_length + 1, &ceed->jit_source_roots[index]);
ierr = CeedRealloc(index + 1, &ceed_parent->jit_source_roots); CeedChk(ierr);
ierr = CeedCalloc(path_length + 1, &ceed_parent->jit_source_roots[index]);
CeedChk(ierr);
strncpy(ceed->jit_source_roots[index], jit_source_root, path_length);
ceed->num_jit_source_roots++;
strncpy(ceed_parent->jit_source_roots[index], jit_source_root, path_length);
ceed_parent->num_jit_source_roots++;

return CEED_ERROR_SUCCESS;
}
Expand Down

0 comments on commit dc78211

Please sign in to comment.