Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Address ignored annotation nvcc warnings on explicitly-defaulted functions #4291

Merged

Conversation

chellmuth
Copy link
Contributor

Description

We're seeing nvcc compilation warnings like the following:

ustring.h(869): warning #20012-D: __device__ annotation is ignored on a function("operator=") that is explicitly defaulted on its first declaration
     __attribute__((host)) __attribute__((device)) 

According to nvidia's documentation (https://docs.nvidia.com/cuda/archive/10.1/cuda-c-programming-guide/index.html#compiler-generated-functions), functions that are explicitly-defaulted should not have execution space specifiers like __device__ or __host__. Instead the compiler will determine the annotations from the functions that invoke it.

This patch goes through the ustring and typedesc headers and removes OIIO_HOSTDEVICE from all defaulted functions.

Tests

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

… functions

For explicitly-defaulted functions, execution space specifiers are
inferred from the function's callers.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will merge when CI finishes.

@lgritz
Copy link
Collaborator

lgritz commented Jun 12, 2024

Instead the compiler will determine the annotations from the functions that invoke it.

WhY cAn'T aLl FuNcTiOnS dO tHiS, NVIDIA? Aaaaaah!

@lgritz lgritz merged commit 762fe7b into AcademySoftwareFoundation:master Jun 12, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants