Skip to content

Commit 747254d

Browse files
author
Vasileios Karakasis
authored
Merge pull request #2184 from hurricane642/python_test
[test] Add Python NumPy library check and build CSCS test on top of it
2 parents af7adff + c8f4033 commit 747254d

File tree

3 files changed

+117
-78
lines changed

3 files changed

+117
-78
lines changed

cscs-checks/apps/python/numpy_check.py

Lines changed: 39 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,87 +4,48 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55

66
import reframe as rfm
7-
import reframe.utility.sanity as sn
87

9-
10-
class NumpyBaseTest(rfm.RunOnlyRegressionTest):
11-
def __init__(self):
12-
self.descr = 'Test a few typical numpy operations'
13-
self.valid_prog_environs = ['builtin']
14-
self.modules = ['numpy']
15-
self.reference = {
16-
'daint:gpu': {
17-
'dot': (0.4, None, 0.05, 'seconds'),
18-
'svd': (0.37, None, 0.05, 'seconds'),
19-
'cholesky': (0.12, None, 0.05, 'seconds'),
20-
'eigendec': (3.5, None, 0.05, 'seconds'),
21-
'inv': (0.21, None, 0.05, 'seconds'),
22-
},
23-
'daint:mc': {
24-
'dot': (0.3, None, 0.05, 'seconds'),
25-
'svd': (0.35, None, 0.05, 'seconds'),
26-
'cholesky': (0.1, None, 0.05, 'seconds'),
27-
'eigendec': (4.14, None, 0.05, 'seconds'),
28-
'inv': (0.16, None, 0.05, 'seconds'),
29-
},
30-
'dom:gpu': {
31-
'dot': (0.4, None, 0.05, 'seconds'),
32-
'svd': (0.37, None, 0.05, 'seconds'),
33-
'cholesky': (0.12, None, 0.05, 'seconds'),
34-
'eigendec': (3.5, None, 0.05, 'seconds'),
35-
'inv': (0.21, None, 0.05, 'seconds'),
36-
},
37-
'dom:mc': {
38-
'dot': (0.3, None, 0.05, 'seconds'),
39-
'svd': (0.35, None, 0.05, 'seconds'),
40-
'cholesky': (0.1, None, 0.05, 'seconds'),
41-
'eigendec': (4.14, None, 0.05, 'seconds'),
42-
'inv': (0.16, None, 0.05, 'seconds'),
43-
},
44-
}
45-
self.perf_patterns = {
46-
'dot': sn.extractsingle(
47-
r'^Dotted two 4096x4096 matrices in\s+(?P<dot>\S+)\s+s',
48-
self.stdout, 'dot', float),
49-
'svd': sn.extractsingle(
50-
r'^SVD of a 2048x1024 matrix in\s+(?P<svd>\S+)\s+s',
51-
self.stdout, 'svd', float),
52-
'cholesky': sn.extractsingle(
53-
r'^Cholesky decomposition of a 2048x2048 matrix in'
54-
r'\s+(?P<cholesky>\S+)\s+s',
55-
self.stdout, 'cholesky', float),
56-
'eigendec': sn.extractsingle(
57-
r'^Eigendecomposition of a 2048x2048 matrix in'
58-
r'\s+(?P<eigendec>\S+)\s+s',
59-
self.stdout, 'eigendec', float),
60-
'inv': sn.extractsingle(
61-
r'^Inversion of a 2048x2048 matrix in\s+(?P<inv>\S+)\s+s',
62-
self.stdout, 'inv', float)
63-
}
64-
self.sanity_patterns = sn.assert_found(r'Numpy version:\s+\S+',
65-
self.stdout)
66-
self.variables = {
67-
'OMP_NUM_THREADS': '$SLURM_CPUS_PER_TASK',
68-
}
69-
self.executable = 'python'
70-
self.executable_opts = ['np_ops.py']
71-
self.num_tasks_per_node = 1
72-
self.use_multithreading = False
73-
self.tags = {'production'}
74-
self.maintainers = ['RS', 'TR']
8+
from hpctestlib.python.numpy.numpy_ops import numpy_ops_check
759

7610

7711
@rfm.simple_test
78-
class NumpyHaswellTest(NumpyBaseTest):
79-
def __init__(self):
80-
super().__init__()
81-
self.valid_systems = ['daint:gpu', 'dom:gpu']
82-
self.num_cpus_per_task = 12
12+
class cscs_numpy_test(numpy_ops_check):
13+
valid_prog_environs = ['builtin']
14+
valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc']
15+
modules = ['numpy']
16+
num_tasks_per_node = 1
17+
use_multithreading = False
18+
all_ref = {
19+
'haswell@12c': {
20+
'dot': (0.4, None, 0.05, 's'),
21+
'svd': (0.37, None, 0.05, 's'),
22+
'cholesky': (0.12, None, 0.05, 's'),
23+
'eigendec': (3.5, None, 0.05, 's'),
24+
'inv': (0.21, None, 0.05, 's'),
25+
},
26+
'broadwell@36c': {
27+
'dot': (0.3, None, 0.05, 's'),
28+
'svd': (0.35, None, 0.05, 's'),
29+
'cholesky': (0.1, None, 0.05, 's'),
30+
'eigendec': (4.14, None, 0.05, 's'),
31+
'inv': (0.16, None, 0.05, 's'),
32+
}
33+
}
34+
tags = {'production'}
35+
maintainers = ['RS', 'TR']
8336

37+
@run_after('setup')
38+
def set_num_cpus_per_task(self):
39+
self.num_cpus_per_task = self.current_partition.processor.num_cores
40+
variables = {
41+
'OMP_NUM_THREADS': self.num_cpus_per_task
42+
}
8443

85-
@rfm.simple_test
86-
class NumpyBroadwellTest(NumpyBaseTest):
87-
def __init__(self):
88-
super().__init__()
89-
self.valid_systems = ['daint:mc', 'dom:mc']
90-
self.num_cpus_per_task = 36
44+
@run_before('performance')
45+
def set_perf_ref(self):
46+
arch = self.current_partition.processor.arch
47+
pname = self.current_partition.fullname
48+
num_cores = self.current_partition.processor.num_cores
49+
self.reference = {
50+
pname: self.all_ref[f'{arch}@{num_cores}c']
51+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import reframe as rfm
7+
import reframe.utility.sanity as sn
8+
9+
10+
@rfm.simple_test
11+
class numpy_ops_check(rfm.RunOnlyRegressionTest, pin_prefix=True):
12+
'''NumPy basic operations test.
13+
14+
`NumPy <https://numpy.org/>`__ is the fundamental package for scientific
15+
computing in Python.
16+
It provides a multidimensional array object, various derived objects
17+
(such as masked arrays and matrices), and an assortment of routines
18+
for fast operations on arrays, including mathematical, logical, shape
19+
manipulation, sorting, selecting, I/O, discrete Fourier transforms,
20+
basic linear algebra, basic statistical operations, random simulation
21+
and much more.
22+
23+
This test test performs some fundamental NumPy linear algebra operations
24+
(matrix product, SVD, Cholesky decomposition, eigendecomposition, and
25+
inverse matrix calculation) and users the execution time as a performance
26+
metric. The default assumption is that NumPy is already installed on the
27+
currest system.
28+
'''
29+
30+
executable = 'python'
31+
executable_opts = ['np_ops.py']
32+
descr = 'Test NumPy operations: dot, svd, cholesky, eigen and inv'
33+
34+
@performance_function('s', perf_key='dot')
35+
def time_dot(self):
36+
'''Time of the ``dot`` kernel in seconds.'''
37+
38+
return sn.extractsingle(
39+
r'^Dotted two 4096x4096 matrices in\s+(?P<dot>\S+)\s+s',
40+
self.stdout, 'dot', float)
41+
42+
@performance_function('s', perf_key='svd')
43+
def time_svd(self):
44+
'''Time of the ``svd`` kernel in seconds.'''
45+
46+
return sn.extractsingle(
47+
r'^SVD of a 2048x1024 matrix in\s+(?P<svd>\S+)\s+s',
48+
self.stdout, 'svd', float)
49+
50+
@performance_function('s', perf_key='cholesky')
51+
def time_cholesky(self):
52+
'''Time of the ``cholesky`` kernel in seconds.'''
53+
54+
return sn.extractsingle(
55+
r'^Cholesky decomposition of a 2048x2048 matrix in'
56+
r'\s+(?P<cholesky>\S+)\s+s',
57+
self.stdout, 'cholesky', float)
58+
59+
@performance_function('s', perf_key='eigendec')
60+
def time_eigendec(self):
61+
'''Time of the ``eigendec`` kernel in seconds.'''
62+
63+
return sn.extractsingle(
64+
r'^Eigendecomposition of a 2048x2048 matrix in'
65+
r'\s+(?P<eigendec>\S+)\s+s',
66+
self.stdout, 'eigendec', float)
67+
68+
@performance_function('s', perf_key='inv')
69+
def time_inv(self):
70+
'''Time of the ``inv`` kernel in seconds.'''
71+
72+
return sn.extractsingle(
73+
r'^Inversion of a 2048x2048 matrix in\s+(?P<inv>\S+)\s+s',
74+
self.stdout, 'inv', float)
75+
76+
@sanity_function
77+
def assert_numpy_version(self):
78+
return sn.assert_found(r'Numpy version:\s+\S+', self.stdout)
File renamed without changes.

0 commit comments

Comments
 (0)