Configure and run DPC++ under linux (including installation method without graphical interface)

First use a computer with an interface to find the link on the official website

https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#dpcpp-cpp

insert image description here

Directly in one step, copy the second link

Back to the terminal to download

wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/89283df8-c667-47b0-b7e1-c4573e37bd3e/l_dpcpp-cpp-compiler_p_2023.1.0.46347_offline.sh

insert image description here

run.sh

At this time, the current folder should have this file, add permissions, run

chmod +x l_dpcpp-cpp-compiler_p_2023.1.0.46347_offline.sh
sudo ./l_dpcpp-cpp-compiler_p_2023.1.0.46347_offline.sh

Install

The following interface appears
insert image description here

Accept, there will be an installation of eclipse in the middle, you can skip it, all the way to next
insert image description here

After loading, display the installation directory,
insert image description here
enter the installation path, and configure it

source setvars.sh intel64

that's it

run the program

Similar to c++ compilation

An official example (be careful not to create a new test file in the installation path just now)

// Copyright (C) 2020 Intel Corporation

// SPDX-License-Identifier: MIT

#include <sycl/sycl.hpp>
#include <iostream>
using namespace sycl;

const std::string secret {
    
    
  "Ifmmp-!xpsme\"\012J(n!tpssz-!Ebwf/!"
  "J(n!bgsbje!J!dbo(u!ep!uibu/!.!IBM\01" };

const auto sz = secret.size();

int main() {
    
    
  queue Q;

  char *result = malloc_shared<char>(sz, Q);
  std::memcpy(result,secret.data(),sz);

  Q.parallel_for(sz,[=](auto& i) {
    
    
      result[i] -= 1;
      }).wait();

  std::cout << result << "\n";
  return 0;
}
dpcpp test.cpp -o test
./test

warn

You may have noticed a warning when compiling above, indicating that the dpcpp command option you are currently using is deprecated and will be removed in a future release. It is recommended to use the icpx -fsycl command option instead, so it is best to compile like this:

insert image description here

Guess you like

Origin blog.csdn.net/qq_44616044/article/details/131188970