Coder Social home page Coder Social logo

Comments (5)

timholy avatar timholy commented on July 20, 2024

Presumably you first have to move the memory over to the GPU. Does it work if you say launch(..., (CudaArray(iostr.data),))?

from cudart.jl.

ikirill avatar ikirill commented on July 20, 2024

No, I don't. If I understand correctly from documentation, cuLaunchKernel copies the arguments itself when those arguments are passed by value. For example, if you pass it a pointer to a device pointer, the device pointer will be copied and used to initialize the function argument, and if you give it a pointer to an int, the int will be copied by cuLaunchKernel, then used to initialize an argument of type int (not int* or something). So all I need is to be able to give it a pointer to the structure in host memory, and it copies the structure itself, initializing function argument from the host memory.

It's just that the interface of launch doesn't let me do that, hence the issue. The way to get around is to ccall((:cuLaunchKernel, ... with kernel arguments set to Ptr{Void}[iostr.data].

Also, I believe arguments are copied to either constant or shared memory (I'm not sure which), not global memory.

from cudart.jl.

timholy avatar timholy commented on July 20, 2024

With Ptr{Void}, how does it know how many bytes to copy over? Different structures have different sizes.

from cudart.jl.

ikirill avatar ikirill commented on July 20, 2024

It knows the kernel function definition, and the definitions of types of its arguments, like a C compiler would, so that's how it knows how many bytes to copy and how to interpret them. So if I tell StrPack to use the right (for nvcc) alignment (align_native? It seems distinct from align_default for some reason), then the structure is laid out in memory correctly and cuda can read it itself without being told anything else.

from cudart.jl.

timholy avatar timholy commented on July 20, 2024

You're right that the kernel function itself is a good source of information. If that really works, fantastic.

It's certainly fine to change the interface of launch if it expands the scope of what it can do. Once you get something working that passes the tests, please do submit a PR.

from cudart.jl.

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.