-
Notifications
You must be signed in to change notification settings - Fork 83
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
Implement SM3 Example and Testing #68
Conversation
Hi @HCPauKaifler - this is great, thank you very much for contributing.
If you add the missing file, it looks like everything should work? |
Hi, I'm pretty sure this code would benefit from some optimization if intended as a benchmark -- this is not really how SM3 or other MD hash functions are usually implemented. Ideally, the instruction counts should match or be better than those at https://github.com/mjosaarinen/lwsha_isa#sm3 Currently, the state words are rotated in a way that can't easily be handled by a compiler. Furthermore, it expands the message, generating many unnecessary loads and stores. A RISC-V benchmark can leverage the large register file which allows the entire 16-word message block to be stored in the register file. See e.g. the SM3 reference code at https://github.com/mjosaarinen/lwsha_isa/blob/master/sm3_rv32_cf.c However, that earlier code will need to adopt the appropriate intrinsics for P0, P1, GREV, ROTATE, etc. Cheers,
|
Apologies I took so long to get around to this again, I'm back from leave now and can give it some attention. I've pulled your latest commit with the testbench file and everything builds and runs well, so thanks for that! I'm sorry I didn't actually get to review the code until now. Broadly though, Markku is right, there are some optimisations to be done. Concretely, I'd say:
If you don't expect you'll have time to do these optimisations, that's no problem, just let me know and I'm happy to merge this in as-is, and do the various optimisations when I (or someone else) gets the chance. Everything fits into the existing benchmark framework well and just having a solid base / set of tests to start optimising from is really good. Cheers, |
This commit optimizes the RV32 SM3 implementation to yield a speedup of about 2.6x the original implementation. The RV64 version is faster now too, but the toolchain seems to be broken as grev and rol don't seem to compile. So it's still a lot slower.
Hello, thanks for your tips @ben-marshall and @mjosaarinen! With Test 4 I am now hashing about 63 IPB using the reference, and 33 IPB with GREV, ROL, P0 and P1 enabled on RV32. Best regards, |
Hi @HCPauKaifler |
Hello @ben-marshall Best regards, |
Hi @HCPauKaifler Thanks a lot for your efforts! |
Closes #15