Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for cl_ext_buffer_device_address #2192

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

franz
Copy link
Contributor

@franz franz commented Dec 14, 2024

No description provided.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use the new test registration framework for these tests? It should reduce a bit of the test boilerplate, and then we won't need to switch them over later.

#2151

@franz
Copy link
Contributor Author

franz commented Dec 19, 2024

@bashbaug added, based on the device_timer test.

@karolherbst
Copy link
Contributor

Not sure if you got to it yet, but I've fixed the test so it compiles and conforms to the recent version, might need some cleanup and reformatting and all that:

@@ -59,8 +59,10 @@ public:
     bool Skip()
     {
         cl_int error = 0;
-        clMemWrapper TempBuffer = clCreateBuffer(
-            context, (cl_mem_flags)(CL_MEM_READ_WRITE | address_type),
+
+        cl_mem_properties buf_props[] = { address_type, CL_TRUE, 0 };
+        clMemWrapper TempBuffer = clCreateBufferWithProperties(
+            context, buf_props, CL_MEM_READ_WRITE,
             (size_t)BUF_SIZE * sizeof(cl_int), nullptr, &error);
         return (error != CL_SUCCESS);
     }
@@ -108,7 +110,7 @@ public:
 
         // Test a buffer which doesn't have any hostptr associated with it.
         dev_addr_no_host_buffer =
-            clCreateBuffer(context, CL_MEM_READ_WRITE | address_type,
+            clCreateBufferWithProperties(context, buf_props, CL_MEM_READ_WRITE,
                            sizeof(cl_int) * BUF_SIZE, nullptr, &error);
         test_error(error, "clCreateBuffer with device address 2 failed\n");
 
@@ -189,7 +191,7 @@ private:
             sizeof(cl_int) * BUF_SIZE, svm_buffer(), &error);
         test_error(error, "clCreateBuffer with device address 1 failed\n");
 
-        cl_mem_device_address_EXT Addr = 0;
+        cl_mem_device_address_ext Addr = 0;
         error = clGetMemObjectInfo(buffer, CL_MEM_DEVICE_ADDRESS_EXT,
                                    sizeof(Addr), &Addr, NULL);
         test_error(error,
@@ -376,10 +378,11 @@ private:
             check_device_address_from_api(dev_addr_buffer, DeviceAddrFromAPI);
         test_error_fail(error, "dev_addr_buffer does not have device address")
 
+        cl_mem_device_address_ext DeviceAddrFromAPIP2 = (cl_mem_device_address_ext)(((cl_uint *)DeviceAddrFromAPI) + 2);
             error = clSetKernelArgDevicePointer(
                 ptr_arith_kernel, 0,
-                (cl_mem_device_address_ext)(((cl_uint *)DeviceAddrFromAPI)
-                                            + 2));
+                &DeviceAddrFromAPIP2);
+
         test_error_fail(error, "clSetKernelArgDevicePointer failed\n");
         error = clSetKernelArg(ptr_arith_kernel, 1, sizeof(cl_mem),
                                &buffer_out_int);

@franz
Copy link
Contributor Author

franz commented Jan 20, 2025

@karolherbst thanks, added

@karolherbst
Copy link
Contributor

I forgot to bump the version

diff --git a/test_conformance/extensions/cl_ext_buffer_device_address/main.cpp b/test_conformance/extensions/cl_ext_buffer_device_address/main.cpp
index 1ce30008..d8475647 100644
--- a/test_conformance/extensions/cl_ext_buffer_device_address/main.cpp
+++ b/test_conformance/extensions/cl_ext_buffer_device_address/main.cpp
@@ -38,7 +38,7 @@ test_status InitCL(cl_device_id device)
 
     cl_version ext_version =
         get_extension_version(device, "cl_ext_buffer_device_address");
-    if (ext_version != CL_MAKE_VERSION(0, 9, 1))
+    if (ext_version != CL_MAKE_VERSION(1, 0, 0))
     {
         log_info("The test is written against cl_ext_buffer_device_address "
                  "extension version 0.9.1, device supports version: %u.%u.%u\n",

@bashbaug
Copy link
Contributor

Note, we are going to need to merge the header changes for cl_ext_buffer_device_address before this PR, or figure out some other way to avoid breaking the build. KhronosGroup/OpenCL-Headers#273

@bashbaug
Copy link
Contributor

Since we merged the header changes, the CI builds should finish now. @franz could you please push a dummy commit or otherwise cause the tests to rerun to verify?

It'd be nice to have an approval from @pjaaskel or @karolherbst before merging.

Copy link
Contributor

@pjaaskel pjaaskel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after the tests pass.

@karolherbst
Copy link
Contributor

needs this patch to compile against upstream headers:

diff --git a/test_conformance/extensions/cl_ext_buffer_device_address/buffer_device_address.cpp b/test_conformance/extensions/cl_ext_buffer_device_address/buffer_device_address.cpp
index d91e3e6d..7fe4522b 100644
--- a/test_conformance/extensions/cl_ext_buffer_device_address/buffer_device_address.cpp
+++ b/test_conformance/extensions/cl_ext_buffer_device_address/buffer_device_address.cpp
@@ -140,7 +140,7 @@ private:
     cl_mem_properties address_type;
 
     int check_device_address_from_api(cl_mem buf,
-                                      cl_mem_device_address_EXT &Addr)
+                                      cl_mem_device_address_ext &Addr)
     {
         Addr = 0;
         cl_int error = clGetMemObjectInfo(buf, CL_MEM_DEVICE_ADDRESS_EXT,
@@ -213,7 +213,7 @@ private:
     {
         cl_int error = 0;
         cl_ulong DeviceAddrFromKernel = 0;
-        cl_mem_device_address_EXT DeviceAddrFromAPI = 0;
+        cl_mem_device_address_ext DeviceAddrFromAPI = 0;
 
         for (int i = 0; i < BUF_SIZE; ++i)
         {
@@ -281,7 +281,7 @@ private:
                              clKernelWrapper &ind_access_kernel)
     {
         cl_int error = 0;
-        cl_mem_device_address_EXT DeviceAddrFromAPI = 0;
+        cl_mem_device_address_ext DeviceAddrFromAPI = 0;
 
         int DataIn = 0x12348765;
         int DataOut = -1;
@@ -355,7 +355,7 @@ private:
                             clKernelWrapper &ptr_arith_kernel)
     {
         cl_int error = 0;
-        cl_mem_device_address_EXT DeviceAddrFromAPI = 0;
+        cl_mem_device_address_ext DeviceAddrFromAPI = 0;
         int DataOut = -1;
         int DataIn = 0x12348765;
 

@franz franz force-pushed the cl_ext_buffer_device_address branch from 47d6695 to 769f4a8 Compare February 27, 2025 14:19
@CLAassistant
Copy link

CLAassistant commented Feb 27, 2025

CLA assistant check
All committers have signed the CLA.

@franz franz force-pushed the cl_ext_buffer_device_address branch from d01dcd4 to 3a88039 Compare February 27, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants