Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ComputeEnvironment Class Reference

#include <qle/math/computeenvironment.hpp>

+ Inheritance diagram for ComputeEnvironment:
+ Collaboration diagram for ComputeEnvironment:

Public Member Functions

 ComputeEnvironment ()
 
 ~ComputeEnvironment ()
 
std::set< std::string > getAvailableDevices () const
 
bool hasContext () const
 
void selectContext (const std::string &deviceName)
 
ComputeContextcontext ()
 
void reset ()
 

Private Member Functions

void releaseFrameworks ()
 

Private Attributes

std::vector< ComputeFramework * > frameworks_
 
ComputeContextcurrentContext_
 
std::string currentContextDeviceName_
 

Detailed Description

Definition at line 39 of file computeenvironment.hpp.

Constructor & Destructor Documentation

◆ ComputeEnvironment()

Definition at line 27 of file computeenvironment.cpp.

+ Here is the call graph for this function:

◆ ~ComputeEnvironment()

Definition at line 29 of file computeenvironment.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ getAvailableDevices()

std::set< std::string > getAvailableDevices ( ) const

Definition at line 45 of file computeenvironment.cpp.

45 {
46 std::set<std::string> result;
47 for (auto const& f : frameworks_) {
48 auto tmp = f->getAvailableDevices();
49 result.insert(tmp.begin(), tmp.end());
50 }
51 return result;
52}
std::vector< ComputeFramework * > frameworks_
+ Here is the caller graph for this function:

◆ hasContext()

bool hasContext ( ) const

Definition at line 54 of file computeenvironment.cpp.

54{ return currentContext_ != nullptr; }

◆ selectContext()

void selectContext ( const std::string &  deviceName)

Definition at line 56 of file computeenvironment.cpp.

56 {
57 if (currentContextDeviceName_ == deviceName)
58 return;
59 for (auto& f : frameworks_) {
60 if (auto tmp = f->getAvailableDevices(); tmp.find(deviceName) != tmp.end()) {
61 currentContext_ = f->getContext(deviceName);
63 currentContextDeviceName_ = deviceName;
64 return;
65 }
66 }
67 QL_FAIL("ComputeEnvironment::selectContext(): device '"
68 << deviceName << "' not found. Available devices: " << boost::join(getAvailableDevices(), ","));
69}
virtual void init()=0
std::set< std::string > getAvailableDevices() const
+ Here is the call graph for this function:

◆ context()

ComputeContext & context ( )

Definition at line 71 of file computeenvironment.cpp.

71{ return *currentContext_; }

◆ reset()

void reset ( )

Definition at line 37 of file computeenvironment.cpp.

37 {
38 currentContext_ = nullptr;
41 for (auto& c : ComputeFrameworkRegistry::instance().getAll())
42 frameworks_.push_back(c());
43}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ releaseFrameworks()

void releaseFrameworks ( )
private

Definition at line 31 of file computeenvironment.cpp.

31 {
32 for (auto& f : frameworks_)
33 delete f;
34 frameworks_.clear();
35}
+ Here is the caller graph for this function:

Member Data Documentation

◆ frameworks_

std::vector<ComputeFramework*> frameworks_
private

Definition at line 52 of file computeenvironment.hpp.

◆ currentContext_

ComputeContext* currentContext_
private

Definition at line 53 of file computeenvironment.hpp.

◆ currentContextDeviceName_

std::string currentContextDeviceName_
private

Definition at line 54 of file computeenvironment.hpp.