method 1
requires building of hijacked .so with appropriate LLVM version. I am too lazy for this
method 2
cool, but does not work - cicc claims on bad arguments. I've tried many combinations with no luck
But hey - we are under linux and can make many hacks, for example check what arguments genuine nvcc passing to cicc. For this I ran nvcc -dc -keep under strace:
strace -o c.strace -s 512 -f --trace=/^exec nvcc ...
Arguments:
- -s NUM - maximum string size, bcs arguments can be very long - I set this parameter to 512
- -f - trace child processes
- and finally --trace - since I don't know which exactly syscall used to launch processes I used regex syntax for all calls starting with exec
Lets check output file c.strace and see launches of
- gcc/cc1plus
- cicc
- ptxas
- fatbinary
- bin2c
- cudafe++
- etc
After some trials right combination of arguments for cicc is
NVVMCCWIZ=553282 cicc --nv_arch compute_XX --device-c -keep 1.cpp1.ii
ls -l *.bc
-rw-rw-r-- 1 redp redp 8072 mar 31 13:25 1.lgenfe.bc
-rw-rw-r-- 1 redp redp 9988 mar 31 13:25 1.lnk.bc
-rw-rw-r-- 1 redp redp 6500 mar 31 13:25 1.opt.bc
lgenfe.bc - bitcode from front-end
opt.bc - bitcode after all optimization passes
to disassembly we can now just use llvm-dis-21:
%1 = tail call i32 asm sideeffect "activemask.b32 $0;", "=r"() #3, !dbg !11
%2 = tail call { i32, i1 } @llvm.nvvm.shfl.sync.i32(i32 %1, i32 3, i32 %val, i32 16, i32 31) #3, !dbg !17
%3 = extractvalue { i32, i1 } %2, 0, !dbg !17
Комментариев нет:
Отправить комментарий