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

omp-single-copyprivate failing #29

Open
tianyizhangcs opened this issue Sep 21, 2018 · 0 comments
Open

omp-single-copyprivate failing #29

tianyizhangcs opened this issue Sep 21, 2018 · 0 comments

Comments

@tianyizhangcs
Copy link
Member

tianyizhangcs commented Sep 21, 2018

failed when num_threads > 5

//  Copyright (c) 2018 Tianyi Zhang
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <stdio.h>
#include <omp.h>
int x = 0, y = 0, Global = 0;
#pragma omp threadprivate(x, y)
float get_int() {
    Global += 1;
    return Global;
}

void use_int(int f, int t) {
    printf("Value = %d, thread = %d\n", f, t);
}


int main() {

    printf("call CopyPrivate from a single thread\n");
#pragma omp single copyprivate(x, y)
    {
        x = get_int();
        y = get_int();
    }
    use_int(x, omp_get_thread_num());
    use_int(y, omp_get_thread_num());

    printf("call CopyPrivate from a parallel region\n");
#pragma omp parallel
    {
#pragma omp single copyprivate(x, y)
        {
            x = get_int();
            y = get_int();
        }
        use_int(x, omp_get_thread_num());
        use_int(y, omp_get_thread_num());
    }
}

@tianyizhangcs tianyizhangcs changed the title omp-single-copyprivate-1var failed omp-single-copyprivate failing Sep 24, 2018
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