fix(gpu): correctly implement summing an array in HIPArkawaA2d

This commit is contained in:
Anthony Berg 2025-07-03 14:54:56 +02:00
parent 3fdd4ab62b
commit 7966ad0032

View File

@ -12,15 +12,13 @@ def _sum_array(array: HIPArray2D):
Args:
array: A HIPArray2D to compute the sum of.
"""
data_h = array.data_h
num_bytes = array.num_bytes
result_d = hip_check(hip.hipMalloc(num_bytes))
result_h = np.zeros(1, dtype=array.dtype)
num_bytes = result_h.size * result_h.itemsize
result_d = hip_check(hip.hipMalloc(num_bytes))
# Sum the ``data_h`` array using hipblas
handle = hip_check(hipblas.hipblasCreate())
hip_check(hipblas.hipblasSasum(handle, data_h.size, data_h.data, 1, result_d))
hip_check(hipblas.hipblasSasum(handle, array.num_bytes, array.data, 1, result_d))
hip_check(hipblas.hipblasDestroy(handle))
# Copy over the result from the device