Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
734 Discussions

How to compile a SYCL program and make it portable?

frmar
Beginner
1,458 Views

I am compiling a very simple program using SYCL, which should be able to run on any Windows machine.

Here it is:

#include <CL/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(int argc, char* argv[]) {
    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;
}

 I work with Visual Studio Code, I have Intel OneAPI installed on my computer and the plug-ins specific to VS Code have been added.

If I compile it from VS Code by typing dpcpp main.cpp -o main.exe in the VS Code terminal, it compiles fine. If I run it from the VS Code terminal, it works fine too.

However, if I run the executable directly from any command prompt, an error tells me that the file "sycl.dll" is missing. If I add the .dll to my executable's folder, it runs... but doesn't show me anything in the terminal.

What should I do to be able to run it anywhere on my computer, but especially to have an executable usable on any Windows machine without having to install anything on it?

In advance, I thank you for your help.

 

0 Kudos
6 Replies
NoorjahanSk_Intel
Moderator
1,407 Views

Hi,

 

Thanks for reaching out to us.

 

>>an error tells me that the file "sycl.dll" is missing

 

You are observing this error because you did not initiate the Intel OneAPI environment, before running that executable. It's mandatory to source the environment in the same session.

Could you please try sourcing the setvars.bat script in the same session where you want to run the executable?

You can find the script fine in the below path:

C:\Program Files (x86)\Intel\oneAPI\setvars.bat

 

Hope this helps to resolve your issue. If not, please provide the compiler version being used to run the program.

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
frmar
Beginner
1,394 Views

Thank you for your answer.

Running the executable inside an Intel oneAPI command prompt will perfectly work, however I cannot run it inside a normal command prompt, even if I run setvars.bat inside the same command prompt before.

This is what is inside my current folder : main.exe, setvars.bat and setvars-vcvarsall.bat.

First, I am running setvars.bat and I obtain the following output:

:: initialising oneAPI environment...
   Initializing Visual Studio command-line environment...
   Visual Studio version 16.11.11 environment configured.
   "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\"
   Visual Studio command-line environment initialized for: 'x64'
:: oneAPI environment intiialized ::

If I run the main.exe directly after that, it is still telling me that sycl.dll is missing. If I add sycl.dll to the folder, the program will execute (apparently), but won't print the desired output, and won't print any error message either.

My objective by doing this is to obtain a portable executable that will work on another Windows 10 machine where I cannot install anything, but only execute a program.

0 Kudos
NoorjahanSk_Intel
Moderator
1,354 Views

Hi,

 

Could you please try to source the setvars.bat file from the below location and then run your executable.

C:\Program Files (x86)\Intel\oneAPI\setvars.bat

 

Please refer to the below screenshot for more details:

NoorjahanSk_Intel_0-1658384063620.png

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
NoorjahanSk_Intel
Moderator
1,326 Views

Hi,

 

>>My objective by doing this is to obtain a portable executable...

We are working on this issue. We will get back to you soon.

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
yzh_intel
Moderator
1,268 Views

Hi , 


The problem is likely due to dynamic library dependency.

Although you copied sycl.dll to your work directory, sycl.dll may depend on a lot other dynamic libraries which cannot be found.  


Can you try to install the compiler runtime to the target computer ?

You can find it in the following page, 

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

Install the suitable version for your computer from "Runtime Versions". 

Please let us know if this can fix the issue. 


Thanks,


0 Kudos
yzh_intel
Moderator
1,227 Views

Hi @frmar, have you solved your problem ?


0 Kudos
Reply