Skip to content

[Build] MSVC Compiler Bug affecting thrust library in CUDA Backend #3565

@edwinsolisf

Description

@edwinsolisf

When compiling the cuda backend with MSVC 19.40, it reports an error for template specialization of a function inside an inline namespace. It has been verified that neither clang nor gcc find this problem

Description

ArrayFire uses a template specialization for the get_stream function in thrust::cuda_cub; however the original template of get_stream is defined inside an inline namespace described in the THRUST_NAMESPACE_BEGIN macro. As MSVC has a problem with template specialization outside of the inline namespace where the function was defined, which is valid C++, it fails to compile.

A solution while the compiler bug gets patch is to replace the namespace thrust { in src/backend/cuda/ThrustArrayFirePolicy.hpp with THRUST_NAMESPACE_BEGIN to force the template specialization be inside the same inline namespace.

Error Log

ThrustArrayFirePolicy.hpp(43): error : get_stream is not a template
1>          __declspec(__host__) __declspec(__device__) inline cudaStream_t get_stream<ThrustArrayFirePolicy>(

Build Environment

Compiler version: MSVC 19.40
Operating system: Windows 11

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions