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

Scoping concern about outlining an OpenMP loop #149

Open
ouankou opened this issue Jan 6, 2023 · 0 comments
Open

Scoping concern about outlining an OpenMP loop #149

ouankou opened this issue Jan 6, 2023 · 0 comments

Comments

@ouankou
Copy link
Contributor

ouankou commented Jan 6, 2023

Moving the declaration of the loop control variable during the normalization of an OpenMP loop may cause a declaration issue because of scoping change. After some thinking and testing on REX, in my opinion, this probably won't be an issue. Given the following AXPY example:

int i = 10; // i(1), scope 1
#pragma omp target parallel for map(...)
  for (int i = 0; i < n; ++i) // i(2), scope 2
    y[i] += a * x[i];

In this case, two symbols i(1) and i(2) share the same name, but it's OK because they are in different scopes. To lower the directive, we move int i(2) out of the loop. It seems like a declaration conflict will happen. However, before doing that, we always outline first so that the OpenMP code will all go to another function. Thus, an intermediate status of lowering would be something like this:

__global__ void outlined_func(...) {
// waiting for loop normalization and transformation
  for (int i = 0; i < n; ++i) // i(2)
    y[i] += a * x[i];
}

int i = 10; // i(1), scope 1
{
  // some statements for GPU kernel call.
}

In this case, i(2) is not even part of the outlined function parameter because its declaration is always inside the outlining region.

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

No branches or pull requests

1 participant