Change the C++ compiller in ROS to use with openACC and CUDA
I'm trying to compile a rospackage with the PGI compiler that uses openACC. I want to parallelize some code.
This works with standard c++ code and uses the pgcc / pgc++ compiler. So I tried to compile a simple ros package with this compiler. Here is the source code:
#include <ros/ros.h>
#include <iostream>
#include "std_msgs/String.h"
#include <sstream>
int main(int argc, char **argv)
{
ros::init(argc, argv, "pgi_test_node");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
ros::Rate loop_rate(10);
int cout = 0;
while(ros::ok()) {
std_msgs::String msg;
ss << heelo world" << count;
ROS_INFO("%s", msg.data.c_str());
chatter_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
And here is the my cmakelists.txt . I've tried a lot of things but the mains change might be the compiler and its flags in the beginning.
cmake_minimum_required(VERSION 2.8.3)
project(pgi_test)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
SET(CMAKE_C_COMPILER /opt/pgi/linux86-64/18.4/bin/pgcc)
SET(CMAKE_CXX_COMPILER /opt/pgi/linux86-64/18.4/bin/pgc++)
# flags
add_definitions("-DENABLE_SSE")
SET(CMAKE_CXX_FLAGS
"${SSE_FLAGS} -O3 -std=c++11 -ta=tesla:cuda9.1 -acc -Minfo=accel"
)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED
roscpp
rospy
std_msgs
genmsg
)
## System dependencies are found with CMake's conventions
#find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
find_package( CUDA REQUIRED )
include_directories(
${catkin_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
)
SET(BOOST_HAS_FLOAT128)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
# )
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and ...