77// ===----------------------------------------------------------------------===//
88
99#include " KernelTranslation.h"
10+ #include " helper/ConfigHelper.h"
1011
1112#include " SPIRVLLVMTranslation.h"
1213#include " llvm/Bitcode/BitcodeReader.h"
@@ -168,11 +169,10 @@ KernelTranslator::loadSPIRVKernel(llvm::LLVMContext &LLVMCtx,
168169 return SPIRVLLVMTranslator::loadSPIRVKernel (LLVMCtx, Kernel);
169170}
170171
171- llvm::Error
172- KernelTranslator::translateKernel (SYCLKernelInfo &Kernel, llvm::Module &Mod,
173- JITContext &JITCtx, BinaryFormat Format,
174- const std::string &TargetCPU,
175- const std::string &TargetFeatures) {
172+ llvm::Error KernelTranslator::translateKernel (SYCLKernelInfo &Kernel,
173+ llvm::Module &Mod,
174+ JITContext &JITCtx,
175+ BinaryFormat Format) {
176176
177177 KernelBinary *KernelBin = nullptr ;
178178 switch (Format) {
@@ -187,7 +187,7 @@ KernelTranslator::translateKernel(SYCLKernelInfo &Kernel, llvm::Module &Mod,
187187 }
188188 case BinaryFormat::PTX: {
189189 llvm::Expected<KernelBinary *> BinaryOrError =
190- translateToPTX (Kernel, Mod, JITCtx, TargetCPU, TargetFeatures );
190+ translateToPTX (Kernel, Mod, JITCtx);
191191 if (auto Error = BinaryOrError.takeError ()) {
192192 return Error;
193193 }
@@ -196,7 +196,7 @@ KernelTranslator::translateKernel(SYCLKernelInfo &Kernel, llvm::Module &Mod,
196196 }
197197 case BinaryFormat::AMDGCN: {
198198 llvm::Expected<KernelBinary *> BinaryOrError =
199- translateToAMDGCN (Kernel, Mod, JITCtx, TargetCPU, TargetFeatures );
199+ translateToAMDGCN (Kernel, Mod, JITCtx);
200200 if (auto Error = BinaryOrError.takeError ())
201201 return Error;
202202 KernelBin = *BinaryOrError;
@@ -227,10 +227,9 @@ KernelTranslator::translateToSPIRV(llvm::Module &Mod, JITContext &JITCtx) {
227227 return SPIRVLLVMTranslator::translateLLVMtoSPIRV (Mod, JITCtx);
228228}
229229
230- llvm::Expected<KernelBinary *> KernelTranslator::translateToPTX (
231- SYCLKernelInfo &KernelInfo, llvm::Module &Mod, JITContext &JITCtx,
232- [[maybe_unused]] const std::string &TargetCPU,
233- [[maybe_unused]] const std::string &TargetFeatures) {
230+ llvm::Expected<KernelBinary *>
231+ KernelTranslator::translateToPTX (SYCLKernelInfo &KernelInfo, llvm::Module &Mod,
232+ JITContext &JITCtx) {
234233#ifndef JIT_SUPPORT_PTX
235234 (void )KernelInfo;
236235 (void )Mod;
@@ -261,8 +260,10 @@ llvm::Expected<KernelBinary *> KernelTranslator::translateToPTX(
261260
262261 // Give priority to user specified values (through environment variables:
263262 // SYCL_JIT_AMDGCN_PTX_TARGET_CPU and SYCL_JIT_AMDGCN_PTX_TARGET_FEATURES).
264- llvm::StringRef CPU{TargetCPU};
265- llvm::StringRef Features{TargetFeatures};
263+ auto CPUVal = ConfigHelper::get<option::JITTargetCPU>();
264+ auto FeaturesVal = ConfigHelper::get<option::JITTargetFeatures>();
265+ llvm::StringRef CPU = CPUVal.begin ();
266+ llvm::StringRef Features = FeaturesVal.begin ();
266267
267268 auto *KernelFunc = Mod.getFunction (KernelInfo.Name .c_str ());
268269 // If they were not set, use default and consult the module for alternatives
@@ -309,10 +310,9 @@ llvm::Expected<KernelBinary *> KernelTranslator::translateToPTX(
309310#endif // JIT_SUPPORT_PTX
310311}
311312
312- llvm::Expected<KernelBinary *> KernelTranslator::translateToAMDGCN (
313- SYCLKernelInfo &KernelInfo, llvm::Module &Mod, JITContext &JITCtx,
314- [[maybe_unused]] const std::string &TargetCPU,
315- [[maybe_unused]] const std::string &TargetFeatures) {
313+ llvm::Expected<KernelBinary *>
314+ KernelTranslator::translateToAMDGCN (SYCLKernelInfo &KernelInfo,
315+ llvm::Module &Mod, JITContext &JITCtx) {
316316#ifndef JIT_SUPPORT_AMDGCN
317317 (void )KernelInfo;
318318 (void )Mod;
@@ -341,8 +341,10 @@ llvm::Expected<KernelBinary *> KernelTranslator::translateToAMDGCN(
341341 " Failed to load and translate AMDGCN LLVM IR module with error %s" ,
342342 ErrorMessage.c_str ());
343343
344- llvm::StringRef CPU{TargetCPU};
345- llvm::StringRef Features{TargetFeatures};
344+ auto CPUVal = ConfigHelper::get<option::JITTargetCPU>();
345+ auto FeaturesVal = ConfigHelper::get<option::JITTargetFeatures>();
346+ llvm::StringRef CPU = CPUVal.begin ();
347+ llvm::StringRef Features = FeaturesVal.begin ();
346348
347349 auto *KernelFunc = Mod.getFunction (KernelInfo.Name .c_str ());
348350 if (CPU.empty ()) {
0 commit comments