As mentioned in Hybridizer's documentation, you can't use the new x() method of instantiating an object in Hybridizer CUDA code.
I tried to use this method, but it would give an error related to the use of typeof(x)
[ERROR] : 0X6079 : EnrichMethodDependencyGraph failed for method System.Type -- Exception: System.NullReferenceException: Object reference not set to an instance of an object.
I also tried just using it like this:
Activator.CreateInstance<x>()
But that would just give a different error that I can find no information on online.
[ERROR] : 0X6079 : EnrichMethodDependencyGraph failed for method System.Activator -- Exception: System.ArgumentException: A BadImageFormatException has been thrown while parsing the signature. This is likely due to lack of a generic context. Ensure genericTypeArguments and genericMethodArguments are provided and contain enough context. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Instantiating an object should be a very simple thing, but I can't find any way to do it online... Does anyone know how?
Using typeof(x)
requires object type information, which is not made available on the GPU side. Activator.CreateInstance<x>
is essentially the same thing.
The limitation does not come from the new
keyword, it comes from the fat that garbage collection is not implemented on the GPU side.
Possible workarounds for your issue:
Your type can be replaced by primitives : you may allocate array of primitive types on the GPU.
You may define your own allocator based on a preallocated array of instances and an atomic index.
User contributions licensed under CC BY-SA 3.0