Skip to content

Commit

Permalink
Remove absolute paths in CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
bentonatura committed Nov 16, 2020
1 parent 2bba822 commit 44d5659
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 22 deletions.
68 changes: 51 additions & 17 deletions examples/EnvelopeProblemSOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,57 @@ project(EnvelopeProblem)

set(CMAKE_CXX_STANDARD 14)

set(MKLROOT /opt/intel/compilers_and_libraries_2020.1.216/mac/mkl)
set(DYLD_LIBRARY_PATH /opt/intel/compilers_and_libraries_2020.1.216/mac/tbb/lib:/opt/intel/compilers_and_libraries_2020.1.216/mac/compiler/lib:/opt/intel/compilers_and_libraries_2020.1.216/mac/mkl/lib)
set(LIBRARY_PATH /opt/intel/compilers_and_libraries_2020.1.216/mac/tbb/lib:/opt/intel/compilers_and_libraries_2020.1.216/mac/compiler/lib:/opt/intel/compilers_and_libraries_2020.1.216/mac/mkl/lib)
set(CPATH /opt/intel/compilers_and_libraries_2020.1.216/mac/mkl/include)
set(NLSPATH /opt/intel/compilers_and_libraries_2020.1.216/mac/mkl/lib/locale/%l_%t/%N)

set(CMAKE_CXX_FLAGS_DEBUG_CUSTOM "-O0 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -DIPM_USE_DOUBLE -DIPM_DOUBLE=double")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG_CUSTOM}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall -Wextra -O3 -DNDEBUG=1")
set(CMAKE_CXX_FLAGS_RELEASE_DOUBLE_AVX "${CMAKE_CXX_FLAGS} -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -Wall -Wextra -O3 -mavx -mfma -DNDEBUG=1 -DIPM_USE_DOUBLE -DDIGITS_PRECISION=250 -DIPM_DOUBLE=double")

set(MKL_OPTIONS "-DMKL_LP64 -m64 -I${MKLROOT}/include -L${DYLD_LIBRARY_PATH} -L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -lm -ldl")
set(CMAKE_CXX_FLAGS_RELEASE_DOUBLE_AVX "${CMAKE_CXX_FLAGS} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Wall -Wextra -O3 -mavx -mfma -DNDEBUG=1 -DIPM_USE_DOUBLE -DDIGITS_PRECISION=250 -DIPM_DOUBLE=double")

#env: DYLD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2020.1.216/mac/tbb/lib:/opt/intel/compilers_and_libraries_2020.1.216/mac/compiler/lib:/opt/intel/compilers_and_libraries_2020.1.216/mac/mkl/lib;NLSPATH=/opt/intel/compilers_and_libraries_2020.1.216/mac/mkl/include;MKLROOT=/opt/intel/compilers_and_libraries_2020.1.216/mac/mkl;TK_SILENCE_DEPRECATION=1
#Environment variables MKLROOT, DYLD_LIBRARY_PATH, LIBRARY_PATH, CPATH and NLSPATH must be set to use MKL. See more information here: https://software.intel.com/content/www/us/en/develop/articles/intel-mkl-link-line-advisor.html
set(MKL_OPTIONS "-DMKL_LP64 -m64 -I$ENV{MKLROOT}/include")

set(CMAKE_CXX_FLAGS_RELEASE_DOUBLE_AVX_OPENMP "${CMAKE_CXX_FLAGS} -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -Wall -Wextra -O3 -march=native -Xclang -fopenmp -lomp -mavx -mfma -fno-math-errno -DNDEBUG=1 -DIPM_USE_DOUBLE -DDIGITS_PRECISION=250 -DIPM_DOUBLE=double -DEIGEN_USE_MKL_ALL=1 ${MKL_OPTIONS}")
set(CMAKE_CXX_FLAGS_RELEASE_DOUBLE "${CMAKE_CXX_FLAGS} -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -Wall -Wextra -O3 -march=native -Xclang -fopenmp -lomp -mavx -mfma -fno-math-errno -DNDEBUG=1 -DIPM_USE_DOUBLE -DDIGITS_PRECISION=250 -DIPM_DOUBLE=double ${MKL_OPTIONS}")
set(CMAKE_CXX_FLAGS_RELEASE_DOUBLE_AVX_OPENMP "${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -O3 -march=native -Xclang -fopenmp -mavx -mfma -fno-math-errno -DNDEBUG=1 -DIPM_USE_DOUBLE -DDIGITS_PRECISION=250 -DIPM_DOUBLE=double -DEIGEN_USE_MKL_ALL=1 ${MKL_OPTIONS}")
set(CMAKE_CXX_FLAGS_RELEASE_DOUBLE "${CMAKE_CXX_FLAGS} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Wall -Wextra -O3 -march=native -Xclang -fopenmp -mavx -mfma -fno-math-errno -DNDEBUG=1 -DIPM_USE_DOUBLE -DDIGITS_PRECISION=250 -DIPM_DOUBLE=double ${MKL_OPTIONS}")

file(GLOB TARGETS "*.h" "*.cpp" "../../include/sos/*.h" "../../include/sos/*.cpp" "../../include/barriers/*.h" "../../include/barriers/*.cpp"
"../../external/ChebTools/*"
"../../external/Padua/*"
"../../include/sos/utils.cpp"
)

find_package(OpenMP REQUIRED)
#find_package(spdlog REQUIRED)
if (CMAKE_BUILD_TYPE STREQUAL "Release_double_avx_openmp")
set(USE_OpenMP TRUE)
else ()
set(USE_OpenMP FALSE)
endif ()

message("USE_OPENMP is ${USE_OpenMP}")

if (APPLE AND USE_OpenMP)
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C "${CMAKE_C_COMPILER}")
set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
set(OpenMP_CXX_FLAGS "-Wno-unused-command-line-argument")
set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
message("libomp library is in ${OpenMP_libomp_LIBRARY}")
endif ()
endif ()

if (USE_OpenMP)
find_package(OpenMP REQUIRED)
endif (USE_OpenMP)

find_package(Python2 COMPONENTS Development NumPy)
add_executable(EnvelopeProblem ${TARGETS} )
add_executable(EnvelopeProblem ${TARGETS})

if (NOT BOOST_DIR)
find_package(Boost 1.67.0 COMPONENTS *boost usr/local/)
Expand All @@ -46,7 +68,19 @@ else ()
../../include/sos ../../external ${SPDLOG_DIR} ../../include/sos/include ${Python2_INCLUDE_DIRS} ${Python2_NumPy_INCLUDE_DIRS}
../../../Eigen/eigen
/usr/local/include
/usr/local/opt/llvm/include)
target_link_directories(EnvelopeProblem PRIVATE /usr/local/lib /usr/local/opt/llvm/lib /usr/local/opt/libomp/lib/ ${DYLD_LIBRARY_PATH} ${LIBRARY_PATH})
${LLVM_INCLUDE_DIRS})
message("LLVM INCLUDE DIRS are ${LLVM_INCLUDE_DIRS}")
if (CMAKE_BUILD_TYPE STREQUAL "Release_double_avx_openmp")
message("Link MKL libraries")
target_link_options(EnvelopeProblem PRIVATE -framework Accelerate /opt/local/lib/lapack/liblapacke.dylib $ENV{MKLROOT}/lib/libmkl_intel_ilp64.a $ENV{MKLROOT}/lib/libmkl_intel_thread.a $ENV{MKLROOT}/lib/libmkl_core.a -liomp5 -lpthread -lm -ldl)
#Common Error on MacOs is that @rpath/libiomp5.dylib can not be linked/found. Fix is to run "install_name_tool -change @rpath/libiomp5.dylib <MKL_LIB>/lib/libiomp5.dylib ./EXECUTABLE"
endif ()
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
target_link_directories(EnvelopeProblem PRIVATE ${llvm_libs})
if (USE_OpenMP)
target_link_directories(EnvelopeProblem PRIVATE ${OPENMP_LIBRARIES})
endif ()
target_link_libraries(EnvelopeProblem Python2::Python Python2::NumPy)
endif ()
6 changes: 2 additions & 4 deletions examples/EnvelopeProblemSOS/config/instance.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"max_degree": 2,
"max_degree": 300,
"num_variables": 1,
"polynomials": [
[1],
[0, 1],
[0,0, 1],
[0,0,0,1]
[0, 1]
]
}
2 changes: 1 addition & 1 deletion include/sos/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},

"use_weighted_polynomials": true,
"input_in_interpolant_basis": false,
"input_in_interpolant_basis": true,
"plot_threshold": 20
}

0 comments on commit 44d5659

Please sign in to comment.