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*

Cannot use boost/thread with DPC++

Daniel_D
Novice
2,935 Views

Hi,

 

I created the DPC++ sample console vector add application. Creating/compiling and executing works well on my system:

 

Windows 11 - all updates

VS 2022 - latest release (17.2.5)

DPC++ from oneAPI_2022.1.0.256

This is the project template I use. I have not changed anything else than the two lines below:

Daniel_D_0-1657182923186.png

 

Now I want to use a boost thread in this application. For that I add these 2 lines to the top of the DPCPPConsoleApplication1.cpp file like this:

 

//==============================================================
// Copyright © Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#include <boost/thread.hpp>


#include <CL/sycl.hpp>
#include <vector>
#include <iostream>
#if FPGA || FPGA_EMULATOR
#include <ext/intel/fpga_extensions.hpp>
#endif

 

No other changes made. Now I cannot compile this application anymore because I get an error and several warning:

 

1>T:\\Development\\3rdParty\\boost_1_79_0\\include\boost/config/requires_threads.hpp(82,4): : error : "Compiler threading support is not turned on. Please set the correct command line options for threading: either /MT /MTd /MD or /MDd"
1># error "Compiler threading support is not turned on. Please set the correct command line options for threading: either /MT /MTd /MD or /MDd"

 

The /MDd flag is already set from thew sample app. The complete commandline looks like this:

/Od //I"T:\Development\3rdParty\boost_1_79_0\include" /Zi /D "_DEBUG" /WX- /MDd /std:c++17 /EHsc /W3 /nologo /Fo"x64\Debug\"

 

and:

/Zc:__cplusplus

as additional option

Any idea how I can use boost together with DPC++?

Thanks.

 

0 Kudos
7 Replies
VidyalathaB_Intel
Moderator
2,918 Views

Hi Daniel,

 

Thanks for reaching out to us.

Since you want to use boost thread along with dpcpp sycl code we would like to understand the use case behind it so that it would help us to address your issue better.

 

Regards,

Vidya.

 

0 Kudos
Daniel_D
Novice
2,908 Views

Hi Vidya,

 

thanks for your fast reply. In this case I have to call a function in a 3rd party library. This function can take up to some minutes to return. So I call it in a thread. If the user want now to exit my application I need to cancel the execution of this thread. std::thread does not offer this option. So I have to use boost::thread. I can cancel the execution and I can terminate my application. This is one sample why I use boost - but there are much more.

 

Thanks,

Daniel

0 Kudos
VidyalathaB_Intel
Moderator
2,847 Views

Hi Daniel,


Apologies for the delay and thanks for your patience.

The issue raised by you is reproducible from our end as well.

We are working on it. we will get back to you soon.


Regards,

Vidya.


0 Kudos
Subarnarek_G_Intel
2,720 Views

Hi Daniel,

Please refer to https://www.intel.com/content/www/us/en/developer/articles/technical/building-boost-with-oneapi.html and let me know if you have further questions.


Regards,

Subarna


0 Kudos
Daniel_D
Novice
2,695 Views

Hi Subarna,

 

thanks for your information. As you might have overread, the problem is NOT to build boost with DPC++. The problem I have is that I cannot USE boost in a DPC++ console application. If you follow this guide, you may see the problem I have:

 

Create a new project:

Daniel_D_0-1664333725367.png

 

and make this modification to add boost support:

Now I want to use a boost thread in this application. For that I add these 2 lines to the top of the DPCPPConsoleApplication1.cpp file like this:

 

//==============================================================
// Copyright © Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#include <boost/thread.hpp>


#include <CL/sycl.hpp>
#include <vector>
#include <iostream>
#if FPGA || FPGA_EMULATOR
#include <ext/intel/fpga_extensions.hpp>
#endif

 

You will see that it is now no longer possible to compile the project. So, using boost in a DPC++ application is not possible and the problem I have. Not building boost with DPC.

Daniel

0 Kudos
Subarnarek_G_Intel
2,620 Views

In dpcpp compiler, the macro "BOOST_HAS_THREADS" isn't recognized. So it generates that error.


There is a workaround, which is defining this macro by yourself before including the boost/thread.hpp file, as follows,


#define BOOST_HAS_THREADS

#include <boost/thread.hpp>


0 Kudos
Subarnarek_G_Intel
2,528 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


0 Kudos
Reply