37 int device_id):cfg_(cfg),
76 #ifdef USE_SINGLE_PRECISION
77 opts_.
Define(
"USE_SINGLE_PRECISION");
93 }
catch (cl::Error &
err ){
94 std::cerr<<
"Error:"<<err.what()<<
"("<<err.err()<<
")\n";
95 std::cerr<<
"@" << __FILE__ <<
":line " << __LINE__ << std::endl;
105 std::vector<cl_float4> host_eos_table;
106 std::ifstream fin(fname);
107 cl_float speed_of_sound_square;
109 cl_float temperature;
110 cl_float entropy_density;
113 fin.getline(comments, 256);
115 fin >> speed_of_sound_square >> pressure >> temperature >> entropy_density;
116 if (fin.eof())
break;
117 host_eos_table.push_back((cl_float4){{speed_of_sound_square,
118 pressure, temperature, entropy_density}});
121 std::cerr<<
"@" << __FILE__ <<
":line " << __LINE__ << std::endl;
122 throw std::runtime_error(
"Failed to open equation of state table" + fname);
125 bool read_only =
true;
130 width, height, read_only);
139 bool read_only_option =
false;
140 for (
int i = 0;
i < 3;
i++) {
149 template <
typename ValueType>
152 for (
size_t idx = 0;
idx < ed.size();
idx++) {
159 template <
typename ValueType>
161 const std::vector<ValueType> &
vx,
162 const std::vector<ValueType> &
vy,
163 const std::vector<ValueType> &
vz)
166 for (
size_t idx = 0;
idx < ed.size();
idx++) {
168 static_cast<cl_real>(vx.at(
idx)), \
169 static_cast<cl_real>(vy.at(
idx)), \
170 static_cast<cl_real>(vz.at(
idx))}});
254 return *std::max_element(h_submax.begin(), h_submax.end());
272 int max_loops = 2000;
273 float total_exec_time = 0.0;
275 double total_exec_time = 0.0;
276 std::time_t timer1, timer2;
283 float time_diff = std::difftime(timer2, timer1);
284 std::cout <<
"tau = " <<
tau_ <<
" fm; ";
285 std::cout <<
"max_ed = " << max_ed <<
" ";
286 std::cout <<
"Total computing time: " << time_diff <<
" s; ";
287 std::cout << std::endl;
288 if ( max_ed < 0.5 )
break;
291 std::cout <<
"Total computing time: " << total_exec_time <<
" s; ";
292 }
catch (cl::Error &
err) {
293 std::cout << err.what() <<
" " << err.err() << std::endl;
294 std::cerr<<
"@" << __FILE__ <<
":line " << __LINE__ << std::endl;
318 const std::vector<float> & vx,
319 const std::vector<float> & vy,
320 const std::vector<float> & vz);
323 const std::vector<double> & vx,
324 const std::vector<double> & vy,
325 const std::vector<double> & vz);