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

Add omp API for omp set get nested which is need by mkl #58

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/intel_hpxMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,4 +1002,11 @@ void omp_unset_nest_lock(omp_lock_t **lock) {
(*lock)->unlock();
}

void omp_set_nested(int val){
#if defined DEBUG && defined HPXMP_HAVE_TRACE
std::cout<<"hpxMP always sets nested to true"<<std::endl;
#endif
start_backend();
};
int omp_get_nested(){return 1;};

3 changes: 3 additions & 0 deletions src/intel_hpxMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ extern "C" void omp_unset_nest_lock(omp_lock_t **lock);
extern "C" int omp_test_lock(omp_lock_t **lock);
extern "C" int omp_test_nest_lock(omp_lock_t **lock);

extern "C" void omp_set_nested(int val);
extern "C" int omp_get_nested();

#if HPXMP_HAVE_OMP_50_ENABLED
extern "C" void *__kmpc_task_reduction_init(int gtid, int num, void *data);
extern "C" void *__kmpc_task_reduction_get_th_data(int gtid, void *tskgrp, void *data);
Expand Down
1 change: 1 addition & 0 deletions tests/openmp/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(tests
for_static
master
max_threads
omp_set_get_nested
par_for
par_nested
par_single
Expand Down
34 changes: 34 additions & 0 deletions tests/openmp/unit/omp_set_get_nested.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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 <iostream>
#include <stdio.h>
#include <omp.h>

using namespace std;

int main()
{
int number;
int i;
omp_set_num_threads(4);
omp_set_nested(1); // 1 - enables nested parallelism; 0 - disables nested parallelism.

#pragma omp parallel // parallel region begins
{
printf("outer parallel region Thread ID == %d\n", omp_get_thread_num());
/*
Code for work to be done by outer parallel region threads over here.
*/
#pragma omp parallel num_threads(2) // nested parallel region
{
/*
Code for work to be done by inner parallel region threads over here.
*/
printf("inner parallel region thread id %d\n", omp_get_thread_num());
}
}
return 0;
}