Skip to content

Commit

Permalink
[WOLF] Initialiaze NerlWolf Cmake and Folders
Browse files Browse the repository at this point in the history
  • Loading branch information
leondavi authored and leondavi committed Sep 22, 2023
1 parent 5bf9f04 commit ced17d5
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 10 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -latomic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -latomic")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

#add_compile_definitions(EIGEN_MAX_ALIGN_BYTES=8) #Open this line for RASPI

# Options
option(NERLWOLF "Use Wolfram Engine workers extension" OFF)
option(USE_OpenMP "Use-OpenMP" ON)

#add_compile_definitions(EIGEN_MAX_ALIGN_BYTES=8) #Open this line for RASPI
if(USE_OpenMP)
find_package(OpenMP)
if(OPENMP_FOUND)
Expand All @@ -30,5 +32,10 @@ endif()
###########################
add_subdirectory(src_cpp) # actually adding opennnBridge

add_library(${PROJECT_NAME} SHARED $<TARGET_OBJECTS:opennnBridge>)
target_link_libraries(${PROJECT_NAME} PUBLIC opennnBridge)
add_library(nerlnet_onn SHARED $<TARGET_OBJECTS:opennnBridge>)
target_link_libraries(nerlnet_onn PUBLIC opennnBridge)

if (NERLWOLF)
add_library(nerlnet_wolf SHARED $<TARGET_OBJECTS:wolframBridge>)
target_link_libraries(nerlnet_wolf PUBLIC wolframBridge)
endif()
21 changes: 17 additions & 4 deletions NerlnetBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

NERLNET_PREFIX="[NERLNET_SCRIPT]"
INPUT_DATA_DIR="inputDataDir"
SHORT_OPTIONS_LIST=p:,j:,c:,h
LONG_OPTIONS_LIST=pull:,jobs:,clean:,help

# arguments parsing
# Thanks to https://github.com/matejak/argbash
Branch="master"
JobsNum=4
NerlWolf=OFF

help()
{
echo "-------------------------------------" && echo "Nerlnet Build" && echo "-------------------------------------"
echo "Usage:"
echo "--p or --pull Warning! this uses checkout -f! and branch name checkout to branch $Branch and pull the latest"
echo "--j or --jobs number of jobs to cmake build"
echo "--w or --wolf wolfram engine workers extension (nerlwolf)"
echo "--j or --jobs number of jobs to cmake build"
echo "--c or --clean remove build directory"
exit 2
}
Expand Down Expand Up @@ -63,6 +63,8 @@ print_help()
printf 'Usage: %s [-h|--help] [-c|--clean] [-j|--jobs <arg>] [-p|--pull <arg>]\n' "$0"
printf '\t%s\n' "-j, --jobs: number of jobs (default: '4')"
printf '\t%s\n' "-p, --pull: pull from branch (default: '4')"
printf '\t%s\n' "-w, --wolf: wolfram engine extension build (default: 'off')"

}


Expand All @@ -88,6 +90,17 @@ parse_commandline()
clean_build_directory
exit 0
;;
-w|--wolf)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
NerlWolf="$2"
shift
;;
--wolf=*)
NerlWolf="${_key##--jobs=}"
;;
-w*)
NerlWolf="${_key##-j}"
;;
-j|--jobs)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
JobsNum="$2"
Expand Down Expand Up @@ -140,7 +153,7 @@ fi
echo "$NERLNET_BUILD_PREFIX Building Nerlnet Library"
echo "$NERLNET_BUILD_PREFIX Cmake command of Nerlnet NIFPP"
set -e
cmake -S . -B build/release -DCMAKE_BUILD_TYPE=RELEASE
cmake -S . -B build/release -DNERLWOLF=$NerlWolf -DCMAKE_BUILD_TYPE=RELEASE
cd build/release
echo "$NERLNET_BUILD_PREFIX Script CWD: $PWD"
echo "$NERLNET_BUILD_PREFIX Build Nerlnet"
Expand Down
6 changes: 5 additions & 1 deletion src_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
project(src_cpp)

add_subdirectory(opennnBridge)
add_library(${PROJECT_NAME} SHARED $<TARGET_OBJECTS:opennnBridge>)

if(NERLWOLF)
message("[NERLNET] Wolfram Engine nif extension is enabled")
add_subdirectory(wolframBridge)
endif()
33 changes: 33 additions & 0 deletions src_cpp/wolframBridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#****************************************************
# Authors: David Leon
# 16/9/2023
#
# @copyright Copyright (c) 2023 Nerlnet
# *****************************************************/

project(wolframBridge)

set(SIMPLE_LOGGER_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../simple-cpp-logger/include")
set(NIFPP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../nifpp/")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "-fpic")
set(ERL_NIF_DEFAULT_LOCATION "/usr/local/lib/erlang/usr/include")

# cpp Simple logger options
add_definitions( -D LOGGER_MAX_LOG_LEVEL_PRINTED=6 )
add_definitions( -D LOGGER_PREFIX_LEVEL=2 )
add_definitions( -D LOGGER_ENABLE_COLORS=1 )
add_definitions( -D LOGGER_ENABLE_COLORS_ON_USER_HEADER=0 )


set(SRC_CODE
"start.cpp")

add_library(${PROJECT_NAME} SHARED ${SRC_CODE})
#target_link_libraries(${PROJECT_NAME} PUBLIC)

# Include NIF, OpenNN and Simple Cpp Logger
target_include_directories(${PROJECT_NAME} PUBLIC
${NIFPP_PATH}
${SIMPLE_LOGGER_PATH}
${ERL_NIF_DEFAULT_LOCATION})
8 changes: 8 additions & 0 deletions src_cpp/wolframBridge/start.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include "nifpp.h"
// Starting point for wolframBridge

int start()
{
return 0;
}
2 changes: 1 addition & 1 deletion src_erl/NerlnetApp/src/Bridge/nerlTensor.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-define(TRAIN_TIMEOUT,20000). % 20 seconds limit for prediction results

%% nerlNIF defines
-define(NERLNET_LIB,"libnerlnet").
-define(NERLNET_LIB,"libnerlnet_onn").
-define(NERLNET_PATH,"/usr/local/lib/nerlnet-lib/NErlNet").
-define(BUILD_TYPE_DEBUG,"debug").
-define(BUILD_TYPE_RELEASE,"/build/release").
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-module(wolfworkerGeneric).

-include("wolfworkerDefinitions.hrl").

0 comments on commit ced17d5

Please sign in to comment.