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

Consider using gfx-rs for gpu compute #12

Open
fu5ha opened this issue Mar 22, 2018 · 6 comments
Open

Consider using gfx-rs for gpu compute #12

fu5ha opened this issue Mar 22, 2018 · 6 comments

Comments

@fu5ha
Copy link

fu5ha commented Mar 22, 2018

https://github.com/gfx-rs/gfx/tree/master/examples/hal/compute

Could make it easier to compile

@PlasmaPower
Copy link
Owner

Interesting, but it looks like it's currently a bit of a pain to use. I'd also have to do the shader compilation manually.

I'll be interested to see the project develop, though. Hopefully someone makes a higher level wrapper for it.

@PlasmaPower
Copy link
Owner

Supporting DirectX would probably mean that GPU support would be easily usable by Windows users. Removing incompatibilities between compilers would also be a great benefit.

I'm now fully in favor of this.

@fu5ha
Copy link
Author

fu5ha commented Mar 28, 2018

As an added bonus, I think gfx would like having an example of being used "in production" as well :D

@expenses
Copy link

Supporting DirectX would probably mean that GPU support would be easily usable by Windows users. Removing incompatibilities between compilers would also be a great benefit.

I'm now fully in favor of this.

I stumbled apon this repo earlier while looking to see if anyone had done ed25519 signature verification via gpu compute. If you're still interested in this issue, then a first step might be to compile the opencl kernel with clspv. When I ran ./merge-kernel.py > merged.cl; clspv merged.cl I got the following error:

merged.cl:89:31: warning: cast from 'const __private void *' to '__private unsigned char *' drops const qualifier
  const uchar *p = ( uchar * )src;
                              ^
merged.cl:84:28: error: pointer-to-void is not supported
static inline uint load32( const void *src )
                           ^

After either setting the types or deleting all the functions with void *, the compilation runs until it terminates with:
%5 = getelementptr inbounds <{ i32, [9 x i32] }>, <{ i32, [9 x i32] }>* %3, i32 0, i32 0*** stack smashing detected ***: terminated fish: Job 1, 'clspv merged.cl' terminated by signal SIGABRT (Abort)

Possibly related to google/clspv#261.

@PlasmaPower
Copy link
Owner

I tried this out probably a year ago but gfx-rs's compute support was not ready for real usage at the time. It's very possible the situation's improved since then though. Thanks for linking clspv, I hadn't seen it before. Writing this stuff in OpenGL is a real pain given the lack of dynamic memory access. At one point I explored autogenerated OpenGL but ran into shader size limitations. It seems like the best path forward would be clspv with the current OpenCL kernel. I think I can clean up at least that error without too much trouble.

@PlasmaPower
Copy link
Owner

PlasmaPower commented Mar 27, 2021

If you want to chat about this more, I'm on Discord at PlasmaPower#0001 . For your use case, I might already have the curve25519 functionality you need implemented. I've got basepoint multiplication obviously, but also point addition for the distributed mining feature. With those two you should be able to verify a signature. Doing the operations individually isn't optimal, but it should work.

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

3 participants