Skip to content

Commit fd26465

Browse files
adstrawLucien0
authored andcommitted
[Hexagon] Remove HexagonBuffer external constructor and support (apache#10978)
1 parent 2ebcb3b commit fd26465

File tree

3 files changed

+0
-64
lines changed

3 files changed

+0
-64
lines changed

src/runtime/hexagon/hexagon/hexagon_buffer.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,6 @@ HexagonBuffer::HexagonBuffer(size_t nallocs, size_t nbytes, size_t alignment,
170170
managed_allocations_.push_back(std::move(alloca));
171171
}
172172

173-
HexagonBuffer::HexagonBuffer(void* data, size_t nbytes, Optional<String> scope)
174-
: ndim_(1), nbytes_per_allocation_(nbytes) {
175-
SetStorageScope(scope);
176-
// disallow external VTCM allocations
177-
CHECK(GetStorageScope() != HexagonBuffer::StorageScope::kVTCM);
178-
allocations_.push_back(data);
179-
}
180-
181173
HexagonBuffer::~HexagonBuffer() { managed_allocations_.clear(); }
182174

183175
void* HexagonBuffer::GetPointer() {
@@ -283,30 +275,20 @@ void hexagon_buffer_copy_across_regions(const BufferSet& dest, const BufferSet&
283275
}
284276

285277
void HexagonBuffer::CopyTo(void* data, size_t nbytes) const {
286-
CHECK(managed_allocations_.size() && "CopyTo not supported on unmanaged `external` allocations");
287-
288278
BufferSet src(allocations_.data(), allocations_.size(), nbytes_per_allocation_);
289279
BufferSet dest(&data, 1, nbytes);
290280

291281
hexagon_buffer_copy_across_regions(dest, src, nbytes);
292282
}
293283

294284
void HexagonBuffer::CopyFrom(void* data, size_t nbytes) {
295-
CHECK(managed_allocations_.size() &&
296-
"CopyFrom not supported on unmanaged `external` allocations");
297-
298285
BufferSet src(&data, 1, nbytes);
299286
BufferSet dest(allocations_.data(), allocations_.size(), nbytes_per_allocation_);
300287

301288
hexagon_buffer_copy_across_regions(dest, src, nbytes);
302289
}
303290

304291
void HexagonBuffer::CopyFrom(const HexagonBuffer& other, size_t nbytes) {
305-
CHECK(managed_allocations_.size() &&
306-
"CopyFrom not supported on unmanaged `external` allocations");
307-
CHECK(other.managed_allocations_.size() &&
308-
"CopyFrom not supported on unmanaged `external` allocations");
309-
310292
BufferSet src(other.allocations_.data(), other.allocations_.size(), other.nbytes_per_allocation_);
311293
BufferSet dest(allocations_.data(), allocations_.size(), nbytes_per_allocation_);
312294

src/runtime/hexagon/hexagon/hexagon_buffer.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ class HexagonBuffer {
6767
*/
6868
HexagonBuffer(size_t nallocs, size_t nbytes, size_t alignment, Optional<String> scope);
6969

70-
/* \brief Construct a Hexagon Buffer from an external buffer.
71-
*
72-
* \param data The pointer to the external buffer.
73-
*
74-
* \param nbytes The size of the external buffer in bytes.
75-
*
76-
* \param scope Optional storage scope indicating the memory
77-
* space in which to allocate. Defaults to global system
78-
* memory (DDR).
79-
*/
80-
explicit HexagonBuffer(void* data, size_t nbytes, Optional<String> scope);
81-
8270
//! \brief Destruction deallocates the underlying allocations.
8371
~HexagonBuffer();
8472

tests/cpp/runtime/hexagon_buffer.cc

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -462,37 +462,3 @@ TEST(HexagonBuffer, nd_copy_to) {
462462
EXPECT_EQ(data_in[i], data_out[i]);
463463
}
464464
}
465-
466-
TEST(HexagonBuffer, external) {
467-
std::vector<uint8_t> data{0, 1, 2, 3, 4, 5, 6, 7};
468-
469-
Optional<String> def;
470-
HexagonBuffer hb_default(data.data(), data.size(), def);
471-
EXPECT_EQ(hb_default.GetPointer(), data.data());
472-
EXPECT_EQ(hb_default.GetStorageScope(), HexagonBuffer::StorageScope::kDDR);
473-
474-
Optional<String> global("global");
475-
HexagonBuffer hb_global(data.data(), data.size(), global);
476-
EXPECT_EQ(hb_global.GetPointer(), data.data());
477-
EXPECT_EQ(hb_global.GetStorageScope(), HexagonBuffer::StorageScope::kDDR);
478-
479-
Optional<String> vtcm("global.vtcm");
480-
EXPECT_THROW(HexagonBuffer hb_vtcm(data.data(), data.size(), vtcm), InternalError);
481-
482-
Optional<String> invalid("invalid");
483-
EXPECT_THROW(HexagonBuffer hb_vtcm(data.data(), data.size(), invalid), InternalError);
484-
}
485-
486-
TEST(HexagonBuffer, external_copy) {
487-
std::vector<uint8_t> data1{0, 1, 2, 3, 4, 5, 6, 7};
488-
Optional<String> global("global");
489-
HexagonBuffer hb_ext(data1.data(), data1.size(), global);
490-
491-
std::vector<uint8_t> data2{0, 1, 2, 3, 4, 5, 6, 7};
492-
EXPECT_THROW(hb_ext.CopyTo(data2.data(), data2.size()), InternalError);
493-
EXPECT_THROW(hb_ext.CopyFrom(data2.data(), data2.size()), InternalError);
494-
495-
HexagonBuffer hb(8 /* nbytes */, 8 /* alignment */, global);
496-
EXPECT_THROW(hb.CopyFrom(hb_ext, 8), InternalError);
497-
EXPECT_THROW(hb_ext.CopyFrom(hb, 8), InternalError);
498-
}

0 commit comments

Comments
 (0)