Skip to content

Latest commit

 

History

History
213 lines (183 loc) · 8.2 KB

README.org

File metadata and controls

213 lines (183 loc) · 8.2 KB

PRODA: PROcessing process DAta

GitHub Pages

Getting started…

Installation

How to use

In the project root folder, use cmake and then make to build the executable program main.

cmake .
make -j8
./main $num_chain $niter $nburn $thin parallel/serial

You can safely ignore anything after this line. These are for my own reference.

Building the Stan math library

First, you need to build Stan Math Library obtained from https://github.com/stan-dev/math. I am using develop commit fd1d8917ee5754810cfab4f7871760315e075135

The below is a shell script borrowed from https://github.com/stan-dev/math. It downloads and builds the Stan Math Library. You may want to change the target directory path/to/stan-math.

git clone https://github.com/stan-dev/math.git path/to/stan-math
make -f path/to/stan-math/make/standalone math-clean
make -j4 -f path/to/stan-math/make/standalone math-libs

The StanHeaders R package may be useful if you want to use the Stan Math Library in the Rcpp.

install.packages("StanHeaders")

For more inforamtion, please see https://cran.r-project.org/web/packages/StanHeaders/vignettes/stanmath.html I initialized an R package in an art directory using the STAN header.

CMake

The below is a CMake build script. You need to set MATH variable to indicate the Stan Math Library path (here, it is set to /Users/yunj/stan-dev/math). Then, save the script as CMakeLists.txt.

 cmake_minimum_required(VERSION 3.0)
 project(diprom)

 set(MATH /Users/yunj/stan-dev/math)
 set(PROJROOT .)
 set(Xcode_CLT /Library/Developer/CommandLineTools)

 # set(CMAKE_BUILD_TYPE Debug)
 set(CMAKE_CXX_FLAGS_DEBUG "-g")
 set(CMAKE_CXX_FLAGS_RELEASE "-O3") # remove this for debugging

 set(CMAKE_CXX_STANDARD 14) # txt2vec needs this

 # # STAN math lib
 include_directories(${MATH}/lib/tbb_2019_U8/include)
 include_directories(${MATH})
 include_directories(${MATH}/lib/eigen_3.3.7)
 include_directories(${MATH}/lib/boost_1.72.0)
 include_directories(${MATH}/lib/sundials_5.2.0/include)

 # xcode commandline toolchain
 include_directories(${Xcode_CLT}/usr/include/c++/v1)
 include_directories(${Xcode_CLT}/usr/lib/clang/11.0.0/include)
 include_directories(${Xcode_CLT}/usr/include)
 include_directories(${Xcode_CLT}/SDKs/MacOSX.sdk/usr/include)

 # set compiler
 # SET(CMAKE_CXX_COMPILER "/usr/bin/clang++")
 # SET(CMAKE_CC_COMPILER "/usr/bin/clnag")

 # c++ linker
 # SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -isystem/Library/Developer/CommandLineTools/usr/include/c++/v1")
 # SET(CMAKE_CXX_FLAGS  "-g ${CMAKE_CXX_FLAGS}")
 SET(CMAKE_CXX_FLAGS  "-Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT ${CMAKE_CXX_FLAGS}")
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -DSTAN_THREADS")
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -DBOOST_DISABLE_ASSERTS")
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wl,-L,${MATH}/lib/tbb -Wl,-rpath,${MATH}/lib/tbb")
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -isysroot ${Xcode_CLT}/SDKs/MacOSX.sdk/usr/include")
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-unused-local-typedef -Wno-unused-function -Wno-ignored-qualifiers -Wno-unused-variable -Wno-sign-compare -Wno-infinite-recursion -Wunused-command-line-argument")

include_directories(${PROJROOT}/include)
file(GLOB SOURCES
    ${PROJROOT}/include/*.h
    ${PROJROOT}/include/*.hpp
    ${PROJROOT}/src/*.cpp
)

 add_executable(main main.cpp ${SOURCES})
 target_link_libraries(main ${CMAKE_CXX_FLAGS} ${MATH}/lib/sundials_5.2.0/lib/libsundials_nvecserial.a ${MATH}/lib/sundials_5.2.0/lib/libsundials_cvodes.a ${MATH}/lib/sundials_5.2.0/lib/libsundials_idas.a ${MATH}/lib/sundials_5.2.0/lib/libsundials_kinsol.a ${MATH}/lib/tbb/libtbb.dylib ${MATH}/lib/tbb/libtbbmalloc.dylib ${MATH}/lib/tbb/libtbbmalloc_proxy.dylib)

Generate compile_commands.json using CMAKE

This is for compiling with the -g flag for debugging. If you are not using gdb, please ignore this part. The executable will be compiled in a Debug directory.

rm -r CMakeFiles/ Debug/ cmake_install.cmake CMakeCache.txt Makefile compile_commands.json
# export CXX="/usr/local/opt/llvm/bin/clang++"
# export CC="/usr/local/opt/llvm/bin/clang"
cmake -H. -BDebug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=YES
ln -s Debug/compile_commands.json

Debug: LLDB

(dap-register-debug-template
   "LLDB::diprom-main"
  (list :type "lldb"
        :request "launch"
        :name "LLDB::diprom-main"
        :arguments "1 100 100 10 serial "
        :target "/Users/yunj/Dropbox/research/procmod/procmod-code/Debug/main"
        :cwd "/Users/yunj/Dropbox/research/procmod/procmod-code/"
        ))