Skip to content

Commit

Permalink
Use PyLong_AsVoidPtr to cast dev_ptr (#2192)
Browse files Browse the repository at this point in the history
Fixes: #2188

Calling PyLong_AsLongLong causes overflow and return of a wrong pointer.

Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
  • Loading branch information
dvrogozh authored Sep 11, 2024
1 parent 3102cf5 commit b6e5fd2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions benchmarks/triton_kernels_benchmark/benchmark_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def format_of(ty):
ptr_info.dev_ptr = 0;
ptr_info.valid = true;
if (PyLong_Check(obj)) {{
ptr_info.dev_ptr = (void*) PyLong_AsLongLong(obj);
ptr_info.dev_ptr = PyLong_AsVoidPtr(obj)
checkDevicePointer(&ptr_info, idx, queue);
return ptr_info;
}}
Expand All @@ -223,7 +223,7 @@ def format_of(ty):
ptr_info.valid = false;
return ptr_info;
}}
ptr_info.dev_ptr = (void*) PyLong_AsLongLong(ret);
ptr_info.dev_ptr = PyLong_AsVoidPtr(ret);
if(!ptr_info.dev_ptr) {{
return ptr_info;
}}
Expand Down
4 changes: 2 additions & 2 deletions third_party/intel/backend/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def format_of(ty):
ptr_info.dev_ptr = 0;
ptr_info.valid = true;
if (PyLong_Check(obj)) {{
ptr_info.dev_ptr = (void*) PyLong_AsLongLong(obj);
ptr_info.dev_ptr = PyLong_AsVoidPtr(obj);
checkDevicePointer(&ptr_info, idx, queue);
return ptr_info;
}}
Expand All @@ -290,7 +290,7 @@ def format_of(ty):
ptr_info.valid = false;
return ptr_info;
}}
ptr_info.dev_ptr = (void*) PyLong_AsLongLong(ret);
ptr_info.dev_ptr = PyLong_AsVoidPtr(ret);
if(!ptr_info.dev_ptr) {{
return ptr_info;
}}
Expand Down

0 comments on commit b6e5fd2

Please sign in to comment.