Updates will be applied - 3:30pm EDT (UTC -500). No downtime expected.

Commit 3a7b9d84 authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Kitware Robot

Merge topic 'fix-cosmo-tools-examples'

e9d0d7de Fix the CosmoTools examples
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Haocheng LIU's avatarHaocheng LIU <haocheng.liu@kitware.com>
Merge-request: !1462
parents 412fe9bb e9d0d7de
......@@ -25,24 +25,16 @@ project(CosmoTools CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
add_executable(CosmoCenterFinder_SERIAL CosmoCenterFinder.cxx)
add_executable(CosmoHaloFinder_SERIAL CosmoHaloFinder.cxx)
target_link_libraries(CosmoCenterFinder_SERIAL PRIVATE vtkm_cont)
target_link_libraries(CosmoHaloFinder_SERIAL PRIVATE vtkm_cont)
if(TARGET vtkm::cuda)
add_executable(CosmoCenterFinder_CUDA CosmoCenterFinder.cu)
add_executable(CosmoHaloFinder_CUDA CosmoHaloFinder.cu)
vtkm_compile_as_cuda(cu_srcs CosmoCenterFinder.cxx)
add_executable(CosmoCenterFinder ${cu_srcs})
target_link_libraries(CosmoCenterFinder_CUDA PRIVATE vtkm_cont)
target_link_libraries(CosmoHaloFinder_CUDA PRIVATE vtkm_cont)
vtkm_compile_as_cuda(cu_srcs CosmoHaloFinder.cxx)
add_executable(CosmoHaloFinder ${cu_srcs})
else()
add_executable(CosmoCenterFinder CosmoCenterFinder.cxx)
add_executable(CosmoHaloFinder CosmoHaloFinder.cxx)
endif()
if(TARGET vtkm::tbb)
add_executable(CosmoCenterFinder_TBB CosmoCenterFinderTBB.cxx)
add_executable(CosmoHaloFinder_TBB CosmoHaloFinderTBB.cxx)
target_link_libraries(CosmoCenterFinder_TBB PRIVATE vtkm_cont)
target_link_libraries(CosmoHaloFinder_TBB PRIVATE vtkm_cont)
endif()
target_link_libraries(CosmoCenterFinder PRIVATE vtkm_cont)
target_link_libraries(CosmoHaloFinder PRIVATE vtkm_cont)
//============================================================================
// 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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_CUDA
#include "CosmoCenterFinder.cxx"
......@@ -19,8 +19,7 @@
//============================================================================
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
......@@ -32,7 +31,7 @@
#include <stdexcept>
#include <string>
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
static const vtkm::cont::LogLevel CosmoLogLevel = vtkm::cont::LogLevel(1);
void TestCosmoCenterFinder(const char* fileName)
{
......@@ -72,29 +71,27 @@ void TestCosmoCenterFinder(const char* fileName)
vtkm::Pair<vtkm::Id, vtkm::Float32> nxnResult;
vtkm::Pair<vtkm::Id, vtkm::Float32> mxnResult;
vtkm::cont::Timer<DeviceAdapter> total;
vtkm::cont::Timer<DeviceAdapter> timer;
const vtkm::Float32 particleMass = 1.08413e+09f;
vtkm::worklet::CosmoTools cosmoTools;
// Create the worklet and run it
vtkm::Float32 particleMass = 1.08413e+09f;
{
VTKM_LOG_SCOPE(CosmoLogLevel, "Executing NxN");
vtkm::worklet::CosmoTools cosmoTools;
cosmoTools.RunMBPCenterFinderNxN(
xLocArray, yLocArray, zLocArray, nParticles, particleMass, nxnResult, DeviceAdapter());
vtkm::Float64 nxnTime = timer.GetElapsedTime();
cosmoTools.RunMBPCenterFinderNxN(
xLocArray, yLocArray, zLocArray, nParticles, particleMass, nxnResult);
std::cout << "**** NxN MPB = " << nxnResult.first << " potential = " << nxnResult.second
<< std::endl;
std::cout << "**** Time for NxN: " << nxnTime << std::endl;
VTKM_LOG_S(CosmoLogLevel,
"NxN MPB = " << nxnResult.first << " potential = " << nxnResult.second);
}
timer.Reset();
cosmoTools.RunMBPCenterFinderMxN(
xLocArray, yLocArray, zLocArray, nParticles, particleMass, mxnResult, DeviceAdapter());
vtkm::Float64 estTime = timer.GetElapsedTime();
{
VTKM_LOG_SCOPE(CosmoLogLevel, "Executing MxN");
cosmoTools.RunMBPCenterFinderMxN(
xLocArray, yLocArray, zLocArray, nParticles, particleMass, mxnResult);
std::cout << "**** MxN MPB = " << mxnResult.first << " potential = " << mxnResult.second
<< std::endl;
std::cout << "**** Time for MxN: " << estTime << std::endl;
VTKM_LOG_S(CosmoLogLevel,
"MxN MPB = " << mxnResult.first << " potential = " << mxnResult.second);
}
if (nxnResult.first == mxnResult.first)
std::cout << "FOUND CORRECT PARTICLE " << mxnResult.first << " with potential "
......@@ -123,12 +120,20 @@ void TestCosmoCenterFinder(const char* fileName)
int main(int argc, char* argv[])
{
vtkm::cont::SetLogLevelName(CosmoLogLevel, "Cosmo");
vtkm::cont::SetStderrLogLevel(CosmoLogLevel);
vtkm::cont::InitLogging(argc, argv);
if (argc < 2)
{
std::cout << "Usage: " << std::endl << "$ " << argv[0] << " <input_file>" << std::endl;
return 1;
}
#ifndef VTKM_ENABLE_LOGGING
std::cout << "Warning: turn on VTKm_ENABLE_LOGGING CMake option to turn on timing." << std::endl;
#endif
TestCosmoCenterFinder(argv[1]);
return 0;
......
//============================================================================
// 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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_TBB
#include "CosmoCenterFinder.cxx"
//============================================================================
// 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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_CUDA
#include "CosmoHaloFinder.cxx"
......@@ -19,8 +19,7 @@
//============================================================================
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
......@@ -32,7 +31,7 @@
#include <stdexcept>
#include <string>
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
static const vtkm::cont::LogLevel CosmoLogLevel = vtkm::cont::LogLevel(1);
void TestCosmoHaloFinder(const char* fileName)
{
......@@ -73,28 +72,26 @@ void TestCosmoHaloFinder(const char* fileName)
vtkm::cont::ArrayHandle<vtkm::Id> resultMBP;
vtkm::cont::ArrayHandle<vtkm::Float32> resultPot;
vtkm::cont::Timer<DeviceAdapter> total;
vtkm::cont::Timer<DeviceAdapter> timer;
// Create the worklet and run it
vtkm::Id minHaloSize = 20;
vtkm::Float32 linkingLength = 0.2f;
vtkm::Float32 particleMass = 1.08413e+09f;
vtkm::worklet::CosmoTools cosmoTools;
cosmoTools.RunHaloFinder(xLocArray,
yLocArray,
zLocArray,
nParticles,
particleMass,
minHaloSize,
linkingLength,
resultHaloId,
resultMBP,
resultPot,
DeviceAdapter());
vtkm::Float64 haloTime = timer.GetElapsedTime();
std::cout << "**** Time for HaloFinder: " << haloTime << std::endl;
{
VTKM_LOG_SCOPE(CosmoLogLevel, "Executing HaloFinder");
vtkm::worklet::CosmoTools cosmoTools;
cosmoTools.RunHaloFinder(xLocArray,
yLocArray,
zLocArray,
nParticles,
particleMass,
minHaloSize,
linkingLength,
resultHaloId,
resultMBP,
resultPot);
}
xLocArray.ReleaseResources();
yLocArray.ReleaseResources();
......@@ -117,12 +114,20 @@ void TestCosmoHaloFinder(const char* fileName)
int main(int argc, char* argv[])
{
vtkm::cont::SetLogLevelName(CosmoLogLevel, "Cosmo");
vtkm::cont::SetStderrLogLevel(CosmoLogLevel);
vtkm::cont::InitLogging(argc, argv);
if (argc < 2)
{
std::cout << "Usage: " << std::endl << "$ " << argv[0] << " <input_file>" << std::endl;
return 1;
}
#ifndef VTKM_ENABLE_LOGGING
std::cout << "Warning: turn on VTKm_ENABLE_LOGGING CMake option to turn on timing." << std::endl;
#endif
TestCosmoHaloFinder(argv[1]);
return 0;
......
//============================================================================
// 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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_TBB
#include "CosmoHaloFinder.cxx"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment