P4 to Git Change 1487653 by wchau@wchau_OCL_boltzmann on 2017/11/28 11:28:09
SWDEV-119491 - Add support for cl_amd_assembly_program extension This is a sub-task of SWDEV-134396. Part 1/4 of the required changes: (1) OpenCL API / Runtime, (2) ROCm Runtime - compiler invocation, (3) ROCm Driver, (4) Enabling Extension Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_common.hpp#19 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#57 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#45 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_ext.h#19 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h#35 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_ext.h#12 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_ext.h#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#215 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#293 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#90 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#42 edit
This commit is contained in:
@@ -291,6 +291,14 @@ clCreateBufferFromImageAMD(
|
||||
cl_mem image,
|
||||
cl_int * errcode_ret);
|
||||
|
||||
extern CL_API_ENTRY cl_program CL_API_CALL
|
||||
clCreateProgramWithAssemblyAMD(
|
||||
cl_context context,
|
||||
cl_uint count,
|
||||
const char ** strings,
|
||||
const size_t * lengths,
|
||||
cl_int * errcode_ret);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
//! \endcond
|
||||
|
||||
@@ -479,6 +479,9 @@ CL_API_ENTRY void* CL_API_CALL clGetExtensionFunctionAddress(const char* func_na
|
||||
#if defined(cl_khr_il_program) || defined(CL_VERSION_2_1)
|
||||
CL_EXTENSION_ENTRYPOINT_CHECK2(clCreateProgramWithILKHR,clCreateProgramWithIL);
|
||||
#endif // defined(cl_khr_il_program) || defined(CL_VERSION_2_1)
|
||||
#if cl_amd_assembly_program
|
||||
CL_EXTENSION_ENTRYPOINT_CHECK(clCreateProgramWithAssemblyAMD);
|
||||
#endif // cl_amd_assembly_program
|
||||
#if cl_amd_liquid_flash
|
||||
CL_EXTENSION_ENTRYPOINT_CHECK(clCreateSsgFileObjectAMD);
|
||||
#endif // cl_amd_liquid_flash
|
||||
|
||||
@@ -134,7 +134,7 @@ RUNTIME_ENTRY_RET(cl_program, clCreateProgramWithSource,
|
||||
}
|
||||
|
||||
// Create the program
|
||||
amd::Program* program = new amd::Program(*as_amd(context), sourceCode);
|
||||
amd::Program* program = new amd::Program(*as_amd(context), sourceCode, amd::Program::OpenCL_C);
|
||||
if (program == NULL) {
|
||||
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY;
|
||||
return (cl_program)0;
|
||||
@@ -196,7 +196,7 @@ RUNTIME_ENTRY_RET(cl_program, clCreateProgramWithIL,
|
||||
}
|
||||
|
||||
// Create the program
|
||||
amd::Program* program = new amd::Program(*as_amd(context), "", true);
|
||||
amd::Program* program = new amd::Program(*as_amd(context), amd::Program::SPIRV);
|
||||
if (program == NULL) {
|
||||
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY;
|
||||
return (cl_program)0;
|
||||
@@ -330,6 +330,58 @@ RUNTIME_ENTRY_RET(cl_program, clCreateProgramWithBinary,
|
||||
}
|
||||
RUNTIME_EXIT
|
||||
|
||||
RUNTIME_ENTRY_RET(cl_program, clCreateProgramWithAssemblyAMD,
|
||||
(cl_context context, cl_uint count, const char** strings, const size_t* lengths,
|
||||
cl_int* errcode_ret)) {
|
||||
if (!is_valid(context)) {
|
||||
*not_null(errcode_ret) = CL_INVALID_CONTEXT;
|
||||
return (cl_program)0;
|
||||
}
|
||||
if (count == 0 || strings == NULL) {
|
||||
*not_null(errcode_ret) = CL_INVALID_VALUE;
|
||||
return (cl_program)0;
|
||||
}
|
||||
|
||||
std::string assembly;
|
||||
for (cl_uint i = 0; i < count; ++i) {
|
||||
if (strings[i] == NULL) {
|
||||
*not_null(errcode_ret) = CL_INVALID_VALUE;
|
||||
return (cl_program)0;
|
||||
}
|
||||
if (lengths && lengths[i] != 0) {
|
||||
assembly.append(strings[i], lengths[i]);
|
||||
} else {
|
||||
assembly.append(strings[i]);
|
||||
}
|
||||
}
|
||||
if (assembly.empty()) {
|
||||
*not_null(errcode_ret) = CL_INVALID_VALUE;
|
||||
return (cl_program)0;
|
||||
}
|
||||
|
||||
// Create the program
|
||||
amd::Program* program = new amd::Program(*as_amd(context), assembly, amd::Program::Assembly);
|
||||
if (program == NULL) {
|
||||
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY;
|
||||
return (cl_program)0;
|
||||
}
|
||||
|
||||
// Add programs for all devices in the context.
|
||||
const std::vector<amd::Device*>& devices = as_amd(context)->devices();
|
||||
std::vector<amd::Device*>::const_iterator it;
|
||||
for (it = devices.begin(); it != devices.end(); ++it) {
|
||||
if (program->addDeviceProgram(**it) == CL_OUT_OF_HOST_MEMORY) {
|
||||
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY;
|
||||
program->release();
|
||||
return (cl_program)0;
|
||||
}
|
||||
}
|
||||
|
||||
*not_null(errcode_ret) = CL_SUCCESS;
|
||||
return as_cl(program);
|
||||
}
|
||||
RUNTIME_EXIT
|
||||
|
||||
/*! \brief Increment the program reference count.
|
||||
*
|
||||
* clCreateProgram does an implicit retain.
|
||||
|
||||
@@ -352,6 +352,19 @@ typedef CL_API_ENTRY cl_int
|
||||
const cl_event* /*event_wait_list*/,
|
||||
cl_event* /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/***********************************
|
||||
* cl_amd_assembly_program extension *
|
||||
***********************************/
|
||||
#define cl_amd_assembly_program 1
|
||||
|
||||
typedef CL_API_ENTRY cl_program (CL_API_CALL * clCreateProgramWithAssemblyAMD_fn) (
|
||||
cl_context /* context */,
|
||||
cl_uint /* count */,
|
||||
const char** /* strings */,
|
||||
const size_t* /* lengths */,
|
||||
cl_int* /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
|
||||
// <amd_internal>
|
||||
/***************************
|
||||
* cl_amd_command_intercept *
|
||||
|
||||
@@ -371,6 +371,18 @@ typedef CL_API_ENTRY cl_int
|
||||
const cl_event* /*event_wait_list*/,
|
||||
cl_event* /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/***********************************
|
||||
* cl_amd_assembly_program extension *
|
||||
***********************************/
|
||||
#define cl_amd_assembly_program 1
|
||||
|
||||
typedef CL_API_ENTRY cl_program (CL_API_CALL * clCreateProgramWithAssemblyAMD_fn) (
|
||||
cl_context /* context */,
|
||||
cl_uint /* count */,
|
||||
const char** /* strings */,
|
||||
const size_t* /* lengths */,
|
||||
cl_int* /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
// <amd_internal>
|
||||
/***************************
|
||||
* cl_amd_command_intercept *
|
||||
|
||||
@@ -352,6 +352,18 @@ typedef CL_API_ENTRY cl_int
|
||||
const cl_event* /*event_wait_list*/,
|
||||
cl_event* /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/***********************************
|
||||
* cl_amd_assembly_program extension *
|
||||
***********************************/
|
||||
#define cl_amd_assembly_program 1
|
||||
|
||||
typedef CL_API_ENTRY cl_program (CL_API_CALL * clCreateProgramWithAssemblyAMD_fn) (
|
||||
cl_context /* context */,
|
||||
cl_uint /* count */,
|
||||
const char** /* strings */,
|
||||
const size_t* /* lengths */,
|
||||
cl_int* /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
// <amd_internal>
|
||||
/***************************
|
||||
* cl_amd_command_intercept *
|
||||
|
||||
@@ -352,6 +352,18 @@ typedef CL_API_ENTRY cl_int
|
||||
const cl_event* /*event_wait_list*/,
|
||||
cl_event* /*event*/) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/***********************************
|
||||
* cl_amd_assembly_program extension *
|
||||
***********************************/
|
||||
#define cl_amd_assembly_program 1
|
||||
|
||||
typedef CL_API_ENTRY cl_program (CL_API_CALL * clCreateProgramWithAssemblyAMD_fn) (
|
||||
cl_context /* context */,
|
||||
cl_uint /* count */,
|
||||
const char** /* strings */,
|
||||
const size_t* /* lengths */,
|
||||
cl_int* /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
// <amd_internal>
|
||||
/***************************
|
||||
* cl_amd_command_intercept *
|
||||
|
||||
Reference in New Issue
Block a user