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

Support LMUL truncation and LMUL extension functions #54

Closed
zakk0610 opened this issue Dec 18, 2020 · 9 comments
Closed

Support LMUL truncation and LMUL extension functions #54

zakk0610 opened this issue Dec 18, 2020 · 9 comments

Comments

@zakk0610
Copy link
Collaborator

zakk0610 commented Dec 18, 2020

There are some requirements from users they want to keep current SEW but change LMUL (in #28 and #37)

Maybe intrinsic functions could support LMUL truncation and LMUL extension regardless of vl. (It mean those functions would not change vl register)

ps. I think this is not a Reinterpret operation because theirs VLEN are different.

naming could be vlmul_[ext|trunc]_v_<src_type_with_lmul>_<dst_type_with_lmul>

interfaces would looks like

// LMUL Extension, vlmul_ext_v_<src_lmul>_<target_lmul>
vint64m2_t vlmul_ext_v_i64m1_i64m2 (vint64m1_t op1);
vint64m4_t vlmul_ext_v_i64m1_i64m4 (vint64m1_t op1);
vint64m8_t vlmul_ext_v_i64m1_i64m8 (vint64m1_t op1);
vint64m4_t vlmul_ext_v_i64m2_i64m4 (vint64m2_t op1);
vint64m8_t vlmul_ext_v_i64m2_i64m8 (vint64m2_t op1);
vint64m8_t vlmul_ext_v_i64m4_i64m8 (vint64m4_t op1);

vint64m1_t vlmul_trunc_v_i64m2_i64m1 (vint64m2_t op1);
vint64m1_t vlmul_trunc_v_i64m4_i64m1 (vint64m4_t op1);
vint64m2_t vlmul_trunc_v_i64m4_i64m2 (vint64m4_t op1);
vint64m1_t vlmul_trunc_v_i64m8_i64m1 (vint64m8_t op1);
vint64m2_t vlmul_trunc_v_i64m8_i64m2 (vint64m8_t op1);
vint64m4_t vlmul_trunc_v_i64m8_i64m4 (vint64m8_t op1);

any thought?

@zakk0610
Copy link
Collaborator Author

What do you think @joy2myself @HanKuanChen?

@HanKuanChen
Copy link
Contributor

LGTM

@joy2myself
Copy link

Hi @zakk0610 ,
Thanks for your proposal! But it doesn't seem like what I want in #28. I want to combine two (or more) small LMUL vectors to one big LMUL vector, or conversely, to split one big LMUL vector to two (or more) small LMUL vectors. Because my development is based on a fixed 128-bits VLEN, the vl should be changed with LMUL.

What I want may looks like

//vector combine
vint64m2_t vcombine_i64m1_i64m2 (vint64m1_t op1, vint64m1_t op2);
//vector split
vint64m1_t vget_low_i64m2_i64m1 (vint64m2_t op1);   //get the low half of big vector
vint64m1_t vget_high_i64m2_i64m1 (vint64m2_t op1);  //get the high half of big vector

In my opinion, two split functions can be implemented based on slide operation and vl modification, but I'm not sure how to implement combine operation. Moreover, even if these operations can be implemented by other intrinsics, will the interface packaged as such be more friendly to the front-end users?

@HanKuanChen
Copy link
Contributor

@joy2myself
How about

vint64m2_t vcombine_i64m1_i64m2 (vint64m1_t op1, vint64m1_t op2, size_t vl)
{
    return vlmul_ext_v_i64m1_i64m2(vslideup(op1, op2, vl));
}

@kito-cheng
Copy link
Collaborator

I guess it should ext before slideup, otherwise the result might truncated?

@joy2myself
Copy link

Like this?

vint64m2_t vcombine_i64m1_i64m2 (vint64m1_t op1, vint64m1_t op2, size_t vl)
{
    return vslideup_vx_i64m2(vlmul_ext_v_i64m1_i64m2(op1), vlmul_ext_v_i64m1_i64m2(op2), vl);
}

I'm not sure does it work since ext operation modified VLEN, right?

@zakk0610
Copy link
Collaborator Author

Those two utility functions would not modified vl so you need to reset vl if need.

like this would be better.

vint64m2_t vcombine_i64m1_i64m2 (vint64m1_t op1, vint64m1_t op2, size_t vl)
{
   vint64m2_t new_op1 = vlmul_ext_v_i64m1_i64m2(op1);
   vint64m2_t new_op2 = vlmul_ext_v_i64m1_i64m2(op2);
   size_t new_vl = vsetvl_e64m2 (vl)
   return vslideup_vx_i64m2(new_op1, new_op2, new_vl);
}

@joy2myself
Copy link

Thanks! If it works, it looks good to me.

@zakk0610
Copy link
Collaborator Author

zakk0610 commented Jan 6, 2021

I create a PR #57
If there is no other questions, I will merge it.

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

No branches or pull requests

4 participants