Skip to content

Instantly share code, notes, and snippets.

@pramodk
Last active March 2, 2017 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pramodk/921be20ee9a2f5c68e8eb409ba18af88 to your computer and use it in GitHub Desktop.
Save pramodk/921be20ee9a2f5c68e8eb409ba18af88 to your computer and use it in GitHub Desktop.
CoreNEURON GPU Installation and ringtest example
#!/bin/bash
# stop if error
set -e
# load required modiles on your cluster
module purge
module load mvapich2/2.0.1-nocuda cmake
export BASE_DIR=`pwd`/coreneuron_tutorial
export INSTALL_DIR=$BASE_DIR/install
export SOURCE_DIR=$BASE_DIR/sources
# create directories
mkdir -p $INSTALL_DIR $SOURCE_DIR
# clone repositories
cd $SOURCE_DIR
git clone https://github.com/BlueBrain/CoreNeuron.git
git clone https://github.com/BlueBrain/mod2c.git
git clone https://github.com/nrnhines/nrn.git
# install neuron
cd $SOURCE_DIR/nrn
sed -i -e 's/GLOBAL minf/RANGE minf/g' src/nrnoc/hh.mod
sed -i -e 's/TABLE minf/:TABLE minf/g' src/nrnoc/hh.mod
./build.sh
./configure --prefix=$INSTALL_DIR --without-iv --with-paranrn --with-nrnpython=`which python`
make
make install
# install mod2c
cd $SOURCE_DIR/mod2c
mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
make && make install
# set path
export PATH=$INSTALL_DIR/x86_64/bin:$INSTALL_DIR/bin:$PATH
export MODLUNIT=$INSTALL_DIR/share/nrnunits.lib
# clone ring test
cd $SOURCE_DIR
git clone https://github.com/pramodk/ringtest.git
cd ringtest && git checkout tutorial
# build special executable with neuron
cd $SOURCE_DIR/ringtest
nrnivmodl mod
# build coreneuron executable
module purge
module load pgi/pgi64/16.5 pgi/mpich/16.5
module load cuda/7.0
export CC=mpicc
export CXX=mpicxx
cd $SOURCE_DIR/ringtest
mkdir -p coreneuron_x86 && cd coreneuron_x86
cmake $BASE_DIR/sources/CoreNeuron -DADDITIONAL_MECHPATH=`pwd`/mod -DCMAKE_C_FLAGS:STRING="-O2" -DCMAKE_CXX_FLAGS:STRING="-O2" -DCOMPILE_LIBRARY_TYPE=STATIC -DCUDA_HOST_COMPILER=`which gcc` -DCUDA_PROPAGATE_HOST_FLAGS=OFF -DENABLE_SELECTIVE_GPU_PROFILING=ON -DENABLE_OPENACC=ON
make VERBOSE=1
# run simulation using neuron
cd $SOURCE_DIR/ringtest
./x86_64/special -python ringtest.py -tstop 100 -coredat coreneuron_data
# run simulation using coreneuron
cd $SOURCE_DIR/ringtest
./coreneuron_x86/bin/coreneuron_exec -e 100 -d coreneuron_data --gpu --cell_permute=1
# sort compare spike output between neuron and coreneuron
sortspike coreneuron_data/spk1.std out.neuron.spk
sortspike out0.dat out.coreneuron.spk
diff -w out.neuron.spk out.coreneuron.spk
# check which version of CUDA being used by PGI compiler
$ pgcc -show
.........
USECUDAROOT =/gpfs/bbp.cscs.ch/apps/viz/tools/pgi/16.5/linux86-64/2016/cuda/7.0
.........
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment