Skip to content

Commit

Permalink
Merge pull request #206 from prabhuramachandran/cuda-support-phase1
Browse files Browse the repository at this point in the history
CUDA support phase1
  • Loading branch information
prabhuramachandran committed Apr 24, 2019
2 parents 52fb394 + bfacd22 commit d198c12
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 95 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ os:

dist:
xenial

language: python
python:
- 2.7
- 3.7

install:
- sudo apt-get update
- sudo apt-get update
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
Expand All @@ -24,7 +24,7 @@ install:
- conda info -a
- conda config --add channels conda-forge
- conda config --add channels defaults
- conda install -c conda-forge pocl pyopencl
- conda install -c conda-forge pocl==1.2 pyopencl
- conda install -c defaults virtualenv
- python -c 'import pyopencl as cl'
- pip install beaker tox tox-travis
Expand Down
13 changes: 13 additions & 0 deletions pysph/solver/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,15 @@ def _setup_argparse(self):
default=False,
help="Use OpenCL to run the simulation.")

# --cuda
parser.add_argument(
"--cuda",
action="store_true",
dest="with_cuda",
default=False,
help="Use CUDA to run the simulation."
)

# --use-local-memory
parser.add_argument(
"--use-local-memory",
Expand Down Expand Up @@ -917,8 +926,12 @@ def _configure_options(self):
config.use_openmp = options.with_openmp
if options.omp_schedule is not None:
config.set_omp_schedule(options.omp_schedule)

if options.with_opencl:
config.use_opencl = True
elif options.with_cuda:
config.use_cuda = True

if options.with_local_memory:
leaf_size = int(options.octree_leaf_size)
config.wgs = leaf_size
Expand Down
10 changes: 7 additions & 3 deletions pysph/sph/acceleration_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from compyle.config import get_config
from pysph.sph.equation import (
CythonGroup, Group, MultiStageEquations, OpenCLGroup,
CUDAGroup, CythonGroup, Group, MultiStageEquations, OpenCLGroup,
get_arrays_used_in_equation)


Expand Down Expand Up @@ -175,9 +175,9 @@ def __init__(self, particle_arrays, equations, kernel, mode='serial',
kernel: The kernel to use.
mode: str: One of 'serial', 'mpi'.
backend: str: indicates the backend to use.
one of ('opencl', 'cython', '', None)
one of ('opencl', 'cython', 'cuda', '', None)
"""
assert backend in ('opencl', 'cython', '', None)
assert backend in ('opencl', 'cython', 'cuda', '', None)
self.backend = self._get_backend(backend)
self.particle_arrays = particle_arrays
self.equation_groups = group_equations(equations)
Expand All @@ -188,6 +188,8 @@ def __init__(self, particle_arrays, equations, kernel, mode='serial',
self.Group = CythonGroup
elif self.backend == 'opencl':
self.Group = OpenCLGroup
elif self.backend == 'cuda':
self.Group = CUDAGroup

all_equations = []
for group in self.equation_groups:
Expand All @@ -213,6 +215,8 @@ def _get_backend(self, backend):
cfg = get_config()
if cfg.use_opencl:
backend = 'opencl'
elif cfg.use_cuda:
backend = 'cuda'
else:
backend = 'cython'
return backend
Expand Down
File renamed without changes.

0 comments on commit d198c12

Please sign in to comment.