Skip to content

Commit

Permalink
Update Tips on NEST.md
Browse files Browse the repository at this point in the history
  • Loading branch information
saq10002 committed Jan 23, 2015
1 parent 9c704e7 commit b83bbcd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Tips on NEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ You can now build and install NEST with
make install
make installcheck
```
It is important to check that the NEST is going to be installed in the location we want (in our virtual environment), and that it has detected MPI, OpenMP, Python and GSL. If something is wrong/missing, NEST will tell you and you should fix these before you proceed.
* It is important to check that the NEST is going to be installed in the location we want (in our virtual environment), and that it has detected MPI, OpenMP, Python and GSL. If something is wrong/missing, NEST will tell you and you should fix these before you proceed.
* Now we are ready to build (```make```) NEST from source. In the shell, just write ```make```, and hope that everything will be fine. If there are no error messages, you have successfully built NEST from source. The binaries (executables and libraries) are still inside the ```build``` directory.
* In the shell, type ```make install```. The executables/libraries will now be copied to the ```prefix``` directory we specified during running the ```configure``` script.
* You can now type ```nest``` and if everything was alright, you should see the following prompt:
Expand Down Expand Up @@ -170,10 +170,14 @@ AM_CPPFLAGS= -I$(top_srcdir)/libnestutil\
```
* Suppose you want to use your code from any part of the original NEST code. In my case, I wanted to call ```GpuDataAdapter::init()``` from within the function ```neststartup()``` in the file ```nest/nest-2.6.0/nest/neststartup.cpp```. For this, inside the ```cpp``` file, I added ```#include "gpudataadapter.h"``` and inside the definition of the function ```neststartup()```, I added ```nest::gpu::GpuDataAdapter::init();```.
* Editing the existing source code was easy. However, how does the compiler/linker know where to find the declaration/definition of the code for the ```GpuDataAdapter::init()``` function? This is the hard part. For this, I had to modify the ```nest/nest-2.6.0/nest/Makefile.am``` file as follows: I added ```nestgpu/libnestgpu.la``` to the existing definition of the variables ```nest_LDADD``` and ```nest_DEPENDENCIES``` so that the linker knows where to find the definition of my new functions. I also added ```-I$(top_srcdir)/nestgpu``` to the existing value of the variable ```AM_CPPFLAGS``` so that the compiler knows where to look for the ```#include``` headers for my new code. However, it turned out that the module ```nest/nest-2.6.0/pynest``` also uses the file ```nest/nest-2.6.0/nest/neststartup.cpp``` and its header. Therefore, I had to specify the ```nest/nest-2.6.0/nestgpu``` directory as an include directory in the file ```nest/nest-2.6.0/pynest/Makefile.am``` as well. However, I did not need to specify the library ```libnestgpu``` because the library ```pynestkernel.la``` was already linked to the library ```libnest.la``` which was also already linked to my library ```libnestgpu.la```.
* Editing the existing source code was easy. However, how does the compiler/linker know where to find the declaration/definition of the code for the ```GpuDataAdapter::init()``` function? This is the hard part. For this, I had to modify the ```nest/nest-2.6.0/nest/Makefile.am``` file as follows:
* I added ```nestgpu/libnestgpu.la``` to the existing definition of the variables ```nest_LDADD``` and ```nest_DEPENDENCIES``` so that the linker knows where to find the definition of my new functions.
* I also added ```-I$(top_srcdir)/nestgpu``` to the existing value of the variable ```AM_CPPFLAGS``` so that the compiler knows where to look for the ```#include``` headers for my new code.
* However, it turned out that the module ```nest/nest-2.6.0/pynest``` also uses the file ```nest/nest-2.6.0/nest/neststartup.cpp``` and its header. Therefore, I had to specify the ```nest/nest-2.6.0/nestgpu``` directory as an include directory in the file ```nest/nest-2.6.0/pynest/Makefile.am``` as well. However, I did not need to specify the library ```libnestgpu``` because the library ```pynestkernel.la``` was already linked to the library ```libnest.la``` which was also already linked to my library ```libnestgpu.la```.

* Next, you should tell the NEST build system to actually visit this subdirectory and build your code. For this, you have to edit the ```nest/nest-2.6.0/configure.ac.in```. In particular, you need to edit two things:
[x] You have to specify that you have a new source directory. You do this by editing the existing value of the variable ```SLI_CORE_LIBS``` and adding the word ```nestgpu``` in its existing list of directories.
[x] You have to specify that you have a new ```Makefile``` to be created by the configure script. You do this by adding the following line: ```AC_CONFIG_FILES(nestgpu/Makefile)``` after the list of existing Makefiles. (Just search for the text ```AC_CONFIG_FILES```) inside the file ```configure.ac.in```.)
* You have to specify that you have a new source directory. You do this by editing the existing value of the variable ```SLI_CORE_LIBS``` and adding the word ```nestgpu``` in its existing list of directories.
* You have to specify that you have a new ```Makefile``` to be created by the configure script. You do this by adding the following line: ```AC_CONFIG_FILES(nestgpu/Makefile)``` after the list of existing Makefiles. (Just search for the text ```AC_CONFIG_FILES```) inside the file ```configure.ac.in```.)
* Now that we have specified that we have new code, we need to rebuild the system, by generating a new ```configure``` script using our recently modified ```configure.ac.in``` file. To do this, just run the script ```nest/nest-2.6.0/bootstrap.sh``` which would generate a new ```configure``` script.
* Then, reconfigure NEST by typing ``` cd /home/saad/nest/build && ../nest-2.6.0/configure ../nest-2.6.0/configure --prefix=/home/saad/venv/nest-dbg --with-mpi --with-openmp --with-debug --with-optimize=-O0```.
* Then, build NEST by running ```make``` and ```make install```.
Expand Down

0 comments on commit b83bbcd

Please sign in to comment.