Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make calculate new vl configurable #608

Merged
merged 3 commits into from
Nov 28, 2024
Merged

Make calculate new vl configurable #608

merged 3 commits into from
Nov 28, 2024

Conversation

rez5427
Copy link
Contributor

@rez5427 rez5427 commented Oct 29, 2024

I don't know whether sail-riscv needs this.
The spike uses VLMAX to calculate new vl, and sail-riscv uses (AVL + 1) / 2.

The spec says:

The number of bits implemented in vl depends on the implementation’s maximum vector
length of the smallest supported type. The smallest vector implementation with VLEN=32
and supporting SEW=8 would need at least six bits in vl to hold the values 0-32
(VLEN=32, with LMUL=8 and SEW=8, yields VLMAX=32).

Copy link

github-actions bot commented Oct 29, 2024

Test Results

396 tests  ±0   396 ✅ ±0   0s ⏱️ ±0s
  4 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 21f2417. ± Comparison against base commit 07fa23e.

♻️ This comment has been updated with latest results.

@Timmmm
Copy link
Collaborator

Timmmm commented Nov 22, 2024

LGTM but I would add some explanation and move the if to the place where it is actually used. Also move the to_bits outside the body to make it clearer.

val sys_vext_vl_use_ceil = pure "sys_vext_vl_use_ceil" : unit -> bool

function calculate_new_vl(AVL : int, VLMAX : int) -> xlenbits = {
  // See "Constraints on Setting vl" in the vector spec.
  let vl =
    if AVL <= VLMAX then AVL
    else if AVL < 2 * VLMAX then {
      // If VLMAX < AVL < 2 * VLMAX then we can use any value
      // such that ceil(AVL / 2) <= vl <= VLMAX. Here we provide
      // two options: ceil(AVL / 2) or VLMAX.
      if sys_vext_vl_use_ceil() then (AVL + 1) / 2 else VLMAX
    }
    else VLMAX;

  to_bits(xlen, vl)
}

(Feel free to copy/paste.)

@Timmmm Timmmm self-requested a review November 22, 2024 10:21
Copy link
Collaborator

@Timmmm Timmmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'm not a vector expert though so we might want to get the opinion of someone who is (although the spec seems pretty unambiguous on this point). I can ask a colleague if nobody is forthcoming.

@avakar
Copy link

avakar commented Nov 27, 2024

@Timmmm's colleague here. LGTM.

@@ -32,6 +32,8 @@ uint64_t rv_ram_size = UINT64_C(0x4000000);
uint64_t rv_rom_base = UINT64_C(0x1000);
uint64_t rv_rom_size = UINT64_C(0x100);

bool rv_vext_vl_use_ceil = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message doesn't mention that you're changing the default behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry..., Is this commit message ok?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which commit message you changed... but don't worry I will squash it and write a descriptive message.

@Timmmm Timmmm merged commit 3911cb7 into riscv:master Nov 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants