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