vosen / ZLUDA

CUDA on AMD GPUs
Apache License 2.0
8.46k stars 494 forks source link

acc-bakeryoptix PTX parsing fails #195

Open xCuri0 opened 3 months ago

xCuri0 commented 3 months ago

https://github.com/ac-custom-shaders-patch/acc-bakeryoptix. For testing a KN5 file is needed which can be found in any Assetto Corsa car/track mod download.

rayhit PTX dumped at runtime https://gist.github.com/xCuri0/36207c7ca7c29e936d971c497c183cfe

Using ZLUDA built with Optix on RX 580 Adrenalin 24.1.1 Windows 10 22H2. I had to do a few changes to override optix.6.0.0.dll instead of optix.6.6.0.dll and make it runtime compile on gfx803 but that shouldn't be relevant here

Downloaded HIP-RT 1.2 from here https://github.com/vosen/ZLUDA/issues/108#issuecomment-2016532313, AMD seems to no longer officially provide older versions.

The raybb and rayIntersection PTX parse and compile without any issues, but rayhit fails during PTX parsing giving errors like this till the PTX file ends

 err: User { error: UnrecognizedDirective { start: 6624, end: 6877 } }

 err: User { error: UnrecognizedDirective { start: 6877, end: 6971 } }

 err: User { error: UnrecognizedDirective { start: 6971, end: 7028 } }

To get these errors to show I added the following after let maybe_ast = ptx::ModuleParser::new().parse(&mut errors, txt); in ptx\src\lib.rs

        for error in &errors {
            println!("\n err: {:?}\n", error);
        }

According to @vosen this is caused by the PTX using unimplemented ldu instruction.

vosen commented 3 months ago

If you want to just compile ptx, one of ZLUDA subprojects is zoc - zluda offline compiler. It's built when you are doing a debug build (cargo xtask) or can be built explicitly (cargo build -p offline_compiler). This will create zoc binary in target/debug. Pass --help to print options