[0398bd] | 1 | /*
|
---|
| 2 | * DataConverter.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Aug 27, 2012
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef DATACONVERTER_HPP_
|
---|
| 9 | #define DATACONVERTER_HPP_
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | // include config.h
|
---|
| 13 | #ifdef HAVE_CONFIG_H
|
---|
| 14 | #include <config.h>
|
---|
| 15 | #endif
|
---|
| 16 |
|
---|
[c9f9bb] | 17 | #include <map>
|
---|
[0398bd] | 18 | #include <boost/fusion/sequence.hpp>
|
---|
| 19 |
|
---|
| 20 | #include "CodePatterns/Assert.hpp"
|
---|
| 21 |
|
---|
[8e84fe] | 22 | #ifdef HAVE_JOBMARKET
|
---|
[0398bd] | 23 | #include "JobMarket/types.hpp"
|
---|
[8e84fe] | 24 | #else
|
---|
| 25 | typedef size_t JobId_t;
|
---|
| 26 | #endif
|
---|
[0398bd] | 27 |
|
---|
| 28 | #include "Fragmentation/KeySetsContainer.hpp"
|
---|
[fbf143] | 29 | #include "Fragmentation/Summation/SetValues/Histogram.hpp"
|
---|
| 30 | #include "Fragmentation/Summation/SetValues/Fragment.hpp"
|
---|
| 31 | #include "Fragmentation/Summation/SetValues/IndexedVectors.hpp"
|
---|
[0398bd] | 32 |
|
---|
[fbf143] | 33 | #include "Fragmentation/Summation/Containers/MPQCData.hpp"
|
---|
| 34 | #include "Fragmentation/Summation/Containers/MPQCDataFused.hpp"
|
---|
| 35 | #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
|
---|
[0398bd] | 36 | #ifdef HAVE_VMG
|
---|
[fbf143] | 37 | #include "Fragmentation/Summation/Containers/VMGData.hpp"
|
---|
| 38 | #include "Fragmentation/Summation/Containers/VMGDataFused.hpp"
|
---|
| 39 | #include "Fragmentation/Summation/Containers/VMGDataMap.hpp"
|
---|
[0398bd] | 40 | #endif
|
---|
| 41 |
|
---|
| 42 | template <typename source, typename dest>
|
---|
| 43 | inline void convertDataTo(
|
---|
[c9f9bb] | 44 | const std::map<JobId_t, source> &fragmentData,
|
---|
| 45 | std::map<JobId_t, dest> &MPQCData_fused)
|
---|
[0398bd] | 46 | {
|
---|
| 47 | MPQCData_fused.clear();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | template <>
|
---|
| 51 | inline void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
|
---|
[c9f9bb] | 52 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
| 53 | std::map<JobId_t, MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
|
---|
[0398bd] | 54 | {
|
---|
| 55 | // energy_t
|
---|
| 56 | MPQCData_Energy_fused.clear();
|
---|
[c9f9bb] | 57 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
[0398bd] | 58 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
[c9f9bb] | 59 | const MPQCData &extractedData = dataiter->second;
|
---|
[0398bd] | 60 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
| 61 | MPQCDataEnergyMap_t instance;
|
---|
| 62 | boost::fusion::at_key<MPQCDataFused::energy_total>(instance) = extractedData.energies.total;
|
---|
| 63 | boost::fusion::at_key<MPQCDataFused::energy_nuclear_repulsion>(instance) = extractedData.energies.nuclear_repulsion;
|
---|
| 64 | boost::fusion::at_key<MPQCDataFused::energy_electron_coulomb>(instance) = extractedData.energies.electron_coulomb;
|
---|
| 65 | boost::fusion::at_key<MPQCDataFused::energy_electron_exchange>(instance) = extractedData.energies.electron_exchange;
|
---|
| 66 | boost::fusion::at_key<MPQCDataFused::energy_correlation>(instance) = extractedData.energies.correlation;
|
---|
| 67 | boost::fusion::at_key<MPQCDataFused::energy_overlap>(instance) = extractedData.energies.overlap;
|
---|
| 68 | boost::fusion::at_key<MPQCDataFused::energy_kinetic>(instance) = extractedData.energies.kinetic;
|
---|
| 69 | boost::fusion::at_key<MPQCDataFused::energy_hcore>(instance) = extractedData.energies.hcore;
|
---|
| 70 | boost::fusion::at_key<MPQCDataFused::energy_eigenvalues>(instance) = extractedData.energies.eigenvalues;
|
---|
[c9f9bb] | 71 | MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
[0398bd] | 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | #ifdef HAVE_VMG
|
---|
| 76 | template <>
|
---|
| 77 | inline void convertDataTo<VMGData, VMGDataMap_t>(
|
---|
[c9f9bb] | 78 | const std::map<JobId_t, VMGData> &longrangeData,
|
---|
| 79 | std::map<JobId_t, VMGDataMap_t> &VMGData_fused)
|
---|
[0398bd] | 80 | {
|
---|
| 81 | // energy_t
|
---|
| 82 | VMGData_fused.clear();
|
---|
[c9f9bb] | 83 | for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
|
---|
[0398bd] | 84 | dataiter != longrangeData.end(); ++dataiter) {
|
---|
[c9f9bb] | 85 | const VMGData &extractedData = dataiter->second;
|
---|
[0398bd] | 86 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
| 87 | VMGDataMap_t instance;
|
---|
| 88 | boost::fusion::at_key<VMGDataFused::sampled_potential>(instance) = extractedData.sampled_potential;
|
---|
| 89 | boost::fusion::at_key<VMGDataFused::energy_potential>(instance) = extractedData.sampled_potential.integral();
|
---|
| 90 | boost::fusion::at_key<VMGDataFused::energy_long>(instance) = extractedData.e_long;
|
---|
[c9f9bb] | 91 | VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
[0398bd] | 92 | }
|
---|
| 93 | }
|
---|
| 94 | #endif
|
---|
| 95 |
|
---|
| 96 | inline void convertMPQCDatatoForceMap(
|
---|
[c9f9bb] | 97 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
[0398bd] | 98 | const KeySetsContainer &ForceKeySet,
|
---|
[c9f9bb] | 99 | std::map<JobId_t, MPQCDataForceMap_t> &MPQCData_Force_fused)
|
---|
[0398bd] | 100 | {
|
---|
| 101 | // forces
|
---|
| 102 | ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
|
---|
| 103 | "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
|
---|
| 104 | MPQCData_Force_fused.clear();
|
---|
[c9f9bb] | 105 | std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
[0398bd] | 106 | KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
|
---|
| 107 | for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
|
---|
[c9f9bb] | 108 | const MPQCData &extractedData = dataiter->second;
|
---|
[0398bd] | 109 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
| 110 | MPQCDataForceMap_t instance;
|
---|
| 111 | // must convert int to index_t
|
---|
| 112 | IndexedVectors::indices_t indices(arrayiter->begin(), arrayiter->end());
|
---|
| 113 | boost::fusion::at_key<MPQCDataFused::forces>(instance) =
|
---|
| 114 | IndexedVectors(indices, extractedData.forces);
|
---|
[c9f9bb] | 115 | MPQCData_Force_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
[0398bd] | 116 | }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | template <>
|
---|
| 120 | inline void convertDataTo<MPQCData, MPQCDataGridMap_t>(
|
---|
[c9f9bb] | 121 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
| 122 | std::map<JobId_t, MPQCDataGridMap_t> &MPQCData_Grid_fused)
|
---|
[0398bd] | 123 | {
|
---|
| 124 | // sampled_grid
|
---|
| 125 | MPQCData_Grid_fused.clear();
|
---|
[c9f9bb] | 126 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
[0398bd] | 127 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
[c9f9bb] | 128 | const MPQCData &extractedData = dataiter->second;
|
---|
[0398bd] | 129 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
| 130 | MPQCDataGridMap_t instance;
|
---|
| 131 | boost::fusion::at_key<MPQCDataFused::sampled_grid>(instance) = extractedData.sampled_grid;
|
---|
[c9f9bb] | 132 | MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
[0398bd] | 133 | }
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | template <>
|
---|
| 137 | inline void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
|
---|
[c9f9bb] | 138 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
| 139 | std::map<JobId_t, MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
|
---|
[0398bd] | 140 | {
|
---|
| 141 | // fragment
|
---|
| 142 | MPQCData_Fragment_fused.clear();
|
---|
[c9f9bb] | 143 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
[0398bd] | 144 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
[c9f9bb] | 145 | const MPQCData &extractedData = dataiter->second;
|
---|
[0398bd] | 146 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
| 147 | MPQCDataFragmentMap_t instance;
|
---|
| 148 | boost::fusion::at_key<MPQCDataFused::fragment>(instance) =
|
---|
| 149 | Fragment(extractedData.positions, extractedData.charges);
|
---|
[c9f9bb] | 150 | MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
[0398bd] | 151 | }
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | template <>
|
---|
| 155 | inline void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
|
---|
[c9f9bb] | 156 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
| 157 | std::map<JobId_t, MPQCDataTimeMap_t> &MPQCData_Time_fused)
|
---|
[0398bd] | 158 | {
|
---|
| 159 | // times
|
---|
| 160 | MPQCData_Time_fused.clear();
|
---|
[c9f9bb] | 161 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
[0398bd] | 162 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
[c9f9bb] | 163 | const MPQCData &extractedData = dataiter->second;
|
---|
[0398bd] | 164 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
| 165 | MPQCDataTimeMap_t instance;
|
---|
[4aee30] | 166 | boost::fusion::at_key<MPQCDataFused::times_total_walltime>(instance) = extractedData.times.total_walltime;
|
---|
| 167 | boost::fusion::at_key<MPQCDataFused::times_total_cputime>(instance) = extractedData.times.total_cputime;
|
---|
| 168 | boost::fusion::at_key<MPQCDataFused::times_total_flops>(instance) = extractedData.times.total_flops;
|
---|
| 169 | boost::fusion::at_key<MPQCDataFused::times_gather_walltime>(instance) = extractedData.times.gather_walltime;
|
---|
| 170 | boost::fusion::at_key<MPQCDataFused::times_gather_cputime>(instance) = extractedData.times.gather_cputime;
|
---|
| 171 | boost::fusion::at_key<MPQCDataFused::times_gather_flops>(instance) = extractedData.times.gather_flops;
|
---|
[c9f9bb] | 172 | MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
[0398bd] | 173 | }
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | #endif /* DATACONVERTER_HPP_ */
|
---|