Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Fixing nrnivmodl-core: Avoid redefined symbols + script startup fixes #133

Merged
merged 24 commits into from
Feb 26, 2019

Conversation

ferdonline
Copy link
Contributor

@ferdonline ferdonline commented Feb 18, 2019

Fixes to nrnivmodl-core and required changes in the build of coreneuron

Current implementation of nrnivmodl-core suffers from a complex problem, redefinition of some symbols which depend on the mechanism set: modl_reg() and those defined in dimplic.cpp

This PR fixes that problem (and other little ones) from the root which required changes in the organization of coreneuron libraries and executables.

Short summary:

  • libcoreneuron shall be a "kernel" lib, i.e. it shall not contain extra mechanisms and their dependencies, but "complete", i.e.: It contains the standard mechanisms and everything (no undefined symbols) to be able to run on standard simulations.
    • modl_reg() call was accordingly moved out main1.cpp
    • scopmath_core package excluded from the libcoreneuron too
  • libcoreneuron's solve_core was split into mk_mech_init and run_solve_core
  • A new (coreneuron+mechanisms) lib exists (corenrnmech) for the previous purpose, which includes
    • mechanisms per se, modl_reg(). solve_core() (which calls modl_reg()) and full scopmath_core (+ dimplic.cpp)
    • links against libcoreneuron
  • coreneuron main therefore only has to do a bare solve_core() from corenrnmech lib (importing the new enginemech.h header)

When building mods with nrnivmodl-core the process is the same!
Note that in order to optionally build-up on previous mechanism, the ADDITIONAL mechamisms are exported as cpp files to share/mod2c and bundled together with the new mods cpp's.
See the diagram below.

@ferdonline ferdonline requested a review from pramodk February 18, 2019 15:53
@ferdonline ferdonline requested a review from nrnhines February 18, 2019 17:02
@ferdonline ferdonline force-pushed the nrnivmodl_core branch 2 times, most recently from 236719a to 3c6eaee Compare February 21, 2019 12:56
@ferdonline
Copy link
Contributor Author

Updated nrnivmodl-core diagram:

@ferdonline ferdonline changed the title Fixing nrnivmodl-core: dir creation, shbang, ;-I Fixing nrnivmodl-core: Avoid redefined symbols + script startup fixes Feb 21, 2019
@ferdonline
Copy link
Contributor Author

@pramodk I don't think we expected this much work :p but it was a nice challenge!
We might need to adapt some software though in case they link to the previous libcoreneuron and expect to have the extra machanisms included

# Disable new-dtags with newer linkers
############################################################

if (UNIX AND NOT APPLE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to avoid this workaround I think we could live with RUNPATH by setting it also in the shared libraries (apparently it allows that). Shall I experiment with that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

without that --disable-dtags option, the RUNPATH is populated correctly but still get library not found error. Didnt understand that quite well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be related to the fact that they are used a bit differently by the dynamic loader: See Bug #1253638 “dynamic linker does not use DT_RUNPATH for transitive dependencies
If I understood well, RUNPATH is only valid for direct dependencies, but sub-dependencies can also define RUNPATH which gets also checked. I kind of agree with the new behavior, but true, breaks things

@pramodk
Copy link
Collaborator

pramodk commented Feb 22, 2019

@pramodk I don't think we expected this much work :p but it was a nice challenge!

yeah....too much headache though! :)

@ferdonline
Copy link
Contributor Author

@pramod I linked using gold, checked it produces RUNPATH, but still it all works in bb5. Is it something specific to ubuntu?
I noticed that libcoreneuron is directly linked so it should indeed work.
To make the test, in the last commit I added rpath also to the lib (it seems RUNPATH supports that in libs) and removed your patch. Check if that also works with you, otherwise please discard that commit.

@@ -315,8 +312,8 @@ add_library(coreneuron ${COMPILE_LIBRARY_TYPE} ${coreneuron_all_headers} ${coren
${coreneuron_all_c_files} ${cudacorenrn_objs} ${MOD2C_STDMECH_OUTPUTS})
add_dependencies(coreneuron kinderiv)

target_link_libraries(coreneuron ${MPI_CXX_LIBRARIES}
${link_reportinglib} ${CUDA_LIBRARIES})
target_link_libraries(coreneuron ${MPI_CXX_LIBRARIES}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

${cudacorenrn_objs} doesnt exist now, right?

ferdonline and others added 16 commits February 26, 2019 21:19
No longer first-found functions in linking. We now strip scoptmath from
the core and link together with generated mods when creating
coreneuron_app or special-core
To avoid client applications to use three instructions every time they
need to run core neuron with mechanisms, we create an intermediate
library (corenrnmech, similar to the process of nrnivmodl-core) which
contains the extra mechanisms and a solve_core() launcher, besides all
dependent registration/hook routines (mod_func.cpp and dimplic.cpp)
Some newer systems use the gold linker which creates RUNPATH instead of
RPATH. This may be problematic as apparently it doesnt propagate the
RPATH to dependencies.
To mitigate the problem (without disabling new dtags) we:
 - Set libcoreneuron as a direct dependency
 - Set rpath on libcorenrnmech itself (LD should ignore, GOLD should
   take it) - This shouldnt be needed due to the previous measure, but
   it's actually a good practice.
ferdonline and others added 5 commits February 26, 2019 21:20
In mac $ORIGIN is called @loader_path. Therefore mac builds would only
work once installed. Fixed.
Second. To avoid having a superfluous RPATH, now we create a
nrnivmech_install.sh script which calls gnu make "install". It will
relink the executable setting the destination RPATH, and install the files
# The coreneuron lib (only internal mechanisms)
#
add_library(coreneuron ${COMPILE_LIBRARY_TYPE} ${coreneuron_all_headers} ${coreneuron_all_templates}
${coreneuron_all_c_files} ${cudacorenrn_objs} ${MOD2C_STDMECH_OUTPUTS})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
${coreneuron_all_c_files} ${cudacorenrn_objs} ${MOD2C_STDMECH_OUTPUTS})
${coreneuron_all_c_files} ${MOD2C_STDMECH_OUTPUTS})

@@ -68,7 +68,7 @@ struct ReportConfiguration {
double start; // start time of report
double stop; // stop time of report
int num_gids; // total number of gids
size_t buffer_size; // hint on buffer size used for this report
int buffer_size; // hint on buffer size used for this report
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
int buffer_size; // hint on buffer size used for this report
int buffer_size; // hint on buffer size used for this report

Copy link
Collaborator

@pramodk pramodk left a comment

Choose a reason for hiding this comment

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

@ferdonline : there is one little issue I faced with GPU build described in #141. But that seems unrelated to this PR and I will take of this next.

Looking cmake & nrnivmodl-core, it doesn't seem like clean workflow and lot to improve. But I will keep energy for v2 refactoring :)

@pramodk pramodk merged commit 8fa8c48 into master Feb 26, 2019
iomaganaris pushed a commit that referenced this pull request Mar 6, 2019
…#133)

* Fixing nrnivmodl-core: dir creation, shbang
* Remove unnecessary mkdir step, create core sub-directory under x86_64
* Avoiding duplicate symbols when using nrnivmodl-core
* Generating libcorenrnmech featuring solve_core()
* Create an intermediate library (corenrnmech, similar to the process of nrnivmodl-core) which
contains the extra mechanisms and a solve_core() launcher, besides all
dependent registration/hook routines (mod_func.cpp and dimplic.cpp)
* Recompile kinderiv dependencies
* Install libcudacoreneuron; link missing
* Set rpath on libcorenrnmech
* Fix for GPU. Simplified build and fixed link flag
* Fixing rpath Origin in Mac and added deploy script
* Remove Wall flags from default compilation
* Cleanup debug messages in GPU implementation
pramodk pushed a commit to neuronsimulator/nrn that referenced this pull request Nov 2, 2022
…BlueBrain/CoreNeuron#133)

* Fixing nrnivmodl-core: dir creation, shbang
* Remove unnecessary mkdir step, create core sub-directory under x86_64
* Avoiding duplicate symbols when using nrnivmodl-core
* Generating libcorenrnmech featuring solve_core()
* Create an intermediate library (corenrnmech, similar to the process of nrnivmodl-core) which
contains the extra mechanisms and a solve_core() launcher, besides all
dependent registration/hook routines (mod_func.cpp and dimplic.cpp)
* Recompile kinderiv dependencies
* Install libcudacoreneuron; link missing
* Set rpath on libcorenrnmech
* Fix for GPU. Simplified build and fixed link flag
* Fixing rpath Origin in Mac and added deploy script
* Remove Wall flags from default compilation
* Cleanup debug messages in GPU implementation

CoreNEURON Repo SHA: BlueBrain/CoreNeuron@8fa8c48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants