-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Diptorup Deb
committed
Dec 12, 2023
1 parent
837109e
commit d175a3b
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 |
78 changes: 78 additions & 0 deletions
78
numba_dpex/tests/experimental/kernel_iface/test_memory_enum_compilation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# SPDX-FileCopyrightText: 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import dpnp | ||
|
||
import numba_dpex.experimental as exp_dpex | ||
from numba_dpex import Range | ||
from numba_dpex.experimental.kernel_iface import ( | ||
AddressSpace, | ||
MemoryOrder, | ||
MemoryScope, | ||
) | ||
|
||
|
||
def test_compilation_of_memory_order(): | ||
"""Tests if a MemoryOrder flags can be used inside a kernel function.""" | ||
|
||
@exp_dpex.kernel | ||
def store_memory_order_flag(a): | ||
a[0] = MemoryOrder.RELAXED | ||
a[1] = MemoryOrder.CONSUME_UNSUPPORTED | ||
a[2] = MemoryOrder.ACQ_REL | ||
a[3] = MemoryOrder.ACQUIRE | ||
a[4] = MemoryOrder.RELEASE | ||
a[5] = MemoryOrder.SEQ_CST | ||
|
||
a = dpnp.ones(10, dtype=dpnp.int64) | ||
exp_dpex.call_kernel(store_memory_order_flag, Range(10), a) | ||
|
||
assert a[0] == MemoryOrder.RELAXED | ||
assert a[1] == MemoryOrder.CONSUME_UNSUPPORTED | ||
assert a[2] == MemoryOrder.ACQ_REL | ||
assert a[3] == MemoryOrder.ACQUIRE | ||
assert a[4] == MemoryOrder.RELEASE | ||
assert a[5] == MemoryOrder.SEQ_CST | ||
|
||
|
||
def test_compilation_of_memory_scope(): | ||
"""Tests if a MemoryScope flags can be used inside a kernel function.""" | ||
|
||
@exp_dpex.kernel | ||
def store_memory_scope_flag(a): | ||
a[0] = MemoryScope.DEVICE | ||
a[1] = MemoryScope.SUB_GROUP | ||
a[2] = MemoryScope.WORK_GROUP | ||
a[3] = MemoryScope.SYSTEM | ||
a[4] = MemoryScope.WORK_ITEM | ||
|
||
a = dpnp.ones(10, dtype=dpnp.int64) | ||
exp_dpex.call_kernel(store_memory_scope_flag, Range(10), a) | ||
|
||
assert a[0] == MemoryScope.DEVICE | ||
assert a[1] == MemoryScope.SUB_GROUP | ||
assert a[2] == MemoryScope.WORK_GROUP | ||
assert a[3] == MemoryScope.SYSTEM | ||
assert a[4] == MemoryScope.WORK_ITEM | ||
|
||
|
||
def test_compilation_of_address_space(): | ||
"""Tests if a AddressSpace flags can be used inside a kernel function.""" | ||
|
||
@exp_dpex.kernel | ||
def store_address_space_flag(a): | ||
a[0] = AddressSpace.CONSTANT | ||
a[1] = AddressSpace.GENERIC | ||
a[2] = AddressSpace.GLOBAL | ||
a[3] = AddressSpace.LOCAL | ||
a[4] = AddressSpace.PRIVATE | ||
|
||
a = dpnp.ones(10, dtype=dpnp.int64) | ||
exp_dpex.call_kernel(store_address_space_flag, Range(10), a) | ||
|
||
assert a[0] == AddressSpace.CONSTANT | ||
assert a[1] == AddressSpace.GENERIC | ||
assert a[2] == AddressSpace.GLOBAL | ||
assert a[3] == AddressSpace.LOCAL | ||
assert a[4] == AddressSpace.PRIVATE |