Skip to content

Commit 1a3a148

Browse files
committed
addressing final formatting comments
1 parent 1da4e7e commit 1a3a148

File tree

10 files changed

+32
-43
lines changed

10 files changed

+32
-43
lines changed

cuda_core/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
88

9-
import pytest
109
from cuda.core.experimental._device import Device
10+
import pytest
1111

1212
@pytest.fixture(scope="module")
1313
def init_cuda():

cuda_core/tests/example_tests/test_basic_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of

cuda_core/tests/example_tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
@@ -51,4 +51,4 @@ def run_example(samples_path, filename, env=None):
5151
sys.argv = old_argv
5252
# further reduce the memory watermark
5353
gc.collect()
54-
cp.get_default_memory_pool().free_all_blocks()
54+
cp.get_default_memory_pool().free_all_blocks()

cuda_core/tests/test_device.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
@@ -12,18 +12,17 @@
1212
precondition
1313
import pytest
1414

15-
1615
def test_device_repr():
1716
device = Device(0)
1817
assert str(device).startswith('<Device 0')
1918

20-
# def test_device_alloc(init_cuda):
21-
# device = Device()
22-
# buffer = device.allocate(1024)
23-
# device.sync()
24-
# assert buffer.handle != 0
25-
# assert buffer.size == 1024
26-
# assert buffer.device_id == 0
19+
def test_device_alloc(init_cuda):
20+
device = Device()
21+
buffer = device.allocate(1024)
22+
device.sync()
23+
assert buffer.handle != 0
24+
assert buffer.size == 1024
25+
assert buffer.device_id == 0
2726

2827
def test_device_set_current():
2928
device = Device()
@@ -65,4 +64,4 @@ def test_compute_capability():
6564
cudart.cudaDeviceAttr.cudaDevAttrComputeCapabilityMinor, device.device_id))
6665
expected_cc = ComputeCapability(major, minor)
6766
assert device.compute_capability == expected_cc
68-
67+

cuda_core/tests/test_event.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
@@ -12,7 +12,6 @@
1212
from cuda.core.experimental._device import Device
1313
import pytest
1414

15-
1615
def test_is_timing_disabled():
1716
options = EventOptions(enable_timing=False)
1817
event = Event._init(options)

cuda_core/tests/test_launcher.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
88

9+
from cuda import cuda
910
from cuda.core.experimental._launcher import LaunchConfig
1011
from cuda.core.experimental._stream import Stream
1112
from cuda.core.experimental._device import Device
1213
from cuda.core.experimental._utils import handle_return
13-
from cuda import cuda
1414
import pytest
1515

1616
def test_launch_config_init():
@@ -64,4 +64,3 @@ def test_launch_config_shmem_size():
6464

6565
config = LaunchConfig(grid=(1, 1, 1), block=(1, 1, 1), stream=None)
6666
assert config.shmem_size == 0
67-

cuda_core/tests/test_memory.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
88

9+
from cuda import cuda
910
from cuda.core.experimental._memory import Buffer, MemoryResource
1011
from cuda.core.experimental._device import Device
11-
from cuda import cuda
1212
from cuda.core.experimental._utils import handle_return
1313
import ctypes
1414
import pytest
1515

1616
class DummyDeviceMemoryResource(MemoryResource):
1717
def __init__(self, device):
1818
self.device = device
19-
pass
2019

2120
def allocate(self, size, stream=None) -> Buffer:
2221
ptr = handle_return(cuda.cuMemAlloc(size))
2322
return Buffer(ptr=ptr, size=size, mr=self)
2423

2524
def deallocate(self, ptr, size, stream=None):
26-
cuda.cuMemFree(ptr)
25+
handle_return(cuda.cuMemFree(ptr))
2726

2827
@property
2928
def is_device_accessible(self) -> bool:
@@ -65,14 +64,13 @@ def device_id(self) -> int:
6564
class DummyUnifiedMemoryResource(MemoryResource):
6665
def __init__(self, device):
6766
self.device = device
68-
pass
6967

7068
def allocate(self, size, stream=None) -> Buffer:
7169
ptr = handle_return(cuda.cuMemAllocManaged(size, cuda.CUmemAttach_flags.CU_MEM_ATTACH_GLOBAL.value))
7270
return Buffer(ptr=ptr, size=size, mr=self)
7371

7472
def deallocate(self, ptr, size, stream=None):
75-
cuda.cuMemFree(ptr)
73+
handle_return(cuda.cuMemFree(ptr))
7674

7775
@property
7876
def is_device_accessible(self) -> bool:
@@ -89,14 +87,13 @@ def device_id(self) -> int:
8987
class DummyPinnedMemoryResource(MemoryResource):
9088
def __init__(self, device):
9189
self.device = device
92-
pass
9390

9491
def allocate(self, size, stream=None) -> Buffer:
9592
ptr = handle_return(cuda.cuMemAllocHost(size))
9693
return Buffer(ptr=ptr, size=size, mr=self)
9794

9895
def deallocate(self, ptr, size, stream=None):
99-
cuda.cuMemFreeHost(ptr)
96+
handle_return(cuda.cuMemFreeHost(ptr))
10097

10198
@property
10299
def is_device_accessible(self) -> bool:
@@ -199,4 +196,3 @@ def test_buffer_close():
199196
buffer_close(DummyUnifiedMemoryResource(device))
200197
buffer_close(DummyPinnedMemoryResource(device))
201198

202-
test_buffer_copy_to()

cuda_core/tests/test_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of

cuda_core/tests/test_program.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
88

9-
from cuda import nvrtc
109
from cuda.core.experimental._program import Program
1110
from cuda.core.experimental._module import ObjectCode, Kernel
1211
from cuda.core.experimental._device import Device
1312
import pytest
1413

15-
1614
def test_program_init_valid_code_type():
1715
code = "extern \"C\" __global__ void my_kernel() {}"
1816
program = Program(code, "c++")
@@ -29,13 +27,13 @@ def test_program_init_invalid_code_format():
2927
with pytest.raises(TypeError):
3028
Program(code, "c++")
3129

32-
# def test_program_compile_valid_target_type():
33-
# code = "extern \"C\" __global__ void my_kernel() {}"
34-
# program = Program(code, "c++")
35-
# object_code = program.compile("ptx")
36-
# kernel = object_code.get_kernel("my_kernel")
37-
# assert isinstance(object_code, ObjectCode)
38-
# assert isinstance(kernel, Kernel)
30+
def test_program_compile_valid_target_type():
31+
code = "extern \"C\" __global__ void my_kernel() {}"
32+
program = Program(code, "c++")
33+
object_code = program.compile("ptx")
34+
kernel = object_code.get_kernel("my_kernel")
35+
assert isinstance(object_code, ObjectCode)
36+
assert isinstance(kernel, Kernel)
3937

4038
def test_program_compile_invalid_target_type():
4139
code = "extern \"C\" __global__ void my_kernel() {}"
@@ -58,4 +56,3 @@ def test_program_close():
5856
program = Program(code, "c++")
5957
program.close()
6058
assert program.handle is None
61-

cuda_core/tests/test_stream.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021-2024 NVIDIA Corporation. All rights reserved.
1+
# Copyright 2024 NVIDIA Corporation. All rights reserved.
22
#
33
# Please refer to the NVIDIA end user license agreement (EULA) associated
44
# with this source code for terms and conditions that govern your use of
@@ -84,4 +84,3 @@ def test_per_thread_default_stream():
8484
def test_default_stream():
8585
stream = default_stream()
8686
assert isinstance(stream, Stream)
87-

0 commit comments

Comments
 (0)