Skip to content

Commit

Permalink
fix: cuda reducer bugfix and more tests (#3228)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed Sep 2, 2024
1 parent 09351fc commit ebf8bf3
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ awkward_reduce_max_b(
T val = identity;

if (idx >= stride && thread_id < lenparents && parents[thread_id] == parents[thread_id - stride]) {
val = temp[idx - stride];
val = temp[thread_id - stride];
}
__syncthreads();
temp[thread_id] = val > temp[thread_id] ? val : temp[thread_id];
Expand Down
72 changes: 30 additions & 42 deletions tests-cuda/test_3149_complex_reducers.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def test_0652_minmax():


def test_block_boundary_sum_complex():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -323,7 +323,6 @@ def test_block_boundary_sum_complex():


def test_block_boundary_prod_complex1():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1000, 0), np.full(1000, 1))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -341,7 +340,6 @@ def test_block_boundary_prod_complex1():


def test_block_boundary_prod_complex2():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1001, 0), np.full(1001, 1))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -359,7 +357,6 @@ def test_block_boundary_prod_complex2():


def test_block_boundary_prod_complex3():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1002, 0), np.full(1002, 1))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -377,7 +374,6 @@ def test_block_boundary_prod_complex3():


def test_block_boundary_prod_complex4():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1000, 0), np.full(1000, 1.01))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -397,7 +393,6 @@ def test_block_boundary_prod_complex4():


def test_block_boundary_prod_complex5():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1001, 0), np.full(1001, 1.01))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -417,7 +412,6 @@ def test_block_boundary_prod_complex5():


def test_block_boundary_prod_complex6():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1002, 0), np.full(1002, 1.01))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -437,7 +431,6 @@ def test_block_boundary_prod_complex6():


def test_block_boundary_prod_complex7():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1000, 0), np.full(1000, 0.99))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -457,7 +450,6 @@ def test_block_boundary_prod_complex7():


def test_block_boundary_prod_complex8():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1001, 0), np.full(1001, 0.99))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -477,7 +469,6 @@ def test_block_boundary_prod_complex8():


def test_block_boundary_prod_complex9():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1002, 0), np.full(1002, 0.99))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -497,7 +488,6 @@ def test_block_boundary_prod_complex9():


def test_block_boundary_prod_complex10():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1000, 0), np.full(1000, 1.1))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -517,7 +507,6 @@ def test_block_boundary_prod_complex10():


def test_block_boundary_prod_complex11():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1001, 0), np.full(1001, 1.1))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -537,7 +526,6 @@ def test_block_boundary_prod_complex11():


def test_block_boundary_prod_complex12():
np.random.seed(42)
complex_array = np.vectorize(complex)(np.full(1002, 0), np.full(1002, 1.1))
content = ak.contents.NumpyArray(complex_array)
cuda_content = ak.to_backend(content, "cuda", highlevel=False)
Expand All @@ -557,8 +545,8 @@ def test_block_boundary_prod_complex12():


def test_block_boundary_prod_complex13():
np.random.seed(42)
array = np.random.randint(50, size=1000)
rng = np.random.default_rng(seed=42)
array = rng.integers(50, size=1000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -580,8 +568,8 @@ def test_block_boundary_prod_complex13():


def test_block_boundary_any_complex():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -601,8 +589,8 @@ def test_block_boundary_any_complex():


def test_block_boundary_all_complex():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -622,8 +610,8 @@ def test_block_boundary_all_complex():


def test_block_boundary_min_complex1():
np.random.seed(42)
array = np.random.randint(5, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(5, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -643,8 +631,8 @@ def test_block_boundary_min_complex1():


def test_block_boundary_min_complex2():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -664,8 +652,8 @@ def test_block_boundary_min_complex2():


def test_block_boundary_max_complex1():
np.random.seed(42)
array = np.random.randint(5, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(5, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -685,8 +673,8 @@ def test_block_boundary_max_complex1():


def test_block_boundary_max_complex2():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -706,8 +694,8 @@ def test_block_boundary_max_complex2():


def test_block_boundary_sum_bool_complex():
np.random.seed(42)
array = np.random.randint(2, size=6000, dtype=np.bool_)
rng = np.random.default_rng(seed=42)
array = rng.integers(2, size=6000, dtype=np.bool_)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -727,8 +715,8 @@ def test_block_boundary_sum_bool_complex():


def test_block_boundary_countnonzero_complex_1():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -749,8 +737,8 @@ def test_block_boundary_countnonzero_complex_1():


def test_block_boundary_countnonzero_complex_2():
np.random.seed(42)
array = np.random.randint(2, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(2, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -772,8 +760,8 @@ def test_block_boundary_countnonzero_complex_2():

@pytest.mark.skip(reason="awkward_reduce_argmax_complex is not implemented")
def test_block_boundary_argmax_complex1():
np.random.seed(42)
array = np.random.randint(5, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(5, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -794,8 +782,8 @@ def test_block_boundary_argmax_complex1():

@pytest.mark.skip(reason="awkward_reduce_argmax_complex is not implemented")
def test_block_boundary_argmax_complex2():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -816,8 +804,8 @@ def test_block_boundary_argmax_complex2():

@pytest.mark.skip(reason="awkward_reduce_argmin_complex is not implemented")
def test_block_boundary_argmin_complex1():
np.random.seed(42)
array = np.random.randint(5, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(5, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand All @@ -838,8 +826,8 @@ def test_block_boundary_argmin_complex1():

@pytest.mark.skip(reason="awkward_reduce_argmin_complex is not implemented")
def test_block_boundary_argmin_complex2():
np.random.seed(42)
array = np.random.randint(6000, size=6000)
rng = np.random.default_rng(seed=42)
array = rng.integers(6000, size=6000)
complex_array = np.vectorize(complex)(
array[0 : len(array) : 2], array[1 : len(array) : 2]
)
Expand Down
2 changes: 0 additions & 2 deletions tests-cuda/test_3150_combinations_n_equal_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,6 @@ def test_1074_combinations_UnmaskedArray():


def test_block_boundary_combinations():
np.random.seed(42)
content = ak.contents.NumpyArray(np.arange(300))
cuda_content = ak.to_backend(content, "cuda", highlevel=False)

Expand Down Expand Up @@ -1219,7 +1218,6 @@ def test_block_boundary_combinations():


def test_block_boundary_argcombinations():
np.random.seed(42)
content = ak.contents.NumpyArray(np.arange(300))
cuda_content = ak.to_backend(content, "cuda", highlevel=False)

Expand Down
Loading

0 comments on commit ebf8bf3

Please sign in to comment.