Issue 143323
Summary [Offload] Kernel launch fails with "too many resources" when parameter type is changed from `size_t` to `int`
Labels new issue
Assignees
Reporter leandrolcampos
    I observed something weird. When I try to launch the following kernel

```cpp
#include <gpuintrin.h>
#include <math.h>
#include <stdlib.h>

extern "C" __gpu_kernel void applyLogf(const float *In, float *Out,
 size_t NumElements) {
  int Index = __gpu_num_threads(__GPU_X_DIM) * __gpu_block_id(__GPU_X_DIM) +
 __gpu_thread_id(__GPU_X_DIM);

  if (Index < NumElements) {
    Out[Index] = logf(In[Index]);
  }
}
```

with these arguments

```cpp
    // ...
    struct {
      void *InBuffer;
      void *OutBuffer;
 size_t NumElements;
    } Args{InBuffer, OutBuffer, NumElements};

 OL_CHECK(olLaunchKernel(nullptr, GPUDevice.Handle, Kernel, &Args,
 sizeof(Args), &LaunchArgs, nullptr));
    // ...
```

everything works fine. But if I try to change the type of `NumElements` to `int`,  here

```cpp
#include <gpuintrin.h>
#include <math.h>

extern "C" __gpu_kernel void applyLogf(const float *In, float *Out,
                                       int NumElements) {
  int Index = __gpu_num_threads(__GPU_X_DIM) * __gpu_block_id(__GPU_X_DIM) +
 __gpu_thread_id(__GPU_X_DIM);

  if (Index < NumElements) {
 Out[Index] = logf(In[Index]);
  }
}
```

and here

```cpp
    // ...
    struct {
      void *InBuffer;
      void *OutBuffer;
      int NumElements;
    } Args{InBuffer, OutBuffer, static_cast<int>(NumElements)};

    OL_CHECK(olLaunchKernel(nullptr, GPUDevice.Handle, Kernel, &Args,
                            sizeof(Args), &LaunchArgs, nullptr));
    // ...
```

I get the following error:

```bash
OL_CHECK FAILED: (olLaunchKernel(nullptr, GPUDevice.Handle, Kernel, &Args, sizeof(Args), &LaunchArgs, nullptr)) != OL_SUCCESS
  Error Code: 1
  Details: error in cuLaunchKernel for 'applyLogf': too many resources requested for launch
  Location: /home/leandro/offload-samples/samples/math_test/Tester.hpp:151
  Function: check
```

**Environment:**
* LLVM version: Custom build from git
    * LLVM Project Commit Hash: `1e4841881ef89aeee77cbf081de42af376bfa3fb`
* Operating System: Ubuntu 24.04.2 LTS (WSL2)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to