Giter Site home page Giter Site logo

Comments (4)

tugrul512bit avatar tugrul512bit commented on May 24, 2024

Sorry for this late response,

If you are asking about pure OpenGL textures, I don't have enough experience with them. But if you just need some array with specific format, then I can help you. Even hello world example can be adjusted to generate an array with some format. I will add some here.

from cekirdekler.

tugrul512bit avatar tugrul512bit commented on May 24, 2024

For example, below code should generate 4096 element arrays with zero on all elements by initializing them as float4 (4-element float vectors) inside kernel (using 1024 threads spanning all GPUs, each thread initializing 1 float4 for a(f), 1 float4 for b(g)).

ClPlatforms platforms = ClPlatforms.all();
var selectedDevices = platforms.devicesWithMostComputeUnits().gpus(true);
selectedDevices.logInfo();
ClNumberCruncher gpu = new ClNumberCruncher(selectedDevices, @"
     __kernel void algorithmTest(__global float4 * a, __global float4 * b)
     { 
          int i=get_global_id(0);
          a[i]=(float4)(0.0f,0.0f,0.0f,0.0f);
          b[i]=(float4)(0.0f,0.0f,0.0f,0.0f);
     }
");
ClArray<float> f = new ClArray<float>(4096);
f.numberOfElementsPerWorkItem = 4;
f.writeOnly=true;
f.zeroCopy=true;
f.write = true;
f.read = false;
f.readOnly = false;
ClArray<float> g = new ClArray<float>(4096);
g.numberOfElementsPerWorkItem = 4;
g.writeOnly=true;
g.zeroCopy=true;
g.write = true;
g.read = false;
g.readOnly = false;
gpu.performanceFeed = true;

// parameter "64" is the minimum allowed thread trade between GPUs so that the balance the workload
f.nextParam(g).compute(gpu, 1, "algorithmTest", 4096/4, 64);
// here f[index] and g[index] must have zero

from cekirdekler.

tugrul512bit avatar tugrul512bit commented on May 24, 2024

Also here is how I tried producing vertices (as height-map of a sphere)

https://github.com/tugrul512bit/unityTestMeshDeformation/blob/master/gpgpu_test/Assets/Kamera.cs
(kernel is from line 236 to 245)

In there, to use "structs" of Unity, such as

public Vector3[] verticesBase

you can use

xyzGPU = ClArray<byte>.wrapArrayOfStructs(verticesBase);

it wraps around whole structs and treats all items in them as floats or whatever items in kernel as you like. Using byte type is just for treating as a data transmission buffer on host side. In kernel, you can use their elements by casting to different type on proper alignment points. You shouldn't dereference a non-multiple of 4 address as a float nor int.

from cekirdekler.

mfagerlund avatar mfagerlund commented on May 24, 2024

from cekirdekler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.