2014-02-10 19:53:03 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2014-02-10 19:53:03 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-05-21 12:09:22 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2014-02-10 19:53:03 +00:00
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2014-02-10 19:53:03 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2014-03-07 15:19:09 +00:00
|
|
|
#ifndef vtk_m_cont_testing_Testing_h
|
|
|
|
#define vtk_m_cont_testing_Testing_h
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2018-04-10 17:57:43 +00:00
|
|
|
#include <vtkm/cont/EnvironmentTracker.h>
|
2014-02-10 19:53:03 +00:00
|
|
|
#include <vtkm/cont/Error.h>
|
|
|
|
#include <vtkm/testing/Testing.h>
|
2018-04-10 17:57:43 +00:00
|
|
|
#include <vtkm/thirdparty/diy/Configure.h>
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
VTKM_THIRDPARTY_PRE_INCLUDE
|
|
|
|
#include VTKM_DIY(diy/mpi.hpp)
|
|
|
|
VTKM_THIRDPARTY_POST_INCLUDE
|
2014-02-10 19:53:03 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
namespace testing
|
|
|
|
{
|
2014-02-10 19:53:03 +00:00
|
|
|
|
|
|
|
struct Testing
|
|
|
|
{
|
|
|
|
public:
|
2017-05-18 14:29:41 +00:00
|
|
|
template <class Func>
|
2016-10-19 22:42:58 +00:00
|
|
|
static VTKM_CONT int Run(Func function)
|
2014-02-10 19:53:03 +00:00
|
|
|
{
|
|
|
|
try
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2014-02-10 19:53:03 +00:00
|
|
|
function();
|
2014-02-11 21:20:30 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
catch (vtkm::testing::Testing::TestFailure& error)
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
std::cout << "***** Test failed @ " << error.GetFile() << ":" << error.GetLine() << std::endl
|
2014-02-10 19:53:03 +00:00
|
|
|
<< error.GetMessage() << std::endl;
|
|
|
|
return 1;
|
2014-02-11 21:20:30 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
catch (vtkm::cont::Error& error)
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2014-02-10 19:53:03 +00:00
|
|
|
std::cout << "***** Uncaught VTKm exception thrown." << std::endl
|
|
|
|
<< error.GetMessage() << std::endl;
|
|
|
|
return 1;
|
2014-02-11 21:20:30 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
catch (std::exception& error)
|
2015-08-28 18:19:46 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
std::cout << "***** STL exception throw." << std::endl << error.what() << std::endl;
|
2015-08-28 18:19:46 +00:00
|
|
|
}
|
2014-02-10 19:53:03 +00:00
|
|
|
catch (...)
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2014-02-10 19:53:03 +00:00
|
|
|
std::cout << "***** Unidentified exception thrown." << std::endl;
|
|
|
|
return 1;
|
2014-02-11 21:20:30 +00:00
|
|
|
}
|
2014-02-10 19:53:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
2018-04-10 17:57:43 +00:00
|
|
|
|
|
|
|
struct Environment
|
|
|
|
{
|
|
|
|
VTKM_CONT Environment(int* argc, char*** argv)
|
|
|
|
{
|
|
|
|
#if defined(VTKM_ENABLE_MPI)
|
|
|
|
int provided_threading;
|
|
|
|
MPI_Init_thread(argc, argv, MPI_THREAD_FUNNELED, &provided_threading);
|
|
|
|
|
|
|
|
// set the global communicator to use in VTKm.
|
|
|
|
diy::mpi::communicator comm(MPI_COMM_WORLD);
|
|
|
|
vtkm::cont::EnvironmentTracker::SetCommunicator(comm);
|
|
|
|
#else
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT ~Environment()
|
|
|
|
{
|
|
|
|
#if defined(VTKM_ENABLE_MPI)
|
|
|
|
MPI_Finalize();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-10 19:53:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::cont::testing
|
|
|
|
|
2014-06-11 16:43:36 +00:00
|
|
|
#endif //vtk_m_cont_internal_Testing_h
|