From fee7c73cd3b78145814b18c0a9187e57f401de27 Mon Sep 17 00:00:00 2001 From: Victor Holanda Date: Fri, 23 Nov 2018 16:43:45 +0100 Subject: [PATCH 1/6] Add Alloc Speed Test The test is inconclusive. I am still making the PR in order to discuss possible solutions. The allocation times fluctuate from 1.90735e-06 to ~2.5 sec. I am not sure if this is because of the OS memory load by the time of the execution of if this is related to the small memory allocation of the test. --- cscs-checks/prgenv/alloc_speed.py | 79 ++++++++++++++++++++++++++ cscs-checks/prgenv/src/alloc_speed.cpp | 34 +++++++++++ 2 files changed, 113 insertions(+) create mode 100644 cscs-checks/prgenv/alloc_speed.py create mode 100644 cscs-checks/prgenv/src/alloc_speed.cpp diff --git a/cscs-checks/prgenv/alloc_speed.py b/cscs-checks/prgenv/alloc_speed.py new file mode 100644 index 0000000000..fb19176ec0 --- /dev/null +++ b/cscs-checks/prgenv/alloc_speed.py @@ -0,0 +1,79 @@ +from datetime import datetime + +import reframe as rfm +import reframe.utility.sanity as sn + + +@rfm.parameterized_test(*([hugepages] for hugepages in ['no', '2M'])) +class AllocSpeedTest(rfm.RegressionTest): + def __init__(self, hugepages): + super().__init__() + + self.descr = 'Time to allocate 4096 MB using %s hugepages' % hugepages + + self.sourcepath = 'alloc_speed.cpp' + self.build_system = 'SingleSource' + self.build_system.cxxflags = ['-O3'] + + self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc', + 'kesch:cn', 'kesch:pn', 'leone:normal'] + + self.valid_prog_environs = ['PrgEnv-gnu'] + + if not hugepages == 'no': + if self.current_system.name in ['dom', 'daint']: + self.modules = ['craype-hugepages%s' % hugepages] + else: + self.valid_prog_environs = [] + + self.sanity_patterns = sn.assert_found('4096 MB', self.stdout) + + self.perf_patterns = { + 'perf': sn.extractsingle(r'4096 MB, allocation time (?P\S+)', + self.stdout, 'perf', float) + } + + self.sys_reference = { + 'no': { + 'dom:gpu': { + 'perf': (1.80, None, 0.10) + }, + 'dom:mc': { + 'perf': (2.40, None, 0.10) + }, + 'daint:gpu': { + 'perf': (1.80, None, 0.10) + }, + 'daint:mc': { + 'perf': (2.40, None, 0.10) + }, + 'kesch:cn': { + 'perf': (1.80, None, 0.10) + }, + 'kesch:pn': { + 'perf': (1.80, None, 0.10) + }, + 'leone:normal': { + 'perf': (1.80, None, 0.10) + }, + }, + '2M': { + 'dom:gpu': { + 'perf': (0.16, None, 0.10) + }, + 'dom:mc': { + 'perf': (0.50, None, 0.10) + }, + 'daint:gpu': { + 'perf': (0.16, None, 0.10) + }, + 'daint:mc': { + 'perf': (0.50, None, 0.10) + }, + }, + } + self.reference = self.sys_reference[hugepages] + + + self.maintainers = ['CB', 'VH'] + self.tags = {'production'} diff --git a/cscs-checks/prgenv/src/alloc_speed.cpp b/cscs-checks/prgenv/src/alloc_speed.cpp new file mode 100644 index 0000000000..8c786a54d5 --- /dev/null +++ b/cscs-checks/prgenv/src/alloc_speed.cpp @@ -0,0 +1,34 @@ +#include +#include +#include + +/// Wall-clock time in seconds. +inline double wtime() +{ + timeval t; + gettimeofday(&t, NULL); + return double(t.tv_sec) + double(t.tv_usec) / 1e6; +} + +double test_alloc(size_t n) +{ + double t0 = wtime(); + /* time to allocate + fill */ + char* ptr = (char*)std::malloc(n); + std::fill(ptr, ptr + n, 0); + double t1 = wtime(); + /* time fo fill */ + std::fill(ptr, ptr + n, 0); + double t2 = wtime(); + std::free(ptr); + + return (t1 - t0) - (t2 - t1); +} + +int main(int argn, char** argv) +{ + for (int i = 20; i < 33; i++) { + size_t sz = size_t(1) << i; + std::cout << sz / 1024.0 / 1024.0 << " MB, allocation time " << test_alloc(sz) << " sec. \n"; + } +} \ No newline at end of file From 37c3140e89aeb8ceae5011e00c656d3ebaf2880b Mon Sep 17 00:00:00 2001 From: Victor Holanda Rusu Date: Mon, 26 Nov 2018 09:49:27 +0100 Subject: [PATCH 2/6] Prevent compiler optimizaitons on Alloc Speed check --- cscs-checks/prgenv/src/alloc_speed.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cscs-checks/prgenv/src/alloc_speed.cpp b/cscs-checks/prgenv/src/alloc_speed.cpp index 8c786a54d5..b22798edab 100644 --- a/cscs-checks/prgenv/src/alloc_speed.cpp +++ b/cscs-checks/prgenv/src/alloc_speed.cpp @@ -20,6 +20,7 @@ double test_alloc(size_t n) /* time fo fill */ std::fill(ptr, ptr + n, 0); double t2 = wtime(); + t0 += ptr[0]; std::free(ptr); return (t1 - t0) - (t2 - t1); From 3bf6c835db053b1d54b35149290350d17547e31b Mon Sep 17 00:00:00 2001 From: Victor Holanda Date: Fri, 30 Nov 2018 09:01:25 +0100 Subject: [PATCH 3/6] Add Anton as maintainer and fix style --- cscs-checks/prgenv/alloc_speed.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cscs-checks/prgenv/alloc_speed.py b/cscs-checks/prgenv/alloc_speed.py index fb19176ec0..da774919dc 100644 --- a/cscs-checks/prgenv/alloc_speed.py +++ b/cscs-checks/prgenv/alloc_speed.py @@ -74,6 +74,5 @@ def __init__(self, hugepages): } self.reference = self.sys_reference[hugepages] - - self.maintainers = ['CB', 'VH'] + self.maintainers = ['AK', 'VH'] self.tags = {'production'} From 12ab953060b08c4bb31c40c453a322c006d47743 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 5 Dec 2018 13:23:37 +0100 Subject: [PATCH 4/6] Use 'chrono' utilities for time measurements --- cscs-checks/prgenv/alloc_speed.py | 5 +---- cscs-checks/prgenv/src/alloc_speed.cpp | 22 +++++++--------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/cscs-checks/prgenv/alloc_speed.py b/cscs-checks/prgenv/alloc_speed.py index da774919dc..dfdd0df05b 100644 --- a/cscs-checks/prgenv/alloc_speed.py +++ b/cscs-checks/prgenv/alloc_speed.py @@ -1,5 +1,3 @@ -from datetime import datetime - import reframe as rfm import reframe.utility.sanity as sn @@ -10,10 +8,9 @@ def __init__(self, hugepages): super().__init__() self.descr = 'Time to allocate 4096 MB using %s hugepages' % hugepages - self.sourcepath = 'alloc_speed.cpp' self.build_system = 'SingleSource' - self.build_system.cxxflags = ['-O3'] + self.build_system.cxxflags = ['-O3', '-std=c++11'] self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc', 'kesch:cn', 'kesch:pn', 'leone:normal'] diff --git a/cscs-checks/prgenv/src/alloc_speed.cpp b/cscs-checks/prgenv/src/alloc_speed.cpp index b22798edab..cd35f85235 100644 --- a/cscs-checks/prgenv/src/alloc_speed.cpp +++ b/cscs-checks/prgenv/src/alloc_speed.cpp @@ -1,29 +1,21 @@ -#include +#include #include #include -/// Wall-clock time in seconds. -inline double wtime() -{ - timeval t; - gettimeofday(&t, NULL); - return double(t.tv_sec) + double(t.tv_usec) / 1e6; -} - double test_alloc(size_t n) { - double t0 = wtime(); + auto t0 = std::chrono::system_clock::now(); /* time to allocate + fill */ char* ptr = (char*)std::malloc(n); std::fill(ptr, ptr + n, 0); - double t1 = wtime(); + auto t1 = std::chrono::system_clock::now(); /* time fo fill */ std::fill(ptr, ptr + n, 0); - double t2 = wtime(); - t0 += ptr[0]; + auto t2 = std::chrono::system_clock::now(); + t0 += static_cast(ptr[0]); std::free(ptr); - return (t1 - t0) - (t2 - t1); + return std::chrono::duration_cast>((t1 - t0) - (t2 - t1)).count(); } int main(int argn, char** argv) @@ -32,4 +24,4 @@ int main(int argn, char** argv) size_t sz = size_t(1) << i; std::cout << sz / 1024.0 / 1024.0 << " MB, allocation time " << test_alloc(sz) << " sec. \n"; } -} \ No newline at end of file +} From 54a1573f89060421ba085b8f68b97d7e68424822 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Mon, 7 Jan 2019 16:59:19 +0100 Subject: [PATCH 5/6] Address PR comments --- .../alloc_speed}/alloc_speed.py | 48 ++++++++----------- .../alloc_speed/src/alloc_speed.cpp | 30 ++++++++++++ cscs-checks/prgenv/src/alloc_speed.cpp | 27 ----------- 3 files changed, 49 insertions(+), 56 deletions(-) rename cscs-checks/{prgenv => microbenchmarks/alloc_speed}/alloc_speed.py (54%) create mode 100644 cscs-checks/microbenchmarks/alloc_speed/src/alloc_speed.cpp delete mode 100644 cscs-checks/prgenv/src/alloc_speed.cpp diff --git a/cscs-checks/prgenv/alloc_speed.py b/cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py similarity index 54% rename from cscs-checks/prgenv/alloc_speed.py rename to cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py index dfdd0df05b..c3a2b5c490 100644 --- a/cscs-checks/prgenv/alloc_speed.py +++ b/cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py @@ -2,7 +2,7 @@ import reframe.utility.sanity as sn -@rfm.parameterized_test(*([hugepages] for hugepages in ['no', '2M'])) +@rfm.parameterized_test(['no'], ['2M']) class AllocSpeedTest(rfm.RegressionTest): def __init__(self, hugepages): super().__init__() @@ -11,61 +11,51 @@ def __init__(self, hugepages): self.sourcepath = 'alloc_speed.cpp' self.build_system = 'SingleSource' self.build_system.cxxflags = ['-O3', '-std=c++11'] - - self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc', - 'kesch:cn', 'kesch:pn', 'leone:normal'] - + self.valid_systems = ['daint:gpu', 'daint:mc', 'dom:gpu', 'dom:mc'] self.valid_prog_environs = ['PrgEnv-gnu'] - - if not hugepages == 'no': - if self.current_system.name in ['dom', 'daint']: - self.modules = ['craype-hugepages%s' % hugepages] - else: - self.valid_prog_environs = [] + if hugepages == 'no': + self.valid_systems += ['kesch:cn', 'kesch:pn'] + else: + self.modules = ['craype-hugepages%s' % hugepages] self.sanity_patterns = sn.assert_found('4096 MB', self.stdout) - self.perf_patterns = { - 'perf': sn.extractsingle(r'4096 MB, allocation time (?P\S+)', - self.stdout, 'perf', float) + 'time': sn.extractsingle(r'4096 MB, allocation time (?P