@@ -58,10 +58,10 @@ DDPTensorImpl::DDPTensorImpl(const int64_t *shape, uint64_t N, rank_type owner)
5858
5959DDPTensorImpl::~DDPTensorImpl () {
6060 if (!_base) {
61- delete[] reinterpret_cast <char *>(_allocated);
61+ free (_allocated); // delete[] reinterpret_cast<char *>(_allocated);
6262 }
63- delete[] _gs_allocated;
64- delete[] _lo_allocated;
63+ free ( _gs_allocated) ;
64+ free ( _lo_allocated) ;
6565 delete[] _sizes;
6666 delete[] _strides;
6767}
@@ -72,7 +72,8 @@ DDPTensorImpl::ptr_type DDPTensorImpl::clone(bool copy) {
7272 auto sz = size ();
7373 auto esz = sizeof_dtype (dtype ());
7474 auto bsz = sz * esz;
75- auto allocated = new (std::align_val_t (esz)) char [bsz];
75+ auto allocated =
76+ aligned_alloc (esz, bsz); // new (std::align_val_t(esz)) char[bsz];
7677 auto aligned = allocated;
7778 if (copy)
7879 memcpy (aligned, _aligned, bsz);
@@ -82,7 +83,8 @@ DDPTensorImpl::ptr_type DDPTensorImpl::clone(bool copy) {
8283 // auto gs_aligned = gs_allocated;
8384 auto gs_allocated = _gs_allocated;
8485 auto gs_aligned = _gs_aligned;
85- auto lo_allocated = new uint64_t [nd];
86+ auto lo_allocated =
87+ (uint64_t *)aligned_alloc (sizeof (uint64_t ), nd * sizeof (uint64_t ));
8688 auto lo_aligned = lo_allocated;
8789 memcpy (lo_aligned, _lo_aligned, nd * sizeof (*lo_aligned));
8890
@@ -94,7 +96,9 @@ DDPTensorImpl::ptr_type DDPTensorImpl::clone(bool copy) {
9496
9597void DDPTensorImpl::alloc (bool all) {
9698 auto esz = sizeof_dtype (_dtype);
97- _allocated = new (std::align_val_t (esz)) char [esz * local_size ()];
99+ _allocated =
100+ aligned_alloc (esz, esz * local_size ()); // new (std::align_val_t(esz))
101+ // char[esz * local_size()];
98102 _aligned = _allocated;
99103 _offset = 0 ;
100104 if (all) {
0 commit comments