mgcpp
A C++ Math Library Based on CUDA
include
mgcpp
context
thread_context.hpp
Go to the documentation of this file.
1
2
// Copyright RedPortal, mujjingun 2017 - 2018.
3
// Distributed under the Boost Software License, Version 1.0.
4
// (See accompanying file LICENSE or copy at
5
// http://www.boost.org/LICENSE_1_0.txt)
6
7
#ifndef _MGCPP_CONTEXT_THREAD_CONTEXT_HPP_
8
#define _MGCPP_CONTEXT_THREAD_CONTEXT_HPP_
9
10
#include <cublas_v2.h>
11
12
#include <functional>
13
#include <memory>
14
#include <unordered_map>
15
16
namespace
mgcpp
{
17
template
<
typename
T,
typename
U>
18
using
hash_table
= std::unordered_map<T, U>;
19
20
class
thread_context
{
21
private
:
22
using
cublas_handle_unique_ptr =
23
std::unique_ptr<cublasContext, std::function<void(cublasHandle_t)>>;
24
25
hash_table<size_t, cublas_handle_unique_ptr>
_cublas_handle;
26
27
public
:
28
thread_context
() =
default
;
29
thread_context
(
thread_context
const
& other) =
delete
;
30
thread_context
&
operator=
(
thread_context
const
& other) =
delete
;
31
32
thread_context
(
thread_context
&& other) noexcept;
33
34
thread_context
&
operator=
(
thread_context
&& other) noexcept;
35
36
cublasHandle_t
get_cublas_context
(
size_t
device_id);
37
};
38
}
// namespace mgcpp
39
40
#endif
mgcpp
Definition:
adapter_base.hpp:12
mgcpp::thread_context
Definition:
thread_context.hpp:20
mgcpp::hash_table
std::unordered_map< T, U > hash_table
Definition:
thread_context.hpp:18
mgcpp::thread_context::thread_context
thread_context()=default
mgcpp::thread_context::operator=
thread_context & operator=(thread_context const &other)=delete
mgcpp::thread_context::get_cublas_context
cublasHandle_t get_cublas_context(size_t device_id)
Generated by
1.8.13