Need for indicating alignment/padding?

Open
#190 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
cpp
Domain
api

Research direction

Start with issue #190 and clarify the compelling alignment or padding use case, since no files or tests are identified. Compare the proposed four-bit power-of-two alignment flag, an additional padded-allocation bit, and extending the struct; done means an agreed design with its allocation and large-load semantics documented.

Written by the indexing model from the issue text.

Description

Right now I am not sure there is a large need for this, as in most cases importers can discover the data alignment itself quickly from the pointer and e.g. CUDA base allocations are padded to 256 bytes.

But it came up once more as a question whether we could indicate alignment and ISTR at least some discussion around it a long time ago. So if there is a compelling use-case it would seem reasonable to me to add this.

One way I think this could be done cheaply, is to:

  • Use 4 bits (uint4) of the flag space to store a power of two alignment (alignment = 2**uint4_val).
  • Either assuming a padded allocation or using an additional bit to indicate that the allocation is padded to allow large loads (writes?).

(Of course one could also extend the struct, this just seems like a smaller decision to use a bit of flag space even if not quite unlimited.)

Dominant language
C++
Stars
1.3k
Forks
168
Avg merge
1m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dmlc/dlpack

All issues in dmlc/dlpack

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.