thrust icon indicating copy to clipboard operation
thrust copied to clipboard

Provide better error message when OpenMP is required but not found

Open jaredhoberock opened this issue 13 years ago • 1 comments

Ideally, we want a human-readable compiler error. When we have static_assert, we can guard just the function bodies and do something like static_assert(_OPENMP, "Did you forget -fopenmp?")

Forwarded from http://code.google.com/p/thrust/issues/detail?id=94

jaredhoberock avatar May 07 '12 21:05 jaredhoberock

Need to see how this fails today.

alliepiper avatar Apr 28 '22 20:04 alliepiper

The current failure mode looks pretty reasonable: https://godbolt.org/z/zTPeTTj1z

If you forget the -fopenmp flag in the following code

#define THRUST_HOST_SYSTEM THRUST_HOST_SYSTEM_OMP
#include <thrust/reduce.h>
#include <thrust/host_vector.h>
#include <thrust/execution_policy.h>
#include <iostream>

int main(){

  thrust::host_vector<int> v(10, 1);
  auto r = thrust::reduce(thrust::host, v.begin(), v.end());
  std::cout << r << std::endl;
} 

you get:

error: static assertion failed with "OpenMP compiler support is not enabled"

jrhemstad avatar Mar 07 '23 17:03 jrhemstad