diff --git a/cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py b/cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py index eec6156950..e060b666c7 100644 --- a/cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py +++ b/cscs-checks/microbenchmarks/alloc_speed/alloc_speed.py @@ -27,10 +27,10 @@ def __init__(self, hugepages): self.sys_reference = { 'no': { 'dom:gpu': { - 'time': (1.80, None, 0.10, 's') + 'time': (1.00, None, 0.10, 's') }, 'dom:mc': { - 'time': (2.00, None, 0.10, 's') + 'time': (1.20, None, 0.10, 's') }, 'daint:gpu': { 'time': (1.80, None, 0.10, 's') diff --git a/cscs-checks/microbenchmarks/alloc_speed/src/alloc_speed.cpp b/cscs-checks/microbenchmarks/alloc_speed/src/alloc_speed.cpp index 3627013633..ac44d28bb1 100644 --- a/cscs-checks/microbenchmarks/alloc_speed/src/alloc_speed.cpp +++ b/cscs-checks/microbenchmarks/alloc_speed/src/alloc_speed.cpp @@ -1,21 +1,28 @@ #include #include #include -#include double test_alloc(size_t n) { auto t_start = std::chrono::system_clock::now(); - std::unique_ptr ptr(new char[n]); /* time to allocate + fill */ - std::fill(ptr.get(), ptr.get() + n, 0); + /* memory is allocated using "malloc" since + "std::unique_ptr ptr(new char[n])" + also creates the objects via "new[]" */ + char* ptr = (char*)std::malloc(n); + std::fill(ptr, ptr + n, 0); auto t_alloc_fill = std::chrono::system_clock::now(); - /* time too fill */ - std::fill(ptr.get(), ptr.get() + n, 0); + /* time to fill */ + std::fill(ptr, ptr + n, 0); auto t_alloc_two_fills = std::chrono::system_clock::now(); + /* prevent compiler optimizations */ + t_start += std::chrono::nanoseconds(ptr[0]); + + std::free(ptr); + return std::chrono::duration_cast>((t_alloc_fill - t_start) - (t_alloc_two_fills - t_alloc_fill)).count(); }