Пример #1
0
 def test_parallel_reduce(self):
     args = ['--directory=%s' % self.root]
     run_parallel_script.run(filename='simple_reduction.py',
                             args=args,
                             nprocs=4,
                             path=path,
                             timeout=60.0)
Пример #2
0
 def test_summation_density(self):
     run_parallel_script.run(filename='./summation_density.py', nprocs=4,
                             path=path)
Пример #3
0
 def test_remote_exchange(self):
     run_parallel_script.run(filename='./remote_exchange.py', nprocs=4, path=path)
Пример #4
0
 def test_summation_density(self):
     run_parallel_script.run(filename='summation_density.py',
                             nprocs=4,
                             path=path)
Пример #5
0
 def test_mpi_reduce_array(self):
     run_parallel_script.run(filename='reduce_array.py',
                             nprocs=4,
                             path=path)
Пример #6
0
 def test_dump_and_load_work_in_parallel(self):
     run_parallel_script.run(filename='check_dump_load.py',
                             nprocs=4,
                             path=path)
Пример #7
0
 def test_remote_exchange(self):
     run_parallel_script.run(filename='remote_exchange.py',
                             nprocs=4,
                             path=path)
Пример #8
0
 def test_zoltan_partition(self):
     run_parallel_script.run(
         path=path, filename='3d_partition.py', nprocs=4, timeout=40.0)
Пример #9
0
 def test_zoltan_zcomm(self):
     run_parallel_script.run(
         path=path, filename='zcomm.py', nprocs=4)
Пример #10
0
 def _test_zoltan_geometric_partitioner(self):
     run_parallel_script.run(
         path=path, filename='geometric_partitioner.py', nprocs=4, args=['>mesh.out'])
Пример #11
0
    def run_example(self,
                    filename,
                    nprocs=2,
                    timeout=300,
                    atol=1e-14,
                    serial_kwargs=None,
                    extra_parallel_kwargs=None):
        """Run an example and compare the results in serial and parallel.

        Parameters:
        -----------

        filename : str
            The name of the file to run

        nprocs : int
            Number of processors to use for the parallel run.

        timeout : float
            Time in seconds to wait for execution before an error is raised.

        atol: float
            Absolute tolerance for differences between the runs.

        serial_kwargs : dict
            The options to pass for a serial run.  Note that if the value of a
            particular key is None, the option is simply set and no value
            passed.  For example if `openmp=None`, then `--openmp` is used.

        extra_parallel_kwargs: dict
            The extra options to pass for the parallel run.

        """
        if serial_kwargs is None:
            serial_kwargs = {}
        if extra_parallel_kwargs is None:
            extra_parallel_kwargs = {}

        parallel_kwargs = dict(serial_kwargs)
        parallel_kwargs.update(extra_parallel_kwargs)

        prefix = os.path.splitext(os.path.basename(filename))[0]
        # dir1 is for the serial run
        dir1 = tempfile.mkdtemp()
        serial_kwargs.update(fname=prefix, directory=dir1)

        # dir2 is for the parallel run
        dir2 = tempfile.mkdtemp()
        parallel_kwargs.update(fname=prefix, directory=dir2)

        serial_args = self._kwargs_to_command_line(serial_kwargs)
        parallel_args = self._kwargs_to_command_line(parallel_kwargs)

        try:
            # run the example script in serial
            run_parallel_script.run(filename=filename,
                                    args=serial_args,
                                    nprocs=1,
                                    timeout=timeout,
                                    path=MY_DIR)

            # run the example script in parallel
            run_parallel_script.run(filename=filename,
                                    args=parallel_args,
                                    nprocs=nprocs,
                                    timeout=timeout,
                                    path=MY_DIR)

            # get the serial and parallel results
            dir1path = os.path.abspath(dir1)
            dir2path = os.path.abspath(dir2)

            # load the serial output
            file = get_files(dirname=dir1path, fname=prefix)[-1]
            serial = load(file)
            serial = serial['arrays']['fluid']

            # load the parallel output
            file = get_files(dirname=dir2path, fname=prefix)[-1]
            parallel = load(file)
            parallel = parallel['arrays']['fluid']

        finally:
            shutil.rmtree(dir1, True)
            shutil.rmtree(dir2, True)

        # test
        self._test(serial, parallel, atol, nprocs)
Пример #12
0
 def test_zoltan_zcomm(self):
     run_parallel_script.run(
         filename='zcomm.py', nprocs=4, path=path
     )
Пример #13
0
 def test_zoltan_partition(self):
     run_parallel_script.run(
         filename='3d_partition.py', nprocs=4, timeout=90.0, path=path
     )
Пример #14
0
 def test_zoltan_geometric_partitioner(self):
     run_parallel_script.run(
         filename='geometric_partitioner.py', nprocs=4, path=path
     )