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

Move codebase to CPP #763

Merged
merged 39 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
864f44a
modern cpp
alexsavulescu Oct 6, 2020
8e871a0
autotools cpp update
alexsavulescu Oct 12, 2020
2597d50
windows cpp update
alexsavulescu Oct 16, 2020
a5d30c1
fix after dynamic units rebase
alexsavulescu Oct 22, 2020
adca6dc
Revert accidental changed to hh.mod
pramodk Oct 28, 2020
5bfa3cc
CR
alexsavulescu Oct 29, 2020
9394877
fix segfault + more extern "C"
alexsavulescu Nov 9, 2020
b4e11ec
more CR
alexsavulescu Nov 9, 2020
343cb07
fix modlunit
alexsavulescu Nov 10, 2020
343833e
Merge branch 'master' into cpp
alexsavulescu Nov 12, 2020
5f2a44a
Merge branch 'master' into cpp
alexsavulescu Nov 16, 2020
13a2074
Merge remote-tracking branch 'origin/master' into cpp
alexsavulescu Dec 1, 2020
c81808b
Merge branch 'master' into cpp
alexsavulescu Dec 8, 2020
2d1abf4
Merge branch 'master' into cpp
alexsavulescu Dec 10, 2020
d242408
Merge branch 'master' into cpp
alexsavulescu Dec 12, 2020
1485644
Merge branch 'master' into cpp
alexsavulescu Dec 14, 2020
1994cab
Merge remote-tracking branch 'origin/master' into cpp
alexsavulescu Jan 4, 2021
c12ad44
Merge branch 'master' into cpp
alexsavulescu Jan 5, 2021
884f726
Merge branch 'master' into cpp
alexsavulescu Jan 9, 2021
3e9df0e
Merge branch 'master' into cpp
alexsavulescu Jan 10, 2021
cc31d24
Merge branch 'master' into cpp
alexsavulescu Jan 11, 2021
4cf6f88
Merge branch 'master' into cpp
alexsavulescu Jan 12, 2021
65eefa7
Merge branch 'master' into cpp
alexsavulescu Jan 13, 2021
e1475f3
Merge branch 'master' into cpp
alexsavulescu Jan 16, 2021
df1b623
Merge branch 'master' into cpp
alexsavulescu Jan 21, 2021
b936e6f
hocusr.h accidentally committed
alexsavulescu Jan 21, 2021
3021da3
Merge branch 'master' into cpp
alexsavulescu Jan 22, 2021
f57d31f
Merge branch 'master' into cpp
alexsavulescu Jan 24, 2021
865a15f
init.cpp TODO - nrn_threads_create single thread
alexsavulescu Jan 30, 2021
4186296
Merge branch 'master' into cpp
alexsavulescu Feb 1, 2021
dc62f2f
rollback CR requested change - #951
alexsavulescu Feb 2, 2021
85b2827
Merge branch 'master' into cpp
alexsavulescu Feb 2, 2021
68e28a7
CR: no ignore flags for other compilers
alexsavulescu Feb 2, 2021
cb593f9
CR updates
alexsavulescu Feb 3, 2021
129d903
Merge branch 'master' into cpp
alexsavulescu Feb 3, 2021
e7a16fc
CR - one last Windows thingy
alexsavulescu Feb 3, 2021
a1966e2
ignore warnings for Clang compilers
alexsavulescu Feb 3, 2021
e717d1e
rxd: nrn_shape_update must be extern "C" now
alexsavulescu Feb 3, 2021
b326017
Merge branch 'master' into cpp
alexsavulescu Feb 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 23 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,38 @@
nmodlconf.h.in
nrnconf.h.in
build
.DS_Store
.eggs/
.idea/
CMakeFiles/
Makefile
Makefile.in
.deps
x86_64
__pycache__
venv
virtualenv
*.o
*.lo
alexsavulescu marked this conversation as resolved.
Show resolved Hide resolved

# These files are generated at build time
# It would be a good idea to create them in the
# build directory in the future.
src/modlunit/lex.c
src/modlunit/parse1.c
src/modlunit/parse1.h
src/nmodl/diffeq.c
src/modlunit/lex.cpp
src/modlunit/parse1.cpp
src/modlunit/parse1.hpp
src/nmodl/diffeq.cpp
src/nmodl/diffeq.h
src/nmodl/lex.c
src/nmodl/parse1.c
src/nmodl/parse1.h
src/nmodl/lex.cpp
src/nmodl/parse1.cpp
src/nmodl/parse1.hpp
src/nrnoc/apcount.c
src/nrnoc/exp2syn.c
src/nrnoc/expsyn.c
src/nrnoc/feature.c
src/nrnoc/hh.c
src/nrnoc/hh.mod.orig
src/nrnoc/hocusr.h
src/nrnoc/intfire1.c
src/nrnoc/intfire2.c
src/nrnoc/intfire4.c
Expand All @@ -35,5 +49,5 @@ src/nrnoc/stim.c
src/nrnoc/svclmp.c
src/nrnoc/syn.c
src/nrnoc/vclmp.c
src/oc/parse.c
src/oc/parse.h
src/oc/parse.cpp
src/oc/parse.hpp
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ if(NRN_ENABLE_MPI)
find_package(MPI REQUIRED)
set(NRNMPI 1)
set(PARANEURON 1)
# avoid linking to C++ bindings
add_definitions("-DMPI_NO_CPPBIND=1")
add_definitions("-DOMPI_SKIP_MPICXX=1")
add_definitions("-DMPICH_SKIP_MPICXX=1")
else()
set(NRNMPI 0)
set(PARANEURON 0)
Expand Down Expand Up @@ -370,7 +374,7 @@ if(READLINE_FOUND)
# this part has to be prior to adding the nrniv subdirectory.
execute_process(COMMAND grep -q rl_event_hook ${Readline_LIBRARY} RESULT_VARIABLE result)
if(NOT result EQUAL 0)
# define for src/oc/hoc.c
# define for src/oc/hoc.cpp
set(DEF_RL_GETC_FUNCTION use_rl_getc_function)
endif()
find_package(Curses QUIET)
Expand Down
2 changes: 1 addition & 1 deletion bin/nrniv_makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ NRNIVOBJS = $(libobjdir)/nrnmain.o $(libobjdir)/ivocmain.o $(libobjdir)/nvkludge
$(bindir)/nocmodl $*
$(COMPILE) -c $*.c

mod_func.o: mod_func.c
mod_func.o: mod_func.cpp
$(COMPILE) -c $<

special: $(MODOBJFILES) $(COBJFILES) mod_func.o
Expand Down
22 changes: 15 additions & 7 deletions bin/nrnivmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -244,31 +244,39 @@ echo '#include <stdio.h>
#include "hocdec.h"
extern int nrnmpi_myid;
extern int nrn_nobanner_;
' > mod_func.c
#if defined(__cplusplus)
extern "C" {
#endif
' > mod_func.cpp
for i in $base_names ; do
echo 'extern void _'$i'_reg(void);'
done >> mod_func.c
done >> mod_func.cpp
echo '
void modl_reg(){
if (!nrn_nobanner_) if (nrnmpi_myid < 1) {
fprintf(stderr, "Additional mechanisms from files'$newline'");
' >> mod_func.c
' >> mod_func.cpp

for i in $files
do
echo ' fprintf(stderr," \"'`unhide_spaces "$i"`'.mod\"");'
done >>mod_func.c
done >>mod_func.cpp

echo ' fprintf(stderr, "'$newline'");
}' >>mod_func.c
}' >>mod_func.cpp

for i in $base_names; do
echo ' _'$i'_reg();'
@USING_CMAKE_TRUE@MODOBJS="$MODOBJS ./$i.o"
@USING_CMAKE_FALSE@MODOBJS="$MODOBJS $i.o"
done >> mod_func.c
done >> mod_func.cpp

echo "}" >> mod_func.c
echo "}" >> mod_func.cpp

echo '
#if defined(__cplusplus)
}
#endif' >> mod_func.cpp

if test -n "$nrnivmodl_cfiles" ; then
if test "$UsingCMake" = "yes" ; then
Expand Down
4 changes: 2 additions & 2 deletions bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod_objs = $(MODOBJFILES)
c_objs = $(COBJFILES)

mod_func_o = $(OBJS_DIR)/mod_func.o
mod_func_c = $(MODC_DIR)/mod_func.c
mod_func_cpp = $(MODC_DIR)/mod_func.cpp

special = $(OUTPUT)/special
LIB_SUFFIX_ = $(if $(MECH_NAME),_$(MECH_NAME),)
Expand Down Expand Up @@ -115,7 +115,7 @@ mech_lib_static: mod_func.o $(mod_objs) $(c_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) static library $(mech_lib)\n"
ar cq ${mech_lib} $(mod_func_o) $(mod_objs) $(cobjs);

mod_func.o: mod_func.c
mod_func.o: mod_func.cpp
@printf " -> $(C_GREEN)Compiling$(C_RESET) $<\n"
$(COMPILE) $(INCLUDES) @CMAKE_CXX_COMPILE_OPTIONS_PIC@ -c $< -o $@

Expand Down
4 changes: 2 additions & 2 deletions bin/nrnmech_makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ NRNIVOBJS = "$(libobjdir)/nrnmain.o" "$(libobjdir)/ivocmain.o" "$(libobjdir)/nvk
"$(bindir)/nocmodl" $*
$(LTCOMPILE) -c -o $@ $*.c

mod_func.lo: mod_func.c
$(LTCOMPILE) -c -o $@ $*.c
mod_func.lo: mod_func.cpp
$(LTCOMPILE) -c -o $@ $*.cpp

libnrnmech_la_OBJECTS = $(MODOBJFILES) mod_func.lo $(COBJFILES)
libnrnmech_la_LIBADD = $(NRNOCLIBS) $(NRNIVLIBS)
Expand Down
2 changes: 1 addition & 1 deletion bin/nrnoc_makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ NRNOCOBJS = $(libobjdir)/ocmain.o $(libobjdir)/nrnnoiv.o $(libobjdir)/ocnoiv.o
$(bindir)/nocmodl $*
$(COMPILE) -c $*.c

mod_func.o: mod_func.c
mod_func.o: mod_func.cpp
$(COMPILE) -c $<

special: $(MODOBJFILES) mod_func.o
Expand Down
18 changes: 13 additions & 5 deletions bin/nrnocmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,30 @@ fi

echo '#include <stdio.h>
#include "hocdec.h"
#if defined(__cplusplus)
extern "C"
#endif
modl_reg(){
NOT_PARALLEL_SUB(fprintf(stderr, "Additional mechanisms from files'$newline'");)
' > mod_func.c
' > mod_func.cpp

for i in $files
do
echo 'NOT_PARALLEL_SUB(fprintf(stderr," '$i'.mod");)' >>mod_func.c
echo 'NOT_PARALLEL_SUB(fprintf(stderr," '$i'.mod");)' >>mod_func.cpp
done
echo 'NOT_PARALLEL_SUB(fprintf(stderr, "'$newline'");)' >>mod_func.c
echo 'NOT_PARALLEL_SUB(fprintf(stderr, "'$newline'");)' >>mod_func.cpp

for i in $files
do
echo _"$i"_reg"();" >> mod_func.c
echo _"$i"_reg"();" >> mod_func.cpp
MODOBJS="$MODOBJS $i.o"
done
echo "}" >> mod_func.c
echo "}" >> mod_func.cpp

echo '
#if defined(__cplusplus)
}
#endif' >> mod_func.cpp

make -f $MAKEFILEDIR/nrnoc_makefile "MODOBJFILES=$MODOBJS" special &&
echo "Successfully created $MODSUBDIR/special"
5 changes: 5 additions & 0 deletions cmake/CompilerFlagsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
set(CMAKE_${COMPILER_LANGUAGE}_POSITION_INDEPENDENT "-fPIC")
set(CMAKE_${COMPILER_LANGUAGE}_VECTORIZE "-ftree-vectorize")
set(IGNORE_UNKNOWN_PRAGMA_FLAGS "-Wno-unknown-pragmas")
set(CMAKE_${COMPILER_LANGUAGE}_IGNORE_WARNINGS "-Wno-write-strings")

if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_VERSION VERSION_GREATER "4.7.0")
set(CMAKE_${COMPILER_LANGUAGE}_LINK_TIME_OPT "-flto")
Expand All @@ -87,6 +88,7 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
set(CMAKE_${COMPILER_LANGUAGE}_VECTORIZE "")
set(IGNORE_UNKNOWN_PRAGMA_FLAGS "-Wno-unknown-pragmas")
set(CMAKE_${COMPILER_LANGUAGE}_GEN_NATIVE "-march=native")
set(CMAKE_${COMPILER_LANGUAGE}_IGNORE_WARNINGS "-Wno-deprecated-register -Wno-writable-strings")
# rest of the world
else()
set(CMAKE_${COMPILER_LANGUAGE}_WARNING_ALL "-Wall")
Expand All @@ -100,5 +102,8 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "PGI")
set(CMAKE_${COMPILER_LANGUAGE}_WARNING_ALL "")
endif()
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID MATCHES "Clang|AppleClang")
set(CMAKE_${COMPILER_LANGUAGE}_IGNORE_WARNINGS "-Wno-deprecated-register -Wno-writable-strings")
endif()
pramodk marked this conversation as resolved.
Show resolved Hide resolved
endif()
endforeach()
18 changes: 9 additions & 9 deletions cmake/MacroHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ macro(nrn_check_dir_exists HEADER VARIABLE)
if(${HAVE_HEADER})
# if header is found, create a code from template
string(REPLACE "@dir_header@" ${HEADER} CONFTEST_DIR "${CONFTEST_DIR_TPL}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/conftest.c ${CONFTEST_DIR})
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/conftest.cpp ${CONFTEST_DIR})
# try to compile
try_compile(RESULT_VAR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/conftest.c)
try_compile(RESULT_VAR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/conftest.cpp)
if(${RESULT_VAR})
set(${VARIABLE} 1)
else()
set(${VARIABLE} 0)
endif()
file(REMOVE "conftest.c")
file(REMOVE "conftest.cpp")
endif()
endmacro()

Expand All @@ -59,13 +59,13 @@ macro(nrn_check_type_exists HEADER TYPE DEFAULT_TYPE VARIABLE)
}")
string(REPLACE "@header@" ${HEADER} CONFTEST_TYPE "${CONFTEST_TYPE_TPL}")
string(REPLACE "@type@" ${TYPE} CONFTEST_TYPE "${CONFTEST_TYPE}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/conftest.c ${CONFTEST_TYPE})
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/conftest.cpp ${CONFTEST_TYPE})

try_compile(RESULT_VAR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/conftest.c)
try_compile(RESULT_VAR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/conftest.cpp)
if(NOT ${RESULT_VAR})
set(${VARIABLE} ${DEFAULT_TYPE})
endif()
file(REMOVE "conftest.c")
file(REMOVE "conftest.cpp")
endmacro()

# =============================================================================
Expand All @@ -81,14 +81,14 @@ macro(nrn_check_signal_return_type VARIABLE)
int main () {
return *(signal (0, 0)) (0) == 1;
}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/conftest.c ${CONFTEST_RETSIGTYPE})
try_compile(RESULT_VAR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/conftest.c)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/conftest.cpp ${CONFTEST_RETSIGTYPE})
try_compile(RESULT_VAR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/conftest.cpp)
if(RESULT_VAR)
set(${VARIABLE} int)
else()
set(${VARIABLE} void)
endif()
file(REMOVE "conftest.c")
file(REMOVE "conftest.cpp")
endmacro()

# =============================================================================
Expand Down
Loading