0

I started my study with OneAPI SYCL but I normally use QtCreator as my IDE. I did a HelloSYCL project with CMake and works fine in the terminal and in the VSCode with OneAPI Extension as well, but didn't work in the QtCreator.

Every time I want to use SYCL I need to start ONEAPI environment with ". /opt/intel/oneapi/setvars.sh", but I don't know how to do it with QtCreator

Here is the way I'm compile

mkdir build; cd build
cmake -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -G Ninja -S .. -DCMAKE_PREFIX_PATH="/opt/intel/oneapi/compiler/latest/linux/cmake/SYCL/" -DSYCL_INCLUDE_DIR=/opt/intel/oneapi/compiler/latest/linux/include/sycl -DSYCL_LIBRARY_DIR=/opt/intel/oneapi/compiler/latest/linux/lib

cmake_minimum_required(VERSION 3.22)

project(testSYCL LANGUAGES CXX)

if(UNIX)
  set(CMAKE_C_COMPILER icx)
  set(CMAKE_CXX_COMPILER dpcpp)
endif(UNIX)

list(APPEND CMAKE_MODULE_PATH "/opt/intel/oneapi/compiler/2021.4.0/linux/")
list(APPEND CMAKE_MODULE_PATH "/opt/intel/oneapi/compiler/2021.4.0/linux/cmake/SYCL/")
find_package(IntelDPCPP REQUIRED)

set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (NOT CMAKE_BUILD_TYPE)
    message(STATUS "No build type selected, default to Release")
    set(CMAKE_BUILD_TYPE "Release" CACHE PATH "Build Type" FORCE)
endif()

add_executable(testSYCL main.cpp)

#include <iostream>
#include <iomanip>

#include <CL/sycl.hpp>

int main()
{
    for ( const auto& plataform : sycl::platform::get_platforms() ) {
        std::cout << "=========================================================\n";
        std::cout << std::setw(25);
        std::cout << plataform.get_info<sycl::info::platform::name>() << "\n"; 
        std::cout << plataform.get_info<sycl::info::platform::vendor>() << "\n"; 
        std::cout << "Plataform: " << plataform.get_info<sycl::info::platform::version>() << "\n"; 
        
        for ( const auto& device : plataform.get_devices() ) {
            std::cout << "Devices\n";
            std::cout << "Name: " << device.get_info<sycl::info::device::name>() << "\n";
            std::cout << "Max Compute Units: " << device.get_info<sycl::info::device::max_compute_units>() << "\n";
            std::cout << "Max Work Group Size: " << device.get_info<sycl::info::device::max_work_group_size>() << "\n";
            std::cout << "Max Clock Frequency: " << device.get_info<sycl::info::device::max_clock_frequency>() << " MHz \n";
        }
    }
}

QtCreator CMake Error QtCreator Custom Compiler added

1 Answers1

1

The answer depends on the contents of setvars.sh. I assume this is a simple script setting environment variables.

One way to mimic it in QtCreator is to define a custom kit. Go to Tools/Options/Kits. Highlight any kit you use and press "clone". Then, add to it manually the necessary environment variables in the field "Environment". Use this kit for your SYCL projects. This will work if your problem is caused by a compiler error.

setting a kit in QtCreator

If the problem occurs while running a program inside QtCreator, look at build/running options:

build/run options

There you'll easily find options for changing the runtime or compile-time environment

enter image description here

zkoza
  • 2,644
  • 3
  • 16
  • 24
  • The setvars.sh in question is indirectly described here: https://github.com/abacusmodeling/abacus-develop/blob/develop/Dockerfile.intel#L23 – ferdymercury Dec 14 '22 at 09:54