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 |
|
---|
17 | #include <map>
|
---|
18 | #include <boost/fusion/sequence.hpp>
|
---|
19 |
|
---|
20 | #include "CodePatterns/Assert.hpp"
|
---|
21 |
|
---|
22 | #ifdef HAVE_JOBMARKET
|
---|
23 | #include "JobMarket/types.hpp"
|
---|
24 | #else
|
---|
25 | typedef size_t JobId_t;
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #include "Fragmentation/KeySetsContainer.hpp"
|
---|
29 | #include "Fragmentation/Summation/SetValues/Histogram.hpp"
|
---|
30 | #include "Fragmentation/Summation/SetValues/Fragment.hpp"
|
---|
31 | #include "Fragmentation/Summation/SetValues/IndexedVectors.hpp"
|
---|
32 |
|
---|
33 | #include "Fragmentation/Summation/Containers/MPQCData.hpp"
|
---|
34 | #include "Fragmentation/Summation/Containers/MPQCDataFused.hpp"
|
---|
35 | #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
|
---|
36 | #ifdef HAVE_VMG
|
---|
37 | #include "Fragmentation/Summation/Containers/VMGData.hpp"
|
---|
38 | #include "Fragmentation/Summation/Containers/VMGDataFused.hpp"
|
---|
39 | #include "Fragmentation/Summation/Containers/VMGDataMap.hpp"
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | template <typename source, typename dest>
|
---|
43 | inline void convertDataTo(
|
---|
44 | const std::map<JobId_t, source> &fragmentData,
|
---|
45 | std::map<JobId_t, dest> &MPQCData_fused)
|
---|
46 | {
|
---|
47 | MPQCData_fused.clear();
|
---|
48 | }
|
---|
49 |
|
---|
50 | template <>
|
---|
51 | inline void convertDataTo<MPQCData, MPQCDataEnergyMap_t>(
|
---|
52 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
53 | std::map<JobId_t, MPQCDataEnergyMap_t> &MPQCData_Energy_fused)
|
---|
54 | {
|
---|
55 | // energy_t
|
---|
56 | MPQCData_Energy_fused.clear();
|
---|
57 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
58 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
59 | const MPQCData &extractedData = dataiter->second;
|
---|
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;
|
---|
71 | MPQCData_Energy_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | #ifdef HAVE_VMG
|
---|
76 | template <>
|
---|
77 | inline void convertDataTo<VMGData, VMGDataMap_t>(
|
---|
78 | const std::map<JobId_t, VMGData> &longrangeData,
|
---|
79 | std::map<JobId_t, VMGDataMap_t> &VMGData_fused)
|
---|
80 | {
|
---|
81 | // energy_t
|
---|
82 | VMGData_fused.clear();
|
---|
83 | for(std::map<JobId_t, VMGData>::const_iterator dataiter = longrangeData.begin();
|
---|
84 | dataiter != longrangeData.end(); ++dataiter) {
|
---|
85 | const VMGData &extractedData = dataiter->second;
|
---|
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;
|
---|
91 | VMGData_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
92 | }
|
---|
93 | }
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | inline void convertMPQCDatatoForceMap(
|
---|
97 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
98 | const KeySetsContainer &ForceKeySet,
|
---|
99 | std::map<JobId_t, MPQCDataForceMap_t> &MPQCData_Force_fused)
|
---|
100 | {
|
---|
101 | // forces
|
---|
102 | ASSERT( ForceKeySet.KeySets.size() == fragmentData.size(),
|
---|
103 | "FragmentationAutomationAction::performCall() - indices and fragmentData differ in size.");
|
---|
104 | MPQCData_Force_fused.clear();
|
---|
105 | std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
106 | KeySetsContainer::ArrayOfIntVectors::const_iterator arrayiter = ForceKeySet.KeySets.begin();
|
---|
107 | for(;dataiter != fragmentData.end(); ++dataiter, ++arrayiter) {
|
---|
108 | const MPQCData &extractedData = dataiter->second;
|
---|
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);
|
---|
115 | MPQCData_Force_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | template <>
|
---|
120 | inline void convertDataTo<MPQCData, MPQCDataGridMap_t>(
|
---|
121 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
122 | std::map<JobId_t, MPQCDataGridMap_t> &MPQCData_Grid_fused)
|
---|
123 | {
|
---|
124 | // sampled_grid
|
---|
125 | MPQCData_Grid_fused.clear();
|
---|
126 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
127 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
128 | const MPQCData &extractedData = dataiter->second;
|
---|
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;
|
---|
132 | MPQCData_Grid_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 | template <>
|
---|
137 | inline void convertDataTo<MPQCData, MPQCDataFragmentMap_t>(
|
---|
138 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
139 | std::map<JobId_t, MPQCDataFragmentMap_t> &MPQCData_Fragment_fused)
|
---|
140 | {
|
---|
141 | // fragment
|
---|
142 | MPQCData_Fragment_fused.clear();
|
---|
143 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
144 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
145 | const MPQCData &extractedData = dataiter->second;
|
---|
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);
|
---|
150 | MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | template <>
|
---|
155 | inline void convertDataTo<MPQCData, MPQCDataTimeMap_t>(
|
---|
156 | const std::map<JobId_t, MPQCData> &fragmentData,
|
---|
157 | std::map<JobId_t, MPQCDataTimeMap_t> &MPQCData_Time_fused)
|
---|
158 | {
|
---|
159 | // times
|
---|
160 | MPQCData_Time_fused.clear();
|
---|
161 | for(std::map<JobId_t, MPQCData>::const_iterator dataiter = fragmentData.begin();
|
---|
162 | dataiter != fragmentData.end(); ++dataiter) {
|
---|
163 | const MPQCData &extractedData = dataiter->second;
|
---|
164 | LOG(4, "DEBUG: Current extracted Data is " << extractedData << ".");
|
---|
165 | MPQCDataTimeMap_t instance;
|
---|
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;
|
---|
172 | MPQCData_Time_fused.insert( std::make_pair(dataiter->first, instance) );
|
---|
173 | }
|
---|
174 | }
|
---|
175 |
|
---|
176 |
|
---|
177 | #endif /* DATACONVERTER_HPP_ */
|
---|