Comments (2)
Unfortunately, it is not possible to pass (global) pointers to OpenCL
buffers within structures, since they require a user-defined driver-specific argument mapping (interested readers should refer to this post). In other words, a C#
structure
public struct Foo
{
public ArrayView<int> Data;
public long SomeField;
}
cannot simply be passed to a kernel by creating a marshalling OpenCL
structure (and a corresponding host structure in managed code) View_Int
:
struct View_Int
{
__global int *ptr;
int length;
}
struct Foo
{
struct View Data;
long SomeField;
}
One solution to this problem is to extract all nested ArrayView<>
values from the arguments of a kernel. We should extract all source view objects (i.e. CLBuffer
instances) and map their values separately with distinct calls to clSetKernelArg
. After bringing the buffer pointers into the OpenCL
world, we can reconstruct the actual view structures to simulate the intended behavior. Consider the following ILGPU
kernel program:
void Kernel(Index index, ArrayView<int> source, Foo foo)
{
// ...
}
As previously mentioned, this kernel cannot be represented in OpenCL
via:
__kernel void Kernel(struct View_Int source, struct Foo foo)
{
// ...
}
However, to avoid the problems presented, we can output the following OpenCL
code:
__kernel void Kernel(
__global int *ptr1, // First nested view pointer
__global int *ptr2, // Second nested view pointer
struct View_Int source, // Source structure without pointer information from host
struct Foo foo) // Source structure without pointer information from host
{
// Setup view pointers in kernel code
source.ptr = ptr1;
foo.Data.ptr = ptr2;
// ...
}
from ilgpu.
Unfortunately, the proposed solution does not work properly, since OpenC
L does not allow nested pointers within structures to be passed to the kernel. However, some drivers accept such code, while others simply fail. Therefore, passing arguments requires an interop structure to be passed to the kernel, which stores the required offset
and length
information for each view. Then, each kernel argument is converted into its internal representation, which can contain (and work on) pointers to device-memory addresses.
from ilgpu.
Related Issues (20)
- Intel GPUs ,float64 type is not supported on this device HOT 5
- Are vector data types supported? HOT 3
- A Tensor Library HOT 6
- VelocityDevice and MaxGridSize HOT 3
- Sample of "AlgorithmsRadixSort" failed on OpenCL device HOT 4
- `NullReferenceException` when passing empty `ArrayView`s to OpenCL kernel HOT 1
- XMath.Pow() only work on CPU HOT 3
- Better error messages when kernel program failed to run. HOT 1
- Is it possible to use a stored dataset on GPU again and again with throwing extra data to GPU, and even change the value of the established dataset? HOT 1
- Add a CPU-GPU-Shared MemoryBuffer for systems that support it HOT 2
- Iteration of value with loops on GPU slows down significantly HOT 5
- Feature request: cudaStreamWaitEvent HOT 7
- Higher precision float (decimal) support? HOT 2
- Passing Int128 as kernel parameter is not working HOT 3
- System.BadImageFormatException in System.Reflection.Metadata.dll HOT 4
- OpenCL.CLException HOT 2
- [QUESTION]: Exception in Accelerator.Synchronize on CUDA HOT 2
- [BUG] Cuda 12 SDK not supported with ILGPU 1.5.X HOT 2
- [POTENTIAL BUG]: CopyToCpu is using refs in unsafe way but there is no indication of that. HOT 2
- [BUG]: Unit tests failing on GitHub runner with MacOS 14 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ilgpu.