-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Handling of heterogeneous computing #10397
Comments
In this message I describe how we can provide support for ergonomic heterogeneous programming, Clang is already providing support for heterogeneous programming and imposes no constraint on what types can be used at the interface between host and device. Let's look at how they handle this (the schema shows Spir-V, but this matches what clang does for targeting NVPTX).
The idea is that the compiler:
The advantage of this approach is that the object files are standalone, and that the device code is hidden. In particular the ABI between the host and device isn't exposed. Now let's look at the approach I used for Cudaz, the library I'm building for Nvidia GPU.
This approach is simpler in the sense that it mostly happen in user-land using Zig killer-features: comptime and build.zig. But it does have some quirks:
|
Notes from yesterday Stage2 meeting (not exact quotes, writing from memory)
Andrew also noted that the problem of writing code that can be compiled for both target (quirk 2 from previous list) can be solved by making the compiler more lazy and not try to analyze the body of a function when a function is only used for metaprogramming. He also suggested client-side mitigations.
|
Could Zig, as a primitive, expose a userland version of the build system in EDIT: Actually, since a version of |
This issue is a follow up on my own issue/experience working to add NVPTX (Nvidia GPU) support to Zig stage2 (#10189 ) and @Snektron ongoing work on SpirV backend (#2683) (also stage2). But the same considerations also to other heterogeneous programming like FPGA.
One of the issue with this "targets" is that they aren't standalone, typically those devices are driven by a more conventional CPU, the host. The host code will first push binary code to the device and then asks the device to execute some functions from this binary on some runtime-known inputs. This creates issues because we need to generate binaries that are consistent across two different targets. Notably what are the types allowed in the host/device interface ?
Main questions
So the questions I'd like to talk about are:
Personally I'd be quite happy if Zig could provide minimal support for ergonomic heterogeneous programming (not constrained by C-ABI), even if there are quirks and only support some combination of platform, so that we can learn more about the issues and then later try to iron those outs.
The text was updated successfully, but these errors were encountered: