• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CCSRC_PS_PS_CACHE_GPU_GPU_PS_CACHE_H_
18 #define MINDSPORE_CCSRC_PS_PS_CACHE_GPU_GPU_PS_CACHE_H_
19 
20 #include <cuda_runtime_api.h>
21 #include <memory>
22 #include "ps/ps_cache/ps_cache_basic.h"
23 
24 namespace mindspore {
25 namespace ps {
26 namespace gpu {
27 class GPUPsCache : public PsCacheBasic {
28  public:
29   GPUPsCache() = default;
30   ~GPUPsCache() override = default;
31   bool InitDevice(uint32_t device_id, const void *context) override;
32   void *MallocMemory(size_t size) override;
33   bool RecordEvent() override;
34   bool SynchronizeEvent() override;
35   bool SynchronizeStream() override;
36   bool CopyHostMemToDevice(void *dst, const void *src, size_t size) override;
37   bool CopyDeviceMemToHost(void *dst, const void *src, size_t size) override;
38   bool HashSwapOut(void *hash_table_addr, void *swap_out_value_addr, void *swap_out_index_addr, size_t cache_vocab_size,
39                    size_t embedding_size, size_t swap_out_size) override;
40   bool HashSwapIn(void *hash_table_addr, void *swap_in_value_addr, void *swap_in_index_addr, size_t cache_vocab_size,
41                   size_t embedding_size, size_t swap_in_size) override;
42 
43  private:
44   std::unique_ptr<cudaEvent_t> event_;
45 };
46 }  // namespace gpu
47 }  // namespace ps
48 }  // namespace mindspore
49 #endif  // MINDSPORE_CCSRC_PS_PS_CACHE_GPU_GPU_PS_CACHE_H_
50