A standard algorithm capturing a vector
#include <vector>
#include <algorithm>
#include <execution>
auto main() -> int
{
std::vector const a = {1u, 0u};
std::vector const b = {5., 7.};
std::vector c = {6., 8.};
std::vector const expected = {7., 5.};
std::transform(
std::execution::par_unseq,
std::cbegin(a), std::cend(a),
std::begin(c),
[b](size_t ind){return b[ind];}
);
auto const success = (expected == c);
if(success) return EXIT_SUCCESS;
else return EXIT_FAILURE;
}
compiles with NVIDIA HPC SDK 22.5 and gcc-10.2.1 for a target with compute capability 70, but fails to compile with NVIDIA HPC SDK 22.7 and gcc-11.2.0 for a target with compute capability 80, giving error
Bitcasts between pointers of different address spaces is not legal.Use AddrSpaceCast instead.
%5 = bitcast double* %storemerge.i.i.i to i8 addrspace(1)*
A similar code capturing a span compiles on both the platforms:
#include <vector>
#include <algorithm>
#include <execution>
#include <span>
auto main() -> int
{
std::vector const a = {1u, 0u};
std::vector const b = {5., 7.};
std::vector c = {6., 8.};
std::vector const expected = {7., 5.};
auto handleB = std::span(b);
std::transform(
std::execution::par_unseq,
std::cbegin(a), std::cend(a),
std::begin(c),
[handleB](size_t ind){return handleB[ind];}
);
auto const success = (expected == c);
if(success) return EXIT_SUCCESS;
else return EXIT_FAILURE;
}
Is it supposed to compile in the first place, and what is the source of the difference?