//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. // // Copyright 2014 Sandia Corporation. // Copyright 2014 UT-Battelle, LLC. // Copyright 2014 Los Alamos National Security. // // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. // // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ #ifndef VTKM_DEVICE_ADAPTER #define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL #endif #include #include #include #include #include #include #include #include void RunTest(const std::string &fname, vtkm::Id numSeeds, vtkm::Id numSteps, vtkm::Float32 stepSize, vtkm::Id numThreads, vtkm::Id advectType) { typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; typedef vtkm::Float32 FieldType; typedef vtkm::cont::ArrayHandle > FieldHandle; typedef typename FieldHandle::template ExecutionTypes::PortalConst FieldPortalConstType; vtkm::io::reader::BOVDataSetReader rdr(fname); vtkm::cont::DataSet ds = rdr.ReadDataSet(); vtkm::worklet::particleadvection::RegularGridEvaluate eval(ds); typedef vtkm::worklet::particleadvection::RegularGridEvaluate RGEvalType; typedef vtkm::worklet::particleadvection::RK4Integrator RK4RGType; RK4RGType rk4(eval, stepSize); std::vector > seeds; vtkm::Bounds bounds = ds.GetCoordinateSystem().GetBounds(); srand(314); for (int i = 0; i < numSeeds; i++) { vtkm::Vec p; vtkm::Float32 rx = (vtkm::Float32)rand()/(vtkm::Float32)RAND_MAX; vtkm::Float32 ry = (vtkm::Float32)rand()/(vtkm::Float32)RAND_MAX; vtkm::Float32 rz = (vtkm::Float32)rand()/(vtkm::Float32)RAND_MAX; p[0] = static_cast(bounds.X.Min + rx*bounds.X.Length()); p[1] = static_cast(bounds.Y.Min + ry*bounds.Y.Length()); p[2] = static_cast(bounds.Z.Min + rz*bounds.Z.Length()); seeds.push_back(p); } #ifdef __BUILDING_TBB_VERSION__ int nT = tbb::task_scheduler_init::default_num_threads(); if (numThreads != -1) nT = numThreads; //make sure the task_scheduler_init object is in scope when running sth w/ TBB tbb::task_scheduler_init init(nT); #endif vtkm::worklet::particleadvection::ParticleAdvectionFilter pa(rk4,seeds,ds,numSteps,(advectType==1)); //time only the actual run auto start = std::chrono::high_resolution_clock::now(); pa.run(false); auto duration_taken = std::chrono::high_resolution_clock::now() - start; std::uint64_t runtime = std::chrono::duration_cast(duration_taken).count(); std::cerr << "Runtime = " << runtime << " ms" << std::endl; } bool ParseArgs(int argc, char **argv, vtkm::Id &numSeeds, vtkm::Id &numSteps, vtkm::Float32 &stepSize, vtkm::Id &advectType, vtkm::Id &numThreads, std::string &dataFile, std::string &pgmType) { numSeeds = 100; numSteps = 100; stepSize = 0.1f; advectType = 0; numThreads = -1; dataFile = ""; pgmType = "UNKNOWN"; if (argc < 2) { std::cerr<<"Usage "<(atoi(argv[++i])); else if (arg == "-steps") numSteps = static_cast(atoi(argv[++i])); else if (arg == "-h") stepSize = static_cast(atof(argv[++i])); else if (arg == "-particle") advectType = 0; else if (arg == "-streamline") advectType = 1; else if (arg == "-file") dataFile = argv[++i]; else if (arg == "-t") numThreads = static_cast(atoi(argv[++i])); else std::cerr<<"Unexpected argument: "<