I’m trying to use OpenACC to parallelize a SLAM system. Although i’m having some trouble adapting my makefile or my CMakeLists.txt (I really dont know which should i change).
For a simple file i know that i only need to have something like this on the makefile:
choose:
@echo make c++ or make fortran or make both
CPP=pgc++
FC=pgfortran
TIMER=/usr/bin/time
OPT=
NOPT=-fast -Minfo=opt $(OPT)
ARGS=1000
c++: jsolvec.exe
$(TIMER) ./jsolvec.exe $(ARGS)
jsolvec.exe: jsolvec.cpp
$(CPP) -o $@ $< $(NOPT)
fortran: jsolvef.exe
$(TIMER) ./jsolvef.exe $(STEPS)
jsolvef.exe: jsolvef.F90
$(FC) -o $@ $< $(NOPT)
both: c++ fortran
clean:
rm -f *.o *.exe *.s *.mod a.out
An to compile i only need to do: “make c++ OPT=”-ta:tesla:cc50 -Minfo=accel".
But, slam uses a lot of files and has giant makefiles and cmake files. My CMakeLists.txt, which i think is the one i should make the changes looks like this:
SET(PROJECT_NAME DSO)
PROJECT(${PROJECT_NAME})
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(BUILD_TYPE Release)
#set(BUILD_TYPE RelWithDebInfo)
SET(CMAKE_C_COMPILER /opt/pgi/linux86-64/17.10/bin/pgc)
set(EXECUTABLE_OUTPUT_PATH bin)
set(LIBRARY_OUTPUT_PATH lib)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# required libraries
find_package(SuiteParse REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Boost COMPONENTS system thread)
# optional libraries
find_package(LibZip QUIET)
find_package(Pangolin 0.2 QUIET)
find_package(OpenCV QUIET)
# flags
add_definitions("-DENABLE_SSE")
set(CMAKE_CXX_FLAGS
"${SSE_FLAGS} -O3 -g -std=c++0x -march=native"
# "${SSE_FLAGS} -O3 -g -std=c++0x -fno-omit-frame-pointer"
)
if (MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif (MSVC)
# Sources files
set(dso_SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystem.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemOptimize.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemOptPoint.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemDebugStuff.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/FullSystemMarginalize.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/Residuals.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/CoarseTracker.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/CoarseInitializer.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/ImmaturePoint.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/HessianBlocks.cpp
${PROJECT_SOURCE_DIR}/src/FullSystem/PixelSelector2.cpp
${PROJECT_SOURCE_DIR}/src/OptimizationBackend/EnergyFunctional.cpp
${PROJECT_SOURCE_DIR}/src/OptimizationBackend/AccumulatedTopHessian.cpp
${PROJECT_SOURCE_DIR}/src/OptimizationBackend/AccumulatedSCHessian.cpp
${PROJECT_SOURCE_DIR}/src/OptimizationBackend/EnergyFunctionalStructs.cpp
${PROJECT_SOURCE_DIR}/src/util/settings.cpp
${PROJECT_SOURCE_DIR}/src/util/Undistort.cpp
${PROJECT_SOURCE_DIR}/src/util/globalCalib.cpp
)
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/thirdparty/Sophus
${PROJECT_SOURCE_DIR}/thirdparty/sse2neon
${EIGEN3_INCLUDE_DIR}
)
# decide if we have pangolin
if (Pangolin_FOUND)
message("--- found PANGOLIN, compiling dso_pangolin library.")
include_directories( ${Pangolin_INCLUDE_DIRS} )
set(dso_pangolin_SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/IOWrapper/Pangolin/KeyFrameDisplay.cpp
${PROJECT_SOURCE_DIR}/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp)
set(HAS_PANGOLIN 1)
else ()
message("--- could not find PANGOLIN, not compiling dso_pangolin library.")
message(" this means there will be no 3D display / GUI available for dso_dataset.")
set(dso_pangolin_SOURCE_FILES )
set(HAS_PANGOLIN 0)
endif ()
# decide if we have openCV
if (OpenCV_FOUND)
message("--- found OpenCV, compiling dso_opencv library.")
include_directories( ${OpenCV_INCLUDE_DIRS} )
set(dso_opencv_SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/IOWrapper/OpenCV/ImageDisplay_OpenCV.cpp
${PROJECT_SOURCE_DIR}/src/IOWrapper/OpenCV/ImageRW_OpenCV.cpp)
set(HAS_OPENCV 1)
else ()
message("--- could not find OpenCV, not compiling dso_opencv library.")
message(" this means there will be no image display, and image read / load functionality.")
set(dso_opencv_SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/IOWrapper/ImageDisplay_dummy.cpp
${PROJECT_SOURCE_DIR}/src/IOWrapper/ImageRW_dummy.cpp)
set(HAS_OPENCV 0)
endif ()
# decide if we have ziplib.
if (LIBZIP_LIBRARY)
message("--- found ziplib (${LIBZIP_VERSION}), compiling with zip capability.")
add_definitions(-DHAS_ZIPLIB=1)
include_directories( ${LIBZIP_INCLUDE_DIR_ZIP} ${LIBZIP_INCLUDE_DIR_ZIPCONF} )
else()
message("--- not found ziplib (${LIBZIP_LIBRARY}), compiling without zip capability.")
set(LIBZIP_LIBRARY "")
endif()
# compile main library.
include_directories( ${CSPARSE_INCLUDE_DIR} ${CHOLMOD_INCLUDE_DIR})
add_library(dso ${dso_SOURCE_FILES} ${dso_opencv_SOURCE_FILES} ${dso_pangolin_SOURCE_FILES})
#set_property( TARGET dso APPEND_STRING PROPERTY COMPILE_FLAGS -Wall )
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # OSX
set(BOOST_THREAD_LIBRARY boost_thread-mt)
else()
set(BOOST_THREAD_LIBRARY boost_thread)
endif()
# build main executable (only if we have both OpenCV and Pangolin)
if (OpenCV_FOUND AND Pangolin_FOUND)
message("--- compiling dso_dataset.")
add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp )
target_link_libraries(dso_dataset dso boost_system cxsparse ${BOOST_THREAD_LIBRARY} ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS})
else()
message("--- not building dso_dataset, since either don't have openCV or Pangolin.")
endif()
Note that i already added the following line: “SET(CMAKE_C_COMPILER /opt/pgi/linux86-64/17.10/bin/pgc)” as a first attempt to compile with pgc. And it compiled without errors, so i think there’s no problem there. I’ve also tried to change line 30 for somthing like this:
“pgc” is our back-end compiler and shouldn’t be called directly. Please use “pgcc”.
This however generates errors because the compiler doesn’t know what “ta” and “Minfo” means.
Given you also have “-march=native”, which is a GCC flag, I’m guessing you’re using GCC. I’m not sure if it’s due to the “pgc” typo or if you haven’t set the C compiler correctly.
Note that we did have an intern here last summer that work with Kitware to add OpenACC support to cmake. So more recent versions will have this support.
I changed the path, and instead of using pgcc i used pgc++ and it already recognizes -ta and Minfo flags. Aren’t these flags suppose to work on pgcc as well?
But now, i do get error becouse of the “-march=native” flag, which, as you said, is a GCC flag, and pgcc doesn’t recognize it. If i try to compile without it e get multiple code errors.
I changed the path, and instead of using pgcc i used pgc++ and it already recognizes -ta and Minfo flags. Aren’t these flags suppose to work on pgcc as well?
Yes, pgcc recognizes these options.
But now, i do get error becouse of the "-march=native" flag, which, as you said, is a GCC flag, and pgcc doesn't recognize it. If i try to compile without it e get multiple code errors.
The errors are probably something else unrelated to “-march=native”. What are the errors?
If i compile for pgcc and with: “set(CMAKE_C_FLAGS
“${SSE_FLAGS} -O3 -g -std=c++0x -march=native -ta=tesla:cc50 -Minfo=accel”)” i get errors like:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
/home/cesar/Documents/dso/src/util/settings.cpp: In function ‘void dso::handleKey(char)’:
/home/cesar/Documents/dso/src/util/settings.cpp:222:55: error: ‘printf’ was not declared in this scope
printf("new freeDebugParam5: %f!\n", freeDebugParam5);
^
CMakeFiles/dso.dir/build.make:422: recipe for target 'CMakeFiles/dso.dir/src/util/settings.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/util/settings.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
i change the flag -std=c++0x to -std=c++11 but still get the same errors
Although, i don’t think the flags are being used, i get no information taht Minfo is suppose to give, and i added a pragma in the code just to see if it recognizes the language, and it does, i compile without errors, although the pragma isn’t being performed, or at least i get no evidences of that.
I think i have to uncomment the line where i tell the compiler to use pgc++, but if i do that i get an error because pgc++ doens’t know what “-march=native” because it is a gcc flag. And i can’t simply erase that flag
I am sure that i’m compiling with pgc, when calling cmake e get the following messages:
-- The C compiler identification is PGI 17.10.0
-- The CXX compiler identification is PGI 17.10.0
-- Check for working C compiler: /opt/pgi/linux86-64/17.10/bin/pgcc
-- Check for working C compiler: /opt/pgi/linux86-64/17.10/bin/pgcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/pgi/linux86-64/17.10/bin/pgc++
-- Check for working CXX compiler: /opt/pgi/linux86-64/17.10/bin/pgc++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
But, when i compile i get error messages in simple things like ‘;’ :
"/home/cesar/Documents/dso/thirdparty/Sophus/sophus/so3.hpp", line 801:
warning: type qualifiers are meaningless here
const ConstQuaternionReference unit_quaternion() const {
^
"/home/cesar/Documents/dso/src/OptimizationBackend/MatrixAccumulators.h", line
29: catastrophic error: cannot open source file "SSE2NEON.h"
#include "SSE2NEON.h"
^
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/FullSystem/CoarseInitializer.cpp".
Compilation terminated.
CMakeFiles/dso.dir/build.make:230: recipe for target 'CMakeFiles/dso.dir/src/FullSystem/CoarseInitializer.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/FullSystem/CoarseInitializer.cpp.o] Error 2
make[2]: *** Waiting for unfinished jobs....
"/home/cesar/Documents/dso/thirdparty/Sophus/sophus/so3.hpp", line 801:
warning: type qualifiers are meaningless here
const ConstQuaternionReference unit_quaternion() const {
^
"/home/cesar/Documents/dso/src/OptimizationBackend/MatrixAccumulators.h", line
29: catastrophic error: cannot open source file "SSE2NEON.h"
#include "SSE2NEON.h"
^
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/OptimizationBackend/AccumulatedTopHessian.cpp".
Compilation terminated.
"/home/cesar/Documents/dso/src/OptimizationBackend/RawResidualJacobian.h", line
34: warning: extra ";" ignored
EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
And i checked that this behavior is due to pgc++, if i compile with pgcc and c++ it compiles fine, but the flags doesn’t work. Compiling with pgcc and pgc++ i get those errors.
Well, from what i’m seeing, which is weird, that file never existed, but compiling with gcc that is ignored… But now that i forced and copied those files to the project i get this erros:
MakeFiles/dso.dir/build.make:326: recipe for target 'CMakeFiles/dso.dir/src/OptimizationBackend/EnergyFunctional.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/OptimizationBackend/EnergyFunctional.cpp.o] Error 2
"/home/cesar/Documents/dso/thirdparty/sse2neon/SSE2NEON.h", line 123:
catastrophic error: cannot open source file "arm_neon.h"
#include "arm_neon.h"
^
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/OptimizationBackend/EnergyFunctionalStructs.cpp".
Compilation terminated.
CMakeFiles/dso.dir/build.make:398: recipe for target 'CMakeFiles/dso.dir/src/OptimizationBackend/EnergyFunctionalStructs.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/OptimizationBackend/EnergyFunctionalStructs.cpp.o] Error 2
"/usr/include/boost/smart_ptr/detail/spinlock_pool.hpp", line 38: catastrophic
error: error while writing intermediate language (4) file: No space
left on device
static spinlock pool_[ 41 ];
^
"/usr/include/boost/smart_ptr/detail/spinlock_pool.hpp", line 38: catastrophic
error: error while writing intermediate language (2) file: No space
left on device
static spinlock pool_[ 41 ];
^
"/usr/include/eigen3/Eigen/src/Core/DenseStorage.h", line 46: catastrophic
error: error while writing intermediate language (5) file: No space
left on device
T array[Size];
^
PGCC-F-0010-File write error occurred (data init file) (/home/cesar/Documents/dso/src/FullSystem/HessianBlocks.cpp)
PGCC/x86 Linux 17.10-0: compilation aborted
"/home/cesar/Documents/Pangolin/include/pangolin/gl/glsl.h", line 532:
catastrophic error: error while writing intermediate language (5)
file: No space left on device
char line[MAXLINESIZE];
^
CMakeFiles/dso.dir/build.make:278: recipe for target 'CMakeFiles/dso.dir/src/FullSystem/HessianBlocks.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/FullSystem/HessianBlocks.cpp.o] Error 2
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/FullSystem/ImmaturePoint.cpp".
Compilation terminated.
CMakeFiles/dso.dir/build.make:254: recipe for target 'CMakeFiles/dso.dir/src/FullSystem/ImmaturePoint.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/FullSystem/ImmaturePoint.cpp.o] Error 2
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/FullSystem/FullSystemOptPoint.cpp".
Compilation terminated.
CMakeFiles/dso.dir/build.make:110: recipe for target 'CMakeFiles/dso.dir/src/FullSystem/FullSystemOptPoint.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/FullSystem/FullSystemOptPoint.cpp.o] Error 2
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/FullSystem/Residuals.cpp".
Compilation terminated.
1 catastrophic error detected in the compilation of "/home/cesar/Documents/dso/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp".
Compilation terminated.
CMakeFiles/dso.dir/build.make:182: recipe for target 'CMakeFiles/dso.dir/src/FullSystem/Residuals.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/FullSystem/Residuals.cpp.o] Error 2
CMakeFiles/dso.dir/build.make:566: recipe for target 'CMakeFiles/dso.dir/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/IOWrapper/Pangolin/PangolinDSOViewer.cpp.o] Error 2
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-S-0000-Internal compiler error. read_debug_info: bad debug file
0 (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC-F-0008-Error limit exceeded (/home/cesar/Documents/dso/src/FullSystem/FullSystemDebugStuff.cpp)
PGCC/x86 Linux 17.10-0: compilation aborted
CMakeFiles/dso.dir/build.make:134: recipe for target 'CMakeFiles/dso.dir/src/FullSystem/FullSystemDebugStuff.cpp.o' failed
make[2]: *** [CMakeFiles/dso.dir/src/FullSystem/FullSystemDebugStuff.cpp.o] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/dso.dir/all' failed
make[1]: *** [CMakeFiles/dso.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2