Ejemplo n.º 1
0
def test_evaluate():
    a = sn.defer(3)
    assert 3 == a.evaluate()
    assert 3 == sn.evaluate(a)
    assert 3 == sn.evaluate(3)
Ejemplo n.º 2
0
 def test_ior(self):
     v = V(2)
     dv = sn.defer(v)
     dv |= V(5)
     sn.evaluate(dv)
     self.assertEqual(7, v._value)
 def n_cubeside(self):
     regex = r'Domain synchronized, nLocalParticles (\d+)'
     n_particles = sn.extractsingle(regex, self.stdout, 1, int)
     return int(pow(sn.evaluate(n_particles), 1 / 3))
Ejemplo n.º 4
0
 def test_ilshift(self):
     v = V(1)
     dv = sn.defer(v)
     dv <<= V(2)
     sn.evaluate(dv)
     self.assertEqual(4, v._value)
Ejemplo n.º 5
0
 def test_iand(self):
     v = V(7)
     dv = sn.defer(v)
     dv &= V(2)
     sn.evaluate(dv)
     self.assertEqual(2, v._value)
Ejemplo n.º 6
0
 def test_itruediv(self):
     v = V(3)
     dv = sn.defer(v)
     dv /= V(2)
     sn.evaluate(dv)
     self.assertEqual(1.5, v._value)
Ejemplo n.º 7
0
 def test_imod(self):
     v = V(3)
     dv = sn.defer(v)
     dv %= V(2)
     sn.evaluate(dv)
     self.assertEqual(1, v._value)
Ejemplo n.º 8
0
def test_imod():
    v = V(3)
    dv = sn.defer(v)
    dv %= V(2)
    sn.evaluate(dv)
    assert 1 == v._value
Ejemplo n.º 9
0
def test_ipow():
    v = V(3)
    dv = sn.defer(v)
    dv **= V(2)
    sn.evaluate(dv)
    assert 9 == v._value
Ejemplo n.º 10
0
def test_itruediv():
    v = V(3)
    dv = sn.defer(v)
    dv /= V(2)
    sn.evaluate(dv)
    assert 1.5 == v._value
Ejemplo n.º 11
0
def test_ifloordiv():
    v = V(3)
    dv = sn.defer(v)
    dv //= V(2)
    sn.evaluate(dv)
    assert 1 == v._value
Ejemplo n.º 12
0
def test_imul():
    v = V(1)
    dv = sn.defer(v)
    dv *= V(3)
    sn.evaluate(dv)
    assert 3 == v._value
Ejemplo n.º 13
0
def test_isub():
    v = V(1)
    dv = sn.defer(v)
    dv -= V(3)
    sn.evaluate(dv)
    assert -2 == v._value
Ejemplo n.º 14
0
def test_iadd():
    v = V(1)
    dv = sn.defer(v)
    dv += V(3)
    sn.evaluate(dv)
    assert 4 == v._value
Ejemplo n.º 15
0
 def test_isub(self):
     v = V(1)
     dv = sn.defer(v)
     dv -= V(3)
     sn.evaluate(dv)
     self.assertEqual(-2, v._value)
Ejemplo n.º 16
0
def test_ilshift():
    v = V(1)
    dv = sn.defer(v)
    dv <<= V(2)
    sn.evaluate(dv)
    assert 4 == v._value
Ejemplo n.º 17
0
 def test_imul(self):
     v = V(1)
     dv = sn.defer(v)
     dv *= V(3)
     sn.evaluate(dv)
     self.assertEqual(3, v._value)
Ejemplo n.º 18
0
def test_irshift():
    v = V(8)
    dv = sn.defer(v)
    dv >>= V(3)
    sn.evaluate(dv)
    assert 1 == v._value
Ejemplo n.º 19
0
 def test_ifloordiv(self):
     v = V(3)
     dv = sn.defer(v)
     dv //= V(2)
     sn.evaluate(dv)
     self.assertEqual(1, v._value)
Ejemplo n.º 20
0
def test_iand():
    v = V(7)
    dv = sn.defer(v)
    dv &= V(2)
    sn.evaluate(dv)
    assert 2 == v._value
Ejemplo n.º 21
0
 def test_ipow(self):
     v = V(3)
     dv = sn.defer(v)
     dv **= V(2)
     sn.evaluate(dv)
     self.assertEqual(9, v._value)
Ejemplo n.º 22
0
def test_ixor():
    v = V(7)
    dv = sn.defer(v)
    dv ^= V(7)
    sn.evaluate(dv)
    assert 0 == v._value
Ejemplo n.º 23
0
 def test_irshift(self):
     v = V(8)
     dv = sn.defer(v)
     dv >>= V(3)
     sn.evaluate(dv)
     self.assertEqual(1, v._value)
Ejemplo n.º 24
0
def test_ior():
    v = V(2)
    dv = sn.defer(v)
    dv |= V(5)
    sn.evaluate(dv)
    assert 7 == v._value
Ejemplo n.º 25
0
 def test_ixor(self):
     v = V(7)
     dv = sn.defer(v)
     dv ^= V(7)
     sn.evaluate(dv)
     self.assertEqual(0, v._value)
Ejemplo n.º 26
0
 def test_evaluate(self):
     a = sn.defer(3)
     self.assertEqual(3, a.evaluate())
     self.assertEqual(3, sn.evaluate(a))
     self.assertEqual(3, sn.evaluate(3))
Ejemplo n.º 27
0
    def eval_sanity(self):
        output_files = []
        output_files = [
            file for file in os.listdir(self.stagedir)
            if file.startswith('output-')
        ]
        num_greasy_tasks = len(output_files)
        failure_msg = (f'Requested {self.num_greasy_tasks} task(s), but '
                       f'executed only {num_greasy_tasks} tasks(s)')
        sn.evaluate(
            sn.assert_eq(num_greasy_tasks,
                         self.num_greasy_tasks,
                         msg=failure_msg))
        num_tasks = sn.getattr(self, 'nranks_per_worker')
        num_cpus_per_task = sn.getattr(self, 'num_cpus_per_task')

        def tid(match):
            return int(match.group(1))

        def num_threads(match):
            return int(match.group(2))

        def rank(match):
            return int(match.group(3))

        def num_ranks(match):
            return int(match.group(4))

        for output_file in output_files:
            result = sn.findall(
                r'Hello, World from thread \s*(\d+) out '
                r'of \s*(\d+) from process \s*(\d+) out of '
                r'\s*(\d+)', output_file)

            failure_msg = (f'Found {sn.count(result)} Hello, World... '
                           f'pattern(s) but expected '
                           f'{num_tasks * num_cpus_per_task} pattern(s) '
                           f'inside the output file {output_file}')
            sn.evaluate(
                sn.assert_eq(sn.count(result),
                             num_tasks * num_cpus_per_task,
                             msg=failure_msg))

            sn.evaluate(
                sn.all(
                    sn.chain(
                        sn.map(
                            lambda x: sn.assert_lt(
                                tid(x),
                                num_threads(x),
                                msg=(f'Found {tid(x)} threads rather than '
                                     f'{num_threads(x)}')), result),
                        sn.map(
                            lambda x: sn.assert_lt(
                                rank(x),
                                num_ranks(x),
                                msg
                                =(f'Rank id {rank(x)} is not lower than the '
                                  f'number of ranks {self.nranks_per_worker} '
                                  f'in output file')), result),
                        sn.map(
                            lambda x: sn.assert_lt(
                                tid(x),
                                self.num_cpus_per_task,
                                msg=(f'Rank id {tid(x)} is not lower than the '
                                     f'number of cpus per task '
                                     f'{self.num_cpus_per_task} in output '
                                     f'file {output_file}')), result),
                        sn.map(
                            lambda x: sn.assert_eq(
                                num_threads(x),
                                num_cpus_per_task,
                                msg
                                =(f'Found {num_threads(x)} threads rather than '
                                  f'{self.num_cpus_per_task} in output file '
                                  f'{output_file}')), result),
                        sn.map(
                            lambda x: sn.assert_lt(
                                rank(x),
                                num_tasks,
                                msg=(
                                    f'Found {rank(x)} threads rather than '
                                    f'{self.num_cpus_per_task} in output file '
                                    f'{output_file}')), result),
                        sn.map(
                            lambda x: sn.assert_eq(
                                num_ranks(x),
                                num_tasks,
                                msg=(f'Number of ranks {num_ranks(x)} is not '
                                     f'equal to {self.nranks_per_worker} in '
                                     f'output file {output_file}')), result))))
        sn.evaluate(sn.assert_found(r'Finished greasing', self.greasy_logfile))
        sn.evaluate(
            sn.assert_found((f'INFO: Summary of {self.num_greasy_tasks} '
                             f'tasks: '
                             f'{self.num_greasy_tasks} OK, '
                             f'0 FAILED, '
                             f'0 CANCELLED, '
                             fr'0 INVALID\.'), self.greasy_logfile))

        return True
Ejemplo n.º 28
0
 def test_iadd(self):
     v = V(1)
     dv = sn.defer(v)
     dv += V(3)
     sn.evaluate(dv)
     self.assertEqual(4, v._value)
 def np_per_cnode(self):
     regex = r'Domain synchronized, nLocalParticles (\d+)'
     n_particles = sn.extractsingle(regex, self.stdout, 1, int)
     return int(sn.evaluate(n_particles) / self.mpi_rks)
Ejemplo n.º 30
0
    def assert_success(self):
        envname = self.current_environ.name
        # {{{ extract CCE version to manage compiler versions:
        cce_version = None
        rptf = os.path.join(self.stagedir, sn.evaluate(self.stdout))
        if self.lang == 'C++' and envname == 'PrgEnv-cray':
            cce_version = sn.extractsingle(r'CRAY_CC_VERSION=(\d+)\.\S+', rptf,
                                           1, int)
        # }}}

        # {{{ extract AOCC version to manage compiler versions:
        aocc_version = None
        rptf = os.path.join(self.stagedir, sn.evaluate(self.stdout))
        if self.lang == 'C++' and envname == 'PrgEnv-aocc':
            aocc_version = sn.extractsingle(
                r'CRAY_AOCC_VERSION=(\d+)\.\S+', rptf, 1, int)
        # }}}

        intel_type = sn.extractsingle(r'INTEL_COMPILER_TYPE=(\S*)', rptf, 1)
        # {{{ print(f'intel_type={intel_type}')
        # intel/19.1.1.217        icpc openmp/201611
        # intel/19.1.3.304        icpc openmp/201611
        # intel/2021.2.0          icpc openmp/201611
        # intel-classic/2021.2.0  icpc openmp/201611
        # intel-oneapi/2021.2.0   icpc openmp/201611 = 4.5
        # intel-oneapi/2021.2.0   icpx openmp/201811 = 5.0
        # __INTEL_COMPILER
        # INTEL_VERSION 2021.2.0 INTEL_COMPILER_TYPE ONEAPI      201811
        # INTEL_VERSION 2021.2.0 INTEL_COMPILER_TYPE RECOMMENDED
        # INTEL_VERSION 2021.2.0 INTEL_COMPILER_TYPE CLASSIC     201611
        # }}}
        # OpenMP support varies between compilers:
        #            c++ - f90
        #  aocc - 201511 - 201307
        #   cce - 201511 - 201511
        #   gnu - 201511 - 201511
        # intel - 201811 - 201611
        #   pgi - 201307 - 201307
        #    nv - 201307 - 201307
        openmp_versions = {
            # 'PrgEnv-aocc': {'C++': 201511, 'F90': 201307},
            'PrgEnv-aocc': {
                'C++': 201511 if aocc_version == 2 else 201811,
                'F90': 201307,
            },
            'PrgEnv-cray': {
                'C++': 201511 if cce_version == 10 else 201811,
                'F90': 201511,
            },
            'PrgEnv-gnu': {'C++': 201511, 'F90': 201511},
            'PrgEnv-intel': {
                'C++': 201811 if (intel_type == 'ONEAPI' or
                                  intel_type == 'RECOMMENDED') else 201611,
                'F90': 201611},
            'PrgEnv-pgi': {'C++': 201307, 'F90': 201307},
            'PrgEnv-nvidia': {'C++': 201307, 'F90': 201307}
        }
        found_version = sn.extractsingle(r'OpenMP-\s*(\d+)', self.stdout, 1,
                                         int)
        return sn.all([
            sn.assert_found('SUCCESS', self.stdout),
            sn.assert_eq(found_version, openmp_versions[envname][self.lang])
        ])