diff --git a/lib/extractkernel.in b/lib/extractkernel.in index ab91d1cbe2c..44a49e0cb34 100755 --- a/lib/extractkernel.in +++ b/lib/extractkernel.in @@ -9,9 +9,9 @@ sub usage { print("-h \t\t\t\tshow this help message\n"); print("-i \t\t\t\tinput file\n"); print("-t \t\t\t\ttarget architecture (optional)\n"); - print(" \t\t\t\t 7:0:0 for CI (Kaveri)\n"); - print(" \t\t\t\t 8:0:1 for subset of VI (Carizzo)\n"); - print(" \t\t\t\t 8:0:3 for subset of VI (Fiji) (default)\n"); + print(" \t\t\t\t gfx700 for CI (Kaveri)\n"); + print(" \t\t\t\t gfx801 for subset of VI (Carizzo)\n"); + print(" \t\t\t\t gfx803 for subset of VI (Fiji) (default)\n"); exit; } @@ -29,15 +29,20 @@ $input_file = $options{i}; (-f $input_file) || die("can't find $input_file"); # Set default target architecture to Fiji -my $target = "8:0:3"; +my $target = "gfx803"; if (defined $options{t}) { $target = $options{t}; } +my $command; + my $binary_start_tag = "_binary_kernel_brig_start"; my $binary_size_tag = "_binary_kernel_brig_size"; -my $binary_start = hex(`objdump -t $input_file | grep $binary_start_tag | awk '{print \$1}'`); -my $binary_size = hex(`objdump -t $input_file | grep $binary_size_tag | awk '{print \$1}'`); + +$command = "objdump -t $input_file | grep $binary_start_tag | awk '{print \$1}'"; +my $binary_start = hex(`$command`); +$command = "objdump -t $input_file | grep $binary_size_tag | awk '{print \$1}'"; +my $binary_size = hex(`$command`); if ($binary_start == 0 || $binary_size == 0) { print("can't find any hsail kernel in $input_file\n"); @@ -51,29 +56,10 @@ else { my $binary_file_name = "$input_file.hsaco"; system("dd if=$input_file of=$binary_file_name skip=$binary_file_offset count=$binary_size bs=1 status=none"); - my $hsa_path = "@HSA_ROOT@"; my $rocm_path = "@ROCM_ROOT@"; + my $llvm_objdump = "$rocm_path/hcc-lc/llvm/bin/llvm-objdump"; + (-f $llvm_objdump) || die("can't find llvm-objdump to diassemble the GPU binary"); - # set the default to rocm path - my $hsafin = "$rocm_path/bin/amdhsafin"; - - if (defined $ENV{'HSA_HOME'}) { - $hsafin = "$ENV{'HSA_HOME'}/bin/amdhsafin"; - } - elsif (!(-f $hsafin)) { - # can't find amdhsafin in rocm, let's try with hsa root - $hsafin = "$hsa_path/bin/amdhsafin"; - } - - if (-f $hsafin) { - - # use the offline finalizer to dump out the hsail and isa - system("$hsafin -target=$target -brig $binary_file_name -output=$input_file.gpu.o -O2 -dump-isa -dump-hsail"); - move("./amdhsa001.hsail","./$input_file.hsail"); - move("./amdhsa001.isa","./$input_file.isa"); - } - else { - print("can't find HSAIL offline finalizer\n"); - } - + $command = "$llvm_objdump -disassemble -mcpu=$target $binary_file_name > $input_file.$target.isa"; + system($command); }