Kokkos Node API and Local Linear Algebra Kernels Version of the Day
Kokkos_TPINode.cpp
00001 #include "Kokkos_TPINode.hpp"
00002 #include <iostream>
00003 #include <Teuchos_ParameterList.hpp>
00004 #include <Teuchos_TestForException.hpp>
00005 
00006 namespace Kokkos {
00007 
00008   TPINode::TPINode(Teuchos::ParameterList &plist) {
00009     using std::cout;
00010     using std::cerr;
00011     using std::endl;
00012 
00013     curNumThreads_ = plist.get<int>("Num Threads", 0);
00014     int verbose = plist.get<int>("Verbose",0);
00015     TEST_FOR_EXCEPTION(curNumThreads_ < 0, std::runtime_error, 
00016         "TPINode::TPINode(): invalid ""Num Threads"" specification.");
00017     if (verbose) {
00018       cout << "TPINode initializing with numThreads == " << curNumThreads_ << std::endl;
00019     }
00020     init(curNumThreads_);
00021   }
00022 
00023   void TPINode::init(int numThreads) {
00024     if (curNumThreads_ >= 1) {
00025       TPI_Finalize();
00026     }
00027     curNumThreads_ = numThreads;
00028     if (curNumThreads_ >= 1) {
00029       TPI_Init(curNumThreads_);
00030     }
00031   }
00032 
00033   TPINode::~TPINode()
00034   {
00035     if (curNumThreads_ >= 1) {
00036       TPI_Finalize();
00037     }
00038   }
00039 
00040 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends