Skip to content

Commit c16c87c

Browse files
authored
Merge pull request #1777 from CEED/jeremy/fix-build-error-fallback
gpu - log error to debug on JiT try & fail
2 parents af16a45 + 28c1f74 commit c16c87c

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

backends/cuda/ceed-cuda-compile.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,23 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const bool throw_
132132
}
133133
CeedCallBackend(CeedFree(&opts));
134134
*is_compile_good = result == NVRTC_SUCCESS;
135-
if (!*is_compile_good && throw_error) {
135+
if (!*is_compile_good) {
136136
char *log;
137137
size_t log_size;
138138

139139
CeedCallNvrtc(ceed, nvrtcGetProgramLogSize(prog, &log_size));
140140
CeedCallBackend(CeedMalloc(log_size, &log));
141141
CeedCallNvrtc(ceed, nvrtcGetProgramLog(prog, log));
142-
return CeedError(ceed, CEED_ERROR_BACKEND, "%s\n%s", nvrtcGetErrorString(result), log);
142+
if (throw_error) {
143+
return CeedError(ceed, CEED_ERROR_BACKEND, "%s\n%s", nvrtcGetErrorString(result), log);
144+
} else {
145+
CeedDebug256(ceed, CEED_DEBUG_COLOR_ERROR, "---------- COMPILE ERROR DETECTED ----------\n");
146+
CeedDebug(ceed, "Error: %s\nCompile log:\n%s\n", nvrtcGetErrorString(result), log);
147+
CeedDebug256(ceed, CEED_DEBUG_COLOR_ERROR, "---------- BACKEND MAY FALLBACK ----------\n");
148+
CeedCallBackend(CeedFree(&log));
149+
CeedCallNvrtc(ceed, nvrtcDestroyProgram(&prog));
150+
return CEED_ERROR_SUCCESS;
151+
}
143152
}
144153

145154
#if CUDA_VERSION >= 11010

backends/hip/ceed-hip-compile.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,23 @@ static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_e
134134
}
135135
CeedCallBackend(CeedFree(&opts));
136136
*is_compile_good = result == HIPRTC_SUCCESS;
137-
if (!*is_compile_good && throw_error) {
137+
if (!*is_compile_good) {
138138
size_t log_size;
139139
char *log;
140140

141141
CeedChk_hiprtc(ceed, hiprtcGetProgramLogSize(prog, &log_size));
142142
CeedCallBackend(CeedMalloc(log_size, &log));
143143
CeedCallHiprtc(ceed, hiprtcGetProgramLog(prog, log));
144-
return CeedError(ceed, CEED_ERROR_BACKEND, "%s\n%s", hiprtcGetErrorString(result), log);
144+
if (throw_error) {
145+
return CeedError(ceed, CEED_ERROR_BACKEND, "%s\n%s", hiprtcGetErrorString(result), log);
146+
} else {
147+
CeedDebug256(ceed, CEED_DEBUG_COLOR_ERROR, "---------- COMPILE ERROR DETECTED ----------\n");
148+
CeedDebug(ceed, "Error: %s\nCompile log:\n%s\n", hiprtcGetErrorString(result), log);
149+
CeedDebug256(ceed, CEED_DEBUG_COLOR_ERROR, "---------- BACKEND MAY FALLBACK ----------\n");
150+
CeedCallBackend(CeedFree(&log));
151+
CeedCallHiprtc(ceed, hiprtcDestroyProgram(&prog));
152+
return CEED_ERROR_SUCCESS;
153+
}
145154
}
146155

147156
CeedCallHiprtc(ceed, hiprtcGetCodeSize(prog, &ptx_size));

0 commit comments

Comments
 (0)