oneapi-src / unified-runtime

https://oneapi-src.github.io/unified-runtime/
Other
31 stars 110 forks source link

Allow for platform dependant type defintions #704

Closed veselypeta closed 1 year ago

veselypeta commented 1 year ago

Currently in UR we have do not have a mechanism to define types diferently for different platforms i.e. Windows/Linux. This is something that would be helpful in implementing for example a file descriptor type which differs across platforms and would be important to implement bindless images experimental features. See discussion here We can do something similar with macros currently using a condition: "defined(_WIN32)" field in the yaml syntax which will include an additional gaurd for the definition, however the is nothing for other yaml types. The most obvious place would be to add this to typedef which would allow us to define types differently for different platforms - a potential way this could look would be:

type: typedef
desc: "file descriptor type:
name: $x_file_descriptor_t
value:
  - condition: "defined(_WIN32)"
    value: HANDLE
alt_value: int
kbenzie commented 1 year ago

I think something like this would be more flexible:

type: typedef
desc: "file descriptor type:"
name: $x_file_descriptor_t
value:
  - if: "defined(_WIN32)"
    value: HANDLE
  - elif: "defined(OTHER_PLATFORM)"
    value: other_platform_t
  - else:
    value: int
veselypeta commented 1 year ago

For now Bindless Images won't use platform dependant type HANDLE and just type is as void * to avoid conditional compilation for windows