Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Make <nv/target> usable in C and C++98 compilations #177

Merged
merged 1 commit into from
Jul 8, 2021
Merged

Conversation

dkolsen-pgi
Copy link
Collaborator

The features of <nv/target> are only available in C++11 CUDA mode. But some headers that use <nv/target> can be compiled, with limited functionality, as C or as C++98. <nv/target> needs to do the same.

This change allows <nv/target> to be included successfully when compiling as C or as C++98. In this situation, "if target" won't
work because the namespace nv::target won't exist, and the compatibility macros will assume host-only.

@dkolsen-pgi dkolsen-pgi requested a review from wmaxey July 1, 2021 18:41
@wmaxey
Copy link
Member

wmaxey commented Jul 1, 2021

We have no configured C++03 testing or compiler configurations, were you able to run this on NVC++ and others yourself?

@wmaxey wmaxey added this to the 1.6.0 milestone Jul 1, 2021
@wmaxey wmaxey added bug: functional Does not work as intended. P0: must have Absolutely must ship with the milestone. labels Jul 1, 2021
@dkolsen-pgi
Copy link
Collaborator Author

I manually tested the change by compiling this program every way I could, with and without CUDA turned on, with nvcc, nvc++, and gcc, and as C, C++98, C++11, and C++14.

#include <stdio.h>
#include <nv/target>
int main() {
  NV_IF_TARGET(NV_IS_HOST, (
    printf("Passed\n");
  ), (
    printf("FAILED: This block should never be run.\n");
  ));
}

The features of <nv/target> are only available in C++11 CUDA mode.
But some headers that use <nv/target> can be compiled, with limited
functionality, as C or as C++98.  <nv/target> needs to do the same.

This change allows <nv/target> to be included successfully when
compiling as C or as C++98.  In this situation, "if target" won't
work because the namespace nv::target won't exist, and the
compatibility macros will assume host-only.
@wmaxey wmaxey force-pushed the bug/nv-target-c branch from 71097f6 to abf8fa0 Compare July 7, 2021 22:15
@wmaxey
Copy link
Member

wmaxey commented Jul 7, 2021

Rebased and launched virtual, I will submit when clean.

http://scdvs.nvidia.com/Build_Results?virtualId=1000072758&which_page=current_build

@wmaxey wmaxey merged commit 3cf5a0f into main Jul 8, 2021
@wmaxey wmaxey deleted the bug/nv-target-c branch July 8, 2021 04:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: functional Does not work as intended. P0: must have Absolutely must ship with the milestone.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants