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

Candidate for ComplexG0 merge #310

Merged
merged 99 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
674b7ba
merge so far. getting parameter pack issue with nvcc
PDoakORNL Feb 15, 2023
f2f42a3
g0_interpolation unit test compiling and passing
PDoakORNL Feb 21, 2023
a1c7ce2
many more tests compile added phase to accumulator test
PDoakORNL Feb 22, 2023
1e4360f
CPU Rashba-Hubbard working
PDoakORNL Feb 23, 2023
20e88b0
fix reading of hdf5 sigma files
PDoakORNL Feb 24, 2023
4018781
tp and space transform fixes for complex
PDoakORNL Feb 24, 2023
846f280
compile for non complex model on summit
PDoakORNL Feb 24, 2023
f826ce1
builds cpu complex on Summit
PDoakORNL Feb 24, 2023
872ee7e
gpu porting continues
PDoakORNL Feb 27, 2023
eb78724
G4 CPU Nan's fixed.
PDoakORNL Mar 6, 2023
761b268
fix that makes main_dca build in more cases
PDoakORNL Mar 6, 2023
9bda247
all fast tests build
PDoakORNL Mar 10, 2023
c67b99a
material_FeSn builds for CPU
PDoakORNL Mar 11, 2023
e00d134
missing file
PDoakORNL Mar 11, 2023
e50f813
NiO and FeSn should at least build now
PDoakORNL Mar 11, 2023
3fd9ca4
ctint + FeSn building
PDoakORNL Mar 13, 2023
19a8394
fixes for GPU and FeSN frequency initialization
PDoakORNL Mar 16, 2023
6087035
small fix for lapackexception
PDoakORNL Mar 22, 2023
7b452e5
cherry pick from working_CPU_FeSn
PDoakORNL Mar 22, 2023
4a2a32b
remove bad second to last step for write every iteration
PDoakORNL Mar 22, 2023
6db7c21
fix CTAUX build
PDoakORNL Mar 22, 2023
55aee1a
fix for reading hdf5 sigma
PDoakORNL Mar 22, 2023
83fe5e5
working on fixing number_of_measurements_ update
PDoakORNL Mar 24, 2023
8ca5d95
many fixes to unit test and testing "framework"
PDoakORNL Apr 10, 2023
f14ca86
get a handle on large function allocations
PDoakORNL Apr 10, 2023
6d7c58e
better handling of Scalar type to allow test coverage
PDoakORNL Apr 11, 2023
8f145ee
we no longer throw if domains are reinitialized just emit error
PDoakORNL Apr 11, 2023
78bf5a4
cleaning up fast tests
PDoakORNL Apr 11, 2023
195b88d
models traits.hpp works as intended
PDoakORNL Apr 13, 2023
96f1ffe
misssing files
PDoakORNL Apr 13, 2023
c2a8be7
model traits test added
PDoakORNL Apr 13, 2023
edd2583
more GPU type management for complex G0
PDoakORNL Apr 18, 2023
6e3e1f5
device interpolation data files
PDoakORNL Apr 18, 2023
69940bb
proper testing of type_help
PDoakORNL Apr 19, 2023
a1959d6
CPU builds again
PDoakORNL Apr 20, 2023
3e3db79
fix bad sign for real G0
PDoakORNL Apr 20, 2023
b517355
specify types more flexibly
PDoakORNL Apr 20, 2023
0379075
fixes for three band model
PDoakORNL Apr 20, 2023
64d97dc
all fast tests build for GPU sp acc GPU does complex
PDoakORNL Apr 20, 2023
1ca929e
fix legacy hdf5 file reading
PDoakORNL May 2, 2023
cf12831
merge summit fix
PDoakORNL May 2, 2023
1d95a67
Well tp on the GPU is closer
PDoakORNL May 9, 2023
129663c
space transform 2D gpu test passes
PDoakORNL May 19, 2023
d457c3d
work on tp accumulator GPU
PDoakORNL May 23, 2023
712a72a
missing test file
PDoakORNL Jun 28, 2023
6b80dfb
add missing mappings for magma types
PDoakORNL Jun 28, 2023
595dbbd
found a few more bugs in complex gpu
PDoakORNL Jul 10, 2023
fff8a2b
agreement between tp CPU and GPU real
PDoakORNL Jul 18, 2023
1971a3d
fixes issues surfaced by cpu build tutorial
PDoakORNL Jul 18, 2023
47193f4
this could be the cpu implementation bug
PDoakORNL Jul 24, 2023
3b59182
fix tp cpu regression
PDoakORNL Jul 25, 2023
f665d43
more debugging tp_gpu
PDoakORNL Aug 2, 2023
7b9d5e0
direct term of phc fixed
PDoakORNL Aug 3, 2023
a134e33
direct term of phm fixed
PDoakORNL Aug 3, 2023
00ae0d8
both terms of phc fixed
PDoakORNL Aug 3, 2023
ea1c5b9
phm seems fixed as well
PDoakORNL Aug 3, 2023
8b1f7b5
particle particle up down fixed
PDoakORNL Aug 3, 2023
cd23663
cleaning up debug output tp_accumulator_gpu_test broken
PDoakORNL Aug 3, 2023
393144c
fix some additional issues
PDoakORNL Aug 3, 2023
71f005e
now working for finite exchange frequency
PDoakORNL Aug 9, 2023
ddf28be
working (for Rashba) complex g0 G4 GPU
PDoakORNL Aug 14, 2023
75337c2
fixing test build issues on summit
PDoakORNL Aug 14, 2023
32ef498
more example cases
PDoakORNL Aug 14, 2023
7a6f9af
debugging full application rashba failures
PDoakORNL Aug 17, 2023
1aa2819
unit test rashba parameters
PDoakORNL Aug 17, 2023
4a42879
allowing allocator used by Matrix on CPU to be selected
PDoakORNL Aug 18, 2023
a4f5470
the working input for tp_accumulator_test_complex test pass
PDoakORNL Aug 21, 2023
95584d2
include complex gflop cost of build_g_matrix
PDoakORNL Aug 21, 2023
a3a3042
Final push of fixes and cleanup for complex g0 tp accumulation.
PDoakORNL Aug 21, 2023
bc08d52
removing debug output
PDoakORNL Aug 21, 2023
867d835
look to have fixed rashba G
PDoakORNL Aug 25, 2023
a31c85e
all extensive tests build
PDoakORNL Sep 1, 2023
768de82
more test udpates ahead of merge
PDoakORNL Sep 5, 2023
f2afa19
added rashba statistical test
PDoakORNL Sep 29, 2023
4622ede
extensive tests expected to pass pass
PDoakORNL Oct 2, 2023
f49098f
Merge branch 'Moire_Hubbard_merge' into MHM_merge
PDoakORNL Oct 2, 2023
654d9d2
fix merge damage
PDoakORNL Oct 2, 2023
9def90b
closer to mixed precision build of complexG0
PDoakORNL Oct 9, 2023
2dcd1a2
fixes for CPU build on summit
PDoakORNL Oct 9, 2023
055fa0b
fix for reading current hdf5
PDoakORNL Oct 11, 2023
9121a1e
stable set of modules for summit
PDoakORNL Oct 23, 2023
0938a19
little cleanup of dca_data reading
PDoakORNL Oct 27, 2023
f1e2241
possible sigma update bugfix
PDoakORNL Oct 27, 2023
b9e0f5e
fixing extensive tests
PDoakORNL Nov 1, 2023
5e32006
check prob equivalence between single double and delayed vertex upd
PDoakORNL Nov 2, 2023
282f26d
extensive tests pass on cpu
PDoakORNL Nov 3, 2023
98f9c28
skeleton of ctaux_walker_test added
PDoakORNL Nov 7, 2023
05f6f87
improved debug support for matrix
PDoakORNL Nov 16, 2023
df7cc78
changes to allow testing of ctaux walkers test
PDoakORNL Nov 16, 2023
8a0306e
additional testing for walkers and rashba
PDoakORNL Nov 16, 2023
5b93b2e
more work on rashba test and inconsistent cplx division
PDoakORNL Nov 30, 2023
8fbbb29
finally the correct consistent scalar div
PDoakORNL Dec 1, 2023
30628b1
missing files
PDoakORNL Dec 1, 2023
4cdc3d6
refresh CI software stack
PDoakORNL Dec 1, 2023
2844b5e
remove mixed precision nfft
PDoakORNL Dec 1, 2023
57e2d06
fix bad NDEBUG placement
PDoakORNL Dec 1, 2023
c917478
older CUDA architectures have complex type problems
PDoakORNL Dec 1, 2023
c68991e
reduced tolerance for ctint complex submatrix test
PDoakORNL Dec 1, 2023
f4e2acf
updated baseline
PDoakORNL Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ set(DCA_LIBS
quantum_domains
time_and_frequency_domains
signals
symmetrization
coarsegraining
${DCA_CONCURRENCY_LIB}
${DCA_THREADING_LIBS}
Expand Down
1 change: 1 addition & 0 deletions applications/analysis/chi_q_omega.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <string>

// Defines Concurrency, Threading, ParametersType, DcaData, and BseSolver.
#include "dca/config/mc_options.hpp"
#include "dca/config/analysis.hpp"
#include "dca/config/cmake_options.hpp"
#include "dca/io/json/json_reader.hpp"
Expand Down
4 changes: 2 additions & 2 deletions applications/analysis/main_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

#include <iostream>
#include <string>

// Defined Precision and Scalar Type
#include "dca/config/mc_options.hpp"
// Defines Concurrency, Threading, ParametersType, DcaData, and BseSolver.
#include "dca/config/analysis.hpp"
#include "dca/config/cmake_options.hpp"
Expand Down Expand Up @@ -63,7 +64,6 @@ int main(int argc, char** argv) {
adios2::ADIOS adios;

if (dca::io::stringToIOType(parameters.get_output_format()) == dca::io::IOType::ADIOS2) {
int rank = concurrency.id();
std::cout << "\nProcessor " << concurrency.id() << " is writing data." << std::endl;
dca::io::Writer writer(adios, concurrency, parameters.get_output_format(), true);
std::string filename_bse(parameters.get_directory() + parameters.getAppropriateFilenameAnalysis());
Expand Down
2 changes: 1 addition & 1 deletion applications/dca/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (DCA_BUILD_DCA)
target_include_directories(main_dca PRIVATE ${DCA_INCLUDE_DIRS})

if (DCA_HAVE_GPU)
target_link_libraries(main_dca PRIVATE ${DCA_GPU_LIBS})
target_link_libraries(main_dca PRIVATE ${DCA_GPU_LIBS} mc_kernels g0_interpolation mc_kernels ctint mc_kernels)
endif()

target_link_libraries(main_dca PUBLIC FFTW::Double signals ${DCA_LIBS})
Expand Down
6 changes: 6 additions & 0 deletions applications/dca/main_dca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ int dca_main(int argc, char** argv) {
// Create the parameters object from the input file.
ParametersType parameters(dca::util::GitVersion::string(), concurrency);
parameters.read_input_and_broadcast<dca::io::JSONReader>(input_file);
if(concurrency.id() == concurrency.first())
std::cout << "Input read and broadcast.\n";
parameters.update_model();
if(concurrency.id() == concurrency.first())
std::cout << "Model updated.\n";
parameters.update_domains();
if(concurrency.id() == concurrency.first())
std::cout << "Domains updated.\n";

dca::DistType distribution = parameters.get_g4_distribution();
{
Expand Down
6 changes: 3 additions & 3 deletions build-aux/summit_load_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Usage: source summit_load_modules.sh

module reset
module load gcc/11.2.0
module load cuda/11.5.2 # ldd shows magma is built with this cuda
module load magma/2.6.2
module load gcc/10.2.0
module load cuda/11.1.1 # ldd shows magma is built with this cuda
module load magma/2.6.1
module load hdf5
module load fftw
module load cmake/3.21.3
Expand Down
24 changes: 15 additions & 9 deletions cmake/dca_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ endif()

# Lattice type
set(DCA_LATTICE "square" CACHE STRING "Lattice type, options are: bilayer | square | triangular |
Kagome | hund | twoband_Cu | threeband | FeAs | material_NiO | material_FeSn ")
Kagome | hund | twoband_Cu | threeband | Rashba_Hubbard | Moire_Hubbard | FeAs | material_NiO | material_FeSn ")
set_property(CACHE DCA_LATTICE PROPERTY STRINGS bilayer square triangular Kagome hund twoband_Cu threeband
FeAs material_NiO material_FeSn)
Rashba_Hubbard Moire_Hubbard FeAs material_NiO material_FeSn)

if (DCA_LATTICE STREQUAL "bilayer")
set(DCA_LATTICE_TYPE dca::phys::models::bilayer_lattice<PointGroup>)
Expand All @@ -145,12 +145,18 @@ elseif (DCA_LATTICE STREQUAL "Kagome")
"dca/phys/models/analytic_hamiltonians/Kagome_hubbard.hpp")
elseif (DCA_LATTICE STREQUAL "hund")
set(DCA_LATTICE_TYPE dca::phys::models::HundLattice<PointGroup>)

elseif (DCA_LATTICE STREQUAL "threeband")
set(DCA_LATTICE_TYPE dca::phys::models::ThreebandHubbard<PointGroup>)
set(DCA_LATTICE_INCLUDE
"dca/phys/models/analytic_hamiltonians/threeband_hubbard.hpp")

elseif (DCA_LATTICE STREQUAL "Rashba_Hubbard")
set(DCA_LATTICE_TYPE dca::phys::models::RashbaHubbard<PointGroup>)
set(DCA_LATTICE_INCLUDE
"dca/phys/models/analytic_hamiltonians/rashba_hubbard.hpp")
elseif (DCA_LATTICE STREQUAL "Moire_Hubbard")
set(DCA_LATTICE_TYPE dca::phys::models::moire_hubbard<PointGroup>)
set(DCA_LATTICE_INCLUDE
"dca/phys/models/analytic_hamiltonians/Moire_Hubbard.hpp")
elseif (DCA_LATTICE STREQUAL "twoband_chain")
set(DCA_LATTICE_TYPE dca::phys::models::twoband_chain<dca::phys::domains::no_symmetry<1>>)
set(DCA_LATTICE_INCLUDE
Expand All @@ -174,7 +180,7 @@ elseif (DCA_LATTICE STREQUAL "material_FeSn")
"dca/phys/models/material_hamiltonians/material_lattice.hpp")
set(DCA_MODEL_IS_MATERIAL_LATTICE ON CACHE BOOL "is the model a material lattice")
else()
message(FATAL_ERROR "Please set DCA_LATTICE to a valid option: bilayer | square | triangular | Kagome | hund | twoband_Cu | threeband | FeAs | material_NiO | material_FeSn.")
message(FATAL_ERROR "Please set DCA_LATTICE to a valid option: bilayer | square | triangular | Kagome | hund | twoband_Cu | threeband | Rashba_Hubbard | Moire_Hubbard | FeAs | material_NiO | material_FeSn.")
endif()

# Model type
Expand Down Expand Up @@ -390,15 +396,15 @@ option(DCA_WITH_SINGLE_PRECISION_TP_MEASUREMENTS "Measure two particle function

if (DCA_WITH_SINGLE_PRECISION_MC)
set(DCA_WITH_SINGLE_PRECISION_TP_MEASUREMENTS ON CACHE BOOL "Measure two particle function in single precision." FORCE)
set(MC_SCALAR float)
set(MC_REAL float)
else()
set(MC_SCALAR double)
set(MC_REAL double)
endif()

if (DCA_WITH_SINGLE_PRECISION_TP_MEASUREMENTS)
set(TP_ACCUMULATION_SCALAR float)
set(TP_ACCUMULATION_PRECISION float)
else()
set(TP_ACCUMULATION_SCALAR double)
set(TP_ACCUMULATION_PRECISION double)
endif()


Expand Down
2 changes: 1 addition & 1 deletion cmake/dca_testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function(dca_add_gtest name)

add_test(NAME ${name}
COMMAND ${TEST_RUNNER} ${MPIEXEC_NUMPROC_FLAG} ${DCA_ADD_GTEST_MPI_NUMPROC}
${MPIEXEC_PREFLAGS} ${SMPIARGS_FLAG_MPI} ${CVD_LAUNCHER} "$<TARGET_FILE:${name}>"
${MPIEXEC_PREFLAGS} ${SMPIARGS_FLAG_MPI} ${MPIEXEC_POSTFLAGS} ${CVD_LAUNCHER} "$<TARGET_FILE:${name}>"
${DCA_TESTING_FLAGS})
target_link_libraries(${name} PRIVATE ${MPI_C_LIBRARIES})
else()
Expand Down
2 changes: 1 addition & 1 deletion examples/NiO_CTINT/input_NiO_ctint.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

"DCA" : {
"accuracy" : 0,
"interacting-orbitals" : [ 0, 1, 2, 3, 4, 5, 6, 7 ],
"interacting-orbitals" : [ 0, 1, 2, 3, 4, 5, 6, 7 ],
"iterations" : 9,
"self-energy-mixing-factor" : 0.75,

Expand Down
11 changes: 8 additions & 3 deletions include/dca/application/dca_loop_dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ class DCALoopDispatch {
// Create and initialize the DCA data object.
DcaDataType<DT> dca_data(parameters);
dca_data.initialize();
if(concurrency.id() == concurrency.first())
std::cout << "dca_data initialized.\n";
DcaLoopType<DT> dca_loop(parameters, dca_data, concurrency);
{
Profiler profiler(__FUNCTION__, __FILE__, __LINE__);

try {
dca_loop.initialize();
if(concurrency.id() == concurrency.first())
std::cout << "dca_loop initialized.\n";
}
catch (const std::exception& exc) {
std::cout << "unhandled exception in dca_loop.initialize(): " << exc.what() << std::endl;
Expand All @@ -56,9 +60,10 @@ class DCALoopDispatch {
// if (concurrency.id() == concurrency.first()) {
// std::cout << "\nProcessor " << concurrency.id() << " is writing data." << std::endl;
dca_loop.write();
std::cout << "final output written to file: " << parameters.get_filename_dca() << '\n';

std::cout << "\nFinish time: " << dca::util::print_time() << "\n" << std::endl;
if(concurrency.id() == concurrency.first()) {
std::cout << "final output written to file: " << parameters.get_filename_dca() << '\n';
std::cout << "\nFinish time: " << dca::util::print_time() << "\n" << std::endl;
}
// }
}
}
Expand Down
7 changes: 5 additions & 2 deletions include/dca/config/analysis.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
constexpr dca::ClusterSolverId solver_name = @DCA_CLUSTER_SOLVER_NAME@;

#include "dca/phys/parameters/parameters.hpp"
using ParametersType = dca::phys::params::Parameters<Concurrency, Threading, Profiler, Model,
void /*RandomNumberGenerator*/, solver_name>;
using ParametersType = dca::phys::params::Parameters<
Concurrency, Threading, Profiler, Model, void, solver_name,
dca::NumericalTraits<dca::config::McOptions::MC_REAL,
typename dca::util::ScalarSelect<dca::config::McOptions::MC_REAL,
Model::lattice_type::complex_g0>::type>>;

#include "dca/phys/dca_data/dca_data.hpp"
using DcaDataType = dca::phys::DcaData<ParametersType>;
Expand Down
19 changes: 12 additions & 7 deletions include/dca/config/dca.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,37 @@
#include "dca/phys/dca_step/cluster_solver/cluster_solver_id.hpp"
constexpr dca::ClusterSolverId solver_name = @DCA_CLUSTER_SOLVER_NAME@;

#include "dca/config/mc_options.hpp"

#include "dca/phys/parameters/parameters.hpp"
using ParametersType = dca::phys::params::Parameters<Concurrency, Threading, Profiler, Model,
RandomNumberGenerator, solver_name>;
using ParametersType = dca::phys::params::Parameters<
Concurrency, Threading, Profiler, Model, RandomNumberGenerator, solver_name,
dca::NumericalTraits<dca::config::McOptions::MC_REAL,
typename dca::util::ScalarSelect<dca::config::McOptions::MC_REAL,
Model::lattice_type::complex_g0>::type>>;

#include "dca/phys/dca_data/dca_data.hpp"
template<dca::DistType DIST>
template <dca::DistType DIST>
using DcaDataType = dca::phys::DcaData<ParametersType, DIST>;

// You know whats probably worse than using the C preprocessor,
// generating code using cmake.
#include "@DCA_CLUSTER_SOLVER_INCLUDE@"
template<dca::DistType DIST>
template <dca::DistType DIST>
using ClusterSolverBaseType = @DCA_CLUSTER_SOLVER_TYPE@;

// TODO: Clean this up (remove #ifdef).
#ifdef DCA_WITH_THREADED_SOLVER
#include "@DCA_THREADED_SOLVER_INCLUDE@"
template<dca::DistType DIST>
template <dca::DistType DIST>
using ClusterSolver = @DCA_THREADED_SOLVER_TYPE@;
#else
template<dca::DistType DIST>
template <dca::DistType DIST>
using ClusterSolver = ClusterSolverBaseType<DIST>;
#endif // DCA_WITH_THREADED_SOLVER

#include "dca/phys/dca_loop/dca_loop.hpp"
template<dca::DistType DIST>
template <dca::DistType DIST>
using DcaLoopType = dca::phys::DcaLoop<ParametersType, DcaDataType<DIST>, ClusterSolver<DIST>, DIST>;

#endif // DCA_CONFIG_DCA_HPP
4 changes: 2 additions & 2 deletions include/dca/config/mc_options.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ namespace config {
// dca::config::

struct McOptions {
using MCScalar = @MC_SCALAR@;
using MC_REAL = @MC_REAL@;

using TPAccumulationScalar = @TP_ACCUMULATION_SCALAR@;
using TPAccumulationPrecision = @TP_ACCUMULATION_PRECISION@;

static constexpr bool memory_savings = @MEMORY_SAVINGS@;

Expand Down
61 changes: 57 additions & 4 deletions include/dca/function/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "dca/util/pack_operations.hpp"
#include "dca/util/integer_division.hpp"
#include "dca/util/type_utils.hpp"
#include "dca/util/type_help.hpp"
#include "dca/util/to_string.hpp"

namespace dca {
Expand Down Expand Up @@ -92,6 +93,9 @@ class function {
// Same as above, but with name change from name argument.
function(const function<scalartype, domain, DT>& other, const std::string& name);

template <typename Scalar2>
function(const function<Scalar2, domain, DT>& other);

// Move constructor
// Constructs the function with elements and name of other using move semantics.
// Precondition: The other function has been resetted, if the domain had been initialized after
Expand Down Expand Up @@ -314,7 +318,6 @@ class function {
return fnc_values_[dmn(static_cast<int>(t), static_cast<int>(subindices)...)];
}


void operator+=(const function<scalartype, domain, DT>& other);
void operator-=(const function<scalartype, domain, DT>& other);
void operator*=(const function<scalartype, domain, DT>& other);
Expand Down Expand Up @@ -363,7 +366,6 @@ class function {
template <typename new_scalartype>
void distribute(int sbdm_index_1, int sbdm_index_2, int* subind, const new_scalartype* fnc_vals);


//
// Methods for printing
//
Expand Down Expand Up @@ -426,6 +428,13 @@ function<scalartype, domain, DT>::function(const std::string& name)
}
start_ = 0;
end_ = dmn.get_size();
// If the function is more than 256 megs report it.
if (end_ > 268435456) {
std::cerr << "function " << name << " allocates " << sizeof(scalartype) * end_ / 1024 / 1024
<< " MB" << '\n';
if (name_ == "no-name")
std::cerr << "large functions need names give yourself a chance.\n";
}
// will zero real or complex values
fnc_values_.resize(dmn.get_size(), {});
}
Expand Down Expand Up @@ -457,6 +466,25 @@ function<scalartype, domain, DT>::function(const function<scalartype, domain, DT
end_ = other.end_;
}

/** converting "copy" constructor
*/
template <typename scalartype, class domain, DistType DT>
template <typename Scalar2>
function<scalartype, domain, DT>::function(const function<Scalar2, domain, DT>& other)
: name_(other.get_name()),
function_type(__PRETTY_FUNCTION__),
dmn(),
Nb_sbdms(dmn.get_leaf_domain_sizes().size()),
fnc_values_(dmn.get_size()) {
if (size() != other.size()) {
// The other function has not been resetted after the domain was initialized.
throw std::logic_error("Copy construction from a not yet resetted function.");
}
start_ = other.get_start();
end_ = other.get_end();
std::copy(other.begin(), other.end(), begin());
}

/** move constructor */
template <typename scalartype, class domain, DistType DT>
function<scalartype, domain, DT>::function(function<scalartype, domain, DT>&& other)
Expand Down Expand Up @@ -640,7 +668,23 @@ template <typename Scalar, class domain, DistType DT>
template <typename Scalar2>
inline function<Scalar, domain, DT>& function<Scalar, domain, DT>::operator=(
const function<Scalar2, domain, DT>& other) {
if (this != &other) {
if constexpr (std::is_same_v<decltype(*this), decltype(other)>) {
if (this != &other) {
if constexpr (dist == DistType::NONE) {
if (size() != other.size()) {
throw(std::logic_error("Function size does not match."));
}
}
else if constexpr (dist == DistType::LINEAR || dist == DistType::BLOCKED) {
Nb_sbdms = other.dmn.get_leaf_domain_sizes().size();
start_ = other.start_;
end_ = other.end_;
fnc_values_.resize(other.size(), {});
}
fnc_values_ = other.fnc_values_;
}
}
else {
if constexpr (dist == DistType::NONE) {
if (size() != other.size()) {
throw(std::logic_error("Function size does not match."));
Expand All @@ -652,7 +696,16 @@ inline function<Scalar, domain, DT>& function<Scalar, domain, DT>::operator=(
end_ = other.end_;
fnc_values_.resize(other.size(), {});
}
fnc_values_ = other.fnc_values_;
auto kConvert = [](auto& kvec) -> std::vector<Scalar> {
std::vector<Scalar> k_converted(kvec.size());
std::transform(kvec.begin(), kvec.end(), k_converted.begin(),
[](auto& val) -> typename decltype(k_converted)::value_type {
return static_cast<typename decltype(k_converted)::value_type>(val);
});
return k_converted;
};

fnc_values_ = kConvert(other.getValues());
}
return *this;
}
Expand Down
1 change: 1 addition & 0 deletions include/dca/io/adios2/adios2_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "adios2.h"

#include "dca/platform/dca_gpu.h"
#include "dca/io/buffer.hpp"
#include "dca/function/domains.hpp"
#include "dca/function/function.hpp"
Expand Down
Loading