Skip to content

Commit b9c9cd2

Browse files
committed
Add debug info dump in kernel launcher.
1 parent 13725c1 commit b9c9cd2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

third_party/intel/backend/driver.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@ def format_of(ty):
243243
#include <stdio.h>
244244
#include <numpy/arrayobject.h>
245245
246+
namespace {{
247+
248+
bool getBoolEnv(const std::string &env) {{
249+
const char *s = std::getenv(env.c_str());
250+
std::string str(s ? s : "");
251+
std::transform(str.begin(), str.end(), str.begin(),
252+
[](unsigned char c) {{ return std::tolower(c); }});
253+
return (str == "on" || str == "true" || str == "1");
254+
}}
255+
256+
}}
257+
246258
static inline void gpuAssert(ze_result_t code, const char *file, int line)
247259
{{
248260
if (code != ZE_RESULT_SUCCESS)
@@ -344,6 +356,26 @@ def format_of(ty):
344356
if (shared_memory) {{
345357
expected_num_params -= 1;
346358
}}
359+
360+
if (getBoolEnv("TRITON_INTEL_KERNEL_LAUNCH_DUMP")){{
361+
std::cout << "kernel info name:" << kernel_name << " @" << &kernel_ptr << std::endl;
362+
std::cout << "kernel info attributes:" << kernel_ptr.get_info<sycl::info::kernel::attributes>() << std::endl;
363+
std::cout << "kernel info reference_count:" << kernel_ptr.get_info<sycl::info::kernel::reference_count>() << std::endl;
364+
std::cout << "kernel info num_args:" << kernel_ptr.get_info<sycl::info::kernel::num_args>() << std::endl;
365+
366+
std::cout << "launch num param:" << num_params << std::endl;
367+
std::cout << " gridx: " << gridX << std::endl;
368+
std::cout << " gridY: " << gridY << std::endl;
369+
std::cout << " gridZ: " << gridZ << std::endl;
370+
std::cout << " num_warps: " << num_warps << std::endl;
371+
std::cout << " threads_per_warp: " << threads_per_warp << std::endl;
372+
std::cout << " global range:[" << "x:"<< global_range_x << ", y:" << global_range_y << ", z:" << global_range_z << "]" << std::endl;
373+
std::cout << " local range:[" << "x:"<< local_range_x << ", y:" << local_range_y << ", z:" << local_range_z << "]" << std::endl;
374+
std::cout << " shared_memory: " << shared_memory << std::endl;
375+
376+
// param
377+
{" ".join(f'std::cout << " param {idx}:" << *({ty_to_cpp(item)}*)params[{idx}] << std::endl;' for idx, item in enumerate([signature[i] for i in signature if i not in constants]))}
378+
}}
347379
assert(num_params == expected_num_params && "number of kernel param not matched");
348380
// Submit the imported kernel.
349381
auto cgf = [&](sycl::handler &cgh) {{

0 commit comments

Comments
 (0)