From dd76036064f2f18fa3589d2ff93add4ec428f5cd Mon Sep 17 00:00:00 2001 From: jgp Date: Sun, 2 Dec 2018 11:13:59 +0100 Subject: [PATCH 1/5] mpi_init_thread Signed-off-by: jgp --- cscs-checks/prgenv/mpi.py | 46 ++++++++++++ cscs-checks/prgenv/src/mpi_init_thread.cpp | 82 ++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 cscs-checks/prgenv/mpi.py create mode 100644 cscs-checks/prgenv/src/mpi_init_thread.cpp diff --git a/cscs-checks/prgenv/mpi.py b/cscs-checks/prgenv/mpi.py new file mode 100644 index 0000000000..6a3dd4db82 --- /dev/null +++ b/cscs-checks/prgenv/mpi.py @@ -0,0 +1,46 @@ +import reframe as rfm +import reframe.utility.sanity as sn + + +@rfm.required_version('>=2.14') +@rfm.parameterized_test(['single'], ['funneled'], ['serialized'], ['multiple']) +class Mpi_InitTest(rfm.RegressionTest): + def __init__(self, required_thread): + super().__init__() + self.descr = 'MPI_Init_thread ' + required_thread + self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] + self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', + 'PrgEnv-intel', 'PrgEnv-pgi'] + self.build_system = 'SingleSource' + self.sourcepath = 'mpi_init_thread.cpp' + self.cppflags = { + 'single': ['-D_MPI_THREAD_SINGLE'], + 'funneled': ['-D_MPI_THREAD_FUNNELED'], + 'serialized': ['-D_MPI_THREAD_SERIALIZED'], + 'multiple': ['-D_MPI_THREAD_MULTIPLE'] + } + self.build_system.cppflags = self.cppflags[required_thread] + ['-static'] + self.time_limit = (0, 1, 0) + found_mpithread = sn.extractsingle( + r'^mpi_thread_required=\w+\s+mpi_thread_supported=(?P\w+)\s+mpi_thread_queried=(?P\w+)\s+(?P\d)$', + self.stdout, 3, int) + self.mpithread_version = { + 'single': 0, + 'funneled': 1, + 'serialized': 2, + 'multiple': 2 + # Output should look the same for every prgenv (cray, gnu, intel, pgi) / mpi_thread_multiple not supported: + # 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], + # 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], + # 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], + # 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] + } + + self.sanity_patterns = sn.all([ + sn.assert_found(r'tid=0 out of 1 from rank \s*(\d+) out of \s*(\d+)', + self.stdout), + sn.assert_eq(found_mpithread, self.mpithread_version[required_thread]) + ]) + + self.maintainers = ['JG'] + self.tags = {'production'} diff --git a/cscs-checks/prgenv/src/mpi_init_thread.cpp b/cscs-checks/prgenv/src/mpi_init_thread.cpp new file mode 100644 index 0000000000..78d25876d3 --- /dev/null +++ b/cscs-checks/prgenv/src/mpi_init_thread.cpp @@ -0,0 +1,82 @@ +// testing MPI_Init_thread +#include +#include +#include +using namespace std; + +int main(int argc, char **argv) { + int rank, size, mpiversion, mpisubversion; + int resultlen = -1, mpi_thread_supported=-1; + char mpilibversion[MPI_MAX_LIBRARY_VERSION_STRING]; + +// -------------------------------------------------------------------------- +// int MPI_Init_thread( int *argc, char ***argv, int required, int *provided ) +// +// { MPI_THREAD_SINGLE} +// Only one thread will execute. +// +// { MPI_THREAD_FUNNELED} +// The process may be multi-threaded, but only the main thread will make MPI calls +// (all MPI calls are funneled to the main thread). +// +// { MPI_THREAD_SERIALIZED} +// The process may be multi-threaded, and multiple threads may make MPI calls, but +// only one at a time: MPI calls are not made concurrently from two distinct +// threads (all MPI calls are serialized). +// +// { MPI_THREAD_MULTIPLE} +// Multiple threads may call MPI, with no restrictions. +// -------------------------------------------------------------------------- + +#if defined(_MPI_THREAD_SINGLE) + cout << "mpi_thread_required=MPI_THREAD_SINGLE "; + int ev = MPI_Init_thread( 0,0, MPI_THREAD_SINGLE, &mpi_thread_supported ); +#elif defined(_MPI_THREAD_FUNNELED) + cout << "mpi_thread_required=MPI_THREAD_FUNNELED "; + int ev = MPI_Init_thread( 0,0, MPI_THREAD_FUNNELED, &mpi_thread_supported ); +#elif defined(_MPI_THREAD_SERIALIZED) + cout << "mpi_thread_required=MPI_THREAD_SERIALIZED "; + int ev = MPI_Init_thread( 0,0, MPI_THREAD_SERIALIZED, &mpi_thread_supported ); +#elif defined(_MPI_THREAD_MULTIPLE) + cout << "mpi_thread_required=MPI_THREAD_MULTIPLE "; + int ev = MPI_Init_thread( 0,0, MPI_THREAD_MULTIPLE, &mpi_thread_supported ); +#else + cout << "mpi_thread_required=none "; + int ev = MPI_Init(0,0); +#endif + + switch ( mpi_thread_supported ) + { + case MPI_THREAD_SINGLE: cout << "mpi_thread_supported=MPI_THREAD_SINGLE" ; break; + case MPI_THREAD_FUNNELED: cout << "mpi_thread_supported=MPI_THREAD_FUNNELED" ; break; + case MPI_THREAD_SERIALIZED: cout << "mpi_thread_supported=MPI_THREAD_SERIALIZED" ;break; + case MPI_THREAD_MULTIPLE: cout << "mpi_thread_supported=MPI_THREAD_MULTIPLE" ; break; + default: cout << "mpi_thread_supported=UNKNOWN" ; + } + + // Return the level of thread support provided by the MPI library: + int mpi_thread_required=-1; + MPI_Query_thread( &mpi_thread_required ); + switch ( mpi_thread_supported ) + { + case MPI_THREAD_SINGLE: cout << " mpi_thread_queried=MPI_THREAD_SINGLE " << mpi_thread_required << std::endl; break; + case MPI_THREAD_FUNNELED: cout << " mpi_thread_queried=MPI_THREAD_FUNNELED " << mpi_thread_required << std::endl; break; + case MPI_THREAD_SERIALIZED: cout << " mpi_thread_queried=MPI_THREAD_SERIALIZED "<< mpi_thread_required << std::endl; break; + case MPI_THREAD_MULTIPLE: cout << " mpi_thread_queried=MPI_THREAD_MULTIPLE " << mpi_thread_required << std::endl; break; + default: cout << " mpi_thread_queried=UNKNOWN " << mpi_thread_required << std::endl; + } + + MPI_Get_version( &mpiversion, &mpisubversion ); + MPI_Get_library_version(mpilibversion, &resultlen); + printf( "# MPI-%d.%d = %s", mpiversion, mpisubversion, mpilibversion); + + rank = MPI::COMM_WORLD.Get_rank(); + size = MPI::COMM_WORLD.Get_size(); + cout << "tid=0 out of 1 from rank " << rank << " out of " << size << "\n"; + + //std::cout << " mpi_thread_queried=" << mpi_thread_required << std::endl; + + MPI::Finalize(); + + return 0; +} /* end func main */ From 3122756caa398ff5c756822db5e54276c0e8bae1 Mon Sep 17 00:00:00 2001 From: jgp Date: Tue, 4 Dec 2018 10:42:14 +0100 Subject: [PATCH 2/5] requested changes Signed-off-by: jgp --- cscs-checks/prgenv/mpi.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cscs-checks/prgenv/mpi.py b/cscs-checks/prgenv/mpi.py index 6a3dd4db82..9cdea01530 100644 --- a/cscs-checks/prgenv/mpi.py +++ b/cscs-checks/prgenv/mpi.py @@ -7,7 +7,6 @@ class Mpi_InitTest(rfm.RegressionTest): def __init__(self, required_thread): super().__init__() - self.descr = 'MPI_Init_thread ' + required_thread self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] self.valid_prog_environs = ['PrgEnv-cray', 'PrgEnv-gnu', 'PrgEnv-intel', 'PrgEnv-pgi'] @@ -19,27 +18,32 @@ def __init__(self, required_thread): 'serialized': ['-D_MPI_THREAD_SERIALIZED'], 'multiple': ['-D_MPI_THREAD_MULTIPLE'] } - self.build_system.cppflags = self.cppflags[required_thread] + ['-static'] + #self.build_system.cppflags = self.cppflags[required_thread] + ['-static'] + self.build_system.cppflags = self.cppflags[required_thread] + self.build_system.cppflags += ['-static'] self.time_limit = (0, 1, 0) found_mpithread = sn.extractsingle( - r'^mpi_thread_required=\w+\s+mpi_thread_supported=(?P\w+)\s+mpi_thread_queried=(?P\w+)\s+(?P\d)$', + r'^mpi_thread_required=\w+\s+mpi_thread_supported=(?P\w+)' + r'\s+mpi_thread_queried=(?P\w+)\s+(?P\d)$', self.stdout, 3, int) self.mpithread_version = { 'single': 0, 'funneled': 1, 'serialized': 2, 'multiple': 2 - # Output should look the same for every prgenv (cray, gnu, intel, pgi) / mpi_thread_multiple not supported: - # 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], - # 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], - # 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], - # 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] +# Output should look the same for every prgenv (cray, gnu, intel, pgi) / mpi_thread_multiple not supported: +# 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], +# 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], +# 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], +# 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] } self.sanity_patterns = sn.all([ - sn.assert_found(r'tid=0 out of 1 from rank \s*(\d+) out of \s*(\d+)', - self.stdout), - sn.assert_eq(found_mpithread, self.mpithread_version[required_thread]) + sn.assert_found( + r'tid=0 out of 1 from rank \s*(\d+) out of \s*(\d+)', + self.stdout), + sn.assert_eq(found_mpithread, + self.mpithread_version[required_thread]) ]) self.maintainers = ['JG'] From 237c60a737d6ca95ab98165e4e83c31f1c740c35 Mon Sep 17 00:00:00 2001 From: jgp Date: Tue, 15 Jan 2019 15:03:29 +0100 Subject: [PATCH 3/5] fixes to resolve the discussion --- cscs-checks/prgenv/mpi.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/cscs-checks/prgenv/mpi.py b/cscs-checks/prgenv/mpi.py index 9cdea01530..7e89a96aa2 100644 --- a/cscs-checks/prgenv/mpi.py +++ b/cscs-checks/prgenv/mpi.py @@ -1,10 +1,18 @@ import reframe as rfm import reframe.utility.sanity as sn - @rfm.required_version('>=2.14') @rfm.parameterized_test(['single'], ['funneled'], ['serialized'], ['multiple']) class Mpi_InitTest(rfm.RegressionTest): + ''' + This test checks the value returned by calling MPI_Init_thread: + Output should look the same for every prgenv (cray, gnu, intel, pgi) + (mpi_thread_multiple seems to be not supported): + # 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], + # 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], + # 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], + # 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] + ''' def __init__(self, required_thread): super().__init__() self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] @@ -18,29 +26,22 @@ def __init__(self, required_thread): 'serialized': ['-D_MPI_THREAD_SERIALIZED'], 'multiple': ['-D_MPI_THREAD_MULTIPLE'] } - #self.build_system.cppflags = self.cppflags[required_thread] + ['-static'] self.build_system.cppflags = self.cppflags[required_thread] self.build_system.cppflags += ['-static'] self.time_limit = (0, 1, 0) found_mpithread = sn.extractsingle( - r'^mpi_thread_required=\w+\s+mpi_thread_supported=(?P\w+)' - r'\s+mpi_thread_queried=(?P\w+)\s+(?P\d)$', - self.stdout, 3, int) + r'^mpi_thread_required=\w+\s+mpi_thread_supported=\w+' + r'\s+mpi_thread_queried=\w+\s+(?P\d)$', + self.stdout, 1, int) self.mpithread_version = { 'single': 0, 'funneled': 1, 'serialized': 2, 'multiple': 2 -# Output should look the same for every prgenv (cray, gnu, intel, pgi) / mpi_thread_multiple not supported: -# 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], -# 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], -# 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], -# 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] } self.sanity_patterns = sn.all([ - sn.assert_found( - r'tid=0 out of 1 from rank \s*(\d+) out of \s*(\d+)', + sn.assert_found(r'tid=0 out of 1 from rank 0 out of 1', self.stdout), sn.assert_eq(found_mpithread, self.mpithread_version[required_thread]) From ac1f77eed39eaf6fb52aa68be94508c78298f815 Mon Sep 17 00:00:00 2001 From: jgp Date: Tue, 15 Jan 2019 15:23:52 +0100 Subject: [PATCH 4/5] pep8 --- cscs-checks/prgenv/mpi.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/cscs-checks/prgenv/mpi.py b/cscs-checks/prgenv/mpi.py index 7e89a96aa2..3c7058a037 100644 --- a/cscs-checks/prgenv/mpi.py +++ b/cscs-checks/prgenv/mpi.py @@ -1,18 +1,28 @@ import reframe as rfm import reframe.utility.sanity as sn + @rfm.required_version('>=2.14') @rfm.parameterized_test(['single'], ['funneled'], ['serialized'], ['multiple']) class Mpi_InitTest(rfm.RegressionTest): ''' - This test checks the value returned by calling MPI_Init_thread: - Output should look the same for every prgenv (cray, gnu, intel, pgi) - (mpi_thread_multiple seems to be not supported): - # 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], - # 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], - # 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], - # 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] +This test checks the value returned by calling MPI_Init_thread: +Output should look the same for every prgenv (cray, gnu, intel, pgi) +(mpi_thread_multiple seems to be not supported): + # 'single': + ['mpi_thread_supported=MPI_THREAD_SINGLE + mpi_thread_queried=MPI_THREAD_SINGLE 0'], + # 'funneled': + ['mpi_thread_supported=MPI_THREAD_FUNNELED + mpi_thread_queried=MPI_THREAD_FUNNELED 1'], + # 'serialized': + ['mpi_thread_supported=MPI_THREAD_SERIALIZED + mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], + # 'multiple': + ['mpi_thread_supported=MPI_THREAD_SERIALIZED + mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] ''' + def __init__(self, required_thread): super().__init__() self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] @@ -26,7 +36,7 @@ def __init__(self, required_thread): 'serialized': ['-D_MPI_THREAD_SERIALIZED'], 'multiple': ['-D_MPI_THREAD_MULTIPLE'] } - self.build_system.cppflags = self.cppflags[required_thread] + self.build_system.cppflags = self.cppflags[required_thread] self.build_system.cppflags += ['-static'] self.time_limit = (0, 1, 0) found_mpithread = sn.extractsingle( @@ -39,13 +49,11 @@ def __init__(self, required_thread): 'serialized': 2, 'multiple': 2 } - self.sanity_patterns = sn.all([ sn.assert_found(r'tid=0 out of 1 from rank 0 out of 1', - self.stdout), + self.stdout), sn.assert_eq(found_mpithread, self.mpithread_version[required_thread]) ]) - self.maintainers = ['JG'] self.tags = {'production'} From 709a4faace418b5da4da3ea11d7873b211e64cf0 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sat, 19 Jan 2019 00:00:20 +0100 Subject: [PATCH 5/5] Fix comment formatting --- cscs-checks/prgenv/mpi.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cscs-checks/prgenv/mpi.py b/cscs-checks/prgenv/mpi.py index 3c7058a037..0c74f12ee0 100644 --- a/cscs-checks/prgenv/mpi.py +++ b/cscs-checks/prgenv/mpi.py @@ -4,24 +4,29 @@ @rfm.required_version('>=2.14') @rfm.parameterized_test(['single'], ['funneled'], ['serialized'], ['multiple']) -class Mpi_InitTest(rfm.RegressionTest): - ''' -This test checks the value returned by calling MPI_Init_thread: -Output should look the same for every prgenv (cray, gnu, intel, pgi) -(mpi_thread_multiple seems to be not supported): +class MpiInitTest(rfm.RegressionTest): + """This test checks the value returned by calling MPI_Init_thread. + + Output should look the same for every prgenv (cray, gnu, intel, pgi) + (mpi_thread_multiple seems to be not supported): + # 'single': ['mpi_thread_supported=MPI_THREAD_SINGLE mpi_thread_queried=MPI_THREAD_SINGLE 0'], + # 'funneled': ['mpi_thread_supported=MPI_THREAD_FUNNELED mpi_thread_queried=MPI_THREAD_FUNNELED 1'], + # 'serialized': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'], + # 'multiple': ['mpi_thread_supported=MPI_THREAD_SERIALIZED mpi_thread_queried=MPI_THREAD_SERIALIZED 2'] - ''' + + """ def __init__(self, required_thread): super().__init__()