DFT-EFE
 
Loading...
Searching...
No Matches
LinAlgOpContext.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Ian C. Lin, Sambit Das
24 */
25
26#ifndef dftefeLinAlgOpContext_h
27#define dftefeLinAlgOpContext_h
28
30#include <memory>
31#include <utils/DeviceUtils.h>
38namespace dftefe
39{
40 namespace linearAlgebra
41 {
43 {
44 FP32,
45 TF32,
46 BF16,
47 FP16
48 };
49
50 template <utils::MemorySpace memorySpace>
52 {
53 public:
55
56 ~LinAlgOpContext() = default;
57
58 void
60 {
61 d_opType = opType;
62 }
63
66 {
67 return d_opType;
68 }
69
72
75 {
76 return d_stream;
77 }
78
81 {
82 return d_deviceBlasHandle;
83 }
84
87 {
88 return d_numBlasStreams;
89 }
90
93 {
94 return d_streams.data();
95 }
96
99 {
100 return d_deviceBlasHandles.data();
101 }
102
103 private:
105 inline static std::vector<utils::deviceBlasHandle_t> d_deviceBlasHandles;
106 inline static std::vector<utils::deviceStream_t> d_streams;
107
110
113
116 utils::deviceStream_t & streamId);
117
120
123
124 }; // end of LinAlgOpContext
125 } // end of namespace linearAlgebra
126} // end of namespace dftefe
128#endif // end of dftefeLinAlgOpContext_h
Definition: LinAlgOpContext.h:52
static utils::deviceStream_t * getBlasStreamsVec()
Definition: LinAlgOpContext.h:92
static std::vector< utils::deviceStream_t > d_streams
Definition: LinAlgOpContext.h:106
static utils::deviceStream_t & getBlasStream()
Definition: LinAlgOpContext.h:74
TensorOpDataType getTensorOpDataType()
Definition: LinAlgOpContext.h:65
TensorOpDataType d_opType
storage for deviceblas handle
Definition: LinAlgOpContext.h:112
void setTensorOpDataType(TensorOpDataType opType)
Definition: LinAlgOpContext.h:59
static utils::deviceStream_t d_stream
Definition: LinAlgOpContext.h:109
static std::vector< utils::deviceBlasHandle_t > d_deviceBlasHandles
Definition: LinAlgOpContext.h:105
static utils::deviceBlasStatus_t setBlasStream(utils::deviceStream_t &streamId)
Definition: LinAlgOpContext.t.cpp:104
static utils::deviceBlasHandle_t & getDeviceBlasHandle()
Definition: LinAlgOpContext.h:80
size_type numBlasStreams() const
Definition: LinAlgOpContext.h:86
size_type d_numBlasStreams
Definition: LinAlgOpContext.h:104
utils::deviceBlasStatus_t create(utils::deviceBlasHandle_t &handleId)
Definition: LinAlgOpContext.t.cpp:129
static utils::deviceBlasHandle_t * getDeviceBlasHandlesVec()
Definition: LinAlgOpContext.h:98
utils::deviceBlasStatus_t destroy(utils::deviceBlasHandle_t &handleId)
Definition: LinAlgOpContext.t.cpp:145
static utils::deviceBlasHandle_t d_deviceBlasHandle
Definition: LinAlgOpContext.h:108
TensorOpDataType
Definition: LinAlgOpContext.h:43
cublasHandle_t deviceBlasHandle_t
Definition: DeviceTypeConfig.cu.h:36
cudaStream_t deviceStream_t
Definition: DeviceTypeConfig.cu.h:27
cublasStatus_t deviceBlasStatus_t
Definition: DeviceTypeConfig.cu.h:38
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9