Skip to content

Commit

Permalink
add platform specific options function
Browse files Browse the repository at this point in the history
  • Loading branch information
StRigaud committed Dec 14, 2023
1 parent 1551139 commit f00284e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions clic/src/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ imageDefines(std::ostringstream & defines,
defines << "\n#define WRITE_" << key << "_IMAGE(a,b,c) write_image" << prefix << "(a,b,c)";
}

static auto
platform_options(const Device::Pointer & device, std::string * source) -> void
{
auto platform = device->getPlatform();
if (platform.find("AMD") != std::string::npos)
{
// append at the begining of the source code the following string "#pragma OPENCL EXTENSION cl_amd_printf : enable"
*source = "#pragma OPENCL EXTENSION cl_amd_printf : enable\n" + *source;
}
}

// Function for creating defines for each array parameters
static auto
Expand Down Expand Up @@ -187,14 +197,15 @@ execute(const Device::Pointer & device,
const ConstantList & constants) -> void
{
// prepare kernel source for compilation and execution
auto kernel_source = kernel_func.second;
const auto kernel_name = kernel_func.first;
const auto kernel_preamble = cle::BackendManager::getInstance().getBackend().getPreamble();
const auto defines = generateDefines(parameters, constants, device->getType());
auto kernel_source = kernel_func.second;
auto kernel_name = kernel_func.first;
auto kernel_preamble = cle::BackendManager::getInstance().getBackend().getPreamble();
auto defines = generateDefines(parameters, constants, device->getType());
if (device->getType() == Device::Type::CUDA)
{
cle::translateOpenclToCuda(kernel_source);
}
platform_options(device, &kernel_preamble);
const std::string program_source = defines + kernel_preamble + kernel_source;

// prepare parameters to be passed to the backend
Expand Down

0 comments on commit f00284e

Please sign in to comment.