* \brief Aligned workspace bundle. * * Each individual workspace is aligned to align_in_bytes. */
| 272 | * Each individual workspace is aligned to align_in_bytes. |
| 273 | */ |
| 274 | class WorkspaceBundle { |
| 275 | public: |
| 276 | WorkspaceBundle( |
| 277 | void* ptr, SmallVector<size_t> sizes_in_bytes, size_t align_in_bytes = 512); |
| 278 | /** |
| 279 | * \returns raw workspace ptr. |
| 280 | * |
| 281 | * Note that ptr() is different than get(0), in that |
| 282 | * the result of ptr() is possibly not aligned. |
| 283 | */ |
| 284 | void* ptr() const; |
| 285 | /** |
| 286 | * \returns the i-th workspace ptr (aligned) |
| 287 | */ |
| 288 | void* get(size_t i) const; |
| 289 | /** |
| 290 | * \returns total size taking into account paddings to solve alignment |
| 291 | * issue. |
| 292 | */ |
| 293 | size_t total_size_in_bytes() const; |
| 294 | size_t get_size(size_t i) const; |
| 295 | size_t nr_workspace() const; |
| 296 | void set(void* ptr); |
| 297 | |
| 298 | Workspace get_workspace(size_t i) const { |
| 299 | return {static_cast<dt_byte*>(get(i)), get_size(i)}; |
| 300 | } |
| 301 | |
| 302 | private: |
| 303 | void* m_ptr; |
| 304 | SmallVector<size_t> m_sizes; |
| 305 | SmallVector<size_t> m_aligned_sizes; |
| 306 | size_t m_align_in_bytes; |
| 307 | }; |
| 308 | |
| 309 | MEGDNN_CONSTEXPR std::size_t operator"" _z(unsigned long long n) { |
| 310 | return n; |
no outgoing calls
no test coverage detected