mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Cleanup offline compilation code
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
This commit is contained in:
committed by
Kévin Petit
parent
982e3ed79c
commit
2c43504923
@@ -219,6 +219,9 @@ static std::string get_offline_compilation_file_type_str(const CompilationMode c
|
|||||||
switch (compilationMode)
|
switch (compilationMode)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
assert(0 && "Invalid compilation mode");
|
||||||
|
abort();
|
||||||
|
case kOnline:
|
||||||
assert(0 && "Invalid compilation mode for offline compilation");
|
assert(0 && "Invalid compilation mode for offline compilation");
|
||||||
abort();
|
abort();
|
||||||
case kBinary:
|
case kBinary:
|
||||||
@@ -228,11 +231,12 @@ static std::string get_offline_compilation_file_type_str(const CompilationMode c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KHRONOS_OFFLINE_COMPILER
|
||||||
static std::string get_khronos_compiler_command(const cl_uint device_address_space_size,
|
static std::string get_khronos_compiler_command(const cl_uint device_address_space_size,
|
||||||
const bool openclCXX,
|
const bool openclCXX,
|
||||||
const std::string &bOptions,
|
const std::string &bOptions,
|
||||||
const std::string &sourceFilename,
|
const std::string &sourceFilename,
|
||||||
const std::string &outputFilename)
|
const std::string &outputFilename)
|
||||||
{
|
{
|
||||||
// Set compiler options
|
// Set compiler options
|
||||||
// Emit SPIR-V
|
// Emit SPIR-V
|
||||||
@@ -275,6 +279,7 @@ static std::string get_khronos_compiler_command(const cl_uint device_address_spa
|
|||||||
|
|
||||||
return runString;
|
return runString;
|
||||||
}
|
}
|
||||||
|
#endif // KHRONOS_OFFLINE_COMPILER
|
||||||
|
|
||||||
static std::string get_offline_compilation_command(const cl_uint device_address_space_size,
|
static std::string get_offline_compilation_command(const cl_uint device_address_space_size,
|
||||||
const CompilationMode compilationMode,
|
const CompilationMode compilationMode,
|
||||||
@@ -369,14 +374,19 @@ static int invoke_offline_compiler(const cl_device_id device,
|
|||||||
log_error("CL C++ compilation is not possible: KHRONOS_OFFLINE_COMPILER was not defined.\n");
|
log_error("CL C++ compilation is not possible: KHRONOS_OFFLINE_COMPILER was not defined.\n");
|
||||||
return CL_INVALID_OPERATION;
|
return CL_INVALID_OPERATION;
|
||||||
#else
|
#else
|
||||||
|
if (compilationMode != kSpir_v)
|
||||||
|
{
|
||||||
|
log_error("Compilation mode must be SPIR-V for Khronos compiler");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
runString = get_khronos_compiler_command(device_address_space_size, openclCXX, bOptions,
|
runString = get_khronos_compiler_command(device_address_space_size, openclCXX, bOptions,
|
||||||
sourceFilename, outputFilename);
|
sourceFilename, outputFilename);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
runString = get_offline_compilation_command(device_address_space_size, compilationMode, bOptions,
|
runString = get_offline_compilation_command(device_address_space_size, compilationMode, bOptions,
|
||||||
sourceFilename, outputFilename);
|
sourceFilename, outputFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute script
|
// execute script
|
||||||
@@ -435,7 +445,7 @@ static int get_offline_compiler_output(std::ifstream &ifs,
|
|||||||
const std::string &bOptions,
|
const std::string &bOptions,
|
||||||
const std::string &kernelName)
|
const std::string &kernelName)
|
||||||
{
|
{
|
||||||
std::string sourceFilename = gCompilationCachePath + slash + kernelName + ".cl";
|
std::string baseFilename = gCompilationCachePath + slash + kernelName;
|
||||||
|
|
||||||
// Get device CL_DEVICE_ADDRESS_BITS
|
// Get device CL_DEVICE_ADDRESS_BITS
|
||||||
cl_uint device_address_space_size = 0;
|
cl_uint device_address_space_size = 0;
|
||||||
@@ -443,7 +453,7 @@ static int get_offline_compiler_output(std::ifstream &ifs,
|
|||||||
if (error != CL_SUCCESS)
|
if (error != CL_SUCCESS)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
std::string outputFilename = gCompilationCachePath + slash + kernelName;
|
std::string outputFilename = baseFilename;
|
||||||
if (compilationMode == kSpir_v)
|
if (compilationMode == kSpir_v)
|
||||||
{
|
{
|
||||||
std::ostringstream extension;
|
std::ostringstream extension;
|
||||||
@@ -452,7 +462,8 @@ static int get_offline_compiler_output(std::ifstream &ifs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try to read cached output file when test is run with gCompilationCacheMode != kCacheModeOverwrite
|
// try to read cached output file when test is run with gCompilationCacheMode != kCacheModeOverwrite
|
||||||
ifs.open(outputFilename.c_str(), std::ios::binary);
|
if (gCompilationCacheMode != kCacheModeOverwrite)
|
||||||
|
ifs.open(outputFilename.c_str(), std::ios::binary);
|
||||||
|
|
||||||
if (gCompilationCacheMode == kCacheModeOverwrite || !ifs.good())
|
if (gCompilationCacheMode == kCacheModeOverwrite || !ifs.good())
|
||||||
{
|
{
|
||||||
@@ -471,6 +482,8 @@ static int get_offline_compiler_output(std::ifstream &ifs,
|
|||||||
log_info("OfflineCompiler: can't find cached %s file: %s\n",
|
log_info("OfflineCompiler: can't find cached %s file: %s\n",
|
||||||
file_type.c_str(), outputFilename.c_str());
|
file_type.c_str(), outputFilename.c_str());
|
||||||
|
|
||||||
|
std::string sourceFilename = baseFilename + ".cl";
|
||||||
|
|
||||||
std::ofstream ofs(sourceFilename.c_str(), std::ios::binary);
|
std::ofstream ofs(sourceFilename.c_str(), std::ios::binary);
|
||||||
if (!ofs.good())
|
if (!ofs.good())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user