Skip to content

[Offload] Set size correctly in olLaunchKernel cts test #142398

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

RossBrunton
Copy link
Contributor

It was previously not scaled by sizeof(uint32_t).

It was previously not scaled by `sizeof(uint32_t)`.
@llvmbot llvmbot added the offload label Jun 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 2, 2025

@llvm/pr-subscribers-offload

Author: Ross Brunton (RossBrunton)

Changes

It was previously not scaled by sizeof(uint32_t).


Full diff: https://github.com/llvm/llvm-project/pull/142398.diff

2 Files Affected:

  • (modified) offload/unittests/OffloadAPI/device_code/foo.c (+2-1)
  • (modified) offload/unittests/OffloadAPI/kernel/olLaunchKernel.cpp (+6-4)
diff --git a/offload/unittests/OffloadAPI/device_code/foo.c b/offload/unittests/OffloadAPI/device_code/foo.c
index 5bc893961d49f..83cdc53cddd8d 100644
--- a/offload/unittests/OffloadAPI/device_code/foo.c
+++ b/offload/unittests/OffloadAPI/device_code/foo.c
@@ -1,5 +1,6 @@
 #include <gpuintrin.h>
+#include <stdint.h>
 
-__gpu_kernel void foo(int *out) {
+__gpu_kernel void foo(uint32_t *out) {
   out[__gpu_thread_id(0)] = __gpu_thread_id(0);
 }
diff --git a/offload/unittests/OffloadAPI/kernel/olLaunchKernel.cpp b/offload/unittests/OffloadAPI/kernel/olLaunchKernel.cpp
index 20462e22fd73f..e17d094cfa612 100644
--- a/offload/unittests/OffloadAPI/kernel/olLaunchKernel.cpp
+++ b/offload/unittests/OffloadAPI/kernel/olLaunchKernel.cpp
@@ -47,7 +47,8 @@ OFFLOAD_TESTS_INSTANTIATE_DEVICE_FIXTURE(olLaunchKernelTest);
 
 TEST_P(olLaunchKernelTest, Success) {
   void *Mem;
-  ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_MANAGED, 64, &Mem));
+  ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_MANAGED,
+                            LaunchArgs.GroupSizeX * sizeof(uint32_t), &Mem));
   struct {
     void *Mem;
   } Args{Mem};
@@ -57,7 +58,7 @@ TEST_P(olLaunchKernelTest, Success) {
 
   ASSERT_SUCCESS(olWaitQueue(Queue));
 
-  int *Data = (int *)Mem;
+  uint32_t *Data = (uint32_t *)Mem;
   for (int i = 0; i < 64; i++) {
     ASSERT_EQ(Data[i], i);
   }
@@ -67,7 +68,8 @@ TEST_P(olLaunchKernelTest, Success) {
 
 TEST_P(olLaunchKernelTest, SuccessSynchronous) {
   void *Mem;
-  ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_MANAGED, 64, &Mem));
+  ASSERT_SUCCESS(olMemAlloc(Device, OL_ALLOC_TYPE_MANAGED,
+                            LaunchArgs.GroupSizeX * sizeof(uint32_t), &Mem));
 
   struct {
     void *Mem;
@@ -76,7 +78,7 @@ TEST_P(olLaunchKernelTest, SuccessSynchronous) {
   ASSERT_SUCCESS(olLaunchKernel(nullptr, Device, Kernel, &Args, sizeof(Args),
                                 &LaunchArgs, nullptr));
 
-  int *Data = (int *)Mem;
+  uint32_t *Data = (uint32_t *)Mem;
   for (int i = 0; i < 64; i++) {
     ASSERT_EQ(Data[i], i);
   }

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

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

Oh yeah I saw that but forgot to fix it, thanks.

@jhuber6 jhuber6 merged commit 41e22aa into llvm:main Jun 2, 2025
11 checks passed
sallto pushed a commit to sallto/llvm-project that referenced this pull request Jun 3, 2025
It was previously not scaled by `sizeof(uint32_t)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants