diff --git a/cmake/NeuronFileLists.cmake b/cmake/NeuronFileLists.cmake index fe41a53a55..22f87449a2 100644 --- a/cmake/NeuronFileLists.cmake +++ b/cmake/NeuronFileLists.cmake @@ -204,14 +204,7 @@ endif() # ============================================================================= set(NRNIV_FILE_LIST backtrace_utils.cpp - bbs.cpp bbsavestate.cpp - bbsdirect.cpp - bbslocal.cpp - bbslsrv.cpp - bbslsrv2.cpp - bbsrcli.cpp - bbssrv.cpp classreg.cpp cxprop.cpp datapath.cpp @@ -243,7 +236,6 @@ set(NRNIV_FILE_LIST nvector_nrnserial_ld.cpp nvector_nrnthread.cpp nvector_nrnthread_ld.cpp - ocbbs.cpp ocjump.cpp partrans.cpp ppshape.cpp @@ -424,7 +416,6 @@ set(NMODL_FILES_LIST simultan.cpp solve.cpp symbol.cpp - units.cpp version.cpp) set(IVOS_FILES_LIST observe.cpp resource.cpp) @@ -433,6 +424,16 @@ set(MPI_DYNAMIC_INCLUDE nrnmpi_dynam.h nrnmpi_dynam_cinc nrnmpi_dynam_wrappers.i set(NRN_MUSIC_FILES_LIST nrnmusic.cpp) +set(NRN_PARALLEL_FILES_LIST + bbs.cpp + bbsclimpi.cpp + bbsdirectmpi.cpp + bbslocal.cpp + bbslsrv.cpp + bbssrv2mpi.cpp + bbssrvmpi.cpp + ocbbs.cpp) + # ============================================================================= # Top level directories under src # ============================================================================= @@ -447,6 +448,7 @@ set(NRN_MODLUNIT_SRC_DIR ${PROJECT_SOURCE_DIR}/src/modlunit) set(NRN_NMODL_SRC_DIR ${PROJECT_SOURCE_DIR}/src/nmodl) set(NRN_IVOS_SRC_DIR ${PROJECT_SOURCE_DIR}/src/ivos) set(NRN_MUSIC_SRC_DIR ${PROJECT_SOURCE_DIR}/src/neuronmusic) +set(NRN_PARALLEL_SRC_DIR ${PROJECT_SOURCE_DIR}/src/parallel) # ============================================================================= # Create source file lists by gathering from various directories @@ -460,10 +462,13 @@ nrn_create_file_list(NRN_NODEORDEROPTIM_SRC_FILES ${NRN_NODEORDEROPTIM_SRC_DIR} list(APPEND NRN_NODEORDEROPTIM_SRC_FILES ${PROJECT_SOURCE_DIR}/src/coreneuron/utils/lpt.cpp) nrn_create_file_list(NRN_NRNCVODE_SRC_FILES ${NRN_NRNCVODE_SRC_DIR} ${NRNCVODE_FILE_LIST}) nrn_create_file_list(NRN_NRNIV_SRC_FILES ${NRN_NRNIV_SRC_DIR} ${NRNIV_FILE_LIST}) -nrn_create_file_list(NRN_PARALLEL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/nrniv - nvector_nrnparallel_ld.cpp) -nrn_create_file_list(NRN_PARALLEL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/sundials/shared - nvector_parallel.c) +nrn_create_file_list(NRN_PARALLEL_SRC_FILES ${NRN_PARALLEL_SRC_DIR} ${NRN_PARALLEL_FILES_LIST}) +if(NRN_ENABLE_MPI) + nrn_create_file_list(NRN_PARALLEL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/nrniv + nvector_nrnparallel_ld.cpp) + nrn_create_file_list(NRN_PARALLEL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/sundials/shared + nvector_parallel.c) +endif() nrn_create_file_list(NRN_SPARSE_SRC_FILES ${PROJECT_SOURCE_DIR}/src/sparse ${SPARSE_FILES_LIST}) nrn_create_file_list(NRN_SCOPMATH_SRC_FILES ${PROJECT_SOURCE_DIR}/src/scopmath ${SCOPMATH_FILES_LIST}) @@ -480,6 +485,7 @@ nrn_create_file_list(NRNMPI_DYNAMIC_INCLUDE_FILE ${PROJECT_SOURCE_DIR}/src/nrnmp nrn_create_file_list(NRN_IVOS_SRC_FILES ${NRN_IVOS_SRC_DIR} ${IVOS_FILES_LIST}) nrn_create_file_list(NRN_MUSIC_SRC_FILES ${NRN_MUSIC_SRC_DIR} ${NRN_MUSIC_FILES_LIST}) list(APPEND NRN_OC_SRC_FILES ${PROJECT_BINARY_DIR}/src/oc/hocusr.h) +list(APPEND NRN_NMODL_SRC_FILES ${NRN_MODLUNIT_SRC_DIR}/units.cpp) # ============================================================================= # Create mswin install lists needed for setup_exe target @@ -487,7 +493,13 @@ list(APPEND NRN_OC_SRC_FILES ${PROJECT_BINARY_DIR}/src/oc/hocusr.h) if(MINGW) set(MSWIN_SRC_DIR ${PROJECT_SOURCE_DIR}/src/mswin) nrn_create_file_list(MSWIN_FILES ${PROJECT_SOURCE_DIR}/src/parallel test0.hoc test0.py) + list(APPEND MSWIN_FILES ${MSWIN_SRC_DIR}/notes.txt) + + list(APPEND NRN_MODLUNIT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/mswin/extra/d2upath.cpp) + list(APPEND NRN_NMODL_SRC_FILES ${PROJECT_SOURCE_DIR}/src/mswin/extra/d2upath.cpp) + list(APPEND NRN_OC_SRC_FILES ${PROJECT_SOURCE_DIR}/src/mswin/extra/d2upath.cpp) + nrn_create_file_list(MSWIN_BIN_FILES ${MSWIN_SRC_DIR} nrniv.ico nrniv10.ico nmodl2a.ico) nrn_create_file_list( MSWIN_LIB_FILES diff --git a/src/ivoc/ivocman1.cpp b/src/ivoc/ivocman1.cpp deleted file mode 100644 index b191de0f60..0000000000 --- a/src/ivoc/ivocman1.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// The problem this hack overcomes is that extending Python requires -// ivocmain.cpp in the shared library (compiled with PIC) and that is -// fine for normal neuron as well. But there are link problems when -// built statically and hence ivocmain.cpp is listed in the -// ivoc_SOURCES so that it is sure to be linked early in the process. - -#include "ivocmain.cpp" diff --git a/src/modlunit/units.cpp b/src/modlunit/units.cpp index 9901f19fae..062b8efa20 100644 --- a/src/modlunit/units.cpp +++ b/src/modlunit/units.cpp @@ -13,8 +13,9 @@ #include #ifdef MINGW -#include "../mswin/extra/d2upath.cpp" +#include "../mswin/extra/d2upath.h" #endif + #if defined(WIN32) #include #endif @@ -109,7 +110,7 @@ static int Getc(FILE* inp) { static struct unit unit_stack[UNIT_STK_SIZE], *usp{nullptr}; static char* neuronhome() { -#if defined(WIN32) +#if defined(MINGW) int i; static char buf[256]; GetModuleFileName(NULL, buf, 256); diff --git a/src/mswin/CMakeLists.txt b/src/mswin/CMakeLists.txt index 94669e77d0..b660eaed4c 100644 --- a/src/mswin/CMakeLists.txt +++ b/src/mswin/CMakeLists.txt @@ -31,8 +31,8 @@ if(MINGW) DEPENDS ${mswinsrc}/nrniv10.ico) set_source_files_properties(${mswinsrc}/extra/neuron.cpp ${mswinsrc}/extra/mos2nrn.cpp ${mswinsrc}/extra/nrnbinstr.cpp PROPERTIES COMPILE_DEFINITIONS MINGW) - add_executable(neuron ${mswinsrc}/extra/neuron.cpp nrnicon.res) - add_executable(mos2nrn ${mswinsrc}/extra/mos2nrn.cpp) + add_executable(neuron ${mswinsrc}/extra/neuron.cpp ${mswinsrc}/extra/d2upath.cpp nrnicon.res) + add_executable(mos2nrn ${mswinsrc}/extra/mos2nrn.cpp ${mswinsrc}/extra/d2upath.cpp) add_executable(nrnbinstr ${mswinsrc}/extra/nrnbinstr.cpp) set(INCDIRS ${PROJECT_SOURCE_DIR}/src/oc) target_include_directories(mos2nrn PUBLIC ${INCDIRS}) diff --git a/src/mswin/extra/d2upath.cpp b/src/mswin/extra/d2upath.cpp index 9b9ce5c064..8c5d929b4d 100644 --- a/src/mswin/extra/d2upath.cpp +++ b/src/mswin/extra/d2upath.cpp @@ -5,18 +5,19 @@ up to 11 characters longer. the output string should be freed with free() when no longer needed. */ -#include -#include -#include +#include +#include +#include char* hoc_dos2unixpath(const char* d) { /* translate x: and x:/ and x:\, to /cygdrive/x/ */ /* and all backslashes to forward slashes */ /* or, for mingw, just backslashes to forward slashes */ - char* cp; + char* cp = nullptr; auto* const u = static_cast(malloc(strlen(d) + 12)); assert(u); - int i{}, j{}; + size_t i = 0; + int j = 0; if (d[0] && d[1] == ':') { strcpy(u, "/cygdrive/"); i = strlen(u); diff --git a/src/mswin/extra/d2upath.h b/src/mswin/extra/d2upath.h new file mode 100644 index 0000000000..c1374dcfff --- /dev/null +++ b/src/mswin/extra/d2upath.h @@ -0,0 +1 @@ +char* hoc_dos2unixpath(const char* d); diff --git a/src/mswin/extra/mos2nrn.cpp b/src/mswin/extra/mos2nrn.cpp index aa3d5072ec..37cb0d2069 100644 --- a/src/mswin/extra/mos2nrn.cpp +++ b/src/mswin/extra/mos2nrn.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "d2upath.cpp" +#include "d2upath.h" char* nrnhome; char* nh; diff --git a/src/mswin/extra/neuron.cpp b/src/mswin/extra/neuron.cpp index cd5f52b94a..50224d6fb4 100644 --- a/src/mswin/extra/neuron.cpp +++ b/src/mswin/extra/neuron.cpp @@ -5,12 +5,12 @@ // finally executes nrniv.exe. Nrniv.exe can be run by itself if // it does not need a console or system("command") #include -#include -#include -#include "d2upath.cpp" +#include "d2upath.h" #include +#include +#include char* nrnhome; char* nh; diff --git a/src/nmodl/units.cpp b/src/nmodl/units.cpp deleted file mode 100755 index a618b6e73b..0000000000 --- a/src/nmodl/units.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include <../../nrnconf.h> -/* - * Automake doesn't deal well with sources that live in other directories. - * This is a quick and dirty workaround. - */ -#include "../modlunit/units.cpp" diff --git a/src/nrncvode/hocevent.cpp b/src/nrncvode/hocevent.cpp deleted file mode 100644 index 5654ea0b7d..0000000000 --- a/src/nrncvode/hocevent.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include -#include -#include -#include -#include - -using HocEventPool = MutexPool; -HocEventPool* HocEvent::hepool_; - -HocEvent::HocEvent() { - stmt_ = nullptr; - ppobj_ = nullptr; - reinit_ = 0; -} - -HocEvent::~HocEvent() { - if (stmt_) { - delete stmt_; - } -} - -void HocEvent::pr(const char* s, double tt, NetCvode* ns) { - Printf("%s HocEvent %s %.15g\n", s, stmt_ ? stmt_->name() : "", tt); -} - -HocEvent* HocEvent::alloc(const char* stmt, Object* ppobj, int reinit, Object* pyact) { - if (!hepool_) { - nrn_hoc_lock(); - if (!hepool_) { - hepool_ = new HocEventPool(100, 1); - } - nrn_hoc_unlock(); - } - HocEvent* he = hepool_->alloc(); - he->stmt_ = nullptr; - he->ppobj_ = ppobj; - he->reinit_ = reinit; - if (pyact) { - he->stmt_ = new HocCommand(pyact); - } else if (stmt) { - he->stmt_ = new HocCommand(stmt); - } - return he; -} - -void HocEvent::hefree() { - if (stmt_) { - delete stmt_; - stmt_ = nullptr; - } - hepool_->hpfree(this); -} - -void HocEvent::clear() { - if (stmt_) { - delete stmt_; - stmt_ = nullptr; - } -} - -void HocEvent::deliver(double tt, NetCvode* nc, NrnThread* nt) { - extern double t; - if (!ppobj_) { - nc->allthread_handle(tt, this, nt); - return; - } - if (stmt_) { - if (nrn_nthread > 1 || nc->is_local()) { - if (!ppobj_) { - hoc_execerror( - "multiple threads and/or local variable time step method require an " - "appropriate POINT_PROCESS arg to CVode.event to safely execute:", - stmt_->name()); - } - Cvode* cv = (Cvode*) ob2pntproc(ppobj_)->nvi_; - if (cv && cvode_active_) { - nc->local_retreat(tt, cv); - if (reinit_) { - cv->set_init_flag(); - } - nt->_t = cv->t_; - } - nrn_hoc_lock(); - t = tt; - } else if (cvode_active_ && reinit_) { - nc->retreat(tt, nc->gcv_); - assert(MyMath::eq(tt, nc->gcv_->t_, NetCvode::eps(tt))); - assert(tt == nt->_t); - nc->gcv_->set_init_flag(); - t = tt; - } else { - t = nt_t = tt; - } - stmt_->execute(false); - if (nrn_nthread > 1 || nc->is_local()) { - nrn_hoc_unlock(); - } - } - hefree(); -} - -void HocEvent::allthread_handle() { - if (stmt_) { - stmt_->execute(false); - } else { - tstopset; - } - hefree(); -} - -void HocEvent::pgvts_deliver(double tt, NetCvode* nc) { - deliver(tt, nc, nrn_threads); -} - -void HocEvent::reclaim() { - if (hepool_) { - hepool_->free_all(); - } -} - -DiscreteEvent* HocEvent::savestate_save() { - // pr("HocEvent::savestate_save", 0, net_cvode_instance); - HocEvent* he = new HocEvent(); - if (stmt_) { - if (stmt_->pyobject()) { - he->stmt_ = new HocCommand(stmt_->pyobject()); - } else { - he->stmt_ = new HocCommand(stmt_->name(), stmt_->object()); - } - he->reinit_ = reinit_; - he->ppobj_ = ppobj_; - } - return he; -} - -void HocEvent::savestate_restore(double tt, NetCvode* nc) { - // pr("HocEvent::savestate_restore", tt, nc); - HocEvent* he = alloc(nullptr, nullptr, 0); - NrnThread* nt = nrn_threads; - if (stmt_) { - if (stmt_->pyobject()) { - he->stmt_ = new HocCommand(stmt_->pyobject()); - } else { - he->stmt_ = new HocCommand(stmt_->name(), stmt_->object()); - } - he->reinit_ = reinit_; - he->ppobj_ = ppobj_; - if (ppobj_) { - nt = (NrnThread*) ob2pntproc(ppobj_)->_vnt; - } - } - nc->event(tt, he, nt); -} - -DiscreteEvent* HocEvent::savestate_read(FILE* f) { - HocEvent* he = new HocEvent(); - int have_stmt, have_obj, index; - char stmt[256], objname[100], buf[200]; - Object* obj = nullptr; - // nrn_assert(fscanf(f, "%d %d\n", &have_stmt, &have_obj) == 2); - nrn_assert(fgets(buf, 200, f)); - nrn_assert(sscanf(buf, "%d %d\n", &have_stmt, &have_obj) == 2); - if (have_stmt) { - nrn_assert(fgets(stmt, 256, f)); - stmt[strlen(stmt) - 1] = '\0'; - if (have_obj) { - // nrn_assert(fscanf(f, "%s %d\n", objname, &index) == 1); - nrn_assert(fgets(buf, 200, f)); - nrn_assert(sscanf(buf, "%s %d\n", objname, &index) == 1); - obj = hoc_name2obj(objname, index); - } - he->stmt_ = new HocCommand(stmt, obj); - } - return he; -} - -void HocEvent::savestate_write(FILE* f) { - fprintf(f, "%d\n", HocEventType); - fprintf(f, "%d %d\n", stmt_ ? 1 : 0, (stmt_ && stmt_->object()) ? 1 : 0); - if (stmt_) { - fprintf(f, "%s\n", stmt_->name()); - if (stmt_->object()) { - fprintf(f, "%s %d\n", stmt_->object()->ctemplate->sym->name, stmt_->object()->index); - } - } -} diff --git a/src/nrncvode/netcvode.cpp b/src/nrncvode/netcvode.cpp index f0421a92da..ca6a9b7657 100644 --- a/src/nrncvode/netcvode.cpp +++ b/src/nrncvode/netcvode.cpp @@ -3396,7 +3396,186 @@ void PlayRecordEvent::pr(const char* s, double tt, NetCvode* ns) { plr_->pr(); } -#include +using HocEventPool = MutexPool; +HocEventPool* HocEvent::hepool_; + +HocEvent::HocEvent() { + stmt_ = nullptr; + ppobj_ = nullptr; + reinit_ = 0; +} + +HocEvent::~HocEvent() { + if (stmt_) { + delete stmt_; + } +} + +void HocEvent::pr(const char* s, double tt, NetCvode* ns) { + Printf("%s HocEvent %s %.15g\n", s, stmt_ ? stmt_->name() : "", tt); +} + +HocEvent* HocEvent::alloc(const char* stmt, Object* ppobj, int reinit, Object* pyact) { + if (!hepool_) { + nrn_hoc_lock(); + if (!hepool_) { + hepool_ = new HocEventPool(100, 1); + } + nrn_hoc_unlock(); + } + HocEvent* he = hepool_->alloc(); + he->stmt_ = nullptr; + he->ppobj_ = ppobj; + he->reinit_ = reinit; + if (pyact) { + he->stmt_ = new HocCommand(pyact); + } else if (stmt) { + he->stmt_ = new HocCommand(stmt); + } + return he; +} + +void HocEvent::hefree() { + if (stmt_) { + delete stmt_; + stmt_ = nullptr; + } + hepool_->hpfree(this); +} + +void HocEvent::clear() { + if (stmt_) { + delete stmt_; + stmt_ = nullptr; + } +} + +void HocEvent::deliver(double tt, NetCvode* nc, NrnThread* nt) { + extern double t; + if (!ppobj_) { + nc->allthread_handle(tt, this, nt); + return; + } + if (stmt_) { + if (nrn_nthread > 1 || nc->is_local()) { + if (!ppobj_) { + hoc_execerror( + "multiple threads and/or local variable time step method require an " + "appropriate POINT_PROCESS arg to CVode.event to safely execute:", + stmt_->name()); + } + Cvode* cv = (Cvode*) ob2pntproc(ppobj_)->nvi_; + if (cv && cvode_active_) { + nc->local_retreat(tt, cv); + if (reinit_) { + cv->set_init_flag(); + } + nt->_t = cv->t_; + } + nrn_hoc_lock(); + t = tt; + } else if (cvode_active_ && reinit_) { + nc->retreat(tt, nc->gcv_); + assert(MyMath::eq(tt, nc->gcv_->t_, NetCvode::eps(tt))); + assert(tt == nt->_t); + nc->gcv_->set_init_flag(); + t = tt; + } else { + t = nt_t = tt; + } + stmt_->execute(false); + if (nrn_nthread > 1 || nc->is_local()) { + nrn_hoc_unlock(); + } + } + hefree(); +} + +void HocEvent::allthread_handle() { + if (stmt_) { + stmt_->execute(false); + } else { + tstopset; + } + hefree(); +} + +void HocEvent::pgvts_deliver(double tt, NetCvode* nc) { + deliver(tt, nc, nrn_threads); +} + +void HocEvent::reclaim() { + if (hepool_) { + hepool_->free_all(); + } +} + +DiscreteEvent* HocEvent::savestate_save() { + // pr("HocEvent::savestate_save", 0, net_cvode_instance); + HocEvent* he = new HocEvent(); + if (stmt_) { + if (stmt_->pyobject()) { + he->stmt_ = new HocCommand(stmt_->pyobject()); + } else { + he->stmt_ = new HocCommand(stmt_->name(), stmt_->object()); + } + he->reinit_ = reinit_; + he->ppobj_ = ppobj_; + } + return he; +} + +void HocEvent::savestate_restore(double tt, NetCvode* nc) { + // pr("HocEvent::savestate_restore", tt, nc); + HocEvent* he = alloc(nullptr, nullptr, 0); + NrnThread* nt = nrn_threads; + if (stmt_) { + if (stmt_->pyobject()) { + he->stmt_ = new HocCommand(stmt_->pyobject()); + } else { + he->stmt_ = new HocCommand(stmt_->name(), stmt_->object()); + } + he->reinit_ = reinit_; + he->ppobj_ = ppobj_; + if (ppobj_) { + nt = (NrnThread*) ob2pntproc(ppobj_)->_vnt; + } + } + nc->event(tt, he, nt); +} + +DiscreteEvent* HocEvent::savestate_read(FILE* f) { + HocEvent* he = new HocEvent(); + int have_stmt, have_obj, index; + char stmt[256], objname[100], buf[200]; + Object* obj = nullptr; + // nrn_assert(fscanf(f, "%d %d\n", &have_stmt, &have_obj) == 2); + nrn_assert(fgets(buf, 200, f)); + nrn_assert(sscanf(buf, "%d %d\n", &have_stmt, &have_obj) == 2); + if (have_stmt) { + nrn_assert(fgets(stmt, 256, f)); + stmt[strlen(stmt) - 1] = '\0'; + if (have_obj) { + // nrn_assert(fscanf(f, "%s %d\n", objname, &index) == 1); + nrn_assert(fgets(buf, 200, f)); + nrn_assert(sscanf(buf, "%s %d\n", objname, &index) == 1); + obj = hoc_name2obj(objname, index); + } + he->stmt_ = new HocCommand(stmt, obj); + } + return he; +} + +void HocEvent::savestate_write(FILE* f) { + fprintf(f, "%d\n", HocEventType); + fprintf(f, "%d %d\n", stmt_ ? 1 : 0, (stmt_ && stmt_->object()) ? 1 : 0); + if (stmt_) { + fprintf(f, "%s\n", stmt_->name()); + if (stmt_->object()) { + fprintf(f, "%s %d\n", stmt_->object()->ctemplate->sym->name, stmt_->object()->index); + } + } +} void NetCvode::local_retreat(double t, Cvode* cv) { if (!cvode_active_) { diff --git a/src/nrniv/CMakeLists.txt b/src/nrniv/CMakeLists.txt index c9331147c3..578be1dd92 100644 --- a/src/nrniv/CMakeLists.txt +++ b/src/nrniv/CMakeLists.txt @@ -157,11 +157,8 @@ set(NRN_NRNIV_LIB_SRC_FILES ${NRN_MODFILE_CPP} ${NRN_SCOPMATH_SRC_FILES} ${NRN_SPARSE_SRC_FILES} - ${NRN_SUNDIALS_SRC_FILES}) - -if(NRN_ENABLE_MPI) - list(APPEND NRN_NRNIV_LIB_SRC_FILES ${NRN_PARALLEL_SRC_FILES}) -endif() + ${NRN_SUNDIALS_SRC_FILES} + ${NRN_PARALLEL_SRC_FILES}) if(NRN_ENABLE_MPI_DYNAMIC) list(APPEND NRN_NRNIV_LIB_SRC_FILES ${PROJECT_SOURCE_DIR}/src/nrnmpi/nrnmpi_dynam.cpp) diff --git a/src/nrniv/bbs.cpp b/src/nrniv/bbs.cpp deleted file mode 100755 index 2eae2b7652..0000000000 --- a/src/nrniv/bbs.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../parallel/bbs.cpp" diff --git a/src/nrniv/bbsdirect.cpp b/src/nrniv/bbsdirect.cpp deleted file mode 100755 index 6639223399..0000000000 --- a/src/nrniv/bbsdirect.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include -#if NRNMPI -#include "../parallel/bbsdirectmpi.cpp" -#endif diff --git a/src/nrniv/bbslocal.cpp b/src/nrniv/bbslocal.cpp deleted file mode 100755 index 16555d709e..0000000000 --- a/src/nrniv/bbslocal.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../parallel/bbslocal.cpp" diff --git a/src/nrniv/bbslsrv.cpp b/src/nrniv/bbslsrv.cpp deleted file mode 100755 index 84bf12f591..0000000000 --- a/src/nrniv/bbslsrv.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../parallel/bbslsrv.cpp" diff --git a/src/nrniv/bbslsrv2.cpp b/src/nrniv/bbslsrv2.cpp deleted file mode 100755 index 058c49810d..0000000000 --- a/src/nrniv/bbslsrv2.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include -#if NRNMPI -#include "../parallel/bbssrv2mpi.cpp" -#endif diff --git a/src/nrniv/bbsrcli.cpp b/src/nrniv/bbsrcli.cpp deleted file mode 100755 index 945ca5a3eb..0000000000 --- a/src/nrniv/bbsrcli.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include -#if NRNMPI -#include "../parallel/bbsclimpi.cpp" -#endif diff --git a/src/nrniv/bbssrv.cpp b/src/nrniv/bbssrv.cpp deleted file mode 100755 index a89f19c495..0000000000 --- a/src/nrniv/bbssrv.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include "../parallel/bbssrvmpi.cpp" diff --git a/src/nrniv/multisend_setup.cpp b/src/nrniv/multisend_setup.cpp index 479d30bf78..8e66681e8c 100644 --- a/src/nrniv/multisend_setup.cpp +++ b/src/nrniv/multisend_setup.cpp @@ -9,8 +9,6 @@ the source host owning the gid. */ #include "oc_ansi.h" -#include "oc_ansi.h" - static void del(int* a) { if (a) { delete[] a; diff --git a/src/nrniv/ocbbs.cpp b/src/nrniv/ocbbs.cpp deleted file mode 100755 index c7233ce4b4..0000000000 --- a/src/nrniv/ocbbs.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../parallel/ocbbs.cpp" diff --git a/src/nrnoc/multicore.cpp b/src/nrnoc/multicore.cpp index 83c8e3ff05..fc1bb40618 100644 --- a/src/nrnoc/multicore.cpp +++ b/src/nrnoc/multicore.cpp @@ -1,4 +1,3 @@ -/* included by treeset.cpp */ #include #include "hoclist.h" diff --git a/src/oc/mswinprt.cpp b/src/oc/mswinprt.cpp index 905aa101b2..29dbdc9571 100644 --- a/src/oc/mswinprt.cpp +++ b/src/oc/mswinprt.cpp @@ -12,7 +12,7 @@ #include #include #include "hoc.h" -#include "../mswin/extra/d2upath.cpp" +#include "../mswin/extra/d2upath.h" #include "gui-redirect.h" diff --git a/src/parallel/ocbbs.cpp b/src/parallel/ocbbs.cpp index 7462d149b3..9f59ad7c5c 100644 --- a/src/parallel/ocbbs.cpp +++ b/src/parallel/ocbbs.cpp @@ -1354,7 +1354,116 @@ char* BBSImpl::execute_helper(size_t* size, int id, bool exec) { return rs; } -#include "subworld.cpp" +void BBSImpl::subworld_worker_execute() { + // execute the same thing that execute_worker is executing. This + // is done for all the nrnmpi_myid_bbs == -1 workers associated with + // the specific nrnmpi_myid == 0 with nrnmpi_myid_bbs >= 0. + // All the nrnmpi/mpispike.cpp functions can be used since the + // proper communicators for a subworld are used by those functions. + // The broadcast functions are particularly useful and those are + // how execute_worker passes messages into here. + + // printf("%d enter subworld_worker_execute\n", nrnmpi_myid_world); + int info[2]; + // wait for something to do + nrnmpi_int_broadcast(info, 2, 0); + // info[0] = -1 means it was from a pc.context. Also -2 means + // DONE. + // printf("%d subworld_worker_execute info %d %d\n", nrnmpi_myid_world, info[0], info[1]); + int id = info[0]; + if (id == -2) { // DONE, so quit. + done(); + } + hoc_ac_ = double(id); + int style = info[1]; + if (style == 0) { // hoc statement form + int size; + nrnmpi_int_broadcast(&size, 1, 0); // includes terminator + char* s = new char[size]; + nrnmpi_char_broadcast(s, size, 0); + hoc_obj_run(s, nullptr); + delete[] s; + // printf("%d leave subworld_worker_execute\n", nrnmpi_myid_world); + return; + } + int i, j; + int npickle; + char* s; + Symbol* fname = 0; + Object* ob = nullptr; + char* sarg[20]; // up to 20 arguments may be strings + int ns = 0; // number of args that are strings + int narg = 0; // total number of args + + if (style == 3) { // python callable + nrnmpi_int_broadcast(&npickle, 1, 0); + s = new char[npickle]; + nrnmpi_char_broadcast(s, npickle, 0); + } else if (style == 1) { // hoc function + int size; + nrnmpi_int_broadcast(&size, 1, 0); // includes terminator + // printf("%d subworld hoc function string size = %d\n", nrnmpi_myid_world, size); + s = new char[size]; + nrnmpi_char_broadcast(s, size, 0); + fname = hoc_lookup(s); + if (!fname) { + return; + } // error raised by sender + } else { + return; // no others implemented, error raised by sender + } + + // now get the args + int argtypes; + nrnmpi_int_broadcast(&argtypes, 1, 0); + // printf("%d subworld argtypes = %d\n", nrnmpi_myid_world, argtypes); + for (j = argtypes; (i = j % 5) != 0; j /= 5) { + ++narg; + if (i == 1) { // double + double x; + nrnmpi_dbl_broadcast(&x, 1, 0); + // printf("%d subworld scalar = %g\n", nrnmpi_myid_world, x); + hoc_pushx(x); + } else if (i == 2) { // string + int size; + nrnmpi_int_broadcast(&size, 1, 0); + sarg[ns] = new char[size]; + nrnmpi_char_broadcast(sarg[ns], size, 0); + hoc_pushstr(sarg + ns); + ns++; + } else if (i == 3) { // Vector + int n; + nrnmpi_int_broadcast(&n, 1, 0); + Vect* vec = new Vect(n); + nrnmpi_dbl_broadcast(vec->data(), n, 0); + hoc_pushobj(vec->temp_objvar()); + } else { // PythonObject + int n; + nrnmpi_int_broadcast(&n, 1, 0); + char* s; + s = new char[n]; + nrnmpi_char_broadcast(s, n, 0); + Object* po = neuron::python::methods.pickle2po(s, size_t(n)); + delete[] s; + hoc_pushobj(hoc_temp_objptr(po)); + } + } + + if (style == 3) { + size_t size; + char* rs = neuron::python::methods.call_picklef(s, size_t(npickle), narg, &size); + assert(rs); + delete[] rs; + } else { + // printf("%d subworld hoc call %s narg=%d\n", nrnmpi_myid_world, fname->name, narg); + hoc_call_objfunc(fname, narg, ob); + // printf("%d subworld return from hoc call %s\n", nrnmpi_myid_world, fname->name); + } + delete[] s; + for (i = 0; i < ns; ++i) { + delete[] sarg[i]; + } +} void BBSImpl::return_args(int id) { // the message has been set up by the subclass diff --git a/src/parallel/subworld.cpp b/src/parallel/subworld.cpp deleted file mode 100644 index c9b82ef2a3..0000000000 --- a/src/parallel/subworld.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// included by ocbbs.cpp - -void BBSImpl::subworld_worker_execute() { - // execute the same thing that execute_worker is executing. This - // is done for all the nrnmpi_myid_bbs == -1 workers associated with - // the specific nrnmpi_myid == 0 with nrnmpi_myid_bbs >= 0. - // All the nrnmpi/mpispike.cpp functions can be used since the - // proper communicators for a subworld are used by those functions. - // The broadcast functions are particularly useful and those are - // how execute_worker passes messages into here. - - // printf("%d enter subworld_worker_execute\n", nrnmpi_myid_world); - int info[2]; - // wait for something to do - nrnmpi_int_broadcast(info, 2, 0); - // info[0] = -1 means it was from a pc.context. Also -2 means - // DONE. - // printf("%d subworld_worker_execute info %d %d\n", nrnmpi_myid_world, info[0], info[1]); - int id = info[0]; - if (id == -2) { // DONE, so quit. - done(); - } - hoc_ac_ = double(id); - int style = info[1]; - if (style == 0) { // hoc statement form - int size; - nrnmpi_int_broadcast(&size, 1, 0); // includes terminator - char* s = new char[size]; - nrnmpi_char_broadcast(s, size, 0); - hoc_obj_run(s, nullptr); - delete[] s; - // printf("%d leave subworld_worker_execute\n", nrnmpi_myid_world); - return; - } - int i, j; - int npickle; - char* s; - Symbol* fname = 0; - Object* ob = nullptr; - char* sarg[20]; // up to 20 arguments may be strings - int ns = 0; // number of args that are strings - int narg = 0; // total number of args - - if (style == 3) { // python callable - nrnmpi_int_broadcast(&npickle, 1, 0); - s = new char[npickle]; - nrnmpi_char_broadcast(s, npickle, 0); - } else if (style == 1) { // hoc function - int size; - nrnmpi_int_broadcast(&size, 1, 0); // includes terminator - // printf("%d subworld hoc function string size = %d\n", nrnmpi_myid_world, size); - s = new char[size]; - nrnmpi_char_broadcast(s, size, 0); - fname = hoc_lookup(s); - if (!fname) { - return; - } // error raised by sender - } else { - return; // no others implemented, error raised by sender - } - - // now get the args - int argtypes; - nrnmpi_int_broadcast(&argtypes, 1, 0); - // printf("%d subworld argtypes = %d\n", nrnmpi_myid_world, argtypes); - for (j = argtypes; (i = j % 5) != 0; j /= 5) { - ++narg; - if (i == 1) { // double - double x; - nrnmpi_dbl_broadcast(&x, 1, 0); - // printf("%d subworld scalar = %g\n", nrnmpi_myid_world, x); - hoc_pushx(x); - } else if (i == 2) { // string - int size; - nrnmpi_int_broadcast(&size, 1, 0); - sarg[ns] = new char[size]; - nrnmpi_char_broadcast(sarg[ns], size, 0); - hoc_pushstr(sarg + ns); - ns++; - } else if (i == 3) { // Vector - int n; - nrnmpi_int_broadcast(&n, 1, 0); - Vect* vec = new Vect(n); - nrnmpi_dbl_broadcast(vec->data(), n, 0); - hoc_pushobj(vec->temp_objvar()); - } else { // PythonObject - int n; - nrnmpi_int_broadcast(&n, 1, 0); - char* s; - s = new char[n]; - nrnmpi_char_broadcast(s, n, 0); - Object* po = neuron::python::methods.pickle2po(s, size_t(n)); - delete[] s; - hoc_pushobj(hoc_temp_objptr(po)); - } - } - - if (style == 3) { - size_t size; - char* rs = neuron::python::methods.call_picklef(s, size_t(npickle), narg, &size); - assert(rs); - delete[] rs; - } else { - // printf("%d subworld hoc call %s narg=%d\n", nrnmpi_myid_world, fname->name, narg); - hoc_call_objfunc(fname, narg, ob); - // printf("%d subworld return from hoc call %s\n", nrnmpi_myid_world, fname->name); - } - delete[] s; - for (i = 0; i < ns; ++i) { - delete[] sarg[i]; - } -}