Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum struct members are not blittable #66

Closed
BenjaminPelletier opened this issue Feb 7, 2020 · 2 comments
Closed

Enum struct members are not blittable #66

BenjaminPelletier opened this issue Feb 7, 2020 · 2 comments
Assignees
Labels
feature A new feature (or feature request)

Comments

@BenjaminPelletier
Copy link

When attempting to accelerator.Allocate<ReceiverFacet>(int), I receive the error message 'Type type 'SimpleTrace.ReceiverFacet' is not blittable' with the ReceiverFacet definition below:

public enum ReceiverFacetType : int
{
    Unknown = 0,
    Triangle = 1,
    Parallelogram = 2,
}

public readonly struct ReceiverFacet
{
    public readonly Int3 Vertices;
    public readonly ReceiverFacetType Type;

    public ReceiverFacet(Int3 vertices, ReceiverFacetType type = ReceiverFacetType.Triangle)
    {
        Vertices = vertices;
        Type = type;
    }
}

However, if I change the definition to that shown below, things work fine even though the data contents should be identical:

public readonly struct ReceiverFacet
{
    public readonly Int3 Vertices;
    public readonly int Type;

    public ReceiverFacet(Int3 vertices, ReceiverFacetType type = ReceiverFacetType.Triangle)
    {
       Vertices = vertices;
       Type = (int)type;
   }
}

It would be great if ILGPU would recognize that Enum types are really their underlying data types for the purposes of storage and transmission.

@m4rs-mt m4rs-mt self-assigned this Feb 19, 2020
@m4rs-mt m4rs-mt added the feature A new feature (or feature request) label Feb 19, 2020
@m4rs-mt
Copy link
Owner

m4rs-mt commented Feb 19, 2020

@BenjaminPelletier Yes, you are right. Since Enums themselves are not blittable, the current API and compiler do not provide 'native' support for Enum types. This makes perfect sense to add in an upcoming version.

@m4rs-mt
Copy link
Owner

m4rs-mt commented Apr 5, 2020

To start kernels, ILGPU creates specially tuned KernelLauncher methods, which are created for each kernel method when compiling the kernel. ArgumentMapper instances generate the actual marshaling source code to pass parameter values to the underlying driver API. This avoids the boxing of value types and ensures the highest possible performance when launching a kernel. The new ILGPU version supports Enum values in the scope of all IR nodes and ArgumentMapper instances. However, the runtime has to be adjusted to support these as well.

m4rs-mt added a commit that referenced this issue Apr 13, 2020
@m4rs-mt m4rs-mt closed this as completed Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature (or feature request)
Projects
None yet
Development

No branches or pull requests

2 participants