Skip to content

Commit 721e055

Browse files
sherry-yuanpcolberg
authored andcommitted
Implement OpenCL Core 3.0 clCreateBufferWithProperties
------------------------------------------------------------- In the most recently imported headers, there is a new function called clCreateBufferWithProperties which is equivalent to our clCreateBufferWithPropertiesINTEL extension function. Implement this function. Closes #51
1 parent c9cca6e commit 721e055

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ target_compile_definitions(acl_objs PUBLIC
211211
CL_USE_DEPRECATED_OPENCL_1_0_APIS=1
212212
CL_USE_DEPRECATED_OPENCL_1_1_APIS=1
213213
CL_USE_DEPRECATED_OPENCL_1_2_APIS=1
214-
CL_TARGET_OPENCL_VERSION=200
214+
CL_TARGET_OPENCL_VERSION=300
215215
)
216216
target_include_directories(acl_objs PUBLIC include)
217217
target_include_directories(acl_objs PRIVATE

src/acl_mem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,15 @@ CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferIntelFPGA(cl_context context,
965965
errcode_ret);
966966
}
967967

968+
// Create a buffer with additional properties
969+
ACL_EXPORT
970+
CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferWithProperties(
971+
cl_context context, const cl_mem_properties *properties, cl_mem_flags flags,
972+
size_t size, void *host_ptr, cl_int *errcode_ret) {
973+
return clCreateBufferWithPropertiesINTEL(context, properties, flags, size,
974+
host_ptr, errcode_ret);
975+
}
976+
968977
ACL_EXPORT
969978
CL_API_ENTRY cl_mem CL_API_CALL clCreateBuffer(cl_context context,
970979
cl_mem_flags flags, size_t size,

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ target_compile_definitions(acl_test PRIVATE
3535
CL_USE_DEPRECATED_OPENCL_1_0_APIS=1
3636
CL_USE_DEPRECATED_OPENCL_1_1_APIS=1
3737
CL_USE_DEPRECATED_OPENCL_1_2_APIS=1
38-
CL_TARGET_OPENCL_VERSION=200
38+
CL_TARGET_OPENCL_VERSION=300
3939
)
4040
target_include_directories(acl_test PRIVATE
4141
"${CMAKE_BINARY_DIR}/include"

test/acl_mem_test.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ TEST(acl_mem, exhaustion) {
13811381
(mem[0]->block_allocation->range).begin);
13821382

13831383
props[1] = 2;
1384-
mem[3] = clCreateBufferWithPropertiesINTEL(
1384+
mem[3] = clCreateBufferWithProperties(
13851385
m_context, props, 0, (size_t)m_context->max_mem_alloc_size / 4, 0,
13861386
&status);
13871387
sofar2 += m_context->max_mem_alloc_size / 4;
@@ -1394,8 +1394,7 @@ TEST(acl_mem, exhaustion) {
13941394
props[1] = 2;
13951395
// the size of dimm#2 is m_context->max_mem_alloc_size/2
13961396
// mem[1] and mem[3] already exhausted dimm#2
1397-
mem[4] =
1398-
clCreateBufferWithPropertiesINTEL(m_context, props, 0, 128, 0, &status);
1397+
mem[4] = clCreateBufferWithProperties(m_context, props, 0, 128, 0, &status);
13991398
CHECK_EQUAL(
14001399
CL_SUCCESS,
14011400
status); // Buffer allocation should always succeed (allocation deferred)

0 commit comments

Comments
 (0)