mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Hardware > GPU Computing

Reply
 
Thread Tools
Old 2023-03-10, 00:40   #1
mrh
 
"mrh"
Oct 2018
Temecula, ca

24×32 Posts
Default Vulkan compute shaders

I've been trying out coding up a few simple things using Vulkan compute shaders, instead of OpenCL. It seems pretty cool so far.
I was thinking of taking a shot at converting mfakt[oc] into a vulkan mfaktv. It would be fun to compare performance. Has anyone already tried something like this? Is it a dumb idea?
mrh is offline   Reply With Quote
Old 2023-03-10, 15:55   #2
M344587487
 
M344587487's Avatar
 
"Composite as Heck"
Oct 2017

2·52·19 Posts
Default

Last time I looked it seemed hard to do generic compute with vulkan because vulkan is so focused on rendering, but that might have changed and I have little experience to be a good judge. It's worth exploring especially if you've had success implementing more trivial but definitely non-render-type compute in vulkan already. It might be much harder than OpenCL to get running performantly on different hardware types, and there might not be much to gain besides compatibility and maybe less overhead, but AFAIK no one has seriously tried and these are just my assumptions.

If you've found good resources on doing generic compute on vulkan please post them here, it's an interesting rabbit hole to learn about.
M344587487 is offline   Reply With Quote
Old 2023-03-10, 16:09   #3
mrh
 
"mrh"
Oct 2018
Temecula, ca

24·32 Posts
Default

Quote:
Originally Posted by M344587487 View Post
Last time I looked it seemed hard to do generic compute with vulkan because vulkan is so focused on rendering, but that might have changed and I have little experience to be a good judge. It's worth exploring especially if you've had success implementing more trivial but definitely non-render-type compute in vulkan already. It might be much harder than OpenCL to get running performantly on different hardware types, and there might not be much to gain besides compatibility and maybe less overhead, but AFAIK no one has seriously tried and these are just my assumptions.

If you've found good resources on doing generic compute on vulkan please post them here, it's an interesting rabbit hole to learn about.
I found this example and thought it did a nice job showing how to get stared on the CPU side. I started with that. I think I can figure out the GPU compute side. I have a lot to learn wrt to other things, for example the vulkan memory models.

I was able to build and run just by installing a few packages from the standard ubuntu distro. I'll keep digging into it and see what happens.

thanks!

Last fiddled with by mrh on 2023-03-10 at 16:15
mrh is offline   Reply With Quote
Old 2023-03-14, 18:02   #4
mrh
 
"mrh"
Oct 2018
Temecula, ca

2208 Posts
Default

So I changed by path a bit. I've started converting gpuowl.cl into GLSL that compiles to SPIR-V to be used as a vulkan compute shader. I'm testing little bits as I go. Learning a lot about gpuowl and vulkan as I go. Fun! The bit-wise manipulations of floats/doubles had me stuck for a bit, but I figured out how to make those work well now.
mrh is offline   Reply With Quote
Old 2023-03-16, 19:58   #5
moebius
 
moebius's Avatar
 
Jul 2009
Germany

2·353 Posts
Default

seems to be a lot of work but useful, respect!
moebius is offline   Reply With Quote
Old 2023-03-17, 10:05   #6
M344587487
 
M344587487's Avatar
 
"Composite as Heck"
Oct 2017

2×52×19 Posts
Default

Have you looked into this or something like it? https://github.com/google/clspv

No idea how far along that project is and it probably isn't as simple as press a button to transpile,but with luck it may be able to do some legwork.
M344587487 is offline   Reply With Quote
Old 2023-03-18, 02:27   #7
mrh
 
"mrh"
Oct 2018
Temecula, ca

9016 Posts
Default

Quote:
Originally Posted by M344587487 View Post
Have you looked into this or something like it? https://github.com/google/clspv

No idea how far along that project is and it probably isn't as simple as press a button to transpile,but with luck it may be able to do some legwork.
I did, but I think I should look at it again. Thanks!
mrh is offline   Reply With Quote
Old 2023-04-24, 23:25   #8
mrh
 
"mrh"
Oct 2018
Temecula, ca

100100002 Posts
Default

I had a little spare time so I wrote a very simple trial factor implementation as a Vulkan shader. It implements simple 96 or 128-bit integer math. It doesn't yet do any fancy montgomery, barrett, etc optimizations. I wanted to make sure I understood enough to make a working TF first.

On a Radeon VII it can test > 100M k-values/sec, so not mfakt[co] speeds, but still interesting.

Shader code is here: https://github.com/mrh42/vtf/blob/main/tf.comp
mrh is offline   Reply With Quote
Old 2023-04-25, 14:43   #9
kriesel
 
kriesel's Avatar
 
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

24·3·163 Posts
Default

Kudos! How did you choose a value for NK? What GPU utilization do you see in GPU-Z or similar, vs cpu utilization of the process in Task Manager (Win) / top (Linux)?
Code:
const int ntestprimes = 160;  // tweak as needed
This seems small to me. You may gain more performance by sieving out more candidate factors, with more known small primes.

Last fiddled with by kriesel on 2023-04-25 at 15:00
kriesel is online now   Reply With Quote
Old 2023-04-25, 15:29   #10
mrh
 
"mrh"
Oct 2018
Temecula, ca

24×32 Posts
Default

Quote:
Originally Posted by kriesel View Post
Kudos! How did you choose a value for NK? What GPU utilization do you see in GPU-Z or similar, vs cpu utilization of the process in Task Manager (Win) / top (Linux)?
Code:
const int ntestprimes = 160;  // tweak as needed
This seems small to me. You may gain more performance by sieving out more candidate factors, with more known small primes.
Thanks! I choose NK, the chunk of work for each thread, to keep the time running on the gpu to around 150ms. Longer than that seems to make the console unusable. It seems to me that when a computer shader is running everything else waits. Still looking at this.

The cpu does basically nothing, mapping/unmapping memory, checking on 64bit result and setting K for the next round. The vulkan calls don't seem to need any overhead that I can see. It will max out my gpu at 250W if I let it go at 2200Mhz. (On linux)

You are correct, as it is now the sieve lets about 12% through. It should do better if it takes it down to around 8%, I think. But it doesn't at the moment. That function needs a little work to make it more pipelined, maybe.

Now, if someone had a fft/ntt based Square-mod function I could use... :)

Last fiddled with by mrh on 2023-04-25 at 15:29
mrh is offline   Reply With Quote
Old 2023-04-26, 23:36   #11
mrh
 
"mrh"
Oct 2018
Temecula, ca

2208 Posts
Default

With a few optimizations, it can test about 420M factors/second, or about 15 ghz-days/day (I think). Pretty good considering the really slow/simple squaring algorithm.
mrh is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does this compute tServo PARI/GP 3 2019-06-22 14:48
New GPU Compute System airsquirrels GPU Computing 90 2017-12-08 00:13
Vulkan CuriousKit GPU Computing 5 2016-02-25 14:00
New Compute Box Christenson Hardware 0 2011-01-15 04:44
My throughput does not compute... petrw1 Hardware 9 2007-08-13 14:38

All times are UTC. The time now is 15:16.


Fri Jul 7 15:16:43 UTC 2023 up 323 days, 12:45, 0 users, load averages: 0.83, 1.10, 1.12

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔