Skip to content

Commit dc78211

Browse files
authored
Merge pull request #937 from CEED/jeremy/parent-source-root
ceed - add JiT source root to topmost parent
2 parents 18562a3 + 6155f12 commit dc78211

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

interface/ceed-jit-tools.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,24 @@ int CeedGetJitRelativePath(const char *absolute_file_path,
279279
int CeedGetJitAbsolutePath(Ceed ceed, const char *relative_file_path,
280280
char **absolute_file_path) {
281281
int ierr;
282+
Ceed ceed_parent;
282283

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

288289

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

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

296298
// Build and check absolute path with current root
297-
ierr = CeedPathConcatenate(ceed, ceed->jit_source_roots[i],
299+
ierr = CeedPathConcatenate(ceed, ceed_parent->jit_source_roots[i],
298300
relative_file_path, absolute_file_path);
299301
CeedChk(ierr);
300302
ierr = CeedCheckFilePath(ceed, *absolute_file_path, &is_valid); CeedChk(ierr);

interface/ceed.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,8 @@ int CeedInit(const char *resource, Ceed *ceed) {
914914
CeedChk(ierr);
915915

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

@@ -1014,14 +1016,17 @@ int CeedIsDeterministic(Ceed ceed, bool *is_deterministic) {
10141016
**/
10151017
int CeedAddJitSourceRoot(Ceed ceed, const char *jit_source_root) {
10161018
int ierr;
1019+
Ceed ceed_parent;
10171020

1018-
CeedInt index = ceed->num_jit_source_roots;
1021+
ierr = CeedGetParent(ceed, &ceed_parent); CeedChk(ierr);
1022+
1023+
CeedInt index = ceed_parent->num_jit_source_roots;
10191024
size_t path_length = strlen(jit_source_root);
1020-
ierr = CeedRealloc(index + 1, &ceed->jit_source_roots); CeedChk(ierr);
1021-
ierr = CeedCalloc(path_length + 1, &ceed->jit_source_roots[index]);
1025+
ierr = CeedRealloc(index + 1, &ceed_parent->jit_source_roots); CeedChk(ierr);
1026+
ierr = CeedCalloc(path_length + 1, &ceed_parent->jit_source_roots[index]);
10221027
CeedChk(ierr);
1023-
strncpy(ceed->jit_source_roots[index], jit_source_root, path_length);
1024-
ceed->num_jit_source_roots++;
1028+
strncpy(ceed_parent->jit_source_roots[index], jit_source_root, path_length);
1029+
ceed_parent->num_jit_source_roots++;
10251030

10261031
return CEED_ERROR_SUCCESS;
10271032
}

0 commit comments

Comments
 (0)