Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
283ee1b
* move coreneuron toward full c++
fouriaux Mar 26, 2018
a18f77e
Update mod2c to new commit
pramodk Mar 27, 2018
d129dbb
fix ivocvect vector compatibility and declarations
fouriaux Mar 28, 2018
32c4b1b
fixing core_read and core_write to be out of coreneuron namespace
fouriaux Mar 29, 2018
e80852c
add missing prototype
fouriaux Mar 29, 2018
9a9aa18
update mod2c
fouriaux Mar 29, 2018
7afb97d
update mod2c link
fouriaux Apr 3, 2018
f6a80aa
update submodule
fouriaux Apr 3, 2018
a812e74
fix public API of coreneuron to explose core_psolve
fouriaux Apr 12, 2018
aabed5d
add pulbic header
fouriaux Apr 12, 2018
a7d0c9b
kinderiv.h has prototype declaration for euler methods
pramodk Apr 12, 2018
859a6a9
public header accessible from C, clean up unused arguments
fouriaux Apr 12, 2018
0e17acd
Changes to integrate with neurodamus: psolve_core renamed and added -…
pramodk Apr 12, 2018
ba4105a
Merge branch 'master' into full_cpp_interface
pramodk Apr 19, 2018
95798d8
mod2c updated
pramodk Apr 19, 2018
a7d827b
W.I.P for fixup openACC version
fouriaux Apr 20, 2018
ca893d6
OpenACC pragma annotation was missing for kernels using euler
pramodk Apr 21, 2018
992000f
cudaMemset wrong pointer fix
pramodk Apr 21, 2018
9a572b7
User provided flags should take precedence
pramodk Apr 21, 2018
f639ed7
Merge remote-tracking branch 'origin/euler_acc' into full_cpp_interface
pramodk Apr 21, 2018
18692d9
Removed unnecessary acc declare annotations: actual errors are coming…
pramodk Apr 21, 2018
503ff8d
Fix issue while compiling with -DENABLE_MPI=OFF
pramodk Apr 28, 2018
f9facdc
Merge branch 'master' into full_cpp_interface
pramodk Apr 30, 2018
66f0a4f
fix mpi build
fouriaux May 8, 2018
1796a8f
track mod2c master
pramodk May 8, 2018
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
7 changes: 3 additions & 4 deletions apps/coreneuron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/


extern int main1(int argc, char** argv, char** env);
#include <coreneuron/engine.h>
extern "C" {extern void modl_reg(void);}

int main(int argc, char** argv, char** env) {
return main1(argc, argv, env);
int main(int argc, char** argv) {
return solve_core(argc, argv);
}

/// Declare an empty function if Neurodamus mechanisms are not used, otherwise register them in mechs/cfile/mod_func.c
Expand Down
15 changes: 8 additions & 7 deletions coreneuron/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ set(MOD2C env "MODLUNIT=${MOD2C_UNITS}" ${MOD2C})
macro(mod2c_target name input)
get_filename_component(mod2c_source_ ${input} ABSOLUTE)
get_filename_component(mod2c_modname_ ${input} NAME)
string(REGEX REPLACE "\\.mod$" ".c" mod2c_cname_ "${mod2c_modname_}")
string(REGEX REPLACE "\\.mod$" ".cpp" mod2c_cname_ "${mod2c_modname_}")

set(mod2c_output_ "${CMAKE_CURRENT_BINARY_DIR}/${mod2c_cname_}")
list(APPEND MOD2C_${name}_OUTPUTS "${mod2c_output_}")
Expand Down Expand Up @@ -192,7 +192,7 @@ mod2c_from_file(OPTMECH "${ADDITIONAL_MECHS}" "${ADDITIONAL_MECHPATH}")

# For 'non-standard' mod files, need to generate registering function in mod_func.c

set(MOD_FUNC_C "${CMAKE_CURRENT_BINARY_DIR}/mod_func.c")
set(MOD_FUNC_C "${CMAKE_CURRENT_BINARY_DIR}/mod_func.cpp")
set(MOD_FUNC_C_PL "${CMAKE_CURRENT_SOURCE_DIR}/mech/mod_func.c.pl")

# ... pass as argument to the perl script the list of mod file names;
Expand Down Expand Up @@ -221,7 +221,7 @@ add_custom_command(OUTPUT "${KINDERIV_H}"

if (EXPORT_MECHS_FUNCTIONS)
# Create C file with all "get function pointers" methods
set(MOD_FUNC_PTRS_C "${CMAKE_CURRENT_BINARY_DIR}/mod_func_ptrs.c")
set(MOD_FUNC_PTRS_C "${CMAKE_CURRENT_BINARY_DIR}/mod_func_ptrs.cpp")
set(MOD_FUNC_PTRS_C_PL "${CMAKE_CURRENT_SOURCE_DIR}/mech/mod_func_ptrs.c.pl")

# ... pass as argument to the perl script the list of mods full paths;
Expand All @@ -236,10 +236,10 @@ set(GENERATED_MECH_C_FILES ${MOD_FUNC_C} ${MOD_FUNC_PTRS_C} ${MOD2C_STDMECH_OUTP

# artificial cells must be on cpu, defaul nrnran123.c is for cpu, nrn_setup.cpp uses nrnran123 for only memory calculation purpose which should use cpu version of nrnran123
set(NOACC_MECH_C_FILES
${CMAKE_CURRENT_BINARY_DIR}/netstim.c
${CMAKE_CURRENT_BINARY_DIR}/netstim_inhpoisson.c
${CMAKE_CURRENT_BINARY_DIR}/pattern.c
${CMAKE_CURRENT_SOURCE_DIR}/utils/randoms/nrnran123.c
${CMAKE_CURRENT_BINARY_DIR}/netstim.cpp
${CMAKE_CURRENT_BINARY_DIR}/netstim_inhpoisson.cpp
${CMAKE_CURRENT_BINARY_DIR}/pattern.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils/randoms/nrnran123.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nrniv/nrn_setup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nrniv/global_vars.cpp)

Expand Down Expand Up @@ -291,6 +291,7 @@ set_target_properties(coreneuron PROPERTIES
install(TARGETS coreneuron
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} )
install(FILES "engine.h" DESTINATION include/coreneuron)

if(ENABLE_DEV_FILES_INSTALLATION)
install(DIRECTORY .
Expand Down
18 changes: 7 additions & 11 deletions coreneuron/coreneuron.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
#include <math.h>

#include "coreneuron/utils/randoms/nrnran123.h" //Random Number Generator
#include "coreneuron/scopmath_core/newton_struct.h" //Newton Struct
#include "coreneuron/nrnoc/membdef.h" //static definitions
#include "coreneuron/nrnoc/nrnoc_ml.h" //Memb_list and mechs info
#include "coreneuron/utils/randoms/nrnran123.h" //Random Number Generator

#if defined(__cplusplus)
#include "coreneuron/nrniv/memory.h" //Memory alignments and padding

extern "C" {
#endif
namespace coreneuron {

#ifdef EXPORT_MECHS_FUNCTIONS
// from (auto-generated) mod_func_ptrs.c
Expand All @@ -59,18 +57,16 @@ extern mod_f_t get_BA_function(const char* sym, int BA_func_id);
#endif

// from nrnoc/capac.c
extern void nrn_init_capacitance(struct NrnThread*, struct Memb_list*, int);
extern void nrn_cur_capacitance(struct NrnThread* _nt, struct Memb_list* ml, int type);
extern void nrn_init_capacitance(NrnThread*, Memb_list*, int);
extern void nrn_cur_capacitance(NrnThread* _nt, Memb_list* ml, int type);
extern void nrn_alloc_capacitance(double* data, Datum* pdata, int type);

// from nrnoc/eion.c
extern void nrn_init_ion(struct NrnThread*, struct Memb_list*, int);
extern void nrn_cur_ion(struct NrnThread* _nt, struct Memb_list* ml, int type);
extern void nrn_init_ion(NrnThread*, Memb_list*, int);
extern void nrn_cur_ion(NrnThread* _nt, Memb_list* ml, int type);
extern void nrn_alloc_ion(double* data, Datum* pdata, int type);
extern void second_order_cur(NrnThread* _nt, int secondorder);

#if defined(__cplusplus)
}
#endif
} //namespace coreneuron

#endif
12 changes: 12 additions & 0 deletions coreneuron/engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef CORENEURON_ENGINE_H
#define CORENEURON_ENGINE_H

#ifdef __cplusplus
extern "C" {
#endif
extern int solve_core (int argc, char** argv);
#ifdef __cplusplus
}
#endif

#endif
5 changes: 4 additions & 1 deletion coreneuron/kinderiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import os

fnames = [f.replace('.mod', '.c') for f in os.listdir('.') if f.endswith('.mod')]
fnames = [f.replace('.mod', '.cpp') for f in os.listdir('.') if f.endswith('.mod')]
euler = []
deriv = []
kin = []
Expand Down Expand Up @@ -47,6 +47,7 @@
fout.write(' */\n')

fout.write("\n/* declarations */\n")
fout.write("\nnamespace coreneuron {\n")
for item in deriv:
fout.write('#pragma acc routine seq\n')
fout.write('extern int %s%s(_threadargsproto_);\n' % (item[0], item[1]))
Expand Down Expand Up @@ -94,6 +95,8 @@
fout.write("\n")

fout.write('\n#endif\n')

fout.write("\n} //namespace coreneuron\n")
fout.close()

# if kf exists and is same as kftmp, just remove kftmp. Otherwise
Expand Down
9 changes: 3 additions & 6 deletions coreneuron/mech/cfile/cabvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef __cplusplus
extern "C" {
#endif

namespace coreneuron {

extern void capacitance_reg(void), _passive_reg(void),
#if EXTRACELLULAR
Expand All @@ -44,6 +43,4 @@ static void (*mechanism[])(void) = {/* type will start at 3 */
#endif
_stim_reg, _hh_reg, _expsyn_reg, _netstim_reg, _exp2syn_reg, 0};

#ifdef __cplusplus
}
#endif
} //namespace coreneuron
8 changes: 2 additions & 6 deletions coreneuron/mech/mod2c_core_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include "coreneuron/nrnoc/multicore.h"
#include "coreneuron/nrnoc/nrnoc_ml.h"

#if defined(__cplusplus)
extern "C" {
#endif
namespace coreneuron {

#if !defined(LAYOUT)
/* 1 means AoS, >1 means AoSoA, <= 0 means SOA */
Expand Down Expand Up @@ -141,8 +139,6 @@ extern void _modl_set_dt_thread(double, NrnThread*);

void nrn_sparseobj_copyto_device(SparseObj* so);

#if defined(__cplusplus)
}
#endif
} // namespace coreneuron

#endif
2 changes: 2 additions & 0 deletions coreneuron/mech/mod_func.c.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

print << "__eof";
#include <stdio.h>
namespace coreneuron {
extern int nrnmpi_myid;
extern int nrn_nobanner_;
extern int @{[join ",\n ", map{"_${_}_reg(void)"} @mods]};
Expand All @@ -41,4 +42,5 @@

@{[join "\n", map{" _${_}_reg();"} @mods] }
}
} //namespace coreneuron
__eof
2 changes: 2 additions & 0 deletions coreneuron/mech/mod_func_ptrs.c.pl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <string.h>
#include <stdlib.h>
#include "coreneuron/coreneuron.h"
namespace coreneuron {
__eof

#Get the correct SUFFIX from each mod file for each mechanism
Expand Down Expand Up @@ -121,5 +122,6 @@
{
return NULL;
}
} //namespace coreneuron
__eof

11 changes: 5 additions & 6 deletions coreneuron/mech/modfile/pattern.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ NET_RECEIVE (w) {LOCAL nst

VERBATIM

extern void nrn_fake_fire(int gid, double spiketime, int fake_out);

typedef struct {
int size;
double* tvec;
Expand All @@ -57,16 +55,17 @@ Info* mkinfo(_threadargsproto_) {
return info;
}
/* for CoreNEURON checkpoint save and restore */
namespace coreneuron {
int checkpoint_save_patternstim(_threadargsproto_) {
INFOCAST; Info* info = *ip;
return info->index;
}
void checkpoint_restore_patternstim(int _index, double _te, _threadargsproto_) {
INFOCAST; Info* info = *ip;
info->index = _index;
artcell_net_send(_tqitem, -1, _nt->_vdata[_ppvar[1*_STRIDE]], _te, 1.0);
artcell_net_send(_tqitem, -1, (Point_process*)_nt->_vdata[_ppvar[1*_STRIDE]], _te, 1.0);
}

} //namespace coreneuron
ENDVERBATIM

FUNCTION initps() {
Expand Down Expand Up @@ -109,7 +108,7 @@ ENDVERBATIM
VERBATIM
static void bbcore_write(double* x, int* d, int* xx, int *offset, _threadargsproto_){}
static void bbcore_read(double* x, int* d, int* xx, int* offset, _threadargsproto_){}

namespace coreneuron {
void pattern_stim_setup_helper(int size, double* tv, int* gv, _threadargsproto_) {
INFOCAST;
Info* info = mkinfo(_threadargs_);
Expand All @@ -118,6 +117,6 @@ void pattern_stim_setup_helper(int size, double* tv, int* gv, _threadargsproto_)
info->tvec = tv;
info->gidvec = gv;
}

} // namespace coreneuron
ENDVERBATIM

12 changes: 6 additions & 6 deletions coreneuron/nrnconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <errno.h>
#include <stdint.h>


namespace coreneuron {

#define NRNBBCORE 1

#define nil NULL
#define Sprintf sprintf

typedef int Datum;
//#define Datum int
typedef int (*Pfri)();
typedef char Symbol;

Expand All @@ -53,11 +57,9 @@ typedef char Symbol;
#define VEC_AREA(i) (_nt->_actual_area[(i)])
#define VECTORIZE 1

#if defined(__cplusplus)
extern "C" {
#endif

extern double celsius;

extern double t, dt;
extern int rev_dt;
extern int secondorder;
Expand Down Expand Up @@ -91,8 +93,6 @@ typedef struct Point_process {

extern char* pnt_name(Point_process* pnt);

#if defined(__cplusplus)
}
#endif
} //namespace coreneuron

#endif
3 changes: 2 additions & 1 deletion coreneuron/nrniv/balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "coreneuron/nrniv/tnode.h"
#include "coreneuron/nrniv/lpt.h"
#include <algorithm>

namespace coreneuron {
int cellorder_nwarp = 0; // 0 means do not balance

// ordering by warp, then old order
Expand Down Expand Up @@ -103,3 +103,4 @@ size_t warp_balance(size_t ncell, VecTNode& nodevec) {

return nwarp;
}
} //namespace coreneuron
4 changes: 2 additions & 2 deletions coreneuron/nrniv/cellorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifdef _OPENACC
#include <openacc.h>
#endif

namespace coreneuron {
int use_interleave_permute;
InterleaveInfo* interleave_info; // nrn_nthread array

Expand Down Expand Up @@ -683,5 +683,5 @@ void solve_interleaved(int ith) {
solve_interleaved1(ith);
}
}

} //namespace coreneuron
#endif
4 changes: 2 additions & 2 deletions coreneuron/nrniv/cellorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define cellorder_h

#include <algorithm>

namespace coreneuron {
int* interleave_order(int ith, int ncell, int nnode, int* parent);

void create_interleave_info();
Expand Down Expand Up @@ -57,5 +57,5 @@ void copy_array(T*& dest, T* src, size_t n) {
#if INTERLEAVE_DEBUG
void mk_cell_indices();
#endif

} //namespace coreneuron
#endif
3 changes: 2 additions & 1 deletion coreneuron/nrniv/cellorder1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <string.h>

using namespace std;

namespace coreneuron {
static size_t groupsize = 32;

static bool tnode_earlier(TNode* a, TNode* b) {
Expand Down Expand Up @@ -669,3 +669,4 @@ for (int i = 0; i <= nwarp; ++i){
}
#endif
}
} //namespace coreneuron
3 changes: 2 additions & 1 deletion coreneuron/nrniv/cellorder2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using namespace std;
// experiment starting with identical cell ordering
// groupindex aleady defined that keeps identical cells together
// begin with leaf to root ordering

namespace coreneuron {
typedef VecTNode VTN; // level of nodes
typedef vector<VTN> VVTN; // group of levels
typedef vector<VVTN> VVVTN; // groups
Expand Down Expand Up @@ -530,3 +530,4 @@ void group_order2(VecTNode& nodevec, size_t groupsize, size_t ncell) {
std::sort(nodevec.begin() + ncell, nodevec.end(), final_nodevec_cmp);
set_nodeindex(nodevec);
}
} //namespace coreneuron
Loading