Comments (11)
See also #213.
from nest-simulator.
With #213, modules can be build statically, dynamically or as plug-in ( Install
mechanism) - also on BlueGene. But you still get an error, when the module is linked dynamically and you load it again with an Install
.
I have not tried it yet, but there is a possibility, to have cmake
build sub-cmake-projects just by adding it as a subdirectory (here).
from nest-simulator.
@jougs @heplesser @apeyser
Dynamic loading of external user modules is the only reason NEST depends on libltdl
. This leads to inconveniences, if the library is not present by default, e.g. on JUQUEEN, see this comment in #390. Further dynamic loading increases the code / project complexity:
- The
DynamicLoaderModule
is responsible for locating, loading and maintaining the modules. - The script
extras/nest-config.in
must be filled correctly with compiler information, flags, include directories, linked libraries, s.t. the user module builds correctly. - The user module has to initialize correctly. It can be build dynamically or statically. If build dynamically, it can be loaded dynamically by
Install()
or linked directly into NEST. If build statically, it must be linked directly into nest. The initialisation is different in every case:- Dynamic / Install()
MyModule
has to create a global instance namedmymodule_LTX_mod
. Thelibltdl
will look for this instance in a dynamic loaded module when callingInstall('mymodule')
. Then theDynamicLoaderModule
will callinit()
in this instance and the module is loaded. - Dynamic / direct
MyModule
has to create a global instance. In the constructor it registers itself with theDynamicLoaderModule
. Inneststartup()
theDynamicLoaderModule
initializes all registered modules withinitLinkedModules()
. - Static
cmake
generates a filestatic_modules.h
withcmake/WriteStaticModules_h.cmake
. This file contains the functionadd_static_modules()
, which is called inneststartup()
. In the function each static module (along with the basic modules of NEST, i.e.models
,precise
,topology
andconngen
) is added to the sli engine and thus initialized. In this case no global instance of the module is necessary (and might be harmful, if state is shared among instances of the same module).
- Dynamic / Install()
Also linking a user module directly into NEST requires to build NEST alone, so that nest-config
is build correctly, required link libraries are available and the install directory is laid out. Then the module can be build and installed (into <prefix>/lib/nest
). Finally, NEST has to be reconfigured, adding -Dexternal-modules=my
to the cmake line, build and installed.
Possible solutions to simplify the situation (of which I can think of):
- Only allowing direct linking (static or dynamic) is not desirable, as one still has to compile NEST twice. This anyway was more a 'emergency solution' to enable user modules for environments that only allow static compilation, e.g. earlier BlueGene systems (please correct me if I am wrong).
- Only allow the Dynamic / Install() strategy: This would simplify the
DynamicLoaderModule
(no registered modules),MyModule
(has to build only as dynamic module),cmake/WriteStaticModules_h.cmake
does not have to consider external modules and users do not have to compile NEST twice. Butnest-config
is still required and NEST still has the dependency withlibltdl
if user modules are used. - Rewrite the user module system to use
cmake
'sadd_subdirectory()
functionality. An example for this is theconngen
module:-
For a new module create a new folder inside of NEST's sources, e.g.
mkdir mymodule
. -
Create a simple
CMakeLists.txt
similar toconngen
's, which only defines the sources the library target, the linking, includes and install instructions. -
Write the module code and the new models, functions, etc inside this folder.
-
In the main
CMakeLists.txt
file have a section that conditionally adds subdirectories that are defined on thecmake
line, e.g.:... -Dexternal-modules=mymodule ...
foreach ( mod ${external-modules} ) add_subdirectory( "$mod" ) endforeach()
-
In
nest/CMakeLists.txt
add the library target of the external module to the calltarget_link_libraries( nest ... )
andtarget_link_libraries( nest_lib ... )
.
The initialization can also be reduced to one strategy: either by dropping theDynamicLoaderModule
registration (and removing the loader completely) and only rely onstatic_modules.h
, or remove thestatic_modules.h
creation and register all modules (also NEST's defaults) with theDynamicLoaderModule
. (Looking at #271 it would also be possible to have two loaders: one for NEST only modules with no link to theSLIInterpreter
and one for SLI modules that register new functions and dictionaries or names with theSLIInterpreter
.) This approach removes the dependancy withlibltdl
completely, makesnest-config
obsolete, reduces the initialization strategies to only one and reduces the overall complexity. The downside is that one has to have access to the sources, which might be difficult if NEST is emploied in prebuild binaries, e.g. as homebrew or APT packages.
-
from nest-simulator.
@tammoippen Thank you for the analysis! I think the next step should be an in-depth analysis of possible use cases (extending your very last remarks above), before we decide on a solution.
from nest-simulator.
@tammoippen 3 is just another way to do 1?
from nest-simulator.
Would 2 still link the standard modules that come with NEST statically? If yes, I like that most.
from nest-simulator.
@apeyser Yes, except that you do not have to compile twice and do not have to hassle with nest-config
.
@jougs Yes, the standard modules will be linked directly (if static or dynamic depends on whether you build NEST statically or dynamically).
from nest-simulator.
@apeyser, @heplesser, @jougs - what needs to happen for this issue to be closed?
from nest-simulator.
I believe we'd have to come to a decision on what dynamic module capabilities to offer re: tammo's analysis, and then actually do it.
I'm not sure who's offering the programmer time for this, now that Tammo is gone.
from nest-simulator.
@abigailm @apeyser I'll take responsibility for this one.
from nest-simulator.
Closing this one as the issue has not been pressing for the last two years.
from nest-simulator.
Related Issues (20)
- Create technical documentation for FULL_LOGGING_ONLY() approach HOT 1
- devdoc and userdoc options not documented in cmake_options.rst
- Update README
- Add `readthedocs/actions/preview` to GHA for doc build status checks and PR previews
- Images from Sudoku and Pong examples do not render properly
- Header files not included in apt package HOT 2
- Iterating on an empty `SynapseCollection` raises `TypeError: 'NoneType' object is not iterable` HOT 1
- CI cmake configures NEST builds without readline HOT 2
- Threading docs `OMP_PLACES` unclear or wrong HOT 1
- Improve search results on Read the Docs
- macOS conda installation has missing random generators HOT 12
- Superfluous clearing of containers HOT 3
- failing spack build of [email protected] (current "ebrains version") without mpi HOT 5
- Use C++11 current_exception/rethrow_exception for exception handling in thread-parallel context HOT 2
- MAC INSTALLATION HOT 1
- Assert adds barrier HOT 2
- The reset of after-spike currents in GLIF model does not seem to conform with the original equations HOT 3
- Recording more detailed memory consumption metrics
- Xcode instructions are outdated HOT 1
- Build fails using OpenMPI 5.0.0 and MUSIC 1.2.1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nest-simulator.