Skip to content

Conversation

@zahiraam
Copy link
Contributor

@zahiraam zahiraam commented Nov 20, 2025

No description provided.

@zahiraam zahiraam changed the title [OpenMP][Clang] Add support for OpenMP6.0 fb_nullify and fb_preserve … [OpenMP][Clang] Add support for OMP6.0 fb_nullify and fb_preserve in need_device_ptr modifier Nov 20, 2025
@github-actions
Copy link

🐧 Linux x64 Test Results

  • 111353 tests passed
  • 4430 tests skipped

@abhinavgaba abhinavgaba changed the title [OpenMP][Clang] Add support for OMP6.0 fb_nullify and fb_preserve in need_device_ptr modifier [OpenMP][Clang] Add support for OMP6.1 fb_nullify and fb_preserve in need_device_ptr modifier Nov 20, 2025
@@ -274,10 +264,12 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
OPENMP_THREADSET_KIND(omp_pool)
OPENMP_THREADSET_KIND(omp_team)

// OpenMP 6.1 modifiers for 'adjust_args' clause.
OPENMP_NEEDDEVICE_MODIFIER(fp_nullify)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: fp should be fb.

@@ -274,10 +264,12 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
OPENMP_THREADSET_KIND(omp_pool)
OPENMP_THREADSET_KIND(omp_team)

// OpenMP 6.1 modifiers for 'adjust_args' clause.
OPENMP_NEEDDEVICE_MODIFIER(fp_nullify)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be specific and use OPENMP_NEED_DEVICE_PTR_MODIFIER, since the fallback is only applicable to need_device_ptr, not need_device_addr.

@@ -5010,6 +4932,37 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
ConsumeToken();
if (Tok.is(tok::colon))
Data.ColonLoc = Tok.getLocation();
if (getLangOpts().OpenMP >= 61) {
// Handle optional need_device_ptr modifier.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should say "Handle the optional fallback argument for the need_device_ptr modifier."

void __attribute__((noinline)) device_impl(int *xp, int *&xpref, int n) {}

#pragma omp declare variant(device_impl) \
adjust_args(need_device_ptr(foo) : xp, xpref) // expected-error{{unknown modifier in 'need_device_ptr' clause (OpenMP 6.1 or later only)}} // expected-error{{expected 'match', 'adjust_args', or 'append_args' clause on 'omp declare variant' directive}}
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message is not really accurate. The clause is adjust_args, modifier is need_device_ptr, and foo here is an argument to the need_device_ptr modifier.

Ideally, we should say something like:

unknown argument for 'need_device_ptr' complex-modifier.
Expected 'fb_nullify' or 'fb_preserve'.

Otherwise, at the very least we should say unknown modifier in 'adjust_args' clause.

: OMPC_NEEDDEVICE_fp_preserve;
} else {
Diag(Tok, diag::err_omp_unknown_need_device_ptr_modifier)
<< (getLangOpts().OpenMP >= 60 ? 1 : 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

getLangOpts().OpenMP >= 60 should it be >=61. Line 4935 checks for >=61.


void __attribute__((noinline)) device_impl(int *xp, int *&xpref, int n) {}

#pragma omp declare variant(device_impl) \
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add 2/3 more cases:

#pragma omp declare variant(device_impl)                                       \
    adjust_args(need_device_ptr(fb_nullify) : xp, xpref)   // no error 
void __attribute__((noinline)) host_entry_a(int *xp, int *&xpref, int n) {}

#pragma omp declare variant(device_impl)                                       \
    adjust_args(need_device_ptr(fb_preserve : xp, xpref)   // no error 
void __attribute__((noinline)) host_entry_a(int *xp, int *&xpref, int n) {} // expected `)`

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I think the LIT tests name should start with need_device_ptr_modifier_<messages/ast_print>.cpp

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.

3 participants