diff --git a/apps/tests/CMakeLists.txt b/apps/tests/CMakeLists.txt index 33363eb3b..e4ad98cdc 100644 --- a/apps/tests/CMakeLists.txt +++ b/apps/tests/CMakeLists.txt @@ -4,7 +4,8 @@ test_mpi_grid;test_enu;test_eigen;test_gemm;test_wf_inner;test_memop;test_gvec_s test_mem_pool;test_mem_alloc;test_examples;test_mpi_p2p_cyclic;test_pw_sph_exp;test_mpi_p2p;\ test_wf_ortho;test_mixer;test_davidson;test_lapw_xc;test_phase;test_fp;test_pppw_xc;\ test_atomic_orbital_index;test_sym;test_blacs;test_reduce;test_mpi_comm_split;test_wf_trans;\ -test_wf_fft;test_potrf;test_lr_solver;test_radial_solver;test_radial_dirac;test_radial_schroed;test_iter_gvec") +test_wf_fft;test_potrf;test_lr_solver;test_radial_solver;test_radial_dirac;test_radial_schroed;test_iter_gvec;\ +test_max_mem") foreach(_test ${_tests}) add_executable(${_test} ${_test}.cpp) diff --git a/apps/tests/test_gemm.cpp b/apps/tests/test_gemm.cpp index 99ee19533..0b5b75337 100644 --- a/apps/tests/test_gemm.cpp +++ b/apps/tests/test_gemm.cpp @@ -54,7 +54,8 @@ test_gemm_impl(int M, int N, int K, int transa, la::lib_t la__, memory_t memA__, c.zero(memC__); if (!is_host_memory(memC__)) { - c.allocate(memory_t::host); + c.allocate(memory_t::host_pinned); + c.zero(); } char TA[] = {'N', 'T', 'C'}; diff --git a/apps/tests/test_hloc.cpp b/apps/tests/test_hloc.cpp index c6ab17156..7a7562ac8 100644 --- a/apps/tests/test_hloc.cpp +++ b/apps/tests/test_hloc.cpp @@ -32,14 +32,15 @@ test_hloc_impl(sirius::Simulation_context& ctx__, int num_bands__, int use_gpu__ sirius::Local_operator hloc(ctx__, fft, gvec_fft); - wf::Wave_functions phi(gvec, wf::num_mag_dims(0), wf::num_bands(4 * num_bands__), memory_t::host); + wf::Wave_functions phi(gvec, wf::num_mag_dims(0), wf::num_bands(4 * num_bands__), memory_t::host_pinned); + #pragma omp patallel for for (int i = 0; i < 4 * num_bands__; i++) { for (int j = 0; j < phi.ld(); j++) { phi.pw_coeffs(j, wf::spin_index(0), wf::band_index(i)) = random>(); } phi.pw_coeffs(0, wf::spin_index(0), wf::band_index(i)) = 1.0; } - wf::Wave_functions hphi(gvec, wf::num_mag_dims(0), wf::num_bands(4 * num_bands__), memory_t::host); + wf::Wave_functions hphi(gvec, wf::num_mag_dims(0), wf::num_bands(4 * num_bands__), memory_t::host_pinned); { auto mem_phi = (use_gpu__) ? memory_t::device : memory_t::host; @@ -59,6 +60,7 @@ test_hloc_impl(sirius::Simulation_context& ctx__, int num_bands__, int use_gpu__ } double diff{0}; + #pragma omp parallel for reduction(+:diff) for (int i = 0; i < 4 * num_bands__; i++) { for (int j = 0; j < phi.ld(); j++) { int ig = gvec->offset() + j; @@ -69,6 +71,7 @@ test_hloc_impl(sirius::Simulation_context& ctx__, int num_bands__, int use_gpu__ 2); } } + if (diff != diff) { RTE_THROW("NaN"); } diff --git a/apps/tests/test_max_mem.cpp b/apps/tests/test_max_mem.cpp new file mode 100644 index 000000000..c5bc9f645 --- /dev/null +++ b/apps/tests/test_max_mem.cpp @@ -0,0 +1,49 @@ +/* This file is part of SIRIUS electronic structure library. + * + * Copyright (c), ETH Zurich. All rights reserved. + * + * Please, refer to the LICENSE file in the root directory. + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include "testing.hpp" + +using namespace sirius; + +int +test_max_mem(cmd_args const& args) +{ + std::cout << "Free avaialble memory : " << (get_available_memory() >> 30) << " Gb" << std::endl; + auto M = get_memory_t(args.value("memory_t", "host")); + size_t size = args.value("size", 1); + + //std::cout << "attempting to allocate " << size << " Gb" << std::endl; + //size *= (1 << 30); + //mdarray a({size}, M); + //a.zero(M); + + std::vector> v; + for (int i = 0; i < 100; i++) { + std::cout << "step : " << i << std::endl; + std::cout << "attempting to allocate " << size << " Gb" << std::endl; + v.push_back(mdarray({size * (1 << 30)}, M)); + v.back().zero(M); + print_memory_usage(std::cout); + std::cout << std::flush; + } + + return 0; +} + +int +main(int argn, char** argv) +{ + cmd_args args(argn, argv, + {{"memory_t=", "{string} type of the memory"}, {"size=", "{int} size of array in Gb"}}); + + sirius::initialize(1); + int result = call_test("test_max_mem", test_max_mem, args); + sirius::finalize(); + return result; +}