Skip to content

[HIPIFY][#2275][feature] Implement nvcc behavior with implicit CUDA headers #2340

@emankov

Description

@emankov

[Synopsis]

The problem is that nvcc automatically pre-includes some CUDA header files at the beginning of ANY compilation unit (not only header files, but also .cu files). They are at least (but probably are not all):

  • cuda_runtime.h (The top-level injection)
  • crt/host_config.h (System check)
  • builtin_types.h (Basic types)
  • device_types.h (enums and structs)
  • host_defines.h (Macro definitions)

Such nvcc behaviour is a design choice by NVIDIA to make writing CUDA device and host code less verbose. It effectively treats CUDA as part of the language environment rather than just an external library, whereas clang reasonably decides that CUDA is a C++ language extension.

nvcc knows which header files are needed for implicit inclusion, and clang doesn't.

[Solution]

  • Implicitly pre-include those CUDA header files during each hipification using hipify-clang.
  • Find all the implicitly pre-included CUDA header files.
  • Provide tests for all those “missing” header files.

Metadata

Metadata

Labels

featureFeature request or implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions