[Solved] Passing cuda-arch when compiling for nvptx64-nvidia-cuda

I have experimented with the nvptx64-nvidia-cuda target for the last few weeks. It certainly works better than I would have initially expected.

Unfortunately, It seems like there are currently no way to pass a cuda arch (like sm_61) to llvm. This is currently possible with Clang and has been for a while.

Is this something of interest to have in rustc as well?

If so, what would be the best way to implement this for rust?

Are there any similar kind of target specific arches implemented for Rustc?

Would it be interesting to also use this in the alternative backend implemented by @RDambrosio016 and the Rust GPU project?

I mean, if it works in Clang then it works in LLVM. Or that's the usual rule, at least. Is Clang doing something different for this?

The problem is that it seems like there's no way to get this argument to llvm. I atleast cannot find anything, even when looking at rustc -C llvm-args=--help

> rustc --print target-cpus --target nvptx64-nvidia-cuda
Available CPUs for this target:
    sm_20
    sm_21
    sm_30
    sm_32
    sm_35
    sm_37
    sm_50
    sm_52
    sm_53
    sm_60
    sm_61
    sm_62
    sm_70
    sm_72
    sm_75
    sm_80
    sm_86

You can select these using the -Ctarget-cpu=sm_61 flag.

1 Like

I didn't realize that was possible. That seem to work fine. Thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.