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

Exposing limb type choice by introducing _ZL and _ZLL #48

Closed

Conversation

itzmeanjan
Copy link

Hello Niek, first of all thanks for writing ctbignum -- such a great and useful library.

I'm using ctbignum for writing code, which I'm offloading to GPU. I noticed when converting literal input to std::integer_sequence, default limb type choice is uint64_t, which is somewhat problematic to me. As I was trying to target SPIRV, which not supporting __uint128_t so I was getting errors when writing GPU kernels which were performing modular multiplication.

Also I noticed your question

I've introduced _ZL and _ZLL -- these two new literal suffixes, while deprecating _Z. I'd love to know your opinion/ suggestion.

Thanks :)

Suffix Note
_ZL uint32_t as limb type
_ZLL uint64_t as limb type
_Z uint64_t ( as it is ) as limb type [ deprecated ]

…troducing `_ZL`, `_ZLL` for limb type uint32_t and uint64_t respectively
itzmeanjan added a commit to itzmeanjan/ff-p-bench that referenced this pull request Nov 23, 2021
@niekbouman
Copy link
Owner

Dear Anjan,

Thanks for your comments and the PR!

I've introduced _ZL and _ZLL -- these two new literal suffixes, while deprecating _Z. I'd love to know your opinion/ suggestion.

I'd like to keep _Z for compatibility reasons (ctbignum is being used in production ;-)
and 'L' and 'LL' sound like long and long long, while the limb types are unsigned.
How about, respectively, _Z32 and _Z64 ?

Another idea is to define a generalized literal, that people can "tailor" to their limb type by means of a using declaration:

// in library 
template <typename limb_t, char... Chars> 
constexpr auto operator"" _generic_limb_literal(); 

// in user code
template<char... Chars>
using _Z16 = _generic_limb_literal<uint16_t, Chars...>;

What would you think of that?

(BTW I'll also reply to your email later today)

@itzmeanjan
Copy link
Author

Hello Niek,

ctbignum is being used in production

This is great news !

What would you think of that?

I find your solution to be sound and easier to understand. In user code when someone reads _Z{16,32,64}, they should get a feeling that limb type/ size is what is being denoted by suffixed number.

@niekbouman
Copy link
Owner

I've added something in spirit of the above in d5bde6d

Please check whether this works for you,

best,
Niek

@itzmeanjan
Copy link
Author

Perfect thanks Niek, it works for me !

@itzmeanjan itzmeanjan closed this Nov 29, 2021
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.

None yet

2 participants