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

Feat/debug logger #38

Merged
merged 6 commits into from
Jul 26, 2024
Merged

Feat/debug logger #38

merged 6 commits into from
Jul 26, 2024

Conversation

nathanielsimard
Copy link
Member

@nathanielsimard nathanielsimard commented Jul 26, 2024

  • Fix cuda slicing pointer cleanup
  • Fix cuda broadcast scalar assign

Example

CUBECL_DEBUG_LOG=stdout cargo run --example gelu --release --features cuda
    Finished `release` profile [optimized] target(s) in 0.11s
     Running `target/release/examples/gelu`

======== Compiled Kernel ========
name: gelu::gelu_array::GeluArray<
    cubecl_core::frontend::element::float::F32,
    cubecl_cuda::runtime::CudaRuntime,
>
cube_dim: (4, 1, 1)
shared_memory: 0 bytes
source:

typedef unsigned int uint;

extern "C" __global__ void kernel(float input_0[], float output_0[],
                                  uint info[]) {

  int3 absoluteIdx = make_int3(blockIdx.x * blockDim.x + threadIdx.x,
                               blockIdx.y * blockDim.y + threadIdx.y,
                               blockIdx.z * blockDim.z + threadIdx.z);

  uint idxGlobal =
      (absoluteIdx.z * gridDim.x * blockDim.x * gridDim.y * blockDim.y) +
      (absoluteIdx.y * gridDim.x * blockDim.x) + absoluteIdx.x;
  uint rank = info[0];
  uint rank_2 = rank * 2;
  uint l_0_0;
  bool l_0_1;
  float l_0_2;
  float l_0_3;
  l_0_0 = info[(2 * 2 * info[0]) + 1];
  l_0_1 = idxGlobal < l_0_0;
  if (l_0_1) {
    l_0_2 = input_0[idxGlobal];
    l_0_3 = sqrt(float(2.0));
    l_0_3 = l_0_2 / l_0_3;
    l_0_3 = erf(l_0_3);
    l_0_3 = l_0_3 + float(1.0);
    l_0_2 = l_0_2 * l_0_3;
    l_0_2 = l_0_2 / float(2.0);
    output_0[idxGlobal] = l_0_2;
  }
}
=================================

Copy link
Member

@louisfd louisfd left a comment

Choose a reason for hiding this comment

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

LGTM

@nathanielsimard nathanielsimard merged commit 6eaccca into main Jul 26, 2024
1 of 2 checks passed
@nathanielsimard nathanielsimard deleted the feat/debug-logger branch October 28, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants