Skip to content

Commit

Permalink
Initial commit of NeuroBayes C++ Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskeck committed Nov 3, 2016
1 parent 92690d4 commit 95bed26
Show file tree
Hide file tree
Showing 17 changed files with 7,515 additions and 0 deletions.
83 changes: 83 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required (VERSION 2.8.7)

set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)

project (NeuroBayes)
enable_language (Fortran)

if(DEFINED ENV{MAXNODE_PREPRO})
set(MAXNODE_PREPRO $ENV{MAXNODE_PREPRO})
else()
set(MAXNODE_PREPRO 100)
endif()

set(CMAKE_Fortran_FLAGS " -fno-automatic -fcheck=bound -Wno-unused -cpp ")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=c++0x -Wall -Wextra")

configure_file (
"${PROJECT_SOURCE_DIR}/cpp_interface/nb_param.hh.in"
"${PROJECT_SOURCE_DIR}/cpp_interface/nb_param.hh"
)

add_library(NeuroBayesCore_shared SHARED IMPORTED)
set_target_properties(NeuroBayesCore_shared PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/core/libNeuroBayesCore_shared.so")

set(NeuroBayesCPPInterface_HEADERS
"${PROJECT_SOURCE_DIR}/cpp_interface/nb_cpp_utils.h"
"${PROJECT_SOURCE_DIR}/cpp_interface/NeuroBayesExpert.hh"
"${PROJECT_SOURCE_DIR}/cpp_interface/NeuroBayesTeacher.hh"
"${PROJECT_SOURCE_DIR}/cpp_interface/nb_param.hh"
"${PROJECT_SOURCE_DIR}/cpp_interface/nb_c_utils.h"
)

set(NeuroBayesCPPInterface_SOURCES
"${PROJECT_SOURCE_DIR}/cpp_interface/NeuroBayesExpert.cc"
"${PROJECT_SOURCE_DIR}/cpp_interface/NeuroBayesTeacher.cc"
"${PROJECT_SOURCE_DIR}/cpp_interface/nb_cpp_utils.cc"
)

add_library(NeuroBayesCPPInterface_shared SHARED ${NeuroBayesCPPInterface_SOURCES} ${NeuroBayesCPPInterface_HEADERS})
target_link_libraries(NeuroBayesCPPInterface_shared NeuroBayesCore_shared)

include_directories("${PROJECT_SOURCE_DIR}/cpp_interface/")

add_executable(crosstest "${PROJECT_SOURCE_DIR}/cpp_interface_tests/crosstest.cc")
target_link_libraries(crosstest NeuroBayesCPPInterface_shared)

add_executable(interfacetest "${PROJECT_SOURCE_DIR}/cpp_interface_tests/interfacetest.cc" ${NeuroBayesCPPInterface_HEADERS})
target_link_libraries(interfacetest NeuroBayesCPPInterface_shared)

add_executable(minimaltest "${PROJECT_SOURCE_DIR}/cpp_interface_tests/minimaltest.cc" ${NeuroBayesCPPInterface_HEADERS})
target_link_libraries(minimaltest NeuroBayesCPPInterface_shared)


install(TARGETS NeuroBayesCPPInterface_shared minimaltest
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

get_target_property(NeuroBayesCore_LOCATION NeuroBayesCore_shared LOCATION)
install(FILES ${NeuroBayesCore_LOCATION} DESTINATION lib)
install(FILES ${NeuroBayesCPPInterface_HEADERS} DESTINATION include)

set(CPACK_PACKAGE_VERSION 4.3)
set(CPACK_GENERATOR "RPM;DEB;TGZ")
set(CPACK_PACKAGE_NAME "NeuroBayes")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_VENDOR "Blue Yonder")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/neurobayes.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/neurobayes.spec" @ONLY IMMEDIATE)
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/neurobayes.spec")

SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})


include(CPack)
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# NeuroBayes C++ Interface

Interface to NeuroBayes(R) for academic purpose

The NeuroBayes package is available under the NeuroBayes license from Blue Yonder GmbH.
Please contact [email protected] for general information and for information about the license.

This repository provides the C++ Interface of the NeuroBayes package. You can only build this project if you
obtained the NeuroBayes licence and NeuroBayes Core library from Blue Yonder GmbH.

The NeuroBayes C++ Interface is usually already shipped with the NeuroBayes package.
The NeuroBayes Core library does only depenend on a very small set of system libraries like libc and libgfortran,
on the other hand the NeuroBayes C++ Interface depends on libstdc++.
It may be necessary to recompile the C++ Interface in the future to support new platforms,
hence Blue Yonder GmbH decided to release the source code of the C++ Interface under the MIT licence for the convinience
of the NeuroBayes user community (in particular for high energy physics experiments).


# Build process and installation
* Extract the NeuroBayes Core shared library named libNeuroBayesCore\_shared.so from the package you obtained from Blue Yonder GmbH and copy it into the previously empty directory core.
* cd build/
* cmake ../
* make


## Building rpm, deb or tgz packages
Optionally you can build rpm, deb and tgz packages using
* make package
Additional third-party libraries are required to do so.


## Maxnode
The NeuroBayes Core library is optimized for a maximum number of nodes.
The maximum number of nodes is printed by the NeuroBayes Teacher
at the start of the program e.g. execute the minimaltest executable and search for NB\_MAXNODE.
The default number is 100. If your library is optimized for a different number of nodes,
you have to provide the correct number using an environment variable named MAXNODE\_PREPRO.
during the build process e.g. MAXNODE\_PREPRO=200 cmake ../


## Tests
To verify the correctness of your executable, you can execute the following test suits:
* cd build
* ./minimaltest
* ./interfacetest

The minimaltest provides also a minimal example to get you started.
Loading

0 comments on commit 95bed26

Please sign in to comment.