0

In title, I am specific about the task that I want to achieve. I want to utilize the c++17 features such as parallel STL etc. On visual studio 2017, I configure to c++17 under project properties for language. Even after doing this I get the error with #include that no execution file. I am just starting with simple example of array addition in parallel with C++ 17 algorithms. How do I resolve this?

Source:

#include <stddef.h>
#include <stdio.h>
#include <algorithm>
#include <execution>
#include <chrono>
#include <random>
#include <ratio>
#include <vector>

using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::high_resolution_clock;
using std::milli;
using std::random_device;
using std::sort;
using std::vector;


const size_t testSize = 1'000'000;
const int iterationCount = 5;

void print_results(const char *const tag, const vector<double>& sorted,
    high_resolution_clock::time_point startTime,
    high_resolution_clock::time_point endTime) {
    printf("%s: Lowest: %g Highest: %g Time: %fms\n", tag, sorted.front(),
        sorted.back(),
        duration_cast<duration<double, milli>>(endTime - startTime).count());
}

int main() {
    random_device rd;

    // generate some random doubles:
    printf("Testing with %zu doubles...\n", testSize);
    vector<double> doubles(testSize);
    for (auto& d : doubles) {
        d = static_cast<double>(rd());
    }

    // time how long it takes to sort them:
    for (int i = 0; i < iterationCount; ++i)
    {
        vector<double> sorted(doubles);
        const auto startTime = high_resolution_clock::now();
        sort(sorted.begin(), sorted.end());
        const auto endTime = high_resolution_clock::now();
        print_results("Serial", sorted, startTime, endTime);
    }
}

and this is error: Error C1083 Cannot open include file: 'execution': No such file or directory

Task that I want to achieve is that C++17 with CUDA GPU. Both new to me although not c++ in itself. But I am interested in parallel STL of C++17 with CUDA. I want to start from base. Any suggestions will help me?

Thanks, Govind

  • show the source and the error message, " I get the error with #include that no execution file" is not clear at all – pm100 Mar 04 '22 at 05:05
  • I edited my question with source and error. However, this is sorting example. In main function, will replace for loop with std::execution::par , std::execution::seq to check out the performance of c++ 17 parallel algorithm. In project properties, I set language standard as "ISO C++17 Standard (/std:c++17)". – govind sharma Mar 04 '22 at 06:09
  • See [How do I use the new C++17 execution policies?](https://stackoverflow.com/q/42567998/3422102) Unless you have the latest (or at least recent) updates to VS2017, you may not have the execution policies available. – David C. Rankin Mar 04 '22 at 06:37
  • @govindsharma Your code works on VS2017 MSVC 19.16.27045.0. – Jinesi Yelizati Mar 04 '22 at 06:38
  • 1
    Works fine on old VS2017 on Win7. VS2017 ver. 15.9.44. Also works fine with gcc 11. – David C. Rankin Mar 04 '22 at 07:00
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 04 '22 at 07:05
  • I am using 2017 15.3.3 version. That's why I am having problem. I tried with gcc-9 also but tbb gives me issue that I should have newest version 2019. On my system, Ubuntu 18 is installed and tbb version 2017. – govind sharma Mar 05 '22 at 12:02

1 Answers1

-1

Please check if the header file is included in the header file directory. the C++ headers path are:

1.C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include

2.C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt

The first contains standard C++ headers such as iostream. The second contains legacy C headers such as stdio.h.

If you are going to use C++ to develop desktop applications, I recommend you to refer to my setup.

enter image description here

Also I tested your code on VS2022 without any errors. So I suggest you to use a higher version of VS and install the environment you need.

  • @Yao: Thanks. I checked the version of VS is 2017 15.3.3. And "execution" header file is also not there. I will try to do in higher version. – govind sharma Mar 05 '22 at 11:46
  • @govind sharma Hi, the most important thing is to make sure that the header files exist in the above directory, so you'd better install the necessary packages. If your case has been solved, please help to mark answers. If not, just feel free to contact us. Your understanding and cooperation will be grateful. – Yujian Yao - MSFT Mar 07 '22 at 06:23
  • @Yao: Thanks. I solved this issue with newest version of visual studio. – govind sharma Mar 07 '22 at 08:50
  • @govind sharma glad to know you've solved this problem, you could click '✔' to mark it as an answer to change its status to Answered. It will also help others to solve a similar issue. – Yujian Yao - MSFT Mar 07 '22 at 09:10