Lines Matching +full:- +full:- +full:ceed

1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
4 // SPDX-License-Identifier: BSD-2-Clause
6 // This file is part of CEED: http://github.com/ceed
8 #include "ceed-hip-compile.h"
10 #include <ceed.h>
11 #include <ceed/backend.h>
12 #include <ceed/jit-tools.h>
19 #include "ceed-hip-common.h"
21 #define CeedChk_hiprtc(ceed, x) … argument
24 …if (result != HIPRTC_SUCCESS) return CeedError((ceed), CEED_ERROR_BACKEND, hiprtcGetErrorString(re…
27 #define CeedCallHiprtc(ceed, ...) \ argument
30 CeedChk_hiprtc(ceed, ierr_q_); \
33 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 static int CeedCompileCore_Hip(Ceed ceed, const char *source, const bool throw_error, bool *is_comp… in CeedCompileCore_Hip() argument
53 CeedCallHip(ceed, hipRuntimeGetVersion(&runtime_version)); in CeedCompileCore_Hip()
77 code << "#include <ceed/jit-source/hip/hip-jit.h>\n\n"; in CeedCompileCore_Hip()
79 // Non-macro options in CeedCompileCore_Hip()
81 opts[0] = "-default-device"; in CeedCompileCore_Hip()
82 CeedCallBackend(CeedGetData(ceed, (void **)&ceed_data)); in CeedCompileCore_Hip()
83 CeedCallHip(ceed, hipGetDeviceProperties(&prop, ceed_data->device_id)); in CeedCompileCore_Hip()
84 std::string arch_arg = "--gpu-architecture=" + std::string(prop.gcnArchName); in CeedCompileCore_Hip()
86 opts[2] = "-munsafe-fp-atomics"; in CeedCompileCore_Hip()
87 opts[3] = "-DCEED_RUNNING_JIT_PASS=1"; in CeedCompileCore_Hip()
92 CeedCallBackend(CeedGetJitSourceRoots(ceed, &num_jit_source_dirs, &jit_source_dirs)); in CeedCompileCore_Hip()
97 include_dir_arg << "-I" << jit_source_dirs[i]; in CeedCompileCore_Hip()
100 CeedCallBackend(CeedRestoreJitSourceRoots(ceed, &jit_source_dirs)); in CeedCompileCore_Hip()
106 CeedCallBackend(CeedGetJitDefines(ceed, &num_jit_defines, &jit_defines)); in CeedCompileCore_Hip()
111 define_arg << "-D" << jit_defines[i]; in CeedCompileCore_Hip()
114 CeedCallBackend(CeedRestoreJitDefines(ceed, &jit_defines)); in CeedCompileCore_Hip()
121 CeedCallHiprtc(ceed, hiprtcCreateProgram(&prog, code.str().c_str(), NULL, 0, NULL, NULL)); in CeedCompileCore_Hip()
124 …CeedDebug256(ceed, CEED_DEBUG_COLOR_SUCCESS, "---------- ATTEMPTING TO COMPILE JIT SOURCE --------… in CeedCompileCore_Hip()
125 CeedDebug(ceed, "Source:\n%s\n", code.str().c_str()); in CeedCompileCore_Hip()
126 CeedDebug256(ceed, CEED_DEBUG_COLOR_SUCCESS, "---------- END OF JIT SOURCE ----------\n"); in CeedCompileCore_Hip()
127 if (CeedDebugFlag(ceed)) { in CeedCompileCore_Hip()
129 CeedDebug256(ceed, CEED_DEBUG_COLOR_SUCCESS, "---------- JiT COMPILER OPTIONS ----------\n"); in CeedCompileCore_Hip()
131 CeedDebug(ceed, "Option %d: %s", i, opts[i]); in CeedCompileCore_Hip()
133 CeedDebug(ceed, ""); in CeedCompileCore_Hip()
134 …CeedDebug256(ceed, CEED_DEBUG_COLOR_SUCCESS, "---------- END OF JiT COMPILER OPTIONS ----------\n"… in CeedCompileCore_Hip()
151 CeedChk_hiprtc(ceed, hiprtcGetProgramLogSize(prog, &log_size)); in CeedCompileCore_Hip()
153 CeedCallHiprtc(ceed, hiprtcGetProgramLog(prog, log)); in CeedCompileCore_Hip()
155 return CeedError(ceed, CEED_ERROR_BACKEND, "%s\n%s", hiprtcGetErrorString(result), log); in CeedCompileCore_Hip()
158 CeedDebug256(ceed, CEED_DEBUG_COLOR_ERROR, "---------- COMPILE ERROR DETECTED ----------\n"); in CeedCompileCore_Hip()
159 CeedDebug(ceed, "Error: %s\nCompile log:\n%s\n", hiprtcGetErrorString(result), log); in CeedCompileCore_Hip()
160 CeedDebug256(ceed, CEED_DEBUG_COLOR_WARNING, "---------- BACKEND MAY FALLBACK ----------\n"); in CeedCompileCore_Hip()
162 CeedCallHiprtc(ceed, hiprtcDestroyProgram(&prog)); in CeedCompileCore_Hip()
168 CeedCallHiprtc(ceed, hiprtcGetCodeSize(prog, &ptx_size)); in CeedCompileCore_Hip()
170 CeedCallHiprtc(ceed, hiprtcGetCode(prog, ptx)); in CeedCompileCore_Hip()
171 CeedCallHiprtc(ceed, hiprtcDestroyProgram(&prog)); in CeedCompileCore_Hip()
173 CeedCallHip(ceed, hipModuleLoadData(module, ptx)); in CeedCompileCore_Hip()
178 int CeedCompile_Hip(Ceed ceed, const char *source, hipModule_t *module, const CeedInt num_defines, … in CeedCompile_Hip() argument
183 …const CeedInt ierr = CeedCompileCore_Hip(ceed, source, true, &is_compile_good, module, num_defines… in CeedCompile_Hip()
190 int CeedTryCompile_Hip(Ceed ceed, const char *source, bool *is_compile_good, hipModule_t *module, c… in CeedTryCompile_Hip() argument
194 …const CeedInt ierr = CeedCompileCore_Hip(ceed, source, false, is_compile_good, module, num_defines… in CeedTryCompile_Hip()
201 //------------------------------------------------------------------------------
203 //------------------------------------------------------------------------------
204 int CeedGetKernel_Hip(Ceed ceed, hipModule_t module, const char *name, hipFunction_t *kernel) { in CeedGetKernel_Hip() argument
205 CeedCallHip(ceed, hipModuleGetFunction(kernel, module, name)); in CeedGetKernel_Hip()
209 //------------------------------------------------------------------------------
211 //------------------------------------------------------------------------------
212 int CeedRunKernel_Hip(Ceed ceed, hipFunction_t kernel, const int grid_size, const int block_size, v… in CeedRunKernel_Hip() argument
213 …CeedCallHip(ceed, hipModuleLaunchKernel(kernel, grid_size, 1, 1, block_size, 1, 1, 0, NULL, args, … in CeedRunKernel_Hip()
217 //------------------------------------------------------------------------------
219 //------------------------------------------------------------------------------
220 int CeedRunKernelDim_Hip(Ceed ceed, hipFunction_t kernel, const int grid_size, const int block_size… in CeedRunKernelDim_Hip() argument
222 …CeedCallHip(ceed, hipModuleLaunchKernel(kernel, grid_size, 1, 1, block_size_x, block_size_y, block… in CeedRunKernelDim_Hip()
226 //------------------------------------------------------------------------------
228 //------------------------------------------------------------------------------
229 static int CeedRunKernelDimSharedCore_Hip(Ceed ceed, hipFunction_t kernel, hipStream_t stream, cons… in CeedRunKernelDimSharedCore_Hip() argument
238 CeedCallHip(ceed, result); in CeedRunKernelDimSharedCore_Hip()
243 CeedDebug256(ceed, CEED_DEBUG_COLOR_ERROR, "---------- LAUNCH ERROR DETECTED ----------\n"); in CeedRunKernelDimSharedCore_Hip()
244 CeedDebug(ceed, "%s\n", message); in CeedRunKernelDimSharedCore_Hip()
245 CeedDebug256(ceed, CEED_DEBUG_COLOR_WARNING, "---------- BACKEND MAY FALLBACK ----------\n"); in CeedRunKernelDimSharedCore_Hip()
253 int CeedRunKernelDimShared_Hip(Ceed ceed, hipFunction_t kernel, hipStream_t stream, const int grid_… in CeedRunKernelDimShared_Hip() argument
257 …CeedCallBackend(CeedRunKernelDimSharedCore_Hip(ceed, kernel, stream, grid_size, block_size_x, bloc… in CeedRunKernelDimShared_Hip()
262 int CeedTryRunKernelDimShared_Hip(Ceed ceed, hipFunction_t kernel, hipStream_t stream, const int gr… in CeedTryRunKernelDimShared_Hip() argument
264 …CeedCallBackend(CeedRunKernelDimSharedCore_Hip(ceed, kernel, stream, grid_size, block_size_x, bloc… in CeedTryRunKernelDimShared_Hip()
269 //------------------------------------------------------------------------------