Skip to content

Commit 44e076a

Browse files
authored
[MSVC] fix error C2466: cannot allocate an array of constant size 0 (#3215)
Part of #3175 Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 9b7fbe1 commit 44e076a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

third_party/intel/backend/driver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ def format_of(ty):
288288
if ty[0] == "*"
289289
]
290290
params = [f"&arg{i}" for i, ty in signature.items() if ty != "constexpr"]
291+
num_params = len(params)
292+
params_decl = ""
293+
if num_params:
294+
params_decl = f"void *params[] = {{ {', '.join(params)} }};"
291295
src = f"""
292296
#include <cstddef>
293297
#include <string>
@@ -392,8 +396,8 @@ def format_of(ty):
392396
std::string kernel_name = kernel_ptr.get_info<sycl::info::kernel::function_name>();
393397
{ 'RECORD_FUNCTION("XPU Triton kernel:" + kernel_name, {});' if COMPILATION_HELPER.inject_pytorch_dep else "" }
394398
395-
void *params[] = {{ {', '.join(params)} }};
396-
uint32_t num_params = sizeof(params)/sizeof(params[0]);
399+
{params_decl};
400+
uint32_t num_params = {num_params};
397401
uint32_t expected_num_params = kernel_ptr.get_info<sycl::info::kernel::num_args>();
398402
size_t global_range_x = gridX*threads_per_warp*num_warps;
399403
size_t global_range_y = gridY;

0 commit comments

Comments
 (0)