![]() |
|
[C#] Cudafy and basic parallel for/foreach - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Cudafy and basic parallel for/foreach (/showthread.php?tid=5912549) |
Cudafy and basic parallel for/foreach - 991z3r0 - Nov 26, 2018 So obviously doing parallel for and foreach in c# isn't that bad to do however i have to make some custom code that will process extremely faster if using CUDA cores/GPU. I have a sample code to just try to understand but im drawing blanks on what/how to adjust the current code to test some simple foreach from a list of strings. This is the code: https://pastebin.com/pPz6GawA So what im confused on is the whole VectorStruct[], is it literally like a list of work to be done and sent to the GPU? I'm also confused as to how each of the for loops come into play for this example. i assume theKernal is the actual code being executed on the cores? I guess any basic breakdown on how this works and how you're supposed to code a parallel for/foreach correctly using all cores. RE: Cudafy and basic parallel for/foreach - deepshit - Nov 29, 2018 VectorStruct is not list of works.It's just a vector.(math vector) thekernel is the gpu thread and the vectors are simply its parameters. first loop is initializing vectors and then in gpu thread they are added together.(vector a and b) then it gets the result vector from gpu.(vector c) I think you can use it like this : gpu.Launch(1, N, ((Action<GThread>) thekernel)); public static void thekernel(GThread thread) { //whatever code } you can pass anything instead of vectors. RE: Cudafy and basic parallel for/foreach - 991z3r0 - Nov 29, 2018 (Nov 29, 2018 04:47 AM)deepshit Wrote: VectorStruct is not list of works.It's just a vector.(math vector) Alright that makes more sense. So would this disperse the workload to all cores? Or is this kinda just submitting one "load" of work to do? Or would the vector's itself be part of cudafy creating work and spreading to the cores? essentially i would want 100% or as many as possible cuda cores to process the work from a list of items if that makes sense RE: Cudafy and basic parallel for/foreach - 991z3r0 - Dec 4, 2018 (Nov 29, 2018 04:47 AM)deepshit Wrote: VectorStruct is not list of works.It's just a vector.(math vector) Wait sorry to sound like a mega noob but when i try to use your snippet it's trying to convert the GThread Action into an int. I have zero insight as to what the minimum arguments are for it to process a simply void of code. RE: Cudafy and basic parallel for/foreach - deepshit - Dec 5, 2018 Send me your project solution and I'll try to fix it for you. Or just the cudafy library. |