Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omp #38

Merged
merged 50 commits into from
Nov 4, 2016
Merged

Omp #38

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
039d5a9
Merge pull request #1 from eth-cscs/master
bcumming Oct 13, 2016
7e0a089
first version of openmp threading back end
bcumming Oct 13, 2016
31beaca
Merge branch 'omp' of github.com:bcumming/nestmc-proto into omp
Ivanmartinezperez Oct 18, 2016
f96499a
adding openmp parallel sort implementation
Ivanmartinezperez Oct 18, 2016
e32842c
OpenMP sort working
Ivanmartinezperez Oct 20, 2016
b6aec69
Support for units syntax within state block.
Oct 22, 2016
e751fcd
Add soma-less cable cell to test cells.
halfflat Oct 24, 2016
d2ce7a6
Change bulk resistivity default.
halfflat Oct 24, 2016
7047383
OpenMP back end working
Ivanmartinezperez Oct 24, 2016
029a3da
Add Extrae+paraver support, needs to fix compilation warnings
Ivanmartinezperez Oct 24, 2016
b263eb2
Reorganize validation data generation
halfflat Oct 24, 2016
7845818
Bugfix: hh_soma.jl
halfflat Oct 24, 2016
fdbe4d8
Refactor convergence tests; add numeric soma ref.
halfflat Oct 25, 2016
732562d
Add Rallpack1 validation, plus bugfix, clean
halfflat Oct 26, 2016
1579e2c
Remove errant test file.
halfflat Oct 26, 2016
f572e62
file's cleanup
Ivanmartinezperez Oct 26, 2016
8dbdde3
Remove tabs
halfflat Oct 26, 2016
07d7e2b
Use correct routine in numeric_rallpack1.jl x0.3
halfflat Oct 26, 2016
ddc8537
Configure-time test for julia
halfflat Oct 26, 2016
104e389
`math::infinity<>()` wrapper for infinity
halfflat Oct 26, 2016
84ec4f5
Use name `i_e` for Stim current density
halfflat Oct 26, 2016
1a9db4a
Use `math::infinity<>()` for infinite value
halfflat Oct 26, 2016
49ed243
Merge pull request #37 from halfflat/feature/cable-validation
bcumming Oct 26, 2016
18a9226
Merge branch 'master' into bugfix/modcc/state-block-units
Oct 26, 2016
05e4770
Adds unit tests for the STATE block.
Oct 26, 2016
3201d72
Add "lib" to search prefixes for libtbb
halfflat Oct 27, 2016
dbca304
Address deprecated use of 'symbol' warning.
halfflat Oct 27, 2016
78c8e12
Address deprecated use of 'symbol' warning.
halfflat Oct 27, 2016
0a37a6d
Merge pull request #44 from halfflat/bugfix/julia-symbol-warning
bcumming Oct 27, 2016
0e4970d
Merge pull request #39 from halfflat/bugfix/findtbb-lib-search
bcumming Oct 27, 2016
9e0b874
Addresses PR comments.
Oct 27, 2016
f1eac25
Merge pull request #35 from vkarak/bugfix/modcc/state-block-units
bcumming Oct 27, 2016
5174b69
Merge remote-tracking branch 'upstream/master'
halfflat Oct 27, 2016
a39c9a3
Unit tests for math.hpp
halfflat Oct 27, 2016
63c507b
Extend range, view functionality.
halfflat Oct 27, 2016
830428a
Add `ball_and_squiggle` model; fix `ball_and_taper`.
halfflat Oct 27, 2016
cee495c
Address PR#46 review comments.
halfflat Oct 28, 2016
c97135d
Merge pull request #46 from halfflat/feature/more-range-utils
bcumming Oct 28, 2016
5ade8d0
Merge pull request #47 from halfflat/feature/new-test-model
bcumming Oct 28, 2016
1b929ff
Consolidate validation test code (issue #41)
halfflat Oct 27, 2016
f189d73
New compartment info structure for FVM.
halfflat Oct 27, 2016
550da10
Merge pull request #48 from halfflat/feature/consolidate-validation-t…
bcumming Oct 28, 2016
5fc61ae
Extrae linked at execution time
Ivanmartinezperez Oct 28, 2016
22b7391
cleaning project
Ivanmartinezperez Oct 28, 2016
a03af27
Merge pull request #49 from halfflat/feature/divided-compartments
bcumming Oct 28, 2016
e7a8fb6
Complex compartments
halfflat Oct 11, 2016
5aeea90
Remove division policy type parameter.
halfflat Oct 31, 2016
e8d3285
Merge pull request #54 from halfflat/feature/complex-compartments
bcumming Oct 31, 2016
d2b7810
Minor twicks and corrections
Ivanmartinezperez Nov 2, 2016
d4c6992
Solving conflicts
Ivanmartinezperez Nov 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 48 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@ if(WITH_TRACE)
add_definitions("-DWITH_TRACE")
endif()

# TBB support
set(WITH_TBB OFF CACHE BOOL "use TBB for on-node threading" )
if(WITH_TBB)
#threading model selection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better. But I think that we should make THREADING_MODEL=serial the default, and throw an error if the user requests an invalid model.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 set(THREADING_MODEL "serial" CACHE STRING "set the threading model, one of serial/tbb/omp")

set(THREADING_MODEL "serial" CACHE STRING "set the threading model, one of serial/tbb/omp")
if(THREADING_MODEL MATCHES "tbb")
# TBB support
find_package(TBB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TBB_DEFINITIONS}")
add_definitions(-DWITH_TBB)

elseif(THREADING_MODEL MATCHES "omp")
# OpenMP support
find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
add_definitions(-DWITH_OMP)

elseif(THREADING_MODEL MATCHES "serial")
#setup previously done

else()
message( FATAL_ERROR "-- Threading model '${THREADING_MODEL}' not supported, use one of serial/tbb/omp")
endif()

# MPI support
Expand All @@ -50,12 +63,15 @@ if(WITH_MPI)
set_property(DIRECTORY APPEND_STRING PROPERTY COMPILE_OPTIONS "${MPI_C_COMPILE_FLAGS}")
endif()

# Profiler support

# Internal profiler support
set(WITH_PROFILING OFF CACHE BOOL "use built-in profiling of miniapp" )
if(WITH_PROFILING)
add_definitions(-DWITH_PROFILING)
endif()



# Cray systems
set(SYSTEM_CRAY OFF CACHE BOOL "add flags for compilation on Cray systems")
if(SYSTEM_CRAY)
Expand Down Expand Up @@ -88,16 +104,34 @@ else()
set(use_external_modcc ON BOOL)
endif()

# whether to attempt to use nrniv to build validation data
# Validation data generation

# destination directory for generated data
set(VALIDATION_DATA_DIR "${CMAKE_SOURCE_DIR}/validation/data" CACHE PATH "location of generated validation data")

# Whether to build validation data at all
set(BUILD_VALIDATION_DATA ON CACHE BOOL "generate validation data")

# Whether to attempt to use julia to build validation data
find_program(JULIA_BIN julia)
if(JULIA_BIN STREQUAL "JULIA_BIN-NOTFOUND")
message(STATUS "julia not found; will not automatically build validation data sets from julia scripts")
set(BUILD_JULIA_VALIDATION_DATA FALSE)
else()
set(BUILD_JULIA_VALIDATION_DATA TRUE)
endif()

# Whether to attempt to use nrniv to build validation data
# (if we find nrniv, do)
find_program(NRNIV_BIN nrniv)
if(NRNIV_BIN STREQUAL "NRNIV_BIN-NOTFOUND")
message(STATUS "nrniv not found; will not automatically build validation data sets")
set(BUILD_VALIDATION_DATA FALSE)
message(STATUS "nrniv not found; will not automatically build NEURON validation data sets")
set(BUILD_NRN_VALIDATION_DATA FALSE)
else()
set(BUILD_VALIDATION_DATA TRUE)
set(BUILD_NRN_VALIDATION_DATA TRUE)
endif()


include_directories(${CMAKE_SOURCE_DIR}/tclap/include)
include_directories(${CMAKE_SOURCE_DIR}/vector)
include_directories(${CMAKE_SOURCE_DIR}/include)
Expand All @@ -109,12 +143,17 @@ if( "${WITH_TBB}" STREQUAL "ON" )
include_directories(${TBB_INCLUDE_DIRS})
endif()

# only include validation data if flag is set
if(BUILD_VALIDATION_DATA)
add_subdirectory(validation)
endif()

# only compile modcc if it is not provided externally
if(use_external_modcc)
add_subdirectory(modcc)
endif()

add_subdirectory(mechanisms)
add_subdirectory(nrn)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(miniapp)
Expand Down
5 changes: 3 additions & 2 deletions cmake/FindTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ if(NOT TBB_FOUND)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
set(TBB_LIB_PATH_SUFFIX "lib/ia32/gcc4.4")
endif()
list(APPEND TBB_LIB_PATH_SUFFIX "lib")
endif()

##################################
Expand All @@ -179,12 +180,12 @@ if(NOT TBB_FOUND)
find_library(TBB_${_comp}_LIBRARY_RELEASE ${_comp}
HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES "${TBB_LIB_PATH_SUFFIX}")
PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})

find_library(TBB_${_comp}_LIBRARY_DEBUG ${_comp}_debug
HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES "${TBB_LIB_PATH_SUFFIX}")
PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})


# Set the library to be used for the component
Expand Down
2 changes: 1 addition & 1 deletion data/test.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NEURON {
}

STATE {
h
h (nA)
m r
}

Expand Down
96 changes: 48 additions & 48 deletions docs/passive_cable/cable_computation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ \section{The Rallpack 1 model}
\begin{table}[ht]
\centering
\begin{tabular}{lSl}
\toprule
Term & {Value} & Property\\
\midrule
$d$ & \SI{1.0}{\um} & cable diameter \\
$L$ & \SI{1.0}{\mm} & cable length \\
$R_A$ & \SI{1.0}{\ohm\m} & bulk axial resistivity \\
$R_M$ & \SI{4.0}{\ohm\m\squared} & areal membrane resistivity \\
$C_M$ & \SI{0.01}{\F\per\m\squared} & areal membrane capacitance \\
$E_M$ & \SI{-65.0}{\mV} & membrane reversal potential \\
\bottomrule
\toprule
Term & {Value} & Property\\
\midrule
$d$ & \SI{1.0}{\um} & cable diameter \\
$L$ & \SI{1.0}{\mm} & cable length \\
$R_A$ & \SI{1.0}{\ohm\m} & bulk axial resistivity \\
$R_M$ & \SI{4.0}{\ohm\m\squared} & areal membrane resistivity \\
$C_M$ & \SI{0.01}{\F\per\m\squared} & areal membrane capacitance \\
$E_M$ & \SI{-65.0}{\mV} & membrane reversal potential \\
\bottomrule
\end{tabular}
\caption{Cable properties for the Rallpack 1 model.}
\label{tbl:rallpack1}
Expand All @@ -87,9 +87,9 @@ \section{The Rallpack 1 model}
With the model boundary conditions,
\begin{subequations}
\begin{align}
v(x, 0) &= E, \\
\left.\frac{\partial v}{\partial x}\right\vert_{x=0} & = -Ir, \\
\left.\frac{\partial v}{\partial x}\right\vert_{x=L} & = 0,
v(x, 0) &= E, \\
\left.\frac{\partial v}{\partial x}\right\vert_{x=0} & = -Ir, \\
\left.\frac{\partial v}{\partial x}\right\vert_{x=L} & = 0,
\end{align}
\end{subequations}
where $I$ is the injected current and $L$ is the cable length.
Expand All @@ -98,18 +98,18 @@ \section{The Rallpack 1 model}
to a normalized version of the cable equation,
\begin{subequations}
\begin{align}
\label{eq:normcable}
\frac{\partial^2 g}{\partial x^2} & =
\frac{\partial g}{\partial t} + g,
\label{eq:normcable}
\frac{\partial^2 g}{\partial x^2} & =
\frac{\partial g}{\partial t} + g,
\\
\label{eq:normcableinitial}
g(x, 0) &= 0,
\\
\label{eq:normcableleft}
\left.\frac{\partial g}{\partial x}\right\vert_{x=0} & = 1,
\\
\label{eq:normcableright}
\left.\frac{\partial g}{\partial x}\right\vert_{x=L} & = 0
\label{eq:normcableinitial}
g(x, 0) &= 0,
\\
\label{eq:normcableleft}
\left.\frac{\partial g}{\partial x}\right\vert_{x=0} & = 1,
\\
\label{eq:normcableright}
\left.\frac{\partial g}{\partial x}\right\vert_{x=L} & = 0
\end{align}
\end{subequations}
by
Expand Down Expand Up @@ -158,7 +158,7 @@ \section{Solution to the normalized cable equation}
Consequently,
\begin{equation}
\begin{aligned}
G(x, s) &= \frac{1}{ms}\cdot\frac{e^{mx}+e^{2mL-mx}}{1-e^{2mL}}\\
G(x, s) &= \frac{1}{ms}\cdot\frac{e^{mx}+e^{2mL-mx}}{1-e^{2mL}}\\
&= - \frac{1}{ms}\cdot\frac{\cosh m(L-x)}{\sinh mL}.
\end{aligned}
\end{equation}
Expand Down Expand Up @@ -199,10 +199,10 @@ \subsection*{Inversion}
For $|s+1|>\epsilon$,
\begin{equation}
\begin{aligned}
|s^{3/2}G(x,s)|^2
& \leq (1+\epsilon)^{-1} \left| \frac{\cosh m(L-x)}{\sinh mL} \right|^2
\\
& \leq (1+\epsilon)^{-1} (1+|\coth mL|)^2
|s^{3/2}G(x,s)|^2
& \leq (1+\epsilon)^{-1} \left| \frac{\cosh m(L-x)}{\sinh mL} \right|^2
\\
& \leq (1+\epsilon)^{-1} (1+|\coth mL|)^2
\label{eq:gbounds}
\end{aligned}
\end{equation}
Expand All @@ -218,8 +218,8 @@ \subsection*{Inversion}
a neighbourhood of $s=0$, and so the pole is simple and
\begin{equation}
\begin{aligned}
\Res(G; 0) & = - \frac{1}{m}\cdot\left.\frac{\cosh m(L-x)}{\sinh mL}\right|_{s=0}\\
& = - \frac{\cosh (L-x)}{\sinh L}.
\Res(G; 0) & = - \frac{1}{m}\cdot\left.\frac{\cosh m(L-x)}{\sinh mL}\right|_{s=0}\\
& = - \frac{\cosh (L-x)}{\sinh L}.
\end{aligned}
\end{equation}

Expand All @@ -235,9 +235,9 @@ \subsection*{Inversion}
Noting that $dm/ds = \frac{1}{2}m^{-1}$,
\begin{equation}
\begin{aligned}
h'(s) &= \frac{1}{2}m^{-1}\sinh mL + \frac{1}{2}L\cosh mL \\
&= \frac{1}{2}L + \frac{1}{2}L + O(m^2) \quad(m\to 0) \\
&= L + O(s+1) \quad(s\to -1).
h'(s) &= \frac{1}{2}m^{-1}\sinh mL + \frac{1}{2}L\cosh mL \\
&= \frac{1}{2}L + \frac{1}{2}L + O(m^2) \quad(m\to 0) \\
&= L + O(s+1) \quad(s\to -1).
\label{eq:hprime}
\end{aligned}
\end{equation}
Expand All @@ -255,11 +255,11 @@ \subsection*{Inversion}
Consequently the pole is simple and
\begin{equation}
\begin{aligned}
\Res(G; s_k)
& = f(x, s_k)/h'(s_k)\\
& = -\frac{2}{s_k L}\frac{\cosh m_k(L-x)}{\cosh m_kL} \\
& = -\frac{2}{s_k L}\frac{\cosh m_kL\cosh m_kx-\sinh m_kL\sinh m_kL}{\cosh m_kL} \\
& = -\frac{2}{s_k L}\cosh m_k x,
\Res(G; s_k)
& = f(x, s_k)/h'(s_k)\\
& = -\frac{2}{s_k L}\frac{\cosh m_k(L-x)}{\cosh m_kL} \\
& = -\frac{2}{s_k L}\frac{\cosh m_kL\cosh m_kx-\sinh m_kL\sinh m_kL}{\cosh m_kL} \\
& = -\frac{2}{s_k L}\cosh m_k x,
\end{aligned}
\end{equation}
as $\sinh m_k=0$.
Expand All @@ -272,7 +272,7 @@ \subsection*{Inversion}
The series exapnsion for $g(x, t)$ therefore is
\begin{equation}
g(x, t) = -\frac{\cosh(L-x)}{\sinh L} + \frac{1}{L}e^{-t}\left\{
1+2\sum_{k=1}^\infty \frac{e^{-ta_k^2}}{1+a_k^2}\cos a_k x\right\}.
1+2\sum_{k=1}^\infty \frac{e^{-ta_k^2}}{1+a_k^2}\cos a_k x\right\}.
\label{eq:theg}
\end{equation}

Expand All @@ -285,16 +285,16 @@ \section{Computation of series}
Let $g_n$ be the partial sum
\begin{equation}
g_n(x, t) = -\frac{\cosh(L-x)}{\sinh L} + \frac{1}{L}e^{-t}\left\{
1+2\sum_{k=1}^n \frac{e^{-ta_k^2}}{1+a_k^2}\cos a_k x\right\}.
1+2\sum_{k=1}^n \frac{e^{-ta_k^2}}{1+a_k^2}\cos a_k x\right\}.
\end{equation}
so that $g(x, t) =\lim_{n\to\infty} g_n(x,t)$. Let $\bar{g}_n = |g-g_n|$ be the
residual. The $a_k$ form an increasing sequence, so
\begin{equation}
\begin{aligned}
\bar{g}_n(x,t)
& \leq \frac{2}{L}e^{-t}\sum_{n+1}^\infty\frac{e^{-ta_k^2}}{1+a_k^2}\\
& \leq \frac{2}{L}e^{-t}\int_{a_n}^\infty \frac{e^{-tu^2}}{1+u^2}\,du\\
& < \frac{2}{L}e^{-t}\int_{a_n}^\infty \frac{e^{-tu^2}}{u^2}\,du.
\bar{g}_n(x,t)
& \leq \frac{2}{L}e^{-t}\sum_{n+1}^\infty\frac{e^{-ta_k^2}}{1+a_k^2}\\
& \leq \frac{2}{L}e^{-t}\int_{a_n}^\infty \frac{e^{-tu^2}}{1+u^2}\,du\\
& < \frac{2}{L}e^{-t}\int_{a_n}^\infty \frac{e^{-tu^2}}{u^2}\,du.
\end{aligned}
\label{eq:gbar}
\end{equation}
Expand All @@ -313,9 +313,9 @@ \section{Computation of series}
Substituting into \eqref{eq:gbar} gives
\begin{equation}
\begin{aligned}
\bar{g}_n(x,t)
& < \frac{1}{L}e^{-t}\sqrt{t}\,\Gamma(-\frac{1}{2},a_n^2 t) \\
& \leq \frac{1}{L}e^{-t}\sqrt{t}\,(a_n^2 t)^{-\frac{3}{2}}e^{-a_n^2t} \\
\bar{g}_n(x,t)
& < \frac{1}{L}e^{-t}\sqrt{t}\,\Gamma(-\frac{1}{2},a_n^2 t) \\
& \leq \frac{1}{L}e^{-t}\sqrt{t}\,(a_n^2 t)^{-\frac{3}{2}}e^{-a_n^2t} \\
& = \frac{e^{-t(1+a_n^2)}}{L t a_n^3}.
\end{aligned}
\end{equation}
Expand Down
46 changes: 23 additions & 23 deletions modcc/blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ enum class moduleKind {
density
};

typedef std::vector<Token> unit_tokens;
struct Id {
Token token;
std::string value; // store the value as a string, not a number : empty
// string == no value
unit_tokens units;

Id(Token const& t, std::string const& v, unit_tokens const& u)
: token(t), value(v), units(u)
{}

Id() {}

bool has_value() const {
return value.size()>0;
}

std::string const& name() const {
return token.spelling;
}
};

// information stored in a NEURON {} block in mod file.
struct NeuronBlock {
bool threadsafe = false;
Expand All @@ -42,7 +64,7 @@ struct NeuronBlock {

// information stored in a NEURON {} block in mod file
struct StateBlock {
std::vector<std::string> state_variables;
std::vector<Id> state_variables;
auto begin() -> decltype(state_variables.begin()) {
return state_variables.begin();
}
Expand All @@ -52,32 +74,11 @@ struct StateBlock {
};

// information stored in a NEURON {} block in mod file
typedef std::vector<Token> unit_tokens;
struct UnitsBlock {
typedef std::pair<unit_tokens, unit_tokens> units_pair;
std::vector<units_pair> unit_aliases;
};

struct Id {
Token token;
std::string value; // store the value as a string, not a number : empty string == no value
unit_tokens units;

Id(Token const& t, std::string const& v, unit_tokens const& u)
: token(t), value(v), units(u)
{}

Id() {}

bool has_value() const {
return value.size()>0;
}

std::string const& name() const {
return token.spelling;
}
};

// information stored in a NEURON {} block in mod file
struct ParameterBlock {
std::vector<Id> parameters;
Expand Down Expand Up @@ -164,4 +165,3 @@ inline std::ostream& operator<< (std::ostream& os, AssignedBlock const& A) {

return os;
}

Loading