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

[OpenMP] Runtime assertion failure (barrier on a single thread with target tasks) #81488

Open
rpereira-dev opened this issue Feb 12, 2024 · 5 comments
Assignees
Labels

Comments

@rpereira-dev
Copy link

rpereira-dev commented Feb 12, 2024

OpenMP runtime assertion failure when executing a barrier on a single thread with target tasks, built from source commit 35fae04

main.c

# include <omp.h>

# define Nz  8
# define DEVICE_ID  0

int
main(void)
{
    # pragma omp parallel
    {
        # pragma omp single
        {
            # pragma omp target teams distribute parallel for nowait device(DEVICE_ID)
            for (int i = 0 ; i < Nz ; ++i)
                {}
        }
        # pragma omp barrier
    }
    return 0;
}

Command line

clang -Wall -Werror -Wextra -fopenmp -O0 -g main.c
OMP_NUM_THREADS=1 ./a.out

Output

Assertion failure at kmp_runtime.cpp(2460): master_th->th.th_task_team == team->t.t_task_team[master_th->th.th_task_state].
OMP: Error #13: Assertion failure at kmp_runtime.cpp(2460).

Insights

  • Using OMP_NUM_THREADS>1 lead to successful termination
  • Removing the target tasks lead to successful termination
  • Removing the explicit barrier lead to successful termination
  • Setting LIBOMP_USE_HIDDEN_HELPER_TASK=0 lead to successful termination

I believe this may be related to HHTs

@rpereira-dev rpereira-dev changed the title OpenMP runtime assertion failure (barrier on a single thread with target tasks) [OpenMP] Runtime assertion failure (barrier on a single thread with target tasks) Feb 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 12, 2024

@llvm/issue-subscribers-openmp

Author: PEREIRA Romain (rpereira-dev)

OpenMP runtime assertion failure when executing a barrier on a single thread with target tasks, built from source commit 35fae04

main.c

# include &lt;omp.h&gt;

# define Nz  8
# define DEVICE_ID  0

int
main(void)
{
    # pragma omp parallel
    {
        # pragma omp single
        {
            # pragma omp target teams distribute parallel for nowait device(DEVICE_ID)
            for (int i = 0 ; i &lt; Nz ; ++i)
                {}
        }
        # pragma omp barrier
    }
    return 0;
}

Command line

clang -Wall -Werror -Wextra -fopenmp -O0 -g main.c
OMP_NUM_THREADS=1 ./a.out

Output

Assertion failure at kmp_runtime.cpp(2460): master_th-&gt;th.th_task_team == team-&gt;t.t_task_team[master_th-&gt;th.th_task_state].
OMP: Error #<!-- -->13: Assertion failure at kmp_runtime.cpp(2460).

Insights

  • Using OMP_NUM_THREADS>1 lead to successful termination
  • Removing the target tasks lead to successful termination
  • Removing the explicit barrier lead to successful termination
  • Setting LIBOMP_USE_HIDDEN_HELPER_TASK=0 lead to successful termination

I believe this may be related to HHTs

@shiltian
Copy link
Contributor

It looks like similar to #50602. The task team "optimization" literally has a lot of inconsistency.
cc @lwshanbd

@lwshanbd
Copy link
Contributor

lwshanbd commented Mar 6, 2024

It looks like similar to #50602. The task team "optimization" literally has a lot of inconsistency. cc @lwshanbd

I am interested in this. Could you assign it to me? @shiltian

@EugeneZelenko
Copy link
Contributor

@lwshanbd: Just create pull request and mention it on this page.

@lwshanbd
Copy link
Contributor

The bug arises from the lack of synchronization for task team when the team is serialized. PR is created.

lwshanbd added a commit to lwshanbd/llvm-project that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants