Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 84b52ca

Browse files
author
Gong, Jiong
committed
allocate mkldnn memory with mlsl api in multinode mode
1 parent 8a80b3a commit 84b52ca

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

include/caffe/mkldnn_memory.hpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,21 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr
112112

113113
void allocate() {
114114
if (_prv_memory == NULL) {
115+
#ifdef USE_MLSL
116+
if (mn::is_multinode()) {
117+
auto mlsl_free = [](char* p) { mn::free((void*)p); };
118+
_mlsl_memory.reset(
119+
(char*)mn::alloc(_prv_memory_pd->get_size(), 64), mlsl_free);
120+
_prv_memory = shared_ptr<memory>(
121+
new memory(*_prv_memory_pd, (void*)_mlsl_memory.get()));
122+
} else {
123+
#endif
115124
_prv_memory = shared_ptr<memory>(new memory(*_prv_memory_pd));
116-
_internal_ptr = (Dtype *)(_prv_memory->get_data_handle());
117-
// TODO: may need initialize memory by 0
125+
#ifdef USE_MLSL
126+
}
127+
#endif
128+
_internal_ptr = (Dtype *)(_prv_memory->get_data_handle());
129+
// TODO: may need initialize memory by 0
118130
}
119131
}
120132
void set_prv_memory_pd(shared_ptr<memory::primitive_desc> memory_pd) {
@@ -156,6 +168,9 @@ class MKLDNNMemoryDescriptorBase : public PrvMemDescr
156168

157169
MKLDNNLayer<Dtype>* _mkldnn_layer;
158170
Blob<Dtype>* _blob;
171+
#ifdef USE_MLSL
172+
shared_ptr<char> _mlsl_memory;
173+
#endif
159174
};
160175

161176
template <typename Dtype, bool is_diff>

0 commit comments

Comments
 (0)