Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cuda_bindings/examples/0_Introduction/simple_zero_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def main():

# Get the device selected by the user or default to 0, and then set it.
if check_cmd_line_flag("device="):
device_count = cudart.cudaGetDeviceCount()
# cudaGetDeviceCount returns (cudaError_t, count); comparing the raw
# tuple against an int below raises TypeError.
device_count = check_cuda_errors(cudart.cudaGetDeviceCount())
idev = int(get_cmd_line_argument_int("device="))

if idev >= device_count or idev < 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,11 @@ def matrix_multiply(dims_a, dims_b, kernel_number):
grid_shared_state_kernel = cudart.dim3()
grid_shared_state_kernel.x = dims_b.x / threads_shared_state_kernel.x
grid_shared_state_kernel.y = dims_a.y / threads_shared_state_kernel.x
# C++ dim3 defaults every component to 1; cudart.dim3 wraps a
# zero-initialised struct, so .z must be set explicitly or the two
# cuLaunchKernel calls below pass gridDimZ=0 and fail with
# CUDA_ERROR_INVALID_VALUE.
grid_shared_state_kernel.z = 1

print(f"Running kernel = {kernel_number} - {kernel_names[kernel_number.value]}")
# Create and start timer
Expand Down
Loading