Skip to content

Commit 99ff24b

Browse files
committed
remove slurm-related env in test scripts, fix Makefile type, add tests_gpu
1 parent 66e3b16 commit 99ff24b

11 files changed

+16
-51
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dev-install:
2929

3030
dev-install_nccl:
3131
make pipcheck
32-
$(PIP) install -r requirements-dev.txt && $(PIP) install cupy-cuda12x nvidia-nccl-cu12 $(PIP) install -e .
32+
$(PIP) install -r requirements-dev.txt && $(PIP) install cupy-cuda12x nvidia-nccl-cu12 && $(PIP) install -e .
3333

3434
install_conda:
3535
conda env create -f environment.yml && conda activate pylops_mpi && pip install .
@@ -49,6 +49,10 @@ lint:
4949
tests:
5050
mpiexec -n $(NUM_PROCESSES) pytest tests/ --with-mpi
5151

52+
# assuming NUM_PROCESSES <= number of gpus available
53+
tests_gpu:
54+
export TEST_CUPY_PYLOPS=1 && mpiexec -n $(NUM_PROCESSES) pytest tests/ --with-mpi
55+
5256
# assuming NUM_PROCESSES <= number of gpus available
5357
tests_nccl:
5458
mpiexec -n $(NUM_PROCESSES) pytest tests_nccl/ --with-mpi

tests/test_blockdiag.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
np.random.seed(42)
3030
rank = MPI.COMM_WORLD.Get_rank()
3131
if backend == "cupy":
32-
device_count = np.cuda.runtime.getDeviceCount()
33-
device_id = int(
34-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
35-
or rank % np.cuda.runtime.getDeviceCount()
36-
)
32+
device_id = rank % np.cuda.runtime.getDeviceCount()
3733
np.cuda.Device(device_id).use()
3834

3935

tests/test_derivative.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
rank = MPI.COMM_WORLD.Get_rank()
2727
size = MPI.COMM_WORLD.Get_size()
2828
if backend == "cupy":
29-
device_count = np.cuda.runtime.getDeviceCount()
30-
device_id = int(
31-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
32-
or rank % np.cuda.runtime.getDeviceCount()
33-
)
29+
device_id = rank % np.cuda.runtime.getDeviceCount()
3430
np.cuda.Device(device_id).use()
3531

3632

tests/test_distributedarray.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
np.random.seed(42)
2424
rank = MPI.COMM_WORLD.Get_rank()
2525
if backend == "cupy":
26-
device_count = np.cuda.runtime.getDeviceCount()
27-
device_id = int(
28-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
29-
or rank % np.cuda.runtime.getDeviceCount()
30-
)
26+
device_id = rank % np.cuda.runtime.getDeviceCount()
3127
np.cuda.Device(device_id).use()
3228

3329
par1 = {'global_shape': (500, 501),

tests/test_fredholm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030
rank = MPI.COMM_WORLD.Get_rank()
3131
size = MPI.COMM_WORLD.Get_size()
3232
if backend == "cupy":
33-
device_count = np.cuda.runtime.getDeviceCount()
34-
device_id = int(
35-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
36-
or rank % np.cuda.runtime.getDeviceCount()
37-
)
33+
device_id = rank % np.cuda.runtime.getDeviceCount()
3834
np.cuda.Device(device_id).use()
3935

4036
par1 = {

tests/test_linearop.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@
3232
rank = MPI.COMM_WORLD.Get_rank()
3333
size = MPI.COMM_WORLD.Get_size()
3434
if backend == "cupy":
35-
device_count = np.cuda.runtime.getDeviceCount()
36-
device_id = int(
37-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
38-
or rank % np.cuda.runtime.getDeviceCount()
39-
)
35+
device_id = rank % np.cuda.runtime.getDeviceCount()
4036
np.cuda.Device(device_id).use()
4137

4238
par1 = {'ny': 101, 'nx': 101, 'dtype': np.float64}

tests/test_matrixmult.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828
size = base_comm.Get_size()
2929
rank = MPI.COMM_WORLD.Get_rank()
3030
if backend == "cupy":
31-
device_count = np.cuda.runtime.getDeviceCount()
32-
device_id = int(
33-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
34-
or rank % np.cuda.runtime.getDeviceCount()
35-
)
31+
device_id = rank % np.cuda.runtime.getDeviceCount()
3632
np.cuda.Device(device_id).use()
33+
3734
# Define test cases: (N, K, M, dtype_str)
3835
# M, K, N are matrix dimensions A(N,K), B(K,M)
3936
# P_prime will be ceil(sqrt(size)).

tests/test_solver.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@
3939
size = MPI.COMM_WORLD.Get_size()
4040
rank = MPI.COMM_WORLD.Get_rank()
4141
if backend == "cupy":
42-
device_count = np.cuda.runtime.getDeviceCount()
43-
device_id = int(
44-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
45-
or rank % np.cuda.runtime.getDeviceCount()
46-
)
42+
device_id = rank % np.cuda.runtime.getDeviceCount()
4743
np.cuda.Device(device_id).use()
4844

4945
par1 = {

tests/test_stack.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323

2424
rank = MPI.COMM_WORLD.Get_rank()
2525
if backend == "cupy":
26-
device_count = np.cuda.runtime.getDeviceCount()
27-
device_id = int(
28-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
29-
or rank % np.cuda.runtime.getDeviceCount()
30-
)
26+
device_id = rank % np.cuda.runtime.getDeviceCount()
3127
np.cuda.Device(device_id).use()
3228

3329
par1 = {'ny': 101, 'nx': 101, 'imag': 0, 'dtype': np.float64}

tests/test_stackedarray.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
np.random.seed(42)
2424
rank = MPI.COMM_WORLD.Get_rank()
2525
if backend == "cupy":
26-
device_count = np.cuda.runtime.getDeviceCount()
27-
device_id = int(
28-
os.environ.get("OMPI_COMM_WORLD_LOCAL_RANK")
29-
or rank % np.cuda.runtime.getDeviceCount()
30-
)
26+
device_id = rank % np.cuda.runtime.getDeviceCount()
3127
np.cuda.Device(device_id).use()
3228

3329

0 commit comments

Comments
 (0)