system
stringclasses
7 values
input
stringlengths
10
94.5k
output
stringlengths
14
55.5k
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_001b9d78_00000000-6_deviceProp.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3672: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3672: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "sharedMem" .LC1: .string "warpSize" .LC2: .string "Maximum thread" .LC3: .string "number of MP" .text .globl main .type main, @function main: .LFB3669: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $1040, %rsp .cfi_def_cfa_offset 1056 movq %fs:40, %rax movq %rax, 1032(%rsp) xorl %eax, %eax movq %rsp, %rbx movl $0, %esi movq %rbx, %rdi call cudaGetDeviceProperties_v2@PLT movq %rbx, %rsi leaq _ZSt4cout(%rip), %rbx movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 360(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 364(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 288(%rsp), %rsi movq %rbx, %rdi call _ZNSo9_M_insertImEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 348(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC0(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 296(%rsp), %rsi movq %rbx, %rdi call _ZNSo9_M_insertImEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 304(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC1(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 308(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC2(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 624(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC3(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 388(%rsp), %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 1032(%rsp), %rax subq %fs:40, %rax jne .L6 movl $0, %eax addq $1040, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L6: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE3669: .size main, .-main .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3695: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3695: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "deviceProp.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r14 .cfi_def_cfa_offset 16 pushq %rbx .cfi_def_cfa_offset 24 subq $1480, %rsp # imm = 0x5C8 .cfi_def_cfa_offset 1504 .cfi_offset %rbx, -24 .cfi_offset %r14, -16 leaq 8(%rsp), %rbx movq %rbx, %rdi xorl %esi, %esi callq hipGetDevicePropertiesR0600 movq %rbx, %rdi callq strlen movl $_ZSt4cout, %edi movq %rbx, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.1: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%rbx) je .LBB0_3 # %bb.2: movzbl 67(%rbx), %eax jmp .LBB0_4 .LBB0_3: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB0_4: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 368(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.5: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i2 cmpb $0, 56(%rbx) je .LBB0_7 # %bb.6: movzbl 67(%rbx), %ecx jmp .LBB0_8 .LBB0_7: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_8: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit5 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 372(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.9: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i7 cmpb $0, 56(%rbx) je .LBB0_11 # %bb.10: movzbl 67(%rbx), %ecx jmp .LBB0_12 .LBB0_11: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_12: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit10 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movq 296(%rsp), %rsi movl $_ZSt4cout, %edi callq _ZNSo9_M_insertImEERSoT_ movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.13: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i12 cmpb $0, 56(%rbx) je .LBB0_15 # %bb.14: movzbl 67(%rbx), %ecx jmp .LBB0_16 .LBB0_15: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_16: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit15 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 356(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.17: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i17 cmpb $0, 56(%rbx) je .LBB0_19 # %bb.18: movzbl 67(%rbx), %ecx jmp .LBB0_20 .LBB0_19: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_20: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit20 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $_ZSt4cout, %edi movl $.L.str, %esi movl $9, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.21: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i22 cmpb $0, 56(%rbx) je .LBB0_23 # %bb.22: movzbl 67(%rbx), %eax jmp .LBB0_24 .LBB0_23: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB0_24: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit25 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movq 304(%rsp), %rsi movl $_ZSt4cout, %edi callq _ZNSo9_M_insertImEERSoT_ movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.25: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i27 cmpb $0, 56(%rbx) je .LBB0_27 # %bb.26: movzbl 67(%rbx), %ecx jmp .LBB0_28 .LBB0_27: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_28: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit30 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 312(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.29: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i32 cmpb $0, 56(%rbx) je .LBB0_31 # %bb.30: movzbl 67(%rbx), %ecx jmp .LBB0_32 .LBB0_31: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_32: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit35 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $8, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.33: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i37 cmpb $0, 56(%rbx) je .LBB0_35 # %bb.34: movzbl 67(%rbx), %eax jmp .LBB0_36 .LBB0_35: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB0_36: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit40 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 316(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.37: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i42 cmpb $0, 56(%rbx) je .LBB0_39 # %bb.38: movzbl 67(%rbx), %ecx jmp .LBB0_40 .LBB0_39: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_40: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit45 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $_ZSt4cout, %edi movl $.L.str.2, %esi movl $14, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.41: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i47 cmpb $0, 56(%rbx) je .LBB0_43 # %bb.42: movzbl 67(%rbx), %eax jmp .LBB0_44 .LBB0_43: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB0_44: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit50 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 632(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.45: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i52 cmpb $0, 56(%rbx) je .LBB0_47 # %bb.46: movzbl 67(%rbx), %ecx jmp .LBB0_48 .LBB0_47: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_48: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit55 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $_ZSt4cout, %edi movl $.L.str.3, %esi movl $12, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.49: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i57 cmpb $0, 56(%rbx) je .LBB0_51 # %bb.50: movzbl 67(%rbx), %eax jmp .LBB0_52 .LBB0_51: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB0_52: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit60 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 396(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %rbx testq %rbx, %rbx je .LBB0_57 # %bb.53: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i62 cmpb $0, 56(%rbx) je .LBB0_55 # %bb.54: movzbl 67(%rbx), %ecx jmp .LBB0_56 .LBB0_55: movq %rbx, %rdi movq %rax, %r14 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r14, %rax .LBB0_56: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit65 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv xorl %eax, %eax addq $1480, %rsp # imm = 0x5C8 .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 retq .LBB0_57: .cfi_def_cfa_offset 1504 callq _ZSt16__throw_bad_castv .Lfunc_end0: .size main, .Lfunc_end0-main .cfi_endproc # -- End function .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "sharedMem" .size .L.str, 10 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "warpSize" .size .L.str.1, 9 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Maximum thread" .size .L.str.2, 15 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "number of MP" .size .L.str.3, 13 .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _ZSt4cout .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int bbox_y, const int bbox_w, const int bbox_h) { uint x = blockIdx.x * blockDim.x + threadIdx.x; uint y = blockIdx.y * blockDim.y + threadIdx.y; if( x < output_w && y < output_h) { float r[2] = { float(x) * bbox_w / output_w + bbox_x, float(y) * bbox_h / output_h + bbox_y }; int pos[4][2] = { { int(floor(r[0])), int(floor(r[1])) }, { int( ceil(r[0])), int(floor(r[1])) }, { int(floor(r[0])), int(ceil(r[1])) }, { int( ceil(r[0])), int(ceil(r[1])) } }; float u = r[0]-floor(r[0]); float v = r[1]-floor(r[1]); float s[4] = { (1-u)*(1-v), u*(1-v), (1-u)*v, u*v }; int map[4] = { pos[0][1]*input_w + pos[0][0], pos[1][1]*input_w + pos[1][0], pos[2][1]*input_w + pos[2][0], pos[3][1]*input_w + pos[3][0]}; int idx = y * output_w + x; output[idx+out_plane_r] = round( s[0]*input[map[0]+in_plane_r] + s[1]*input[map[1]+in_plane_r] + s[2]*input[map[2]+in_plane_r] + s[3]*input[map[3]+in_plane_r] );// float(mean[idx+out_plane_r])); output[idx+out_plane_g] = round( s[0]*input[map[0]+in_plane_g] + s[1]*input[map[1]+in_plane_g] + s[2]*input[map[2]+in_plane_g] + s[3]*input[map[3]+in_plane_g] );//float(mean[idx+out_plane_g])); output[idx+out_plane_b] = round( s[0]*input[map[0]+in_plane_b] + s[1]*input[map[1]+in_plane_b] + s[2]*input[map[2]+in_plane_b] + s[3]*input[map[3]+in_plane_b] );//float(mean[idx+out_plane_b])); } }
code for sm_80 Function : _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R10, SR_CTAID.Y ; /* 0x00000000000a7919 */ /* 0x000e280000002600 */ /*0020*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e280000002200 */ /*0030*/ S2R R11, SR_CTAID.X ; /* 0x00000000000b7919 */ /* 0x000e680000002500 */ /*0040*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e620000002100 */ /*0050*/ IMAD R10, R10, c[0x0][0x4], R3 ; /* 0x000001000a0a7a24 */ /* 0x001fca00078e0203 */ /*0060*/ ISETP.GE.U32.AND P0, PT, R10, c[0x0][0x180], PT ; /* 0x000060000a007a0c */ /* 0x000fe20003f06070 */ /*0070*/ IMAD R11, R11, c[0x0][0x0], R0 ; /* 0x000000000b0b7a24 */ /* 0x002fca00078e0200 */ /*0080*/ ISETP.GE.U32.OR P0, PT, R11, c[0x0][0x17c], P0 ; /* 0x00005f000b007a0c */ /* 0x000fda0000706470 */ /*0090*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00a0*/ I2F R5, c[0x0][0x17c] ; /* 0x00005f0000057b06 */ /* 0x000e220000201400 */ /*00b0*/ BSSY B0, 0x1c0 ; /* 0x0000010000007945 */ /* 0x000fee0003800000 */ /*00c0*/ I2F.U32 R0, R11 ; /* 0x0000000b00007306 */ /* 0x000ff00000201000 */ /*00d0*/ I2F R3, c[0x0][0x1a4] ; /* 0x0000690000037b06 */ /* 0x000e700000201400 */ /*00e0*/ MUFU.RCP R2, R5 ; /* 0x0000000500027308 */ /* 0x001e220000001000 */ /*00f0*/ FMUL R0, R0, R3 ; /* 0x0000000300007220 */ /* 0x002fce0000400000 */ /*0100*/ FCHK P0, R0, R5 ; /* 0x0000000500007302 */ /* 0x000e620000000000 */ /*0110*/ FFMA R7, -R5, R2, 1 ; /* 0x3f80000005077423 */ /* 0x001fc80000000102 */ /*0120*/ FFMA R7, R2, R7, R2 ; /* 0x0000000702077223 */ /* 0x000fc80000000002 */ /*0130*/ FFMA R2, R0, R7, RZ ; /* 0x0000000700027223 */ /* 0x000fc800000000ff */ /*0140*/ FFMA R3, -R5, R2, R0 ; /* 0x0000000205037223 */ /* 0x000fc80000000100 */ /*0150*/ FFMA R12, R7, R3, R2 ; /* 0x00000003070c7223 */ /* 0x000fe20000000002 */ /*0160*/ @!P0 BRA 0x1b0 ; /* 0x0000004000008947 */ /* 0x002fea0003800000 */ /*0170*/ IMAD.MOV.U32 R6, RZ, RZ, R0 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0000 */ /*0180*/ MOV R0, 0x1a0 ; /* 0x000001a000007802 */ /* 0x000fe40000000f00 */ /*0190*/ CALL.REL.NOINC 0x8d0 ; /* 0x0000073000007944 */ /* 0x000fea0003c00000 */ /*01a0*/ MOV R12, R13 ; /* 0x0000000d000c7202 */ /* 0x000fe40000000f00 */ /*01b0*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*01c0*/ I2F R7, c[0x0][0x180] ; /* 0x0000600000077b06 */ /* 0x000e220000201400 */ /*01d0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*01e0*/ BSSY B0, 0x310 ; /* 0x0000012000007945 */ /* 0x000fec0003800000 */ /*01f0*/ I2F R0, c[0x0][0x1a8] ; /* 0x00006a0000007b06 */ /* 0x000ff00000201400 */ /*0200*/ I2F.U32 R5, R10 ; /* 0x0000000a00057306 */ /* 0x000e700000201000 */ /*0210*/ MUFU.RCP R2, R7 ; /* 0x0000000700027308 */ /* 0x001e220000001000 */ /*0220*/ FMUL R0, R0, R5 ; /* 0x0000000500007220 */ /* 0x002fce0000400000 */ /*0230*/ I2F R3, c[0x0][0x19c] ; /* 0x0000670000037b06 */ /* 0x000e620000201400 */ /*0240*/ FFMA R9, -R7, R2, 1 ; /* 0x3f80000007097423 */ /* 0x001fce0000000102 */ /*0250*/ FCHK P0, R0, R7 ; /* 0x0000000700007302 */ /* 0x000e220000000000 */ /*0260*/ FFMA R9, R2, R9, R2 ; /* 0x0000000902097223 */ /* 0x000fc80000000002 */ /*0270*/ FFMA R2, R0, R9, RZ ; /* 0x0000000900027223 */ /* 0x000fe400000000ff */ /*0280*/ FADD R12, R3, R12 ; /* 0x0000000c030c7221 */ /* 0x002fe40000000000 */ /*0290*/ FFMA R4, -R7, R2, R0 ; /* 0x0000000207047223 */ /* 0x000fc80000000100 */ /*02a0*/ FFMA R13, R9, R4, R2 ; /* 0x00000004090d7223 */ /* 0x000fe20000000002 */ /*02b0*/ @!P0 BRA 0x300 ; /* 0x0000004000008947 */ /* 0x001fea0003800000 */ /*02c0*/ IMAD.MOV.U32 R6, RZ, RZ, R0 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0000 */ /*02d0*/ MOV R0, 0x300 ; /* 0x0000030000007802 */ /* 0x000fe20000000f00 */ /*02e0*/ IMAD.MOV.U32 R5, RZ, RZ, R7 ; /* 0x000000ffff057224 */ /* 0x000fe400078e0007 */ /*02f0*/ CALL.REL.NOINC 0x8d0 ; /* 0x000005d000007944 */ /* 0x000fea0003c00000 */ /*0300*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0310*/ I2F R0, c[0x0][0x1a0] ; /* 0x0000680000007b06 */ /* 0x000e300000201400 */ /*0320*/ F2I.CEIL.NTZ R15, R12 ; /* 0x0000000c000f7305 */ /* 0x000fe2000020b100 */ /*0330*/ FADD R13, R0, R13 ; /* 0x0000000d000d7221 */ /* 0x001fce0000000000 */ /*0340*/ F2I.FLOOR.NTZ R5, R12 ; /* 0x0000000c00057305 */ /* 0x000ff00000207100 */ /*0350*/ F2I.FLOOR.NTZ R0, R13 ; /* 0x0000000d00007305 */ /* 0x000e300000207100 */ /*0360*/ F2I.CEIL.NTZ R2, R13 ; /* 0x0000000d00027305 */ /* 0x000e62000020b100 */ /*0370*/ IMAD R4, R0, c[0x0][0x178], R15 ; /* 0x00005e0000047a24 */ /* 0x001fc400078e020f */ /*0380*/ IMAD R3, R0, c[0x0][0x178], R5.reuse ; /* 0x00005e0000037a24 */ /* 0x100fe200078e0205 */ /*0390*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fe400000001ff */ /*03a0*/ IADD3 R9, R4, c[0x0][0x184], RZ ; /* 0x0000610004097a10 */ /* 0x000fe40007ffe0ff */ /*03b0*/ IADD3 R7, R3, c[0x0][0x184], RZ ; /* 0x0000610003077a10 */ /* 0x000fe20007ffe0ff */ /*03c0*/ IMAD R5, R2.reuse, c[0x0][0x178], R5 ; /* 0x00005e0002057a24 */ /* 0x042fe400078e0205 */ /*03d0*/ IMAD R2, R2, c[0x0][0x178], R15 ; /* 0x00005e0002027a24 */ /* 0x000fc600078e020f */ /*03e0*/ IMAD.WIDE R8, R9, R0, c[0x0][0x160] ; /* 0x0000580009087625 */ /* 0x000fe200078e0200 */ /*03f0*/ IADD3 R15, R5, c[0x0][0x184], RZ ; /* 0x00006100050f7a10 */ /* 0x000fc60007ffe0ff */ /*0400*/ IMAD.WIDE R6, R7, R0.reuse, c[0x0][0x160] ; /* 0x0000580007067625 */ /* 0x080fe200078e0200 */ /*0410*/ LDG.E R20, [R8.64] ; /* 0x0000000408147981 */ /* 0x0000a2000c1e1900 */ /*0420*/ IADD3 R17, R2, c[0x0][0x184], RZ ; /* 0x0000610002117a10 */ /* 0x000fe40007ffe0ff */ /*0430*/ IMAD.WIDE R14, R15, R0.reuse, c[0x0][0x160] ; /* 0x000058000f0e7625 */ /* 0x080fe200078e0200 */ /*0440*/ LDG.E R21, [R6.64] ; /* 0x0000000406157981 */ /* 0x0002e6000c1e1900 */ /*0450*/ IMAD.WIDE R16, R17, R0, c[0x0][0x160] ; /* 0x0000580011107625 */ /* 0x000fe400078e0200 */ /*0460*/ LDG.E R14, [R14.64] ; /* 0x000000040e0e7981 */ /* 0x000968000c1e1900 */ /*0470*/ LDG.E R16, [R16.64] ; /* 0x0000000410107981 */ /* 0x000162000c1e1900 */ /*0480*/ FRND.FLOOR R18, R13 ; /* 0x0000000d00127307 */ /* 0x000e620000205000 */ /*0490*/ IMAD R10, R10, c[0x0][0x17c], R11 ; /* 0x00005f000a0a7a24 */ /* 0x000fca00078e020b */ /*04a0*/ IADD3 R15, R10, c[0x0][0x190], RZ ; /* 0x000064000a0f7a10 */ /* 0x010fe40007ffe0ff */ /*04b0*/ FRND.FLOOR R19, R12 ; /* 0x0000000c00137307 */ /* 0x000f220000205000 */ /*04c0*/ IADD3 R17, R5, c[0x0][0x188], RZ ; /* 0x0000620005117a10 */ /* 0x001fe20007ffe0ff */ /*04d0*/ FADD R18, R13, -R18 ; /* 0x800000120d127221 */ /* 0x002fc80000000000 */ /*04e0*/ FADD R8, -R18, 1 ; /* 0x3f80000012087421 */ /* 0x000fe40000000100 */ /*04f0*/ FADD R19, R12, -R19 ; /* 0x800000130c137221 */ /* 0x010fc80000000000 */ /*0500*/ FADD R7, -R19.reuse, 1 ; /* 0x3f80000013077421 */ /* 0x040fe40000000100 */ /*0510*/ FMUL R9, R19, R8.reuse ; /* 0x0000000813097220 */ /* 0x080fe40000400000 */ /*0520*/ FMUL R8, R7, R8 ; /* 0x0000000807087220 */ /* 0x000fe40000400000 */ /*0530*/ FMUL R7, R18, R7 ; /* 0x0000000712077220 */ /* 0x000fe40000400000 */ /*0540*/ FMUL R6, R19, R18 ; /* 0x0000001213067220 */ /* 0x000fe20000400000 */ /*0550*/ IADD3 R19, R3, c[0x0][0x188], RZ ; /* 0x0000620003137a10 */ /* 0x000fca0007ffe0ff */ /*0560*/ IMAD.WIDE R18, R19, R0, c[0x0][0x160] ; /* 0x0000580013127625 */ /* 0x000fc800078e0200 */ /*0570*/ FMUL R20, R9, R20 ; /* 0x0000001409147220 */ /* 0x004fc80000400000 */ /*0580*/ FFMA R20, R8, R21, R20 ; /* 0x0000001508147223 */ /* 0x008fc80000000014 */ /*0590*/ FFMA R13, R7, R14, R20 ; /* 0x0000000e070d7223 */ /* 0x020fe40000000014 */ /*05a0*/ IMAD.WIDE R14, R15, R0, c[0x0][0x168] ; /* 0x00005a000f0e7625 */ /* 0x000fc800078e0200 */ /*05b0*/ FFMA R13, R6, R16, R13 ; /* 0x00000010060d7223 */ /* 0x000fca000000000d */ /*05c0*/ LOP3.LUT R12, R13, 0x80000000, RZ, 0xc0, !PT ; /* 0x800000000d0c7812 */ /* 0x000fc800078ec0ff */ /*05d0*/ LOP3.LUT R12, R12, 0x3f000000, RZ, 0xfc, !PT ; /* 0x3f0000000c0c7812 */ /* 0x000fca00078efcff */ /*05e0*/ FADD.RZ R16, R13, R12 ; /* 0x0000000c0d107221 */ /* 0x000fe2000000c000 */ /*05f0*/ IADD3 R13, R4, c[0x0][0x188], RZ ; /* 0x00006200040d7a10 */ /* 0x000fc60007ffe0ff */ /*0600*/ FRND.TRUNC R23, R16 ; /* 0x0000001000177307 */ /* 0x000064000020d000 */ /*0610*/ IMAD.WIDE R12, R13, R0, c[0x0][0x160] ; /* 0x000058000d0c7625 */ /* 0x000fe200078e0200 */ /*0620*/ IADD3 R21, R2, c[0x0][0x188], RZ ; /* 0x0000620002157a10 */ /* 0x000fc60007ffe0ff */ /*0630*/ IMAD.WIDE R16, R17, R0.reuse, c[0x0][0x160] ; /* 0x0000580011107625 */ /* 0x081fe200078e0200 */ /*0640*/ STG.E [R14.64], R23 ; /* 0x000000170e007986 */ /* 0x0021e8000c101904 */ /*0650*/ LDG.E R12, [R12.64] ; /* 0x000000040c0c7981 */ /* 0x0002a2000c1e1900 */ /*0660*/ IMAD.WIDE R20, R21, R0, c[0x0][0x160] ; /* 0x0000580015147625 */ /* 0x000fc600078e0200 */ /*0670*/ LDG.E R19, [R18.64] ; /* 0x0000000412137981 */ /* 0x000ee8000c1e1900 */ /*0680*/ LDG.E R16, [R16.64] ; /* 0x0000000410107981 */ /* 0x000968000c1e1900 */ /*0690*/ LDG.E R20, [R20.64] ; /* 0x0000000414147981 */ /* 0x000f62000c1e1900 */ /*06a0*/ IADD3 R13, R10, c[0x0][0x194], RZ ; /* 0x000065000a0d7a10 */ /* 0x002fe40007ffe0ff */ /*06b0*/ IADD3 R15, R4, c[0x0][0x18c], RZ ; /* 0x00006300040f7a10 */ /* 0x001fc40007ffe0ff */ /*06c0*/ IADD3 R3, R3, c[0x0][0x18c], RZ ; /* 0x0000630003037a10 */ /* 0x000fe40007ffe0ff */ /*06d0*/ IADD3 R17, R5, c[0x0][0x18c], RZ ; /* 0x0000630005117a10 */ /* 0x010fc60007ffe0ff */ /*06e0*/ IMAD.WIDE R4, R3, R0, c[0x0][0x160] ; /* 0x0000580003047625 */ /* 0x000fc800078e0200 */ /*06f0*/ FMUL R11, R9, R12 ; /* 0x0000000c090b7220 */ /* 0x004fc80000400000 */ /*0700*/ FFMA R14, R8, R19, R11 ; /* 0x00000013080e7223 */ /* 0x008fc8000000000b */ /*0710*/ FFMA R11, R7, R16, R14 ; /* 0x00000010070b7223 */ /* 0x020fe4000000000e */ /*0720*/ IMAD.WIDE R14, R15, R0, c[0x0][0x160] ; /* 0x000058000f0e7625 */ /* 0x000fc800078e0200 */ /*0730*/ FFMA R11, R6, R20, R11 ; /* 0x00000014060b7223 */ /* 0x000fca000000000b */ /*0740*/ LOP3.LUT R12, R11, 0x80000000, RZ, 0xc0, !PT ; /* 0x800000000b0c7812 */ /* 0x000fc800078ec0ff */ /*0750*/ LOP3.LUT R12, R12, 0x3f000000, RZ, 0xfc, !PT ; /* 0x3f0000000c0c7812 */ /* 0x000fca00078efcff */ /*0760*/ FADD.RZ R11, R11, R12 ; /* 0x0000000c0b0b7221 */ /* 0x000fe4000000c000 */ /*0770*/ IMAD.WIDE R12, R13, R0, c[0x0][0x168] ; /* 0x00005a000d0c7625 */ /* 0x000fc800078e0200 */ /*0780*/ FRND.TRUNC R11, R11 ; /* 0x0000000b000b7307 */ /* 0x000e22000020d000 */ /*0790*/ IADD3 R19, R2, c[0x0][0x18c], RZ ; /* 0x0000630002137a10 */ /* 0x000fe20007ffe0ff */ /*07a0*/ IMAD.WIDE R2, R17, R0, c[0x0][0x160] ; /* 0x0000580011027625 */ /* 0x000fc800078e0200 */ /*07b0*/ IMAD.WIDE R16, R19, R0, c[0x0][0x160] ; /* 0x0000580013107625 */ /* 0x000fe200078e0200 */ /*07c0*/ STG.E [R12.64], R11 ; /* 0x0000000b0c007986 */ /* 0x001fe8000c101904 */ /*07d0*/ LDG.E R14, [R14.64] ; /* 0x000000040e0e7981 */ /* 0x000ea8000c1e1900 */ /*07e0*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ee8000c1e1900 */ /*07f0*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000f28000c1e1900 */ /*0800*/ LDG.E R16, [R16.64] ; /* 0x0000000410107981 */ /* 0x000f62000c1e1900 */ /*0810*/ FMUL R9, R9, R14 ; /* 0x0000000e09097220 */ /* 0x004fc80000400000 */ /*0820*/ FFMA R8, R8, R5, R9 ; /* 0x0000000508087223 */ /* 0x008fc80000000009 */ /*0830*/ FFMA R7, R7, R2, R8 ; /* 0x0000000207077223 */ /* 0x010fc80000000008 */ /*0840*/ FFMA R7, R6, R16, R7 ; /* 0x0000001006077223 */ /* 0x020fca0000000007 */ /*0850*/ LOP3.LUT R6, R7, 0x80000000, RZ, 0xc0, !PT ; /* 0x8000000007067812 */ /* 0x000fc800078ec0ff */ /*0860*/ LOP3.LUT R6, R6, 0x3f000000, RZ, 0xfc, !PT ; /* 0x3f00000006067812 */ /* 0x000fca00078efcff */ /*0870*/ FADD.RZ R6, R7, R6 ; /* 0x0000000607067221 */ /* 0x000fe2000000c000 */ /*0880*/ IADD3 R7, R10, c[0x0][0x198], RZ ; /* 0x000066000a077a10 */ /* 0x000fc60007ffe0ff */ /*0890*/ FRND.TRUNC R5, R6 ; /* 0x0000000600057307 */ /* 0x000e24000020d000 */ /*08a0*/ IMAD.WIDE R2, R7, R0, c[0x0][0x168] ; /* 0x00005a0007027625 */ /* 0x000fca00078e0200 */ /*08b0*/ STG.E [R2.64], R5 ; /* 0x0000000502007986 */ /* 0x001fe2000c101904 */ /*08c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*08d0*/ SHF.R.U32.HI R3, RZ, 0x17, R5 ; /* 0x00000017ff037819 */ /* 0x000fe20000011605 */ /*08e0*/ BSSY B1, 0xf30 ; /* 0x0000064000017945 */ /* 0x000fe20003800000 */ /*08f0*/ SHF.R.U32.HI R2, RZ, 0x17, R6.reuse ; /* 0x00000017ff027819 */ /* 0x100fe40000011606 */ /*0900*/ LOP3.LUT R14, R3, 0xff, RZ, 0xc0, !PT ; /* 0x000000ff030e7812 */ /* 0x000fe400078ec0ff */ /*0910*/ LOP3.LUT R8, R2, 0xff, RZ, 0xc0, !PT ; /* 0x000000ff02087812 */ /* 0x000fe200078ec0ff */ /*0920*/ IMAD.MOV.U32 R2, RZ, RZ, R6 ; /* 0x000000ffff027224 */ /* 0x000fe200078e0006 */ /*0930*/ IADD3 R9, R14, -0x1, RZ ; /* 0xffffffff0e097810 */ /* 0x000fe40007ffe0ff */ /*0940*/ IADD3 R7, R8, -0x1, RZ ; /* 0xffffffff08077810 */ /* 0x000fc40007ffe0ff */ /*0950*/ ISETP.GT.U32.AND P0, PT, R9, 0xfd, PT ; /* 0x000000fd0900780c */ /* 0x000fe40003f04070 */ /*0960*/ MOV R3, R5 ; /* 0x0000000500037202 */ /* 0x000fe40000000f00 */ /*0970*/ ISETP.GT.U32.OR P0, PT, R7, 0xfd, P0 ; /* 0x000000fd0700780c */ /* 0x000fda0000704470 */ /*0980*/ @!P0 IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff048224 */ /* 0x000fe200078e00ff */ /*0990*/ @!P0 BRA 0xb10 ; /* 0x0000017000008947 */ /* 0x000fea0003800000 */ /*09a0*/ FSETP.GTU.FTZ.AND P0, PT, |R6|, +INF , PT ; /* 0x7f8000000600780b */ /* 0x000fe40003f1c200 */ /*09b0*/ FSETP.GTU.FTZ.AND P1, PT, |R5|, +INF , PT ; /* 0x7f8000000500780b */ /* 0x000fc80003f3c200 */ /*09c0*/ PLOP3.LUT P0, PT, P0, P1, PT, 0xa8, 0x0 ; /* 0x000000000000781c */ /* 0x000fda0000703570 */ /*09d0*/ @P0 BRA 0xf10 ; /* 0x0000053000000947 */ /* 0x000fea0003800000 */ /*09e0*/ LOP3.LUT P0, RZ, R3, 0x7fffffff, R2, 0xc8, !PT ; /* 0x7fffffff03ff7812 */ /* 0x000fda000780c802 */ /*09f0*/ @!P0 BRA 0xef0 ; /* 0x000004f000008947 */ /* 0x000fea0003800000 */ /*0a00*/ FSETP.NEU.FTZ.AND P2, PT, |R6|.reuse, +INF , PT ; /* 0x7f8000000600780b */ /* 0x040fe40003f5d200 */ /*0a10*/ FSETP.NEU.FTZ.AND P1, PT, |R5|, +INF , PT ; /* 0x7f8000000500780b */ /* 0x000fe40003f3d200 */ /*0a20*/ FSETP.NEU.FTZ.AND P0, PT, |R6|, +INF , PT ; /* 0x7f8000000600780b */ /* 0x000fd60003f1d200 */ /*0a30*/ @!P1 BRA !P2, 0xef0 ; /* 0x000004b000009947 */ /* 0x000fea0005000000 */ /*0a40*/ LOP3.LUT P2, RZ, R2, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff02ff7812 */ /* 0x000fc8000784c0ff */ /*0a50*/ PLOP3.LUT P1, PT, P1, P2, PT, 0x2a, 0x0 ; /* 0x000000000000781c */ /* 0x000fda0000f24572 */ /*0a60*/ @P1 BRA 0xed0 ; /* 0x0000046000001947 */ /* 0x000fea0003800000 */ /*0a70*/ LOP3.LUT P1, RZ, R3, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff03ff7812 */ /* 0x000fc8000782c0ff */ /*0a80*/ PLOP3.LUT P0, PT, P0, P1, PT, 0x2a, 0x0 ; /* 0x000000000000781c */ /* 0x000fda0000702572 */ /*0a90*/ @P0 BRA 0xea0 ; /* 0x0000040000000947 */ /* 0x000fea0003800000 */ /*0aa0*/ ISETP.GE.AND P0, PT, R7, RZ, PT ; /* 0x000000ff0700720c */ /* 0x000fe40003f06270 */ /*0ab0*/ ISETP.GE.AND P1, PT, R9, RZ, PT ; /* 0x000000ff0900720c */ /* 0x000fd60003f26270 */ /*0ac0*/ @P0 MOV R4, RZ ; /* 0x000000ff00040202 */ /* 0x000fe20000000f00 */ /*0ad0*/ @!P0 IMAD.MOV.U32 R4, RZ, RZ, -0x40 ; /* 0xffffffc0ff048424 */ /* 0x000fe400078e00ff */ /*0ae0*/ @!P0 FFMA R2, R6, 1.84467440737095516160e+19, RZ ; /* 0x5f80000006028823 */ /* 0x000fe400000000ff */ /*0af0*/ @!P1 FFMA R3, R5, 1.84467440737095516160e+19, RZ ; /* 0x5f80000005039823 */ /* 0x000fe200000000ff */ /*0b00*/ @!P1 IADD3 R4, R4, 0x40, RZ ; /* 0x0000004004049810 */ /* 0x000fe40007ffe0ff */ /*0b10*/ LEA R6, R14, 0xc0800000, 0x17 ; /* 0xc08000000e067811 */ /* 0x000fe200078eb8ff */ /*0b20*/ BSSY B2, 0xe90 ; /* 0x0000036000027945 */ /* 0x000fe60003800000 */ /*0b30*/ IADD3 R6, -R6, R3, RZ ; /* 0x0000000306067210 */ /* 0x000fc40007ffe1ff */ /*0b40*/ IADD3 R3, R8, -0x7f, RZ ; /* 0xffffff8108037810 */ /* 0x000fe40007ffe0ff */ /*0b50*/ MUFU.RCP R5, R6 ; /* 0x0000000600057308 */ /* 0x000e220000001000 */ /*0b60*/ FADD.FTZ R7, -R6, -RZ ; /* 0x800000ff06077221 */ /* 0x000fe40000010100 */ /*0b70*/ IMAD R2, R3, -0x800000, R2 ; /* 0xff80000003027824 */ /* 0x000fe400078e0202 */ /*0b80*/ FFMA R8, R5, R7, 1 ; /* 0x3f80000005087423 */ /* 0x001fc80000000007 */ /*0b90*/ FFMA R9, R5, R8, R5 ; /* 0x0000000805097223 */ /* 0x000fc80000000005 */ /*0ba0*/ FFMA R5, R2, R9, RZ ; /* 0x0000000902057223 */ /* 0x000fc800000000ff */ /*0bb0*/ FFMA R8, R7, R5, R2 ; /* 0x0000000507087223 */ /* 0x000fc80000000002 */ /*0bc0*/ FFMA R8, R9, R8, R5 ; /* 0x0000000809087223 */ /* 0x000fe20000000005 */ /*0bd0*/ IADD3 R5, R3, 0x7f, -R14 ; /* 0x0000007f03057810 */ /* 0x000fc60007ffe80e */ /*0be0*/ FFMA R7, R7, R8, R2 ; /* 0x0000000807077223 */ /* 0x000fe40000000002 */ /*0bf0*/ IMAD.IADD R5, R5, 0x1, R4 ; /* 0x0000000105057824 */ /* 0x000fe400078e0204 */ /*0c00*/ FFMA R2, R9, R7, R8 ; /* 0x0000000709027223 */ /* 0x000fca0000000008 */ /*0c10*/ SHF.R.U32.HI R3, RZ, 0x17, R2 ; /* 0x00000017ff037819 */ /* 0x000fc80000011602 */ /*0c20*/ LOP3.LUT R3, R3, 0xff, RZ, 0xc0, !PT ; /* 0x000000ff03037812 */ /* 0x000fc800078ec0ff */ /*0c30*/ IADD3 R13, R3, R5, RZ ; /* 0x00000005030d7210 */ /* 0x000fc80007ffe0ff */ /*0c40*/ IADD3 R3, R13, -0x1, RZ ; /* 0xffffffff0d037810 */ /* 0x000fc80007ffe0ff */ /*0c50*/ ISETP.GE.U32.AND P0, PT, R3, 0xfe, PT ; /* 0x000000fe0300780c */ /* 0x000fda0003f06070 */ /*0c60*/ @!P0 BRA 0xe70 ; /* 0x0000020000008947 */ /* 0x000fea0003800000 */ /*0c70*/ ISETP.GT.AND P0, PT, R13, 0xfe, PT ; /* 0x000000fe0d00780c */ /* 0x000fda0003f04270 */ /*0c80*/ @P0 BRA 0xe40 ; /* 0x000001b000000947 */ /* 0x000fea0003800000 */ /*0c90*/ ISETP.GE.AND P0, PT, R13, 0x1, PT ; /* 0x000000010d00780c */ /* 0x000fda0003f06270 */ /*0ca0*/ @P0 BRA 0xe80 ; /* 0x000001d000000947 */ /* 0x000fea0003800000 */ /*0cb0*/ ISETP.GE.AND P0, PT, R13, -0x18, PT ; /* 0xffffffe80d00780c */ /* 0x000fe40003f06270 */ /*0cc0*/ LOP3.LUT R2, R2, 0x80000000, RZ, 0xc0, !PT ; /* 0x8000000002027812 */ /* 0x000fd600078ec0ff */ /*0cd0*/ @!P0 BRA 0xe80 ; /* 0x000001a000008947 */ /* 0x000fea0003800000 */ /*0ce0*/ FFMA.RZ R3, R9, R7.reuse, R8.reuse ; /* 0x0000000709037223 */ /* 0x180fe2000000c008 */ /*0cf0*/ IADD3 R6, R13, 0x20, RZ ; /* 0x000000200d067810 */ /* 0x000fe20007ffe0ff */ /*0d00*/ FFMA.RM R4, R9, R7.reuse, R8.reuse ; /* 0x0000000709047223 */ /* 0x180fe20000004008 */ /*0d10*/ ISETP.NE.AND P2, PT, R13, RZ, PT ; /* 0x000000ff0d00720c */ /* 0x000fe40003f45270 */ /*0d20*/ LOP3.LUT R5, R3, 0x7fffff, RZ, 0xc0, !PT ; /* 0x007fffff03057812 */ /* 0x000fe200078ec0ff */ /*0d30*/ FFMA.RP R3, R9, R7, R8 ; /* 0x0000000709037223 */ /* 0x000fe20000008008 */ /*0d40*/ ISETP.NE.AND P1, PT, R13, RZ, PT ; /* 0x000000ff0d00720c */ /* 0x000fe20003f25270 */ /*0d50*/ IMAD.MOV R7, RZ, RZ, -R13 ; /* 0x000000ffff077224 */ /* 0x000fe200078e0a0d */ /*0d60*/ LOP3.LUT R5, R5, 0x800000, RZ, 0xfc, !PT ; /* 0x0080000005057812 */ /* 0x000fe400078efcff */ /*0d70*/ FSETP.NEU.FTZ.AND P0, PT, R3, R4, PT ; /* 0x000000040300720b */ /* 0x000fc40003f1d000 */ /*0d80*/ SHF.L.U32 R6, R5, R6, RZ ; /* 0x0000000605067219 */ /* 0x000fe400000006ff */ /*0d90*/ SEL R4, R7, RZ, P2 ; /* 0x000000ff07047207 */ /* 0x000fe40001000000 */ /*0da0*/ ISETP.NE.AND P1, PT, R6, RZ, P1 ; /* 0x000000ff0600720c */ /* 0x000fe40000f25270 */ /*0db0*/ SHF.R.U32.HI R4, RZ, R4, R5 ; /* 0x00000004ff047219 */ /* 0x000fe40000011605 */ /*0dc0*/ PLOP3.LUT P0, PT, P0, P1, PT, 0xa8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40000703570 */ /*0dd0*/ SHF.R.U32.HI R6, RZ, 0x1, R4 ; /* 0x00000001ff067819 */ /* 0x000fc40000011604 */ /*0de0*/ SEL R3, RZ, 0x1, !P0 ; /* 0x00000001ff037807 */ /* 0x000fc80004000000 */ /*0df0*/ LOP3.LUT R3, R3, 0x1, R6, 0xf8, !PT ; /* 0x0000000103037812 */ /* 0x000fc800078ef806 */ /*0e00*/ LOP3.LUT R3, R3, R4, RZ, 0xc0, !PT ; /* 0x0000000403037212 */ /* 0x000fc800078ec0ff */ /*0e10*/ IADD3 R3, R6, R3, RZ ; /* 0x0000000306037210 */ /* 0x000fc80007ffe0ff */ /*0e20*/ LOP3.LUT R2, R3, R2, RZ, 0xfc, !PT ; /* 0x0000000203027212 */ /* 0x000fe200078efcff */ /*0e30*/ BRA 0xe80 ; /* 0x0000004000007947 */ /* 0x000fea0003800000 */ /*0e40*/ LOP3.LUT R2, R2, 0x80000000, RZ, 0xc0, !PT ; /* 0x8000000002027812 */ /* 0x000fc800078ec0ff */ /*0e50*/ LOP3.LUT R2, R2, 0x7f800000, RZ, 0xfc, !PT ; /* 0x7f80000002027812 */ /* 0x000fe200078efcff */ /*0e60*/ BRA 0xe80 ; /* 0x0000001000007947 */ /* 0x000fea0003800000 */ /*0e70*/ IMAD R2, R5, 0x800000, R2 ; /* 0x0080000005027824 */ /* 0x000fe400078e0202 */ /*0e80*/ BSYNC B2 ; /* 0x0000000000027941 */ /* 0x000fea0003800000 */ /*0e90*/ BRA 0xf20 ; /* 0x0000008000007947 */ /* 0x000fea0003800000 */ /*0ea0*/ LOP3.LUT R2, R3, 0x80000000, R2, 0x48, !PT ; /* 0x8000000003027812 */ /* 0x000fc800078e4802 */ /*0eb0*/ LOP3.LUT R2, R2, 0x7f800000, RZ, 0xfc, !PT ; /* 0x7f80000002027812 */ /* 0x000fe200078efcff */ /*0ec0*/ BRA 0xf20 ; /* 0x0000005000007947 */ /* 0x000fea0003800000 */ /*0ed0*/ LOP3.LUT R2, R3, 0x80000000, R2, 0x48, !PT ; /* 0x8000000003027812 */ /* 0x000fe200078e4802 */ /*0ee0*/ BRA 0xf20 ; /* 0x0000003000007947 */ /* 0x000fea0003800000 */ /*0ef0*/ MUFU.RSQ R2, -QNAN ; /* 0xffc0000000027908 */ /* 0x000e220000001400 */ /*0f00*/ BRA 0xf20 ; /* 0x0000001000007947 */ /* 0x000fea0003800000 */ /*0f10*/ FADD.FTZ R2, R6, R5 ; /* 0x0000000506027221 */ /* 0x000fe40000010000 */ /*0f20*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0f30*/ HFMA2.MMA R3, -RZ, RZ, 0, 0 ; /* 0x00000000ff037435 */ /* 0x000fe200000001ff */ /*0f40*/ MOV R13, R2 ; /* 0x00000002000d7202 */ /* 0x001fe20000000f00 */ /*0f50*/ IMAD.MOV.U32 R2, RZ, RZ, R0 ; /* 0x000000ffff027224 */ /* 0x000fc800078e0000 */ /*0f60*/ RET.REL.NODEC R2 0x0 ; /* 0xfffff09002007950 */ /* 0x000fea0003c3ffff */ /*0f70*/ BRA 0xf70; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0f80*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0f90*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0fa0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0fb0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0fc0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0fd0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0fe0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ff0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int bbox_y, const int bbox_w, const int bbox_h) { uint x = blockIdx.x * blockDim.x + threadIdx.x; uint y = blockIdx.y * blockDim.y + threadIdx.y; if( x < output_w && y < output_h) { float r[2] = { float(x) * bbox_w / output_w + bbox_x, float(y) * bbox_h / output_h + bbox_y }; int pos[4][2] = { { int(floor(r[0])), int(floor(r[1])) }, { int( ceil(r[0])), int(floor(r[1])) }, { int(floor(r[0])), int(ceil(r[1])) }, { int( ceil(r[0])), int(ceil(r[1])) } }; float u = r[0]-floor(r[0]); float v = r[1]-floor(r[1]); float s[4] = { (1-u)*(1-v), u*(1-v), (1-u)*v, u*v }; int map[4] = { pos[0][1]*input_w + pos[0][0], pos[1][1]*input_w + pos[1][0], pos[2][1]*input_w + pos[2][0], pos[3][1]*input_w + pos[3][0]}; int idx = y * output_w + x; output[idx+out_plane_r] = round( s[0]*input[map[0]+in_plane_r] + s[1]*input[map[1]+in_plane_r] + s[2]*input[map[2]+in_plane_r] + s[3]*input[map[3]+in_plane_r] );// float(mean[idx+out_plane_r])); output[idx+out_plane_g] = round( s[0]*input[map[0]+in_plane_g] + s[1]*input[map[1]+in_plane_g] + s[2]*input[map[2]+in_plane_g] + s[3]*input[map[3]+in_plane_g] );//float(mean[idx+out_plane_g])); output[idx+out_plane_b] = round( s[0]*input[map[0]+in_plane_b] + s[1]*input[map[1]+in_plane_b] + s[2]*input[map[2]+in_plane_b] + s[3]*input[map[3]+in_plane_b] );//float(mean[idx+out_plane_b])); } }
.file "tmpxft_00101852_00000000-6_kernel_extract_roi.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2029: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2029: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii .type _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii, @function _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii: .LFB2051: .cfi_startproc endbr64 subq $264, %rsp .cfi_def_cfa_offset 272 movq %rdi, 40(%rsp) movq %rsi, 32(%rsp) movq %rdx, 24(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) movq %fs:40, %rax movq %rax, 248(%rsp) xorl %eax, %eax leaq 40(%rsp), %rax movq %rax, 112(%rsp) leaq 32(%rsp), %rax movq %rax, 120(%rsp) leaq 24(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 16(%rsp), %rax movq %rax, 144(%rsp) leaq 12(%rsp), %rax movq %rax, 152(%rsp) leaq 272(%rsp), %rax movq %rax, 160(%rsp) leaq 280(%rsp), %rax movq %rax, 168(%rsp) leaq 288(%rsp), %rax movq %rax, 176(%rsp) leaq 296(%rsp), %rax movq %rax, 184(%rsp) leaq 304(%rsp), %rax movq %rax, 192(%rsp) leaq 312(%rsp), %rax movq %rax, 200(%rsp) leaq 320(%rsp), %rax movq %rax, 208(%rsp) leaq 328(%rsp), %rax movq %rax, 216(%rsp) leaq 336(%rsp), %rax movq %rax, 224(%rsp) leaq 344(%rsp), %rax movq %rax, 232(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) leaq 56(%rsp), %rcx leaq 48(%rsp), %rdx leaq 76(%rsp), %rsi leaq 64(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 248(%rsp), %rax subq %fs:40, %rax jne .L8 addq $264, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 56(%rsp) .cfi_def_cfa_offset 280 pushq 56(%rsp) .cfi_def_cfa_offset 288 leaq 128(%rsp), %r9 movq 92(%rsp), %rcx movl 100(%rsp), %r8d movq 80(%rsp), %rsi movl 88(%rsp), %edx leaq _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 272 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii, .-_Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii .globl _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .type _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, @function _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 24 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 32 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 40 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 48 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 56 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 64 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 72 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 80 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 88 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 96 call _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii addq $88, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, .-_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2054: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2054: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int bbox_y, const int bbox_w, const int bbox_h) { uint x = blockIdx.x * blockDim.x + threadIdx.x; uint y = blockIdx.y * blockDim.y + threadIdx.y; if( x < output_w && y < output_h) { float r[2] = { float(x) * bbox_w / output_w + bbox_x, float(y) * bbox_h / output_h + bbox_y }; int pos[4][2] = { { int(floor(r[0])), int(floor(r[1])) }, { int( ceil(r[0])), int(floor(r[1])) }, { int(floor(r[0])), int(ceil(r[1])) }, { int( ceil(r[0])), int(ceil(r[1])) } }; float u = r[0]-floor(r[0]); float v = r[1]-floor(r[1]); float s[4] = { (1-u)*(1-v), u*(1-v), (1-u)*v, u*v }; int map[4] = { pos[0][1]*input_w + pos[0][0], pos[1][1]*input_w + pos[1][0], pos[2][1]*input_w + pos[2][0], pos[3][1]*input_w + pos[3][0]}; int idx = y * output_w + x; output[idx+out_plane_r] = round( s[0]*input[map[0]+in_plane_r] + s[1]*input[map[1]+in_plane_r] + s[2]*input[map[2]+in_plane_r] + s[3]*input[map[3]+in_plane_r] );// float(mean[idx+out_plane_r])); output[idx+out_plane_g] = round( s[0]*input[map[0]+in_plane_g] + s[1]*input[map[1]+in_plane_g] + s[2]*input[map[2]+in_plane_g] + s[3]*input[map[3]+in_plane_g] );//float(mean[idx+out_plane_g])); output[idx+out_plane_b] = round( s[0]*input[map[0]+in_plane_b] + s[1]*input[map[1]+in_plane_b] + s[2]*input[map[2]+in_plane_b] + s[3]*input[map[3]+in_plane_b] );//float(mean[idx+out_plane_b])); } }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int bbox_y, const int bbox_w, const int bbox_h) { uint x = blockIdx.x * blockDim.x + threadIdx.x; uint y = blockIdx.y * blockDim.y + threadIdx.y; if( x < output_w && y < output_h) { float r[2] = { float(x) * bbox_w / output_w + bbox_x, float(y) * bbox_h / output_h + bbox_y }; int pos[4][2] = { { int(floor(r[0])), int(floor(r[1])) }, { int( ceil(r[0])), int(floor(r[1])) }, { int(floor(r[0])), int(ceil(r[1])) }, { int( ceil(r[0])), int(ceil(r[1])) } }; float u = r[0]-floor(r[0]); float v = r[1]-floor(r[1]); float s[4] = { (1-u)*(1-v), u*(1-v), (1-u)*v, u*v }; int map[4] = { pos[0][1]*input_w + pos[0][0], pos[1][1]*input_w + pos[1][0], pos[2][1]*input_w + pos[2][0], pos[3][1]*input_w + pos[3][0]}; int idx = y * output_w + x; output[idx+out_plane_r] = round( s[0]*input[map[0]+in_plane_r] + s[1]*input[map[1]+in_plane_r] + s[2]*input[map[2]+in_plane_r] + s[3]*input[map[3]+in_plane_r] );// float(mean[idx+out_plane_r])); output[idx+out_plane_g] = round( s[0]*input[map[0]+in_plane_g] + s[1]*input[map[1]+in_plane_g] + s[2]*input[map[2]+in_plane_g] + s[3]*input[map[3]+in_plane_g] );//float(mean[idx+out_plane_g])); output[idx+out_plane_b] = round( s[0]*input[map[0]+in_plane_b] + s[1]*input[map[1]+in_plane_b] + s[2]*input[map[2]+in_plane_b] + s[3]*input[map[3]+in_plane_b] );//float(mean[idx+out_plane_b])); } }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int bbox_y, const int bbox_w, const int bbox_h) { uint x = blockIdx.x * blockDim.x + threadIdx.x; uint y = blockIdx.y * blockDim.y + threadIdx.y; if( x < output_w && y < output_h) { float r[2] = { float(x) * bbox_w / output_w + bbox_x, float(y) * bbox_h / output_h + bbox_y }; int pos[4][2] = { { int(floor(r[0])), int(floor(r[1])) }, { int( ceil(r[0])), int(floor(r[1])) }, { int(floor(r[0])), int(ceil(r[1])) }, { int( ceil(r[0])), int(ceil(r[1])) } }; float u = r[0]-floor(r[0]); float v = r[1]-floor(r[1]); float s[4] = { (1-u)*(1-v), u*(1-v), (1-u)*v, u*v }; int map[4] = { pos[0][1]*input_w + pos[0][0], pos[1][1]*input_w + pos[1][0], pos[2][1]*input_w + pos[2][0], pos[3][1]*input_w + pos[3][0]}; int idx = y * output_w + x; output[idx+out_plane_r] = round( s[0]*input[map[0]+in_plane_r] + s[1]*input[map[1]+in_plane_r] + s[2]*input[map[2]+in_plane_r] + s[3]*input[map[3]+in_plane_r] );// float(mean[idx+out_plane_r])); output[idx+out_plane_g] = round( s[0]*input[map[0]+in_plane_g] + s[1]*input[map[1]+in_plane_g] + s[2]*input[map[2]+in_plane_g] + s[3]*input[map[3]+in_plane_g] );//float(mean[idx+out_plane_g])); output[idx+out_plane_b] = round( s[0]*input[map[0]+in_plane_b] + s[1]*input[map[1]+in_plane_b] + s[2]*input[map[2]+in_plane_b] + s[3]*input[map[3]+in_plane_b] );//float(mean[idx+out_plane_b])); } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .globl _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .p2align 8 .type _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii,@function _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x5c s_load_b64 s[12:13], s[0:1], 0x1c v_and_b32_e32 v2, 0x3ff, v0 v_bfe_u32 v3, v0, 10, 10 s_waitcnt lgkmcnt(0) s_and_b32 s3, s2, 0xffff s_lshr_b32 s2, s2, 16 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_mad_u64_u32 v[0:1], null, s14, s3, v[2:3] v_mad_u64_u32 v[1:2], null, s15, s2, v[3:4] v_cmp_gt_u32_e32 vcc_lo, s12, v0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_gt_u32_e64 s2, s13, v1 s_and_b32 s2, vcc_lo, s2 s_delay_alu instid0(SALU_CYCLE_1) s_and_saveexec_b32 s3, s2 s_cbranch_execz .LBB0_2 s_load_b64 s[2:3], s[0:1], 0x44 v_cvt_f32_u32_e32 v2, v0 v_cvt_f32_u32_e32 v4, v1 v_cvt_f32_i32_e32 v6, s12 s_load_b256 s[4:11], s[0:1], 0x24 s_waitcnt lgkmcnt(0) v_cvt_f32_i32_e32 v3, s2 v_cvt_f32_i32_e32 v5, s3 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_mul_f32_e32 v2, v3, v2 v_cvt_f32_i32_e32 v3, s13 v_mul_f32_e32 v4, v5, v4 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2) v_div_scale_f32 v5, null, v6, v6, v2 v_div_scale_f32 v7, null, v3, v3, v4 v_div_scale_f32 v12, vcc_lo, v2, v6, v2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2) v_rcp_f32_e32 v8, v5 v_rcp_f32_e32 v9, v7 s_waitcnt_depctr 0xfff v_fma_f32 v10, -v5, v8, 1.0 v_fma_f32 v11, -v7, v9, 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_dual_fmac_f32 v9, v11, v9 :: v_dual_fmac_f32 v8, v10, v8 v_div_scale_f32 v10, s2, v4, v3, v4 v_mul_f32_e32 v13, v10, v9 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f32 v15, -v7, v13, v10 v_fmac_f32_e32 v13, v15, v9 v_mul_f32_e32 v11, v12, v8 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_fma_f32 v7, -v7, v13, v10 v_fma_f32 v14, -v5, v11, v12 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fmac_f32_e32 v11, v14, v8 v_fma_f32 v5, -v5, v11, v12 s_delay_alu instid0(VALU_DEP_1) v_div_fmas_f32 v5, v5, v8, v11 s_mov_b32 vcc_lo, s2 s_load_b32 s2, s[0:1], 0x18 v_div_fmas_f32 v7, v7, v9, v13 v_cvt_f32_i32_e32 v8, s11 v_div_fixup_f32 v2, v5, v6, v2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_div_fixup_f32 v3, v7, v3, v4 v_add_f32_e32 v10, v3, v8 v_cvt_f32_i32_e32 v3, s10 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_floor_f32_e32 v11, v10 v_add_f32_e32 v12, v2, v3 v_ceil_f32_e32 v3, v10 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_cvt_i32_f32_e32 v2, v11 v_ceil_f32_e32 v4, v12 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_cvt_i32_f32_e32 v3, v3 s_waitcnt lgkmcnt(0) v_mul_lo_u32 v2, v2, s2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_cvt_i32_f32_e32 v6, v4 v_mul_lo_u32 v7, v3, s2 s_load_b128 s[0:3], s[0:1], 0x0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v15, v2, v6 v_add_nc_u32_e32 v17, v7, v6 v_floor_f32_e32 v13, v12 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v4, s4, v15 v_add_nc_u32_e32 v8, s4, v17 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2) v_cvt_i32_f32_e32 v5, v13 v_ashrrev_i32_e32 v9, 31, v8 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v14, v2, v5 v_add_nc_u32_e32 v16, v7, v5 v_ashrrev_i32_e32 v5, 31, v4 v_add_nc_u32_e32 v2, s4, v14 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v6, s4, v16 v_lshlrev_b64 v[4:5], 2, v[4:5] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v3, 31, v2 v_ashrrev_i32_e32 v7, 31, v6 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[2:3], 2, v[2:3] v_lshlrev_b64 v[6:7], 2, v[6:7] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v2, vcc_lo, s0, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo v_add_co_u32 v4, vcc_lo, s0, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo s_clause 0x1 global_load_b32 v18, v[2:3], off global_load_b32 v19, v[4:5], off v_lshlrev_b64 v[2:3], 2, v[8:9] v_add_co_u32 v4, vcc_lo, s0, v6 v_add_co_ci_u32_e32 v5, vcc_lo, s1, v7, vcc_lo v_sub_f32_e32 v6, v10, v11 s_delay_alu instid0(VALU_DEP_4) v_add_co_u32 v2, vcc_lo, s0, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo s_clause 0x1 global_load_b32 v4, v[4:5], off global_load_b32 v5, v[2:3], off v_sub_f32_e32 v7, v12, v13 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_dual_sub_f32 v8, 1.0, v7 :: v_dual_add_nc_u32 v9, s5, v17 v_sub_f32_e32 v2, 1.0, v6 v_mul_f32_e32 v11, v7, v2 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_3) | instid1(VALU_DEP_3) v_mul_f32_e32 v12, v8, v2 v_mad_u64_u32 v[2:3], null, v1, s12, v[0:1] v_add_nc_u32_e32 v3, s5, v14 v_mul_f32_e32 v13, v8, v6 v_add_nc_u32_e32 v0, s7, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[0:1], 2, v[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_waitcnt vmcnt(2) v_mul_f32_e32 v10, v11, v19 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_fmac_f32_e32 v10, v12, v18 v_dual_mul_f32 v18, v7, v6 :: v_dual_add_nc_u32 v7, s5, v16 s_waitcnt vmcnt(1) v_fmac_f32_e32 v10, v13, v4 v_ashrrev_i32_e32 v4, 31, v3 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_dual_fmac_f32 v10, v18, v5 :: v_dual_add_nc_u32 v5, s5, v15 v_lshlrev_b64 v[3:4], 2, v[3:4] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_trunc_f32_e32 v19, v10 v_ashrrev_i32_e32 v6, 31, v5 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v3, vcc_lo, s0, v3 v_sub_f32_e32 v8, v10, v19 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_lshlrev_b64 v[5:6], 2, v[5:6] v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo v_cmp_ge_f32_e64 s4, |v8|, 0.5 v_ashrrev_i32_e32 v8, 31, v7 s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4) v_add_co_u32 v5, vcc_lo, s0, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s1, v6, vcc_lo v_cndmask_b32_e64 v20, 0, 1.0, s4 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[7:8], 2, v[7:8] v_bfi_b32 v10, 0x7fffffff, v20, v10 s_delay_alu instid0(VALU_DEP_1) v_add_f32_e32 v19, v19, v10 v_ashrrev_i32_e32 v10, 31, v9 global_store_b32 v[0:1], v19, off v_lshlrev_b64 v[0:1], 2, v[9:10] v_add_nc_u32_e32 v9, s6, v17 s_clause 0x1 global_load_b32 v19, v[3:4], off global_load_b32 v5, v[5:6], off v_add_co_u32 v3, vcc_lo, s0, v7 v_add_co_ci_u32_e32 v4, vcc_lo, s1, v8, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_clause 0x1 global_load_b32 v3, v[3:4], off global_load_b32 v1, v[0:1], off v_add_nc_u32_e32 v7, s6, v16 v_add_nc_u32_e32 v0, s8, v2 s_waitcnt vmcnt(2) v_dual_mul_f32 v10, v11, v5 :: v_dual_add_nc_u32 v5, s6, v15 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_fmac_f32_e32 v10, v12, v19 v_ashrrev_i32_e32 v6, 31, v5 s_waitcnt vmcnt(1) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_dual_fmac_f32 v10, v13, v3 :: v_dual_add_nc_u32 v3, s6, v14 v_lshlrev_b64 v[5:6], 2, v[5:6] s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_fmac_f32_e32 v10, v18, v1 v_ashrrev_i32_e32 v1, 31, v0 v_ashrrev_i32_e32 v4, 31, v3 v_trunc_f32_e32 v19, v10 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_lshlrev_b64 v[0:1], 2, v[0:1] v_lshlrev_b64 v[3:4], 2, v[3:4] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_sub_f32_e32 v8, v10, v19 v_add_co_u32 v0, vcc_lo, s2, v0 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo v_cmp_ge_f32_e64 s4, |v8|, 0.5 v_ashrrev_i32_e32 v8, 31, v7 v_add_co_u32 v3, vcc_lo, s0, v3 v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_cndmask_b32_e64 v14, 0, 1.0, s4 v_add_co_u32 v5, vcc_lo, s0, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s1, v6, vcc_lo v_bfi_b32 v10, 0x7fffffff, v14, v10 v_lshlrev_b64 v[7:8], 2, v[7:8] s_delay_alu instid0(VALU_DEP_2) v_add_f32_e32 v14, v19, v10 v_ashrrev_i32_e32 v10, 31, v9 global_store_b32 v[0:1], v14, off v_lshlrev_b64 v[0:1], 2, v[9:10] s_clause 0x1 global_load_b32 v14, v[3:4], off global_load_b32 v5, v[5:6], off v_add_co_u32 v3, vcc_lo, s0, v7 v_add_co_ci_u32_e32 v4, vcc_lo, s1, v8, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_clause 0x1 global_load_b32 v3, v[3:4], off global_load_b32 v0, v[0:1], off s_waitcnt vmcnt(2) v_mul_f32_e32 v4, v11, v5 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_fmac_f32_e32 v4, v12, v14 s_waitcnt vmcnt(1) v_fmac_f32_e32 v4, v13, v3 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_fmac_f32_e32 v4, v18, v0 v_add_nc_u32_e32 v0, s9, v2 v_trunc_f32_e32 v3, v4 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_sub_f32_e32 v1, v4, v3 v_cmp_ge_f32_e64 s0, |v1|, 0.5 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v1, 31, v0 v_cndmask_b32_e64 v2, 0, 1.0, s0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[0:1], 2, v[0:1] v_bfi_b32 v2, 0x7fffffff, v2, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_delay_alu instid0(VALU_DEP_3) v_add_f32_e32 v2, v3, v2 global_store_b32 v[0:1], v2, off .LBB0_2: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 336 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 21 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, .Lfunc_end0-_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: by_value - .offset: 36 .size: 4 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: by_value - .offset: 44 .size: 4 .value_kind: by_value - .offset: 48 .size: 4 .value_kind: by_value - .offset: 52 .size: 4 .value_kind: by_value - .offset: 56 .size: 4 .value_kind: by_value - .offset: 60 .size: 4 .value_kind: by_value - .offset: 64 .size: 4 .value_kind: by_value - .offset: 68 .size: 4 .value_kind: by_value - .offset: 72 .size: 4 .value_kind: by_value - .offset: 80 .size: 4 .value_kind: hidden_block_count_x - .offset: 84 .size: 4 .value_kind: hidden_block_count_y - .offset: 88 .size: 4 .value_kind: hidden_block_count_z - .offset: 92 .size: 2 .value_kind: hidden_group_size_x - .offset: 94 .size: 2 .value_kind: hidden_group_size_y - .offset: 96 .size: 2 .value_kind: hidden_group_size_z - .offset: 98 .size: 2 .value_kind: hidden_remainder_x - .offset: 100 .size: 2 .value_kind: hidden_remainder_y - .offset: 102 .size: 2 .value_kind: hidden_remainder_z - .offset: 120 .size: 8 .value_kind: hidden_global_offset_x - .offset: 128 .size: 8 .value_kind: hidden_global_offset_y - .offset: 136 .size: 8 .value_kind: hidden_global_offset_z - .offset: 144 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 336 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 21 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int bbox_y, const int bbox_w, const int bbox_h) { uint x = blockIdx.x * blockDim.x + threadIdx.x; uint y = blockIdx.y * blockDim.y + threadIdx.y; if( x < output_w && y < output_h) { float r[2] = { float(x) * bbox_w / output_w + bbox_x, float(y) * bbox_h / output_h + bbox_y }; int pos[4][2] = { { int(floor(r[0])), int(floor(r[1])) }, { int( ceil(r[0])), int(floor(r[1])) }, { int(floor(r[0])), int(ceil(r[1])) }, { int( ceil(r[0])), int(ceil(r[1])) } }; float u = r[0]-floor(r[0]); float v = r[1]-floor(r[1]); float s[4] = { (1-u)*(1-v), u*(1-v), (1-u)*v, u*v }; int map[4] = { pos[0][1]*input_w + pos[0][0], pos[1][1]*input_w + pos[1][0], pos[2][1]*input_w + pos[2][0], pos[3][1]*input_w + pos[3][0]}; int idx = y * output_w + x; output[idx+out_plane_r] = round( s[0]*input[map[0]+in_plane_r] + s[1]*input[map[1]+in_plane_r] + s[2]*input[map[2]+in_plane_r] + s[3]*input[map[3]+in_plane_r] );// float(mean[idx+out_plane_r])); output[idx+out_plane_g] = round( s[0]*input[map[0]+in_plane_g] + s[1]*input[map[1]+in_plane_g] + s[2]*input[map[2]+in_plane_g] + s[3]*input[map[3]+in_plane_g] );//float(mean[idx+out_plane_g])); output[idx+out_plane_b] = round( s[0]*input[map[0]+in_plane_b] + s[1]*input[map[1]+in_plane_b] + s[2]*input[map[2]+in_plane_b] + s[3]*input[map[3]+in_plane_b] );//float(mean[idx+out_plane_b])); } }
.text .file "kernel_extract_roi.hip" .globl _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii # -- Begin function _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .p2align 4, 0x90 .type _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii,@function _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii: # @_Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .cfi_startproc # %bb.0: subq $232, %rsp .cfi_def_cfa_offset 240 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 20(%rsp), %rax movq %rax, 120(%rsp) leaq 16(%rsp), %rax movq %rax, 128(%rsp) leaq 12(%rsp), %rax movq %rax, 136(%rsp) leaq 240(%rsp), %rax movq %rax, 144(%rsp) leaq 248(%rsp), %rax movq %rax, 152(%rsp) leaq 256(%rsp), %rax movq %rax, 160(%rsp) leaq 264(%rsp), %rax movq %rax, 168(%rsp) leaq 272(%rsp), %rax movq %rax, 176(%rsp) leaq 280(%rsp), %rax movq %rax, 184(%rsp) leaq 288(%rsp), %rax movq %rax, 192(%rsp) leaq 296(%rsp), %rax movq %rax, 200(%rsp) leaq 304(%rsp), %rax movq %rax, 208(%rsp) leaq 312(%rsp), %rax movq %rax, 216(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $248, %rsp .cfi_adjust_cfa_offset -248 retq .Lfunc_end0: .size _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii, .Lfunc_end0-_Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB1_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB1_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end1: .size __hip_module_ctor, .Lfunc_end1-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB2_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB2_2: retq .Lfunc_end2: .size __hip_module_dtor, .Lfunc_end2-__hip_module_dtor .cfi_endproc # -- End function .type _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii,@object # @_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .section .rodata,"a",@progbits .globl _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .p2align 3, 0x0 _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii: .quad _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .size _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii" .size .L__unnamed_1, 42 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00101852_00000000-6_kernel_extract_roi.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2029: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2029: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii .type _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii, @function _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii: .LFB2051: .cfi_startproc endbr64 subq $264, %rsp .cfi_def_cfa_offset 272 movq %rdi, 40(%rsp) movq %rsi, 32(%rsp) movq %rdx, 24(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) movq %fs:40, %rax movq %rax, 248(%rsp) xorl %eax, %eax leaq 40(%rsp), %rax movq %rax, 112(%rsp) leaq 32(%rsp), %rax movq %rax, 120(%rsp) leaq 24(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 16(%rsp), %rax movq %rax, 144(%rsp) leaq 12(%rsp), %rax movq %rax, 152(%rsp) leaq 272(%rsp), %rax movq %rax, 160(%rsp) leaq 280(%rsp), %rax movq %rax, 168(%rsp) leaq 288(%rsp), %rax movq %rax, 176(%rsp) leaq 296(%rsp), %rax movq %rax, 184(%rsp) leaq 304(%rsp), %rax movq %rax, 192(%rsp) leaq 312(%rsp), %rax movq %rax, 200(%rsp) leaq 320(%rsp), %rax movq %rax, 208(%rsp) leaq 328(%rsp), %rax movq %rax, 216(%rsp) leaq 336(%rsp), %rax movq %rax, 224(%rsp) leaq 344(%rsp), %rax movq %rax, 232(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) leaq 56(%rsp), %rcx leaq 48(%rsp), %rdx leaq 76(%rsp), %rsi leaq 64(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 248(%rsp), %rax subq %fs:40, %rax jne .L8 addq $264, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 56(%rsp) .cfi_def_cfa_offset 280 pushq 56(%rsp) .cfi_def_cfa_offset 288 leaq 128(%rsp), %r9 movq 92(%rsp), %rcx movl 100(%rsp), %r8d movq 80(%rsp), %rsi movl 88(%rsp), %edx leaq _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 272 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii, .-_Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii .globl _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .type _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, @function _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 24 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 32 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 40 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 48 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 56 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 64 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 72 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 80 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 88 movl 88(%rsp), %eax pushq %rax .cfi_def_cfa_offset 96 call _Z55__device_stub__Z18kernel_extract_roiPfS_PciiiiiiiiiiiiiPfS_Pciiiiiiiiiiiii addq $88, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, .-_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2054: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2054: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "kernel_extract_roi.hip" .globl _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii # -- Begin function _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .p2align 4, 0x90 .type _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii,@function _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii: # @_Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .cfi_startproc # %bb.0: subq $232, %rsp .cfi_def_cfa_offset 240 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 20(%rsp), %rax movq %rax, 120(%rsp) leaq 16(%rsp), %rax movq %rax, 128(%rsp) leaq 12(%rsp), %rax movq %rax, 136(%rsp) leaq 240(%rsp), %rax movq %rax, 144(%rsp) leaq 248(%rsp), %rax movq %rax, 152(%rsp) leaq 256(%rsp), %rax movq %rax, 160(%rsp) leaq 264(%rsp), %rax movq %rax, 168(%rsp) leaq 272(%rsp), %rax movq %rax, 176(%rsp) leaq 280(%rsp), %rax movq %rax, 184(%rsp) leaq 288(%rsp), %rax movq %rax, 192(%rsp) leaq 296(%rsp), %rax movq %rax, 200(%rsp) leaq 304(%rsp), %rax movq %rax, 208(%rsp) leaq 312(%rsp), %rax movq %rax, 216(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $248, %rsp .cfi_adjust_cfa_offset -248 retq .Lfunc_end0: .size _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii, .Lfunc_end0-_Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB1_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB1_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end1: .size __hip_module_ctor, .Lfunc_end1-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB2_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB2_2: retq .Lfunc_end2: .size __hip_module_dtor, .Lfunc_end2-__hip_module_dtor .cfi_endproc # -- End function .type _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii,@object # @_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .section .rodata,"a",@progbits .globl _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .p2align 3, 0x0 _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii: .quad _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .size _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii" .size .L__unnamed_1, 42 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z33__device_stub__kernel_extract_roiPfS_Pciiiiiiiiiiiii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z18kernel_extract_roiPfS_Pciiiiiiiiiiiii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include "includes.h" extern "C" { } const double TOLERANCE = 1.0e-10; /* cgsolver with CUDA support solves the linear equation A*x = b where A is of size m x n */ __global__ void mvm_gpu(double *A_cuda, double *X_cuda, double *Y_cuda, int *m_locals_cuda, int *A_all_pos_cuda, int n, int nthreads){ int t = blockIdx.x * blockDim.x + threadIdx.x; if (t < nthreads){ for (int i=A_all_pos_cuda[t]; i<A_all_pos_cuda[t]+m_locals_cuda[t]; ++i) { Y_cuda[i] = 0.; for (int j=0; j<n; ++j) Y_cuda[i] += A_cuda[i * n + j] * X_cuda[j]; } } }
code for sm_80 Function : _Z7mvm_gpuPdS_S_PiS0_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0203 */ /*0040*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x18c], PT ; /* 0x0000630000007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ IMAD.MOV.U32 R9, RZ, RZ, 0x4 ; /* 0x00000004ff097424 */ /* 0x000fe200078e00ff */ /*0070*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0080*/ IMAD.WIDE R8, R0, R9, c[0x0][0x178] ; /* 0x00005e0000087625 */ /* 0x000fca00078e0209 */ /*0090*/ LDG.E R2, [R8.64] ; /* 0x0000000408027981 */ /* 0x000ea4000c1e1900 */ /*00a0*/ ISETP.GE.AND P0, PT, R2, 0x1, PT ; /* 0x000000010200780c */ /* 0x004fda0003f06270 */ /*00b0*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*00c0*/ SHF.R.S32.HI R3, RZ, 0x1f, R0 ; /* 0x0000001fff037819 */ /* 0x000fe40000011400 */ /*00d0*/ LEA R10, P0, R0, c[0x0][0x180], 0x2 ; /* 0x00006000000a7a11 */ /* 0x000fc800078010ff */ /*00e0*/ LEA.HI.X R11, R0, c[0x0][0x184], R3, 0x2, P0 ; /* 0x00006100000b7a11 */ /* 0x000fca00000f1403 */ /*00f0*/ LDG.E R0, [R10.64] ; /* 0x000000040a007981 */ /* 0x000162000c1e1900 */ /*0100*/ ISETP.LT.AND P0, PT, RZ, c[0x0][0x188], PT ; /* 0x00006200ff007a0c */ /* 0x000fda0003f01270 */ /*0110*/ @P0 BRA 0x1c0 ; /* 0x000000a000000947 */ /* 0x001fea0003800000 */ /*0120*/ IMAD.MOV.U32 R3, RZ, RZ, 0x8 ; /* 0x00000008ff037424 */ /* 0x000fc800078e00ff */ /*0130*/ IMAD.WIDE R2, R0, R3, c[0x0][0x170] ; /* 0x00005c0000027625 */ /* 0x020fca00078e0203 */ /*0140*/ STG.E.64 [R2.64], RZ ; /* 0x000000ff02007986 */ /* 0x0001e8000c101b04 */ /*0150*/ LDG.E R4, [R8.64] ; /* 0x0000000408047981 */ /* 0x000ea8000c1e1900 */ /*0160*/ LDG.E R5, [R10.64] ; /* 0x000000040a057981 */ /* 0x000ea2000c1e1900 */ /*0170*/ IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100007810 */ /* 0x000fe20007ffe0ff */ /*0180*/ IMAD.IADD R5, R4, 0x1, R5 ; /* 0x0000000104057824 */ /* 0x004fca00078e0205 */ /*0190*/ ISETP.GE.AND P0, PT, R0, R5, PT ; /* 0x000000050000720c */ /* 0x000fda0003f06270 */ /*01a0*/ @!P0 BRA 0x120 ; /* 0xffffff7000008947 */ /* 0x001fea000383ffff */ /*01b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01c0*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x188] ; /* 0x00006200ff027624 */ /* 0x000fca00078e00ff */ /*01d0*/ IADD3 R3, R2.reuse, -0x1, RZ ; /* 0xffffffff02037810 */ /* 0x040fe40007ffe0ff */ /*01e0*/ LOP3.LUT R2, R2, 0x3, RZ, 0xc0, !PT ; /* 0x0000000302027812 */ /* 0x000fe400078ec0ff */ /*01f0*/ ISETP.GE.U32.AND P1, PT, R3, 0x3, PT ; /* 0x000000030300780c */ /* 0x000fe40003f26070 */ /*0200*/ IADD3 R3, -R2, c[0x0][0x188], RZ ; /* 0x0000620002037a10 */ /* 0x000fe40007ffe1ff */ /*0210*/ IMAD.MOV.U32 R5, RZ, RZ, 0x8 ; /* 0x00000008ff057424 */ /* 0x000fe200078e00ff */ /*0220*/ CS2R R28, SRZ ; /* 0x00000000001c7805 */ /* 0x006fe2000001ff00 */ /*0230*/ IMAD R4, R0.reuse, c[0x0][0x188], RZ ; /* 0x0000620000047a24 */ /* 0x060fe400078e02ff */ /*0240*/ IMAD.WIDE R12, R0, R5, c[0x0][0x170] ; /* 0x00005c00000c7625 */ /* 0x001fc800078e0205 */ /*0250*/ IMAD.MOV.U32 R7, RZ, RZ, RZ ; /* 0x000000ffff077224 */ /* 0x000fe200078e00ff */ /*0260*/ STG.E.64 [R12.64], RZ ; /* 0x000000ff0c007986 */ /* 0x0001e2000c101b04 */ /*0270*/ @!P1 BRA 0xcb0 ; /* 0x00000a3000009947 */ /* 0x000fea0003800000 */ /*0280*/ ISETP.GT.AND P0, PT, R3, RZ, PT ; /* 0x000000ff0300720c */ /* 0x000fe20003f04270 */ /*0290*/ IMAD.MOV.U32 R7, RZ, RZ, RZ ; /* 0x000000ffff077224 */ /* 0x000fe200078e00ff */ /*02a0*/ CS2R R28, SRZ ; /* 0x00000000001c7805 */ /* 0x000fe2000001ff00 */ /*02b0*/ IMAD.MOV.U32 R6, RZ, RZ, R3 ; /* 0x000000ffff067224 */ /* 0x000fe400078e0003 */ /*02c0*/ IMAD.WIDE R14, R4, R5, c[0x0][0x160] ; /* 0x00005800040e7625 */ /* 0x000fc800078e0205 */ /*02d0*/ IMAD.MOV.U32 R16, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff107624 */ /* 0x000fe400078e00ff */ /*02e0*/ IMAD.MOV.U32 R17, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff117624 */ /* 0x000fe400078e00ff */ /*02f0*/ @!P0 BRA 0xaf0 ; /* 0x000007f000008947 */ /* 0x000fea0003800000 */ /*0300*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fe40003f44270 */ /*0310*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0320*/ @!P2 BRA 0x800 ; /* 0x000004d00000a947 */ /* 0x000fea0003800000 */ /*0330*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0340*/ LDG.E.64 R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1b00 */ /*0350*/ LDG.E.64 R26, [R14.64] ; /* 0x000000040e1a7981 */ /* 0x002ea4000c1e1b00 */ /*0360*/ DFMA R26, R18, R26, R28 ; /* 0x0000001a121a722b */ /* 0x004e4e000000001c */ /*0370*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0380*/ LDG.E.64 R24, [R16.64+0x8] ; /* 0x0000080410187981 */ /* 0x000ea8000c1e1b00 */ /*0390*/ LDG.E.64 R18, [R14.64+0x8] ; /* 0x000008040e127981 */ /* 0x000ea4000c1e1b00 */ /*03a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*03b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0045e8000c101b04 */ /*03c0*/ LDG.E.64 R22, [R16.64+0x10] ; /* 0x0000100410167981 */ /* 0x000ee8000c1e1b00 */ /*03d0*/ LDG.E.64 R18, [R14.64+0x10] ; /* 0x000010040e127981 */ /* 0x000ee4000c1e1b00 */ /*03e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008ece0000000018 */ /*03f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*0400*/ LDG.E.64 R20, [R16.64+0x18] ; /* 0x0000180410147981 */ /* 0x000f28000c1e1b00 */ /*0410*/ LDG.E.64 R18, [R14.64+0x18] ; /* 0x000018040e127981 */ /* 0x000f24000c1e1b00 */ /*0420*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x010f0e0000000016 */ /*0430*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0109e8000c101b04 */ /*0440*/ LDG.E.64 R26, [R16.64+0x20] ; /* 0x00002004101a7981 */ /* 0x002f68000c1e1b00 */ /*0450*/ LDG.E.64 R18, [R14.64+0x20] ; /* 0x000020040e127981 */ /* 0x000f64000c1e1b00 */ /*0460*/ DFMA R26, R26, R18, R20 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000014 */ /*0470*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0480*/ LDG.E.64 R24, [R16.64+0x28] ; /* 0x0000280410187981 */ /* 0x004ea8000c1e1b00 */ /*0490*/ LDG.E.64 R18, [R14.64+0x28] ; /* 0x000028040e127981 */ /* 0x000ea4000c1e1b00 */ /*04a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*04b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0045e8000c101b04 */ /*04c0*/ LDG.E.64 R22, [R16.64+0x30] ; /* 0x0000300410167981 */ /* 0x008ee8000c1e1b00 */ /*04d0*/ LDG.E.64 R18, [R14.64+0x30] ; /* 0x000030040e127981 */ /* 0x000ee4000c1e1b00 */ /*04e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008ece0000000018 */ /*04f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*0500*/ LDG.E.64 R20, [R16.64+0x38] ; /* 0x0000380410147981 */ /* 0x010f28000c1e1b00 */ /*0510*/ LDG.E.64 R18, [R14.64+0x38] ; /* 0x000038040e127981 */ /* 0x000f24000c1e1b00 */ /*0520*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x010f0e0000000016 */ /*0530*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0109e8000c101b04 */ /*0540*/ LDG.E.64 R26, [R16.64+0x40] ; /* 0x00004004101a7981 */ /* 0x002f68000c1e1b00 */ /*0550*/ LDG.E.64 R18, [R14.64+0x40] ; /* 0x000040040e127981 */ /* 0x000f64000c1e1b00 */ /*0560*/ DFMA R26, R26, R18, R20 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000014 */ /*0570*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0580*/ LDG.E.64 R24, [R16.64+0x48] ; /* 0x0000480410187981 */ /* 0x004ea8000c1e1b00 */ /*0590*/ LDG.E.64 R18, [R14.64+0x48] ; /* 0x000048040e127981 */ /* 0x000ea4000c1e1b00 */ /*05a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*05b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0045e8000c101b04 */ /*05c0*/ LDG.E.64 R22, [R16.64+0x50] ; /* 0x0000500410167981 */ /* 0x008ee8000c1e1b00 */ /*05d0*/ LDG.E.64 R18, [R14.64+0x50] ; /* 0x000050040e127981 */ /* 0x000ee4000c1e1b00 */ /*05e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008ece0000000018 */ /*05f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*0600*/ LDG.E.64 R20, [R16.64+0x58] ; /* 0x0000580410147981 */ /* 0x010f28000c1e1b00 */ /*0610*/ LDG.E.64 R18, [R14.64+0x58] ; /* 0x000058040e127981 */ /* 0x000f24000c1e1b00 */ /*0620*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x010f0e0000000016 */ /*0630*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0109e8000c101b04 */ /*0640*/ LDG.E.64 R26, [R16.64+0x60] ; /* 0x00006004101a7981 */ /* 0x002f68000c1e1b00 */ /*0650*/ LDG.E.64 R18, [R14.64+0x60] ; /* 0x000060040e127981 */ /* 0x000f64000c1e1b00 */ /*0660*/ DFMA R26, R26, R18, R20 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000014 */ /*0670*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0680*/ LDG.E.64 R24, [R16.64+0x68] ; /* 0x0000680410187981 */ /* 0x004ea8000c1e1b00 */ /*0690*/ LDG.E.64 R18, [R14.64+0x68] ; /* 0x000068040e127981 */ /* 0x000ea4000c1e1b00 */ /*06a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*06b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0043e8000c101b04 */ /*06c0*/ LDG.E.64 R22, [R16.64+0x70] ; /* 0x0000700410167981 */ /* 0x008ea8000c1e1b00 */ /*06d0*/ LDG.E.64 R18, [R14.64+0x70] ; /* 0x000070040e127981 */ /* 0x000ea4000c1e1b00 */ /*06e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x004e8e0000000018 */ /*06f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0043e8000c101b04 */ /*0700*/ LDG.E.64 R18, [R16.64+0x78] ; /* 0x0000780410127981 */ /* 0x000ea8000c1e1b00 */ /*0710*/ LDG.E.64 R20, [R14.64+0x78] ; /* 0x000078040e147981 */ /* 0x010ea2000c1e1b00 */ /*0720*/ IADD3 R6, R6, -0x10, RZ ; /* 0xfffffff006067810 */ /* 0x000fe40007ffe0ff */ /*0730*/ IADD3 R7, R7, 0x10, RZ ; /* 0x0000001007077810 */ /* 0x000fc40007ffe0ff */ /*0740*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fe20003f44270 */ /*0750*/ DFMA R28, R18, R20, R22 ; /* 0x00000014121c722b */ /* 0x0044e40000000016 */ /*0760*/ IADD3 R18, P4, R16, 0x80, RZ ; /* 0x0000008010127810 */ /* 0x004fe40007f9e0ff */ /*0770*/ IADD3 R20, P3, R14, 0x80, RZ ; /* 0x000000800e147810 */ /* 0x000fc60007f7e0ff */ /*0780*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0083e2000c101b04 */ /*0790*/ IMAD.X R19, RZ, RZ, R17, P4 ; /* 0x000000ffff137224 */ /* 0x000fe200020e0611 */ /*07a0*/ MOV R14, R20 ; /* 0x00000014000e7202 */ /* 0x000fe20000000f00 */ /*07b0*/ IMAD.X R21, RZ, RZ, R15, P3 ; /* 0x000000ffff157224 */ /* 0x000fe400018e060f */ /*07c0*/ IMAD.MOV.U32 R16, RZ, RZ, R18 ; /* 0x000000ffff107224 */ /* 0x000fe400078e0012 */ /*07d0*/ IMAD.MOV.U32 R17, RZ, RZ, R19 ; /* 0x000000ffff117224 */ /* 0x000fe400078e0013 */ /*07e0*/ IMAD.MOV.U32 R15, RZ, RZ, R21 ; /* 0x000000ffff0f7224 */ /* 0x000fe200078e0015 */ /*07f0*/ @P2 BRA 0x340 ; /* 0xfffffb4000002947 */ /* 0x000fea000383ffff */ /*0800*/ ISETP.GT.AND P2, PT, R6, 0x4, PT ; /* 0x000000040600780c */ /* 0x000fda0003f44270 */ /*0810*/ @!P2 BRA 0xad0 ; /* 0x000002b00000a947 */ /* 0x000fea0003800000 */ /*0820*/ LDG.E.64 R26, [R16.64] ; /* 0x00000004101a7981 */ /* 0x002ea8000c1e1b00 */ /*0830*/ LDG.E.64 R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000ea4000c1e1b00 */ /*0840*/ DFMA R26, R26, R18, R28 ; /* 0x000000121a1a722b */ /* 0x004e4e000000001c */ /*0850*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0860*/ LDG.E.64 R20, [R16.64+0x8] ; /* 0x0000080410147981 */ /* 0x000ea8000c1e1b00 */ /*0870*/ LDG.E.64 R18, [R14.64+0x8] ; /* 0x000008040e127981 */ /* 0x000ea4000c1e1b00 */ /*0880*/ DFMA R20, R20, R18, R26 ; /* 0x000000121414722b */ /* 0x004e8e000000001a */ /*0890*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0045e8000c101b04 */ /*08a0*/ LDG.E.64 R22, [R16.64+0x10] ; /* 0x0000100410167981 */ /* 0x000ee8000c1e1b00 */ /*08b0*/ LDG.E.64 R18, [R14.64+0x10] ; /* 0x000010040e127981 */ /* 0x000ee4000c1e1b00 */ /*08c0*/ DFMA R22, R22, R18, R20 ; /* 0x000000121616722b */ /* 0x008ece0000000014 */ /*08d0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*08e0*/ LDG.E.64 R24, [R16.64+0x18] ; /* 0x0000180410187981 */ /* 0x000f28000c1e1b00 */ /*08f0*/ LDG.E.64 R18, [R14.64+0x18] ; /* 0x000018040e127981 */ /* 0x000f24000c1e1b00 */ /*0900*/ DFMA R24, R24, R18, R22 ; /* 0x000000121818722b */ /* 0x010f0e0000000016 */ /*0910*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0109e8000c101b04 */ /*0920*/ LDG.E.64 R26, [R16.64+0x20] ; /* 0x00002004101a7981 */ /* 0x002f68000c1e1b00 */ /*0930*/ LDG.E.64 R18, [R14.64+0x20] ; /* 0x000020040e127981 */ /* 0x000f64000c1e1b00 */ /*0940*/ DFMA R26, R26, R18, R24 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000018 */ /*0950*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x002fe8000c101b04 */ /*0960*/ LDG.E.64 R18, [R16.64+0x28] ; /* 0x0000280410127981 */ /* 0x000f68000c1e1b00 */ /*0970*/ LDG.E.64 R20, [R14.64+0x28] ; /* 0x000028040e147981 */ /* 0x004f64000c1e1b00 */ /*0980*/ DFMA R18, R18, R20, R26 ; /* 0x000000141212722b */ /* 0x020e4e000000001a */ /*0990*/ STG.E.64 [R12.64], R18 ; /* 0x000000120c007986 */ /* 0x0023e8000c101b04 */ /*09a0*/ LDG.E.64 R20, [R16.64+0x30] ; /* 0x0000300410147981 */ /* 0x000ea8000c1e1b00 */ /*09b0*/ LDG.E.64 R22, [R14.64+0x30] ; /* 0x000030040e167981 */ /* 0x008ea4000c1e1b00 */ /*09c0*/ DFMA R20, R20, R22, R18 ; /* 0x000000161414722b */ /* 0x004e8e0000000012 */ /*09d0*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0045e8000c101b04 */ /*09e0*/ LDG.E.64 R22, [R16.64+0x38] ; /* 0x0000380410167981 */ /* 0x000768000c1e1b00 */ /*09f0*/ LDG.E.64 R24, [R14.64+0x38] ; /* 0x000038040e187981 */ /* 0x010f62000c1e1b00 */ /*0a00*/ IADD3 R18, P3, R16, 0x40, RZ ; /* 0x0000004010127810 */ /* 0x002fe40007f7e0ff */ /*0a10*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fc40003f0e170 */ /*0a20*/ IADD3 R7, R7, 0x8, RZ ; /* 0x0000000807077810 */ /* 0x000fe20007ffe0ff */ /*0a30*/ IMAD.X R19, RZ, RZ, R17, P3 ; /* 0x000000ffff137224 */ /* 0x000fe200018e0611 */ /*0a40*/ IADD3 R6, R6, -0x8, RZ ; /* 0xfffffff806067810 */ /* 0x000fe20007ffe0ff */ /*0a50*/ IMAD.MOV.U32 R16, RZ, RZ, R18 ; /* 0x000000ffff107224 */ /* 0x008fe400078e0012 */ /*0a60*/ IMAD.MOV.U32 R17, RZ, RZ, R19 ; /* 0x000000ffff117224 */ /* 0x000fe200078e0013 */ /*0a70*/ DFMA R28, R22, R24, R20 ; /* 0x00000018161c722b */ /* 0x0202e40000000014 */ /*0a80*/ IADD3 R22, P2, R14, 0x40, RZ ; /* 0x000000400e167810 */ /* 0x002fca0007f5e0ff */ /*0a90*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0085e2000c101b04 */ /*0aa0*/ IMAD.X R23, RZ, RZ, R15, P2 ; /* 0x000000ffff177224 */ /* 0x000fe400010e060f */ /*0ab0*/ IMAD.MOV.U32 R14, RZ, RZ, R22 ; /* 0x000000ffff0e7224 */ /* 0x000fe400078e0016 */ /*0ac0*/ IMAD.MOV.U32 R15, RZ, RZ, R23 ; /* 0x000000ffff0f7224 */ /* 0x000fe400078e0017 */ /*0ad0*/ ISETP.NE.OR P0, PT, R6, RZ, P0 ; /* 0x000000ff0600720c */ /* 0x000fda0000705670 */ /*0ae0*/ @!P0 BRA 0xcb0 ; /* 0x000001c000008947 */ /* 0x000fea0003800000 */ /*0af0*/ LDG.E.64 R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ee8000c1e1b00 */ /*0b00*/ LDG.E.64 R24, [R14.64] ; /* 0x000000040e187981 */ /* 0x002ee4000c1e1b00 */ /*0b10*/ DFMA R24, R18, R24, R28 ; /* 0x000000181218722b */ /* 0x008e4e000000001c */ /*0b20*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x002fe8000c101b04 */ /*0b30*/ LDG.E.64 R22, [R16.64+0x8] ; /* 0x0000080410167981 */ /* 0x000ee8000c1e1b00 */ /*0b40*/ LDG.E.64 R18, [R14.64+0x8] ; /* 0x000008040e127981 */ /* 0x000ee4000c1e1b00 */ /*0b50*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008e4e0000000018 */ /*0b60*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0023e8000c101b04 */ /*0b70*/ LDG.E.64 R20, [R16.64+0x10] ; /* 0x0000100410147981 */ /* 0x004ea8000c1e1b00 */ /*0b80*/ LDG.E.64 R18, [R14.64+0x10] ; /* 0x000010040e127981 */ /* 0x000ea4000c1e1b00 */ /*0b90*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x004e8e0000000016 */ /*0ba0*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0045e8000c101b04 */ /*0bb0*/ LDG.E.64 R28, [R16.64+0x18] ; /* 0x00001804101c7981 */ /* 0x000ee8000c1e1b00 */ /*0bc0*/ LDG.E.64 R18, [R14.64+0x18] ; /* 0x000018040e127981 */ /* 0x0008e2000c1e1b00 */ /*0bd0*/ IADD3 R6, R6, -0x4, RZ ; /* 0xfffffffc06067810 */ /* 0x000fe40007ffe0ff */ /*0be0*/ IADD3 R22, P2, R14, 0x20, RZ ; /* 0x000000200e167810 */ /* 0x002fc40007f5e0ff */ /*0bf0*/ ISETP.NE.AND P0, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fe40003f05270 */ /*0c00*/ IADD3.X R23, RZ, R15, RZ, P2, !PT ; /* 0x0000000fff177210 */ /* 0x000fe400017fe4ff */ /*0c10*/ IADD3 R7, R7, 0x4, RZ ; /* 0x0000000407077810 */ /* 0x000fe20007ffe0ff */ /*0c20*/ IMAD.MOV.U32 R14, RZ, RZ, R22 ; /* 0x000000ffff0e7224 */ /* 0x010fe400078e0016 */ /*0c30*/ IMAD.MOV.U32 R15, RZ, RZ, R23 ; /* 0x000000ffff0f7224 */ /* 0x000fe200078e0017 */ /*0c40*/ DFMA R28, R28, R18, R20 ; /* 0x000000121c1c722b */ /* 0x0082e40000000014 */ /*0c50*/ IADD3 R18, P3, R16, 0x20, RZ ; /* 0x0000002010127810 */ /* 0x002fca0007f7e0ff */ /*0c60*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0085e2000c101b04 */ /*0c70*/ IMAD.X R19, RZ, RZ, R17, P3 ; /* 0x000000ffff137224 */ /* 0x000fe400018e0611 */ /*0c80*/ IMAD.MOV.U32 R16, RZ, RZ, R18 ; /* 0x000000ffff107224 */ /* 0x000fe400078e0012 */ /*0c90*/ IMAD.MOV.U32 R17, RZ, RZ, R19 ; /* 0x000000ffff117224 */ /* 0x000fe200078e0013 */ /*0ca0*/ @P0 BRA 0xaf0 ; /* 0xfffffe4000000947 */ /* 0x005fea000383ffff */ /*0cb0*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fda0003f05270 */ /*0cc0*/ @!P0 BRA 0xdf0 ; /* 0x0000012000008947 */ /* 0x000fea0003800000 */ /*0cd0*/ IMAD.IADD R4, R4, 0x1, R7 ; /* 0x0000000104047824 */ /* 0x000fe400078e0207 */ /*0ce0*/ IMAD.WIDE R6, R7, R5, c[0x0][0x168] ; /* 0x00005a0007067625 */ /* 0x000fc800078e0205 */ /*0cf0*/ IMAD.WIDE R4, R4, R5, c[0x0][0x160] ; /* 0x0000580004047625 */ /* 0x000fe200078e0205 */ /*0d00*/ LDG.E.64 R14, [R6.64] ; /* 0x00000004060e7981 */ /* 0x000ee8000c1e1b00 */ /*0d10*/ LDG.E.64 R16, [R4.64] ; /* 0x0000000404107981 */ /* 0x000ee2000c1e1b00 */ /*0d20*/ ISETP.NE.AND P0, PT, R2, 0x1, PT ; /* 0x000000010200780c */ /* 0x000fe20003f05270 */ /*0d30*/ DFMA R28, R14, R16, R28 ; /* 0x000000100e1c722b */ /* 0x00ee4e000000001c */ /*0d40*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0023ea000c101b04 */ /*0d50*/ @!P0 BRA 0xdf0 ; /* 0x0000009000008947 */ /* 0x000fea0003800000 */ /*0d60*/ LDG.E.64 R14, [R6.64+0x8] ; /* 0x00000804060e7981 */ /* 0x000ea8000c1e1b00 */ /*0d70*/ LDG.E.64 R16, [R4.64+0x8] ; /* 0x0000080404107981 */ /* 0x000ea2000c1e1b00 */ /*0d80*/ ISETP.NE.AND P0, PT, R2, 0x2, PT ; /* 0x000000020200780c */ /* 0x000fe20003f05270 */ /*0d90*/ DFMA R28, R14, R16, R28 ; /* 0x000000100e1c722b */ /* 0x006e4e000000001c */ /*0da0*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0023ea000c101b04 */ /*0db0*/ @P0 LDG.E.64 R14, [R6.64+0x10] ; /* 0x00001004060e0981 */ /* 0x000ea8000c1e1b00 */ /*0dc0*/ @P0 LDG.E.64 R16, [R4.64+0x10] ; /* 0x0000100404100981 */ /* 0x000ea4000c1e1b00 */ /*0dd0*/ @P0 DFMA R14, R14, R16, R28 ; /* 0x000000100e0e022b */ /* 0x004e8e000000001c */ /*0de0*/ @P0 STG.E.64 [R12.64], R14 ; /* 0x0000000e0c000986 */ /* 0x0043e8000c101b04 */ /*0df0*/ LDG.E R4, [R8.64] ; /* 0x0000000408047981 */ /* 0x000ee8000c1e1900 */ /*0e00*/ LDG.E R5, [R10.64] ; /* 0x000000040a057981 */ /* 0x000ee2000c1e1900 */ /*0e10*/ IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100007810 */ /* 0x000fe20007ffe0ff */ /*0e20*/ IMAD.IADD R5, R4, 0x1, R5 ; /* 0x0000000104057824 */ /* 0x008fca00078e0205 */ /*0e30*/ ISETP.GE.AND P0, PT, R0, R5, PT ; /* 0x000000050000720c */ /* 0x000fda0003f06270 */ /*0e40*/ @!P0 BRA 0x210 ; /* 0xfffff3c000008947 */ /* 0x000fea000383ffff */ /*0e50*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0e60*/ BRA 0xe60; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0e70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e80*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e90*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ea0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0eb0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ec0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ed0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ee0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ef0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" extern "C" { } const double TOLERANCE = 1.0e-10; /* cgsolver with CUDA support solves the linear equation A*x = b where A is of size m x n */ __global__ void mvm_gpu(double *A_cuda, double *X_cuda, double *Y_cuda, int *m_locals_cuda, int *A_all_pos_cuda, int n, int nthreads){ int t = blockIdx.x * blockDim.x + threadIdx.x; if (t < nthreads){ for (int i=A_all_pos_cuda[t]; i<A_all_pos_cuda[t]+m_locals_cuda[t]; ++i) { Y_cuda[i] = 0.; for (int j=0; j<n; ++j) Y_cuda[i] += A_cuda[i * n + j] * X_cuda[j]; } } }
.file "tmpxft_0015f82b_00000000-6_mvm_gpu.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2029: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2029: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii .type _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii, @function _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii: .LFB2051: .cfi_startproc endbr64 subq $184, %rsp .cfi_def_cfa_offset 192 movq %rdi, 40(%rsp) movq %rsi, 32(%rsp) movq %rdx, 24(%rsp) movq %rcx, 16(%rsp) movq %r8, 8(%rsp) movl %r9d, 4(%rsp) movq %fs:40, %rax movq %rax, 168(%rsp) xorl %eax, %eax leaq 40(%rsp), %rax movq %rax, 112(%rsp) leaq 32(%rsp), %rax movq %rax, 120(%rsp) leaq 24(%rsp), %rax movq %rax, 128(%rsp) leaq 16(%rsp), %rax movq %rax, 136(%rsp) leaq 8(%rsp), %rax movq %rax, 144(%rsp) leaq 4(%rsp), %rax movq %rax, 152(%rsp) leaq 192(%rsp), %rax movq %rax, 160(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) leaq 56(%rsp), %rcx leaq 48(%rsp), %rdx leaq 76(%rsp), %rsi leaq 64(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 168(%rsp), %rax subq %fs:40, %rax jne .L8 addq $184, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 56(%rsp) .cfi_def_cfa_offset 200 pushq 56(%rsp) .cfi_def_cfa_offset 208 leaq 128(%rsp), %r9 movq 92(%rsp), %rcx movl 100(%rsp), %r8d movq 80(%rsp), %rsi movl 88(%rsp), %edx leaq _Z7mvm_gpuPdS_S_PiS0_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 192 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii, .-_Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii .globl _Z7mvm_gpuPdS_S_PiS0_ii .type _Z7mvm_gpuPdS_S_PiS0_ii, @function _Z7mvm_gpuPdS_S_PiS0_ii: .LFB2052: .cfi_startproc endbr64 subq $16, %rsp .cfi_def_cfa_offset 24 movl 24(%rsp), %eax pushq %rax .cfi_def_cfa_offset 32 call _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z7mvm_gpuPdS_S_PiS0_ii, .-_Z7mvm_gpuPdS_S_PiS0_ii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z7mvm_gpuPdS_S_PiS0_ii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2054: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z7mvm_gpuPdS_S_PiS0_ii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2054: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include "includes.h" extern "C" { } const double TOLERANCE = 1.0e-10; /* cgsolver with CUDA support solves the linear equation A*x = b where A is of size m x n */ __global__ void mvm_gpu(double *A_cuda, double *X_cuda, double *Y_cuda, int *m_locals_cuda, int *A_all_pos_cuda, int n, int nthreads){ int t = blockIdx.x * blockDim.x + threadIdx.x; if (t < nthreads){ for (int i=A_all_pos_cuda[t]; i<A_all_pos_cuda[t]+m_locals_cuda[t]; ++i) { Y_cuda[i] = 0.; for (int j=0; j<n; ++j) Y_cuda[i] += A_cuda[i * n + j] * X_cuda[j]; } } }
#include <hip/hip_runtime.h> #include "includes.h" extern "C" { } const double TOLERANCE = 1.0e-10; /* cgsolver with CUDA support solves the linear equation A*x = b where A is of size m x n */ __global__ void mvm_gpu(double *A_cuda, double *X_cuda, double *Y_cuda, int *m_locals_cuda, int *A_all_pos_cuda, int n, int nthreads){ int t = blockIdx.x * blockDim.x + threadIdx.x; if (t < nthreads){ for (int i=A_all_pos_cuda[t]; i<A_all_pos_cuda[t]+m_locals_cuda[t]; ++i) { Y_cuda[i] = 0.; for (int j=0; j<n; ++j) Y_cuda[i] += A_cuda[i * n + j] * X_cuda[j]; } } }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include "includes.h" extern "C" { } const double TOLERANCE = 1.0e-10; /* cgsolver with CUDA support solves the linear equation A*x = b where A is of size m x n */ __global__ void mvm_gpu(double *A_cuda, double *X_cuda, double *Y_cuda, int *m_locals_cuda, int *A_all_pos_cuda, int n, int nthreads){ int t = blockIdx.x * blockDim.x + threadIdx.x; if (t < nthreads){ for (int i=A_all_pos_cuda[t]; i<A_all_pos_cuda[t]+m_locals_cuda[t]; ++i) { Y_cuda[i] = 0.; for (int j=0; j<n; ++j) Y_cuda[i] += A_cuda[i * n + j] * X_cuda[j]; } } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z7mvm_gpuPdS_S_PiS0_ii .globl _Z7mvm_gpuPdS_S_PiS0_ii .p2align 8 .type _Z7mvm_gpuPdS_S_PiS0_ii,@function _Z7mvm_gpuPdS_S_PiS0_ii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x3c s_load_b32 s3, s[0:1], 0x2c s_waitcnt lgkmcnt(0) s_and_b32 s2, s2, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1] s_mov_b32 s2, exec_lo v_cmpx_gt_i32_e64 s3, v1 s_cbranch_execz .LBB0_7 s_load_b64 s[2:3], s[0:1], 0x18 v_ashrrev_i32_e32 v2, 31, v1 s_mov_b32 s8, 0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[0:1], 2, v[1:2] s_waitcnt lgkmcnt(0) v_add_co_u32 v2, vcc_lo, s2, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo global_load_b32 v2, v[2:3], off s_waitcnt vmcnt(0) v_cmp_lt_i32_e32 vcc_lo, 0, v2 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_7 s_clause 0x1 s_load_b64 s[2:3], s[0:1], 0x20 s_load_b32 s9, s[0:1], 0x28 v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v13, 0 s_waitcnt lgkmcnt(0) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_cmp_gt_i32 s9, 0 s_cselect_b32 s10, -1, 0 global_load_b32 v0, v[0:1], off s_clause 0x1 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 s_waitcnt vmcnt(0) v_add_nc_u32_e32 v12, v2, v0 v_mul_lo_u32 v2, v0, s9 s_set_inst_prefetch_distance 0x1 s_branch .LBB0_4 .p2align 6 .LBB0_3: v_add_nc_u32_e32 v0, 1, v0 v_add_nc_u32_e32 v2, s9, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_cmp_ge_i32_e32 vcc_lo, v0, v12 s_or_b32 s8, vcc_lo, s8 s_and_not1_b32 exec_lo, exec_lo, s8 s_cbranch_execz .LBB0_7 .LBB0_4: v_ashrrev_i32_e32 v1, 31, v0 v_mov_b32_e32 v5, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[6:7], 3, v[0:1] s_waitcnt lgkmcnt(0) v_add_co_u32 v6, vcc_lo, s0, v6 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v7, vcc_lo, s1, v7, vcc_lo s_and_not1_b32 vcc_lo, exec_lo, s10 global_store_b64 v[6:7], v[4:5], off s_cbranch_vccnz .LBB0_3 global_load_b64 v[8:9], v[6:7], off v_ashrrev_i32_e32 v3, 31, v2 s_mov_b64 s[2:3], s[6:7] s_mov_b32 s11, s9 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[10:11], 3, v[2:3] v_add_co_u32 v10, vcc_lo, s4, v10 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v11, vcc_lo, s5, v11, vcc_lo .p2align 6 .LBB0_6: global_load_b64 v[14:15], v[10:11], off global_load_b64 v[16:17], v13, s[2:3] v_add_co_u32 v10, vcc_lo, v10, 8 s_add_i32 s11, s11, -1 v_add_co_ci_u32_e32 v11, vcc_lo, 0, v11, vcc_lo s_add_u32 s2, s2, 8 s_addc_u32 s3, s3, 0 s_cmp_eq_u32 s11, 0 s_waitcnt vmcnt(0) v_fma_f64 v[8:9], v[14:15], v[16:17], v[8:9] global_store_b64 v[6:7], v[8:9], off s_cbranch_scc0 .LBB0_6 s_branch .LBB0_3 .LBB0_7: s_set_inst_prefetch_distance 0x2 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z7mvm_gpuPdS_S_PiS0_ii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 304 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 18 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z7mvm_gpuPdS_S_PiS0_ii, .Lfunc_end0-_Z7mvm_gpuPdS_S_PiS0_ii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 24 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 32 .size: 8 .value_kind: global_buffer - .offset: 40 .size: 4 .value_kind: by_value - .offset: 44 .size: 4 .value_kind: by_value - .offset: 48 .size: 4 .value_kind: hidden_block_count_x - .offset: 52 .size: 4 .value_kind: hidden_block_count_y - .offset: 56 .size: 4 .value_kind: hidden_block_count_z - .offset: 60 .size: 2 .value_kind: hidden_group_size_x - .offset: 62 .size: 2 .value_kind: hidden_group_size_y - .offset: 64 .size: 2 .value_kind: hidden_group_size_z - .offset: 66 .size: 2 .value_kind: hidden_remainder_x - .offset: 68 .size: 2 .value_kind: hidden_remainder_y - .offset: 70 .size: 2 .value_kind: hidden_remainder_z - .offset: 88 .size: 8 .value_kind: hidden_global_offset_x - .offset: 96 .size: 8 .value_kind: hidden_global_offset_y - .offset: 104 .size: 8 .value_kind: hidden_global_offset_z - .offset: 112 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 304 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z7mvm_gpuPdS_S_PiS0_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z7mvm_gpuPdS_S_PiS0_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 18 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include "includes.h" extern "C" { } const double TOLERANCE = 1.0e-10; /* cgsolver with CUDA support solves the linear equation A*x = b where A is of size m x n */ __global__ void mvm_gpu(double *A_cuda, double *X_cuda, double *Y_cuda, int *m_locals_cuda, int *A_all_pos_cuda, int n, int nthreads){ int t = blockIdx.x * blockDim.x + threadIdx.x; if (t < nthreads){ for (int i=A_all_pos_cuda[t]; i<A_all_pos_cuda[t]+m_locals_cuda[t]; ++i) { Y_cuda[i] = 0.; for (int j=0; j<n; ++j) Y_cuda[i] += A_cuda[i * n + j] * X_cuda[j]; } } }
.text .file "mvm_gpu.hip" .globl _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii # -- Begin function _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .p2align 4, 0x90 .type _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii,@function _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii: # @_Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .cfi_startproc # %bb.0: subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movq %rcx, 64(%rsp) movq %r8, 56(%rsp) movl %r9d, 4(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 64(%rsp), %rax movq %rax, 120(%rsp) leaq 56(%rsp), %rax movq %rax, 128(%rsp) leaq 4(%rsp), %rax movq %rax, 136(%rsp) leaq 160(%rsp), %rax movq %rax, 144(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z7mvm_gpuPdS_S_PiS0_ii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $168, %rsp .cfi_adjust_cfa_offset -168 retq .Lfunc_end0: .size _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii, .Lfunc_end0-_Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB1_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB1_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z7mvm_gpuPdS_S_PiS0_ii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end1: .size __hip_module_ctor, .Lfunc_end1-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB2_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB2_2: retq .Lfunc_end2: .size __hip_module_dtor, .Lfunc_end2-__hip_module_dtor .cfi_endproc # -- End function .type _Z7mvm_gpuPdS_S_PiS0_ii,@object # @_Z7mvm_gpuPdS_S_PiS0_ii .section .rodata,"a",@progbits .globl _Z7mvm_gpuPdS_S_PiS0_ii .p2align 3, 0x0 _Z7mvm_gpuPdS_S_PiS0_ii: .quad _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .size _Z7mvm_gpuPdS_S_PiS0_ii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z7mvm_gpuPdS_S_PiS0_ii" .size .L__unnamed_1, 24 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z7mvm_gpuPdS_S_PiS0_ii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z7mvm_gpuPdS_S_PiS0_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0203 */ /*0040*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x18c], PT ; /* 0x0000630000007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ IMAD.MOV.U32 R9, RZ, RZ, 0x4 ; /* 0x00000004ff097424 */ /* 0x000fe200078e00ff */ /*0070*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0080*/ IMAD.WIDE R8, R0, R9, c[0x0][0x178] ; /* 0x00005e0000087625 */ /* 0x000fca00078e0209 */ /*0090*/ LDG.E R2, [R8.64] ; /* 0x0000000408027981 */ /* 0x000ea4000c1e1900 */ /*00a0*/ ISETP.GE.AND P0, PT, R2, 0x1, PT ; /* 0x000000010200780c */ /* 0x004fda0003f06270 */ /*00b0*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*00c0*/ SHF.R.S32.HI R3, RZ, 0x1f, R0 ; /* 0x0000001fff037819 */ /* 0x000fe40000011400 */ /*00d0*/ LEA R10, P0, R0, c[0x0][0x180], 0x2 ; /* 0x00006000000a7a11 */ /* 0x000fc800078010ff */ /*00e0*/ LEA.HI.X R11, R0, c[0x0][0x184], R3, 0x2, P0 ; /* 0x00006100000b7a11 */ /* 0x000fca00000f1403 */ /*00f0*/ LDG.E R0, [R10.64] ; /* 0x000000040a007981 */ /* 0x000162000c1e1900 */ /*0100*/ ISETP.LT.AND P0, PT, RZ, c[0x0][0x188], PT ; /* 0x00006200ff007a0c */ /* 0x000fda0003f01270 */ /*0110*/ @P0 BRA 0x1c0 ; /* 0x000000a000000947 */ /* 0x001fea0003800000 */ /*0120*/ IMAD.MOV.U32 R3, RZ, RZ, 0x8 ; /* 0x00000008ff037424 */ /* 0x000fc800078e00ff */ /*0130*/ IMAD.WIDE R2, R0, R3, c[0x0][0x170] ; /* 0x00005c0000027625 */ /* 0x020fca00078e0203 */ /*0140*/ STG.E.64 [R2.64], RZ ; /* 0x000000ff02007986 */ /* 0x0001e8000c101b04 */ /*0150*/ LDG.E R4, [R8.64] ; /* 0x0000000408047981 */ /* 0x000ea8000c1e1900 */ /*0160*/ LDG.E R5, [R10.64] ; /* 0x000000040a057981 */ /* 0x000ea2000c1e1900 */ /*0170*/ IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100007810 */ /* 0x000fe20007ffe0ff */ /*0180*/ IMAD.IADD R5, R4, 0x1, R5 ; /* 0x0000000104057824 */ /* 0x004fca00078e0205 */ /*0190*/ ISETP.GE.AND P0, PT, R0, R5, PT ; /* 0x000000050000720c */ /* 0x000fda0003f06270 */ /*01a0*/ @!P0 BRA 0x120 ; /* 0xffffff7000008947 */ /* 0x001fea000383ffff */ /*01b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01c0*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x188] ; /* 0x00006200ff027624 */ /* 0x000fca00078e00ff */ /*01d0*/ IADD3 R3, R2.reuse, -0x1, RZ ; /* 0xffffffff02037810 */ /* 0x040fe40007ffe0ff */ /*01e0*/ LOP3.LUT R2, R2, 0x3, RZ, 0xc0, !PT ; /* 0x0000000302027812 */ /* 0x000fe400078ec0ff */ /*01f0*/ ISETP.GE.U32.AND P1, PT, R3, 0x3, PT ; /* 0x000000030300780c */ /* 0x000fe40003f26070 */ /*0200*/ IADD3 R3, -R2, c[0x0][0x188], RZ ; /* 0x0000620002037a10 */ /* 0x000fe40007ffe1ff */ /*0210*/ IMAD.MOV.U32 R5, RZ, RZ, 0x8 ; /* 0x00000008ff057424 */ /* 0x000fe200078e00ff */ /*0220*/ CS2R R28, SRZ ; /* 0x00000000001c7805 */ /* 0x006fe2000001ff00 */ /*0230*/ IMAD R4, R0.reuse, c[0x0][0x188], RZ ; /* 0x0000620000047a24 */ /* 0x060fe400078e02ff */ /*0240*/ IMAD.WIDE R12, R0, R5, c[0x0][0x170] ; /* 0x00005c00000c7625 */ /* 0x001fc800078e0205 */ /*0250*/ IMAD.MOV.U32 R7, RZ, RZ, RZ ; /* 0x000000ffff077224 */ /* 0x000fe200078e00ff */ /*0260*/ STG.E.64 [R12.64], RZ ; /* 0x000000ff0c007986 */ /* 0x0001e2000c101b04 */ /*0270*/ @!P1 BRA 0xcb0 ; /* 0x00000a3000009947 */ /* 0x000fea0003800000 */ /*0280*/ ISETP.GT.AND P0, PT, R3, RZ, PT ; /* 0x000000ff0300720c */ /* 0x000fe20003f04270 */ /*0290*/ IMAD.MOV.U32 R7, RZ, RZ, RZ ; /* 0x000000ffff077224 */ /* 0x000fe200078e00ff */ /*02a0*/ CS2R R28, SRZ ; /* 0x00000000001c7805 */ /* 0x000fe2000001ff00 */ /*02b0*/ IMAD.MOV.U32 R6, RZ, RZ, R3 ; /* 0x000000ffff067224 */ /* 0x000fe400078e0003 */ /*02c0*/ IMAD.WIDE R14, R4, R5, c[0x0][0x160] ; /* 0x00005800040e7625 */ /* 0x000fc800078e0205 */ /*02d0*/ IMAD.MOV.U32 R16, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff107624 */ /* 0x000fe400078e00ff */ /*02e0*/ IMAD.MOV.U32 R17, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff117624 */ /* 0x000fe400078e00ff */ /*02f0*/ @!P0 BRA 0xaf0 ; /* 0x000007f000008947 */ /* 0x000fea0003800000 */ /*0300*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fe40003f44270 */ /*0310*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0320*/ @!P2 BRA 0x800 ; /* 0x000004d00000a947 */ /* 0x000fea0003800000 */ /*0330*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0340*/ LDG.E.64 R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1b00 */ /*0350*/ LDG.E.64 R26, [R14.64] ; /* 0x000000040e1a7981 */ /* 0x002ea4000c1e1b00 */ /*0360*/ DFMA R26, R18, R26, R28 ; /* 0x0000001a121a722b */ /* 0x004e4e000000001c */ /*0370*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0380*/ LDG.E.64 R24, [R16.64+0x8] ; /* 0x0000080410187981 */ /* 0x000ea8000c1e1b00 */ /*0390*/ LDG.E.64 R18, [R14.64+0x8] ; /* 0x000008040e127981 */ /* 0x000ea4000c1e1b00 */ /*03a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*03b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0045e8000c101b04 */ /*03c0*/ LDG.E.64 R22, [R16.64+0x10] ; /* 0x0000100410167981 */ /* 0x000ee8000c1e1b00 */ /*03d0*/ LDG.E.64 R18, [R14.64+0x10] ; /* 0x000010040e127981 */ /* 0x000ee4000c1e1b00 */ /*03e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008ece0000000018 */ /*03f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*0400*/ LDG.E.64 R20, [R16.64+0x18] ; /* 0x0000180410147981 */ /* 0x000f28000c1e1b00 */ /*0410*/ LDG.E.64 R18, [R14.64+0x18] ; /* 0x000018040e127981 */ /* 0x000f24000c1e1b00 */ /*0420*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x010f0e0000000016 */ /*0430*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0109e8000c101b04 */ /*0440*/ LDG.E.64 R26, [R16.64+0x20] ; /* 0x00002004101a7981 */ /* 0x002f68000c1e1b00 */ /*0450*/ LDG.E.64 R18, [R14.64+0x20] ; /* 0x000020040e127981 */ /* 0x000f64000c1e1b00 */ /*0460*/ DFMA R26, R26, R18, R20 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000014 */ /*0470*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0480*/ LDG.E.64 R24, [R16.64+0x28] ; /* 0x0000280410187981 */ /* 0x004ea8000c1e1b00 */ /*0490*/ LDG.E.64 R18, [R14.64+0x28] ; /* 0x000028040e127981 */ /* 0x000ea4000c1e1b00 */ /*04a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*04b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0045e8000c101b04 */ /*04c0*/ LDG.E.64 R22, [R16.64+0x30] ; /* 0x0000300410167981 */ /* 0x008ee8000c1e1b00 */ /*04d0*/ LDG.E.64 R18, [R14.64+0x30] ; /* 0x000030040e127981 */ /* 0x000ee4000c1e1b00 */ /*04e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008ece0000000018 */ /*04f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*0500*/ LDG.E.64 R20, [R16.64+0x38] ; /* 0x0000380410147981 */ /* 0x010f28000c1e1b00 */ /*0510*/ LDG.E.64 R18, [R14.64+0x38] ; /* 0x000038040e127981 */ /* 0x000f24000c1e1b00 */ /*0520*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x010f0e0000000016 */ /*0530*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0109e8000c101b04 */ /*0540*/ LDG.E.64 R26, [R16.64+0x40] ; /* 0x00004004101a7981 */ /* 0x002f68000c1e1b00 */ /*0550*/ LDG.E.64 R18, [R14.64+0x40] ; /* 0x000040040e127981 */ /* 0x000f64000c1e1b00 */ /*0560*/ DFMA R26, R26, R18, R20 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000014 */ /*0570*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0580*/ LDG.E.64 R24, [R16.64+0x48] ; /* 0x0000480410187981 */ /* 0x004ea8000c1e1b00 */ /*0590*/ LDG.E.64 R18, [R14.64+0x48] ; /* 0x000048040e127981 */ /* 0x000ea4000c1e1b00 */ /*05a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*05b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0045e8000c101b04 */ /*05c0*/ LDG.E.64 R22, [R16.64+0x50] ; /* 0x0000500410167981 */ /* 0x008ee8000c1e1b00 */ /*05d0*/ LDG.E.64 R18, [R14.64+0x50] ; /* 0x000050040e127981 */ /* 0x000ee4000c1e1b00 */ /*05e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008ece0000000018 */ /*05f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*0600*/ LDG.E.64 R20, [R16.64+0x58] ; /* 0x0000580410147981 */ /* 0x010f28000c1e1b00 */ /*0610*/ LDG.E.64 R18, [R14.64+0x58] ; /* 0x000058040e127981 */ /* 0x000f24000c1e1b00 */ /*0620*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x010f0e0000000016 */ /*0630*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0109e8000c101b04 */ /*0640*/ LDG.E.64 R26, [R16.64+0x60] ; /* 0x00006004101a7981 */ /* 0x002f68000c1e1b00 */ /*0650*/ LDG.E.64 R18, [R14.64+0x60] ; /* 0x000060040e127981 */ /* 0x000f64000c1e1b00 */ /*0660*/ DFMA R26, R26, R18, R20 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000014 */ /*0670*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0680*/ LDG.E.64 R24, [R16.64+0x68] ; /* 0x0000680410187981 */ /* 0x004ea8000c1e1b00 */ /*0690*/ LDG.E.64 R18, [R14.64+0x68] ; /* 0x000068040e127981 */ /* 0x000ea4000c1e1b00 */ /*06a0*/ DFMA R24, R24, R18, R26 ; /* 0x000000121818722b */ /* 0x004e8e000000001a */ /*06b0*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0043e8000c101b04 */ /*06c0*/ LDG.E.64 R22, [R16.64+0x70] ; /* 0x0000700410167981 */ /* 0x008ea8000c1e1b00 */ /*06d0*/ LDG.E.64 R18, [R14.64+0x70] ; /* 0x000070040e127981 */ /* 0x000ea4000c1e1b00 */ /*06e0*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x004e8e0000000018 */ /*06f0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0043e8000c101b04 */ /*0700*/ LDG.E.64 R18, [R16.64+0x78] ; /* 0x0000780410127981 */ /* 0x000ea8000c1e1b00 */ /*0710*/ LDG.E.64 R20, [R14.64+0x78] ; /* 0x000078040e147981 */ /* 0x010ea2000c1e1b00 */ /*0720*/ IADD3 R6, R6, -0x10, RZ ; /* 0xfffffff006067810 */ /* 0x000fe40007ffe0ff */ /*0730*/ IADD3 R7, R7, 0x10, RZ ; /* 0x0000001007077810 */ /* 0x000fc40007ffe0ff */ /*0740*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fe20003f44270 */ /*0750*/ DFMA R28, R18, R20, R22 ; /* 0x00000014121c722b */ /* 0x0044e40000000016 */ /*0760*/ IADD3 R18, P4, R16, 0x80, RZ ; /* 0x0000008010127810 */ /* 0x004fe40007f9e0ff */ /*0770*/ IADD3 R20, P3, R14, 0x80, RZ ; /* 0x000000800e147810 */ /* 0x000fc60007f7e0ff */ /*0780*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0083e2000c101b04 */ /*0790*/ IMAD.X R19, RZ, RZ, R17, P4 ; /* 0x000000ffff137224 */ /* 0x000fe200020e0611 */ /*07a0*/ MOV R14, R20 ; /* 0x00000014000e7202 */ /* 0x000fe20000000f00 */ /*07b0*/ IMAD.X R21, RZ, RZ, R15, P3 ; /* 0x000000ffff157224 */ /* 0x000fe400018e060f */ /*07c0*/ IMAD.MOV.U32 R16, RZ, RZ, R18 ; /* 0x000000ffff107224 */ /* 0x000fe400078e0012 */ /*07d0*/ IMAD.MOV.U32 R17, RZ, RZ, R19 ; /* 0x000000ffff117224 */ /* 0x000fe400078e0013 */ /*07e0*/ IMAD.MOV.U32 R15, RZ, RZ, R21 ; /* 0x000000ffff0f7224 */ /* 0x000fe200078e0015 */ /*07f0*/ @P2 BRA 0x340 ; /* 0xfffffb4000002947 */ /* 0x000fea000383ffff */ /*0800*/ ISETP.GT.AND P2, PT, R6, 0x4, PT ; /* 0x000000040600780c */ /* 0x000fda0003f44270 */ /*0810*/ @!P2 BRA 0xad0 ; /* 0x000002b00000a947 */ /* 0x000fea0003800000 */ /*0820*/ LDG.E.64 R26, [R16.64] ; /* 0x00000004101a7981 */ /* 0x002ea8000c1e1b00 */ /*0830*/ LDG.E.64 R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000ea4000c1e1b00 */ /*0840*/ DFMA R26, R26, R18, R28 ; /* 0x000000121a1a722b */ /* 0x004e4e000000001c */ /*0850*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x0023e8000c101b04 */ /*0860*/ LDG.E.64 R20, [R16.64+0x8] ; /* 0x0000080410147981 */ /* 0x000ea8000c1e1b00 */ /*0870*/ LDG.E.64 R18, [R14.64+0x8] ; /* 0x000008040e127981 */ /* 0x000ea4000c1e1b00 */ /*0880*/ DFMA R20, R20, R18, R26 ; /* 0x000000121414722b */ /* 0x004e8e000000001a */ /*0890*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0045e8000c101b04 */ /*08a0*/ LDG.E.64 R22, [R16.64+0x10] ; /* 0x0000100410167981 */ /* 0x000ee8000c1e1b00 */ /*08b0*/ LDG.E.64 R18, [R14.64+0x10] ; /* 0x000010040e127981 */ /* 0x000ee4000c1e1b00 */ /*08c0*/ DFMA R22, R22, R18, R20 ; /* 0x000000121616722b */ /* 0x008ece0000000014 */ /*08d0*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0087e8000c101b04 */ /*08e0*/ LDG.E.64 R24, [R16.64+0x18] ; /* 0x0000180410187981 */ /* 0x000f28000c1e1b00 */ /*08f0*/ LDG.E.64 R18, [R14.64+0x18] ; /* 0x000018040e127981 */ /* 0x000f24000c1e1b00 */ /*0900*/ DFMA R24, R24, R18, R22 ; /* 0x000000121818722b */ /* 0x010f0e0000000016 */ /*0910*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x0109e8000c101b04 */ /*0920*/ LDG.E.64 R26, [R16.64+0x20] ; /* 0x00002004101a7981 */ /* 0x002f68000c1e1b00 */ /*0930*/ LDG.E.64 R18, [R14.64+0x20] ; /* 0x000020040e127981 */ /* 0x000f64000c1e1b00 */ /*0940*/ DFMA R26, R26, R18, R24 ; /* 0x000000121a1a722b */ /* 0x020e4e0000000018 */ /*0950*/ STG.E.64 [R12.64], R26 ; /* 0x0000001a0c007986 */ /* 0x002fe8000c101b04 */ /*0960*/ LDG.E.64 R18, [R16.64+0x28] ; /* 0x0000280410127981 */ /* 0x000f68000c1e1b00 */ /*0970*/ LDG.E.64 R20, [R14.64+0x28] ; /* 0x000028040e147981 */ /* 0x004f64000c1e1b00 */ /*0980*/ DFMA R18, R18, R20, R26 ; /* 0x000000141212722b */ /* 0x020e4e000000001a */ /*0990*/ STG.E.64 [R12.64], R18 ; /* 0x000000120c007986 */ /* 0x0023e8000c101b04 */ /*09a0*/ LDG.E.64 R20, [R16.64+0x30] ; /* 0x0000300410147981 */ /* 0x000ea8000c1e1b00 */ /*09b0*/ LDG.E.64 R22, [R14.64+0x30] ; /* 0x000030040e167981 */ /* 0x008ea4000c1e1b00 */ /*09c0*/ DFMA R20, R20, R22, R18 ; /* 0x000000161414722b */ /* 0x004e8e0000000012 */ /*09d0*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0045e8000c101b04 */ /*09e0*/ LDG.E.64 R22, [R16.64+0x38] ; /* 0x0000380410167981 */ /* 0x000768000c1e1b00 */ /*09f0*/ LDG.E.64 R24, [R14.64+0x38] ; /* 0x000038040e187981 */ /* 0x010f62000c1e1b00 */ /*0a00*/ IADD3 R18, P3, R16, 0x40, RZ ; /* 0x0000004010127810 */ /* 0x002fe40007f7e0ff */ /*0a10*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fc40003f0e170 */ /*0a20*/ IADD3 R7, R7, 0x8, RZ ; /* 0x0000000807077810 */ /* 0x000fe20007ffe0ff */ /*0a30*/ IMAD.X R19, RZ, RZ, R17, P3 ; /* 0x000000ffff137224 */ /* 0x000fe200018e0611 */ /*0a40*/ IADD3 R6, R6, -0x8, RZ ; /* 0xfffffff806067810 */ /* 0x000fe20007ffe0ff */ /*0a50*/ IMAD.MOV.U32 R16, RZ, RZ, R18 ; /* 0x000000ffff107224 */ /* 0x008fe400078e0012 */ /*0a60*/ IMAD.MOV.U32 R17, RZ, RZ, R19 ; /* 0x000000ffff117224 */ /* 0x000fe200078e0013 */ /*0a70*/ DFMA R28, R22, R24, R20 ; /* 0x00000018161c722b */ /* 0x0202e40000000014 */ /*0a80*/ IADD3 R22, P2, R14, 0x40, RZ ; /* 0x000000400e167810 */ /* 0x002fca0007f5e0ff */ /*0a90*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0085e2000c101b04 */ /*0aa0*/ IMAD.X R23, RZ, RZ, R15, P2 ; /* 0x000000ffff177224 */ /* 0x000fe400010e060f */ /*0ab0*/ IMAD.MOV.U32 R14, RZ, RZ, R22 ; /* 0x000000ffff0e7224 */ /* 0x000fe400078e0016 */ /*0ac0*/ IMAD.MOV.U32 R15, RZ, RZ, R23 ; /* 0x000000ffff0f7224 */ /* 0x000fe400078e0017 */ /*0ad0*/ ISETP.NE.OR P0, PT, R6, RZ, P0 ; /* 0x000000ff0600720c */ /* 0x000fda0000705670 */ /*0ae0*/ @!P0 BRA 0xcb0 ; /* 0x000001c000008947 */ /* 0x000fea0003800000 */ /*0af0*/ LDG.E.64 R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ee8000c1e1b00 */ /*0b00*/ LDG.E.64 R24, [R14.64] ; /* 0x000000040e187981 */ /* 0x002ee4000c1e1b00 */ /*0b10*/ DFMA R24, R18, R24, R28 ; /* 0x000000181218722b */ /* 0x008e4e000000001c */ /*0b20*/ STG.E.64 [R12.64], R24 ; /* 0x000000180c007986 */ /* 0x002fe8000c101b04 */ /*0b30*/ LDG.E.64 R22, [R16.64+0x8] ; /* 0x0000080410167981 */ /* 0x000ee8000c1e1b00 */ /*0b40*/ LDG.E.64 R18, [R14.64+0x8] ; /* 0x000008040e127981 */ /* 0x000ee4000c1e1b00 */ /*0b50*/ DFMA R22, R22, R18, R24 ; /* 0x000000121616722b */ /* 0x008e4e0000000018 */ /*0b60*/ STG.E.64 [R12.64], R22 ; /* 0x000000160c007986 */ /* 0x0023e8000c101b04 */ /*0b70*/ LDG.E.64 R20, [R16.64+0x10] ; /* 0x0000100410147981 */ /* 0x004ea8000c1e1b00 */ /*0b80*/ LDG.E.64 R18, [R14.64+0x10] ; /* 0x000010040e127981 */ /* 0x000ea4000c1e1b00 */ /*0b90*/ DFMA R20, R20, R18, R22 ; /* 0x000000121414722b */ /* 0x004e8e0000000016 */ /*0ba0*/ STG.E.64 [R12.64], R20 ; /* 0x000000140c007986 */ /* 0x0045e8000c101b04 */ /*0bb0*/ LDG.E.64 R28, [R16.64+0x18] ; /* 0x00001804101c7981 */ /* 0x000ee8000c1e1b00 */ /*0bc0*/ LDG.E.64 R18, [R14.64+0x18] ; /* 0x000018040e127981 */ /* 0x0008e2000c1e1b00 */ /*0bd0*/ IADD3 R6, R6, -0x4, RZ ; /* 0xfffffffc06067810 */ /* 0x000fe40007ffe0ff */ /*0be0*/ IADD3 R22, P2, R14, 0x20, RZ ; /* 0x000000200e167810 */ /* 0x002fc40007f5e0ff */ /*0bf0*/ ISETP.NE.AND P0, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fe40003f05270 */ /*0c00*/ IADD3.X R23, RZ, R15, RZ, P2, !PT ; /* 0x0000000fff177210 */ /* 0x000fe400017fe4ff */ /*0c10*/ IADD3 R7, R7, 0x4, RZ ; /* 0x0000000407077810 */ /* 0x000fe20007ffe0ff */ /*0c20*/ IMAD.MOV.U32 R14, RZ, RZ, R22 ; /* 0x000000ffff0e7224 */ /* 0x010fe400078e0016 */ /*0c30*/ IMAD.MOV.U32 R15, RZ, RZ, R23 ; /* 0x000000ffff0f7224 */ /* 0x000fe200078e0017 */ /*0c40*/ DFMA R28, R28, R18, R20 ; /* 0x000000121c1c722b */ /* 0x0082e40000000014 */ /*0c50*/ IADD3 R18, P3, R16, 0x20, RZ ; /* 0x0000002010127810 */ /* 0x002fca0007f7e0ff */ /*0c60*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0085e2000c101b04 */ /*0c70*/ IMAD.X R19, RZ, RZ, R17, P3 ; /* 0x000000ffff137224 */ /* 0x000fe400018e0611 */ /*0c80*/ IMAD.MOV.U32 R16, RZ, RZ, R18 ; /* 0x000000ffff107224 */ /* 0x000fe400078e0012 */ /*0c90*/ IMAD.MOV.U32 R17, RZ, RZ, R19 ; /* 0x000000ffff117224 */ /* 0x000fe200078e0013 */ /*0ca0*/ @P0 BRA 0xaf0 ; /* 0xfffffe4000000947 */ /* 0x005fea000383ffff */ /*0cb0*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fda0003f05270 */ /*0cc0*/ @!P0 BRA 0xdf0 ; /* 0x0000012000008947 */ /* 0x000fea0003800000 */ /*0cd0*/ IMAD.IADD R4, R4, 0x1, R7 ; /* 0x0000000104047824 */ /* 0x000fe400078e0207 */ /*0ce0*/ IMAD.WIDE R6, R7, R5, c[0x0][0x168] ; /* 0x00005a0007067625 */ /* 0x000fc800078e0205 */ /*0cf0*/ IMAD.WIDE R4, R4, R5, c[0x0][0x160] ; /* 0x0000580004047625 */ /* 0x000fe200078e0205 */ /*0d00*/ LDG.E.64 R14, [R6.64] ; /* 0x00000004060e7981 */ /* 0x000ee8000c1e1b00 */ /*0d10*/ LDG.E.64 R16, [R4.64] ; /* 0x0000000404107981 */ /* 0x000ee2000c1e1b00 */ /*0d20*/ ISETP.NE.AND P0, PT, R2, 0x1, PT ; /* 0x000000010200780c */ /* 0x000fe20003f05270 */ /*0d30*/ DFMA R28, R14, R16, R28 ; /* 0x000000100e1c722b */ /* 0x00ee4e000000001c */ /*0d40*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0023ea000c101b04 */ /*0d50*/ @!P0 BRA 0xdf0 ; /* 0x0000009000008947 */ /* 0x000fea0003800000 */ /*0d60*/ LDG.E.64 R14, [R6.64+0x8] ; /* 0x00000804060e7981 */ /* 0x000ea8000c1e1b00 */ /*0d70*/ LDG.E.64 R16, [R4.64+0x8] ; /* 0x0000080404107981 */ /* 0x000ea2000c1e1b00 */ /*0d80*/ ISETP.NE.AND P0, PT, R2, 0x2, PT ; /* 0x000000020200780c */ /* 0x000fe20003f05270 */ /*0d90*/ DFMA R28, R14, R16, R28 ; /* 0x000000100e1c722b */ /* 0x006e4e000000001c */ /*0da0*/ STG.E.64 [R12.64], R28 ; /* 0x0000001c0c007986 */ /* 0x0023ea000c101b04 */ /*0db0*/ @P0 LDG.E.64 R14, [R6.64+0x10] ; /* 0x00001004060e0981 */ /* 0x000ea8000c1e1b00 */ /*0dc0*/ @P0 LDG.E.64 R16, [R4.64+0x10] ; /* 0x0000100404100981 */ /* 0x000ea4000c1e1b00 */ /*0dd0*/ @P0 DFMA R14, R14, R16, R28 ; /* 0x000000100e0e022b */ /* 0x004e8e000000001c */ /*0de0*/ @P0 STG.E.64 [R12.64], R14 ; /* 0x0000000e0c000986 */ /* 0x0043e8000c101b04 */ /*0df0*/ LDG.E R4, [R8.64] ; /* 0x0000000408047981 */ /* 0x000ee8000c1e1900 */ /*0e00*/ LDG.E R5, [R10.64] ; /* 0x000000040a057981 */ /* 0x000ee2000c1e1900 */ /*0e10*/ IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100007810 */ /* 0x000fe20007ffe0ff */ /*0e20*/ IMAD.IADD R5, R4, 0x1, R5 ; /* 0x0000000104057824 */ /* 0x008fca00078e0205 */ /*0e30*/ ISETP.GE.AND P0, PT, R0, R5, PT ; /* 0x000000050000720c */ /* 0x000fda0003f06270 */ /*0e40*/ @!P0 BRA 0x210 ; /* 0xfffff3c000008947 */ /* 0x000fea000383ffff */ /*0e50*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0e60*/ BRA 0xe60; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0e70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e80*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e90*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ea0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0eb0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ec0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ed0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ee0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ef0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z7mvm_gpuPdS_S_PiS0_ii .globl _Z7mvm_gpuPdS_S_PiS0_ii .p2align 8 .type _Z7mvm_gpuPdS_S_PiS0_ii,@function _Z7mvm_gpuPdS_S_PiS0_ii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x3c s_load_b32 s3, s[0:1], 0x2c s_waitcnt lgkmcnt(0) s_and_b32 s2, s2, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1] s_mov_b32 s2, exec_lo v_cmpx_gt_i32_e64 s3, v1 s_cbranch_execz .LBB0_7 s_load_b64 s[2:3], s[0:1], 0x18 v_ashrrev_i32_e32 v2, 31, v1 s_mov_b32 s8, 0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[0:1], 2, v[1:2] s_waitcnt lgkmcnt(0) v_add_co_u32 v2, vcc_lo, s2, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo global_load_b32 v2, v[2:3], off s_waitcnt vmcnt(0) v_cmp_lt_i32_e32 vcc_lo, 0, v2 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_7 s_clause 0x1 s_load_b64 s[2:3], s[0:1], 0x20 s_load_b32 s9, s[0:1], 0x28 v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v13, 0 s_waitcnt lgkmcnt(0) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_cmp_gt_i32 s9, 0 s_cselect_b32 s10, -1, 0 global_load_b32 v0, v[0:1], off s_clause 0x1 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 s_waitcnt vmcnt(0) v_add_nc_u32_e32 v12, v2, v0 v_mul_lo_u32 v2, v0, s9 s_set_inst_prefetch_distance 0x1 s_branch .LBB0_4 .p2align 6 .LBB0_3: v_add_nc_u32_e32 v0, 1, v0 v_add_nc_u32_e32 v2, s9, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_cmp_ge_i32_e32 vcc_lo, v0, v12 s_or_b32 s8, vcc_lo, s8 s_and_not1_b32 exec_lo, exec_lo, s8 s_cbranch_execz .LBB0_7 .LBB0_4: v_ashrrev_i32_e32 v1, 31, v0 v_mov_b32_e32 v5, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[6:7], 3, v[0:1] s_waitcnt lgkmcnt(0) v_add_co_u32 v6, vcc_lo, s0, v6 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v7, vcc_lo, s1, v7, vcc_lo s_and_not1_b32 vcc_lo, exec_lo, s10 global_store_b64 v[6:7], v[4:5], off s_cbranch_vccnz .LBB0_3 global_load_b64 v[8:9], v[6:7], off v_ashrrev_i32_e32 v3, 31, v2 s_mov_b64 s[2:3], s[6:7] s_mov_b32 s11, s9 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[10:11], 3, v[2:3] v_add_co_u32 v10, vcc_lo, s4, v10 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v11, vcc_lo, s5, v11, vcc_lo .p2align 6 .LBB0_6: global_load_b64 v[14:15], v[10:11], off global_load_b64 v[16:17], v13, s[2:3] v_add_co_u32 v10, vcc_lo, v10, 8 s_add_i32 s11, s11, -1 v_add_co_ci_u32_e32 v11, vcc_lo, 0, v11, vcc_lo s_add_u32 s2, s2, 8 s_addc_u32 s3, s3, 0 s_cmp_eq_u32 s11, 0 s_waitcnt vmcnt(0) v_fma_f64 v[8:9], v[14:15], v[16:17], v[8:9] global_store_b64 v[6:7], v[8:9], off s_cbranch_scc0 .LBB0_6 s_branch .LBB0_3 .LBB0_7: s_set_inst_prefetch_distance 0x2 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z7mvm_gpuPdS_S_PiS0_ii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 304 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 18 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z7mvm_gpuPdS_S_PiS0_ii, .Lfunc_end0-_Z7mvm_gpuPdS_S_PiS0_ii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 24 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 32 .size: 8 .value_kind: global_buffer - .offset: 40 .size: 4 .value_kind: by_value - .offset: 44 .size: 4 .value_kind: by_value - .offset: 48 .size: 4 .value_kind: hidden_block_count_x - .offset: 52 .size: 4 .value_kind: hidden_block_count_y - .offset: 56 .size: 4 .value_kind: hidden_block_count_z - .offset: 60 .size: 2 .value_kind: hidden_group_size_x - .offset: 62 .size: 2 .value_kind: hidden_group_size_y - .offset: 64 .size: 2 .value_kind: hidden_group_size_z - .offset: 66 .size: 2 .value_kind: hidden_remainder_x - .offset: 68 .size: 2 .value_kind: hidden_remainder_y - .offset: 70 .size: 2 .value_kind: hidden_remainder_z - .offset: 88 .size: 8 .value_kind: hidden_global_offset_x - .offset: 96 .size: 8 .value_kind: hidden_global_offset_y - .offset: 104 .size: 8 .value_kind: hidden_global_offset_z - .offset: 112 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 304 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z7mvm_gpuPdS_S_PiS0_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z7mvm_gpuPdS_S_PiS0_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 18 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_0015f82b_00000000-6_mvm_gpu.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2029: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2029: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii .type _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii, @function _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii: .LFB2051: .cfi_startproc endbr64 subq $184, %rsp .cfi_def_cfa_offset 192 movq %rdi, 40(%rsp) movq %rsi, 32(%rsp) movq %rdx, 24(%rsp) movq %rcx, 16(%rsp) movq %r8, 8(%rsp) movl %r9d, 4(%rsp) movq %fs:40, %rax movq %rax, 168(%rsp) xorl %eax, %eax leaq 40(%rsp), %rax movq %rax, 112(%rsp) leaq 32(%rsp), %rax movq %rax, 120(%rsp) leaq 24(%rsp), %rax movq %rax, 128(%rsp) leaq 16(%rsp), %rax movq %rax, 136(%rsp) leaq 8(%rsp), %rax movq %rax, 144(%rsp) leaq 4(%rsp), %rax movq %rax, 152(%rsp) leaq 192(%rsp), %rax movq %rax, 160(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) leaq 56(%rsp), %rcx leaq 48(%rsp), %rdx leaq 76(%rsp), %rsi leaq 64(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 168(%rsp), %rax subq %fs:40, %rax jne .L8 addq $184, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 56(%rsp) .cfi_def_cfa_offset 200 pushq 56(%rsp) .cfi_def_cfa_offset 208 leaq 128(%rsp), %r9 movq 92(%rsp), %rcx movl 100(%rsp), %r8d movq 80(%rsp), %rsi movl 88(%rsp), %edx leaq _Z7mvm_gpuPdS_S_PiS0_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 192 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii, .-_Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii .globl _Z7mvm_gpuPdS_S_PiS0_ii .type _Z7mvm_gpuPdS_S_PiS0_ii, @function _Z7mvm_gpuPdS_S_PiS0_ii: .LFB2052: .cfi_startproc endbr64 subq $16, %rsp .cfi_def_cfa_offset 24 movl 24(%rsp), %eax pushq %rax .cfi_def_cfa_offset 32 call _Z37__device_stub__Z7mvm_gpuPdS_S_PiS0_iiPdS_S_PiS0_ii addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z7mvm_gpuPdS_S_PiS0_ii, .-_Z7mvm_gpuPdS_S_PiS0_ii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z7mvm_gpuPdS_S_PiS0_ii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2054: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z7mvm_gpuPdS_S_PiS0_ii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2054: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "mvm_gpu.hip" .globl _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii # -- Begin function _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .p2align 4, 0x90 .type _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii,@function _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii: # @_Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .cfi_startproc # %bb.0: subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movq %rcx, 64(%rsp) movq %r8, 56(%rsp) movl %r9d, 4(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 64(%rsp), %rax movq %rax, 120(%rsp) leaq 56(%rsp), %rax movq %rax, 128(%rsp) leaq 4(%rsp), %rax movq %rax, 136(%rsp) leaq 160(%rsp), %rax movq %rax, 144(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z7mvm_gpuPdS_S_PiS0_ii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $168, %rsp .cfi_adjust_cfa_offset -168 retq .Lfunc_end0: .size _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii, .Lfunc_end0-_Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB1_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB1_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z7mvm_gpuPdS_S_PiS0_ii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end1: .size __hip_module_ctor, .Lfunc_end1-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB2_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB2_2: retq .Lfunc_end2: .size __hip_module_dtor, .Lfunc_end2-__hip_module_dtor .cfi_endproc # -- End function .type _Z7mvm_gpuPdS_S_PiS0_ii,@object # @_Z7mvm_gpuPdS_S_PiS0_ii .section .rodata,"a",@progbits .globl _Z7mvm_gpuPdS_S_PiS0_ii .p2align 3, 0x0 _Z7mvm_gpuPdS_S_PiS0_ii: .quad _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .size _Z7mvm_gpuPdS_S_PiS0_ii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z7mvm_gpuPdS_S_PiS0_ii" .size .L__unnamed_1, 24 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z22__device_stub__mvm_gpuPdS_S_PiS0_ii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z7mvm_gpuPdS_S_PiS0_ii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include <iostream> #include <cuda.h> using namespace std; __global__ void AddIntsCuda(int *a, int *b){ for(int i = 0; i<10000005; i++) a[0] +=b[0]*b[0]; } int main(){ int h_a=2, h_b=3; int *d_a, *d_b; //Device pointer // Allocate memory to device if(cudaMalloc((void**)&d_a, sizeof(int))!=cudaSuccess){ cout << "Error allocating memory!"<<endl; return 0; } if(cudaMalloc(&d_b, sizeof(int)) !=cudaSuccess){ cout << "Error allocating memory!"<<endl; cudaFree(d_a); return 0; } // Copy to device memory if(cudaMemcpy(d_a,&h_a, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess){ cout << "Error copying memory!"<<endl; cudaFree(d_a); cudaFree(d_b); return 0; } if(cudaMemcpy(d_b,&h_b, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess){ cout << "Error copying memory!"<<endl; cudaFree(d_a); cudaFree(d_b); return 0; } // Call the kernel AddIntsCuda<<<1,1>>>(d_a,d_b); // Copy answer from GPU to HOST if(cudaMemcpy(&h_a, d_a, sizeof(int), cudaMemcpyDeviceToHost) != cudaSuccess){ cout << "Error copying to memory!" << endl; cudaFree(d_a); cudaFree(d_b); return 0; } // Print from host cout<<"Answer "<<h_a<<endl; // Free memory cudaFree(d_a); cudaFree(d_b); cudaDeviceReset(); return 0; }
code for sm_80 Function : _Z11AddIntsCudaPiS_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ MOV R2, c[0x0][0x160] ; /* 0x0000580000027a02 */ /* 0x000fe20000000f00 */ /*0020*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0030*/ MOV R3, c[0x0][0x164] ; /* 0x0000590000037a02 */ /* 0x000fe40000000f00 */ /*0040*/ MOV R4, c[0x0][0x168] ; /* 0x00005a0000047a02 */ /* 0x000fe40000000f00 */ /*0050*/ MOV R5, c[0x0][0x16c] ; /* 0x00005b0000057a02 */ /* 0x000fe20000000f00 */ /*0060*/ LDG.E R0, [R2.64] ; /* 0x0000000402007981 */ /* 0x000ea8000c1e1900 */ /*0070*/ LDG.E R7, [R4.64] ; /* 0x0000000404077981 */ /* 0x000ea4000c1e1900 */ /*0080*/ IMAD R7, R7, R7, R0 ; /* 0x0000000707077224 */ /* 0x004fca00078e0200 */ /*0090*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*00a0*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea4000c1e1900 */ /*00b0*/ IMAD R9, R0, R0, R7 ; /* 0x0000000000097224 */ /* 0x004fca00078e0207 */ /*00c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*00d0*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea4000c1e1900 */ /*00e0*/ IMAD R11, R0, R0, R9 ; /* 0x00000000000b7224 */ /* 0x004fca00078e0209 */ /*00f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0003e8000c101904 */ /*0100*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea4000c1e1900 */ /*0110*/ IMAD R13, R0, R0, R11 ; /* 0x00000000000d7224 */ /* 0x004fca00078e020b */ /*0120*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0003e8000c101904 */ /*0130*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000e24000c1e1900 */ /*0140*/ IMAD R7, R0, R0, R13 ; /* 0x0000000000077224 */ /* 0x001fe200078e020d */ /*0150*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fc800000001ff */ /*0160*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0003e8000c101904 */ /*0170*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0180*/ IMAD R7, R6, R6, R7 ; /* 0x0000000606077224 */ /* 0x016fca00078e0207 */ /*0190*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*01a0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*01b0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x004fca00078e0207 */ /*01c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*01d0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*01e0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*01f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0200*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0210*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0220*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0230*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0240*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0250*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0260*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0270*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0280*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0290*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*02a0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*02b0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*02c0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*02d0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*02e0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*02f0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0300*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0310*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0320*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0330*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0340*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0350*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0360*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0370*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0380*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0390*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*03a0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*03b0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*03c0*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*03d0*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*03e0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*03f0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0400*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0410*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0420*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0430*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0440*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0450*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0460*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0470*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0480*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0490*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*04a0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*04b0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*04c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*04d0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*04e0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*04f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0500*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0510*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0520*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0530*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0540*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0550*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0560*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0570*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0580*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0590*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*05a0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*05b0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*05c0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*05d0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*05e0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*05f0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0600*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0610*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0620*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0630*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0640*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0650*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0660*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0670*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0680*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0690*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*06a0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*06b0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*06c0*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*06d0*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*06e0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*06f0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0700*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0710*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0720*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0730*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0740*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0750*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0760*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0770*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0780*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0790*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*07a0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*07b0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*07c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*07d0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*07e0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*07f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0800*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0810*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0820*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0830*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0840*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0850*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0860*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0870*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0880*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0890*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*08a0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*08b0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*08c0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*08d0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*08e0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*08f0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0900*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0910*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0920*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0930*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0940*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0950*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0960*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0970*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0980*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0990*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*09a0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*09b0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*09c0*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*09d0*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*09e0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*09f0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0a00*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0a10*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0a20*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0a30*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0a40*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0a50*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0a60*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0a70*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0a80*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0a90*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0aa0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0ab0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0ac0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0ad0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0ae0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0af0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0b00*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0b10*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0b20*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0b30*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0b40*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0b50*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0b60*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0b70*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0b80*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0b90*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0ba0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0bb0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0bc0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0bd0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0be0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0bf0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0c00*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0c10*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0c20*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000f24000c1e1900 */ /*0c30*/ IMAD R15, R6, R6, R7 ; /* 0x00000006060f7224 */ /* 0x010fca00078e0207 */ /*0c40*/ STG.E [R2.64], R15 ; /* 0x0000000f02007986 */ /* 0x0009e8000c101904 */ /*0c50*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000f64000c1e1900 */ /*0c60*/ IMAD R17, R6, R6, R15 ; /* 0x0000000606117224 */ /* 0x020fca00078e020f */ /*0c70*/ STG.E [R2.64], R17 ; /* 0x0000001102007986 */ /* 0x0009e8000c101904 */ /*0c80*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000f64000c1e1900 */ /*0c90*/ IMAD R19, R6, R6, R17 ; /* 0x0000000606137224 */ /* 0x020fca00078e0211 */ /*0ca0*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0009e8000c101904 */ /*0cb0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0cc0*/ IMAD R9, R6, R6, R19 ; /* 0x0000000606097224 */ /* 0x002fca00078e0213 */ /*0cd0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0009e8000c101904 */ /*0ce0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0cf0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0d00*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0009e8000c101904 */ /*0d10*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee2000c1e1900 */ /*0d20*/ IADD3 R0, R0, 0x40, RZ ; /* 0x0000004000007810 */ /* 0x000fe20007ffe0ff */ /*0d30*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0d40*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0009e8000c101904 */ /*0d50*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e22000c1e1900 */ /*0d60*/ ISETP.NE.AND P0, PT, R0, 0x989684, PT ; /* 0x009896840000780c */ /* 0x000fe20003f05270 */ /*0d70*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0d80*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0009ee000c101904 */ /*0d90*/ @P0 BRA 0x170 ; /* 0xfffff3d000000947 */ /* 0x000fea000383ffff */ /*0da0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0db0*/ BRA 0xdb0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0dc0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0dd0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0de0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0df0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e00*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e10*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e20*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e30*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e40*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e50*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e60*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <iostream> #include <cuda.h> using namespace std; __global__ void AddIntsCuda(int *a, int *b){ for(int i = 0; i<10000005; i++) a[0] +=b[0]*b[0]; } int main(){ int h_a=2, h_b=3; int *d_a, *d_b; //Device pointer // Allocate memory to device if(cudaMalloc((void**)&d_a, sizeof(int))!=cudaSuccess){ cout << "Error allocating memory!"<<endl; return 0; } if(cudaMalloc(&d_b, sizeof(int)) !=cudaSuccess){ cout << "Error allocating memory!"<<endl; cudaFree(d_a); return 0; } // Copy to device memory if(cudaMemcpy(d_a,&h_a, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess){ cout << "Error copying memory!"<<endl; cudaFree(d_a); cudaFree(d_b); return 0; } if(cudaMemcpy(d_b,&h_b, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess){ cout << "Error copying memory!"<<endl; cudaFree(d_a); cudaFree(d_b); return 0; } // Call the kernel AddIntsCuda<<<1,1>>>(d_a,d_b); // Copy answer from GPU to HOST if(cudaMemcpy(&h_a, d_a, sizeof(int), cudaMemcpyDeviceToHost) != cudaSuccess){ cout << "Error copying to memory!" << endl; cudaFree(d_a); cudaFree(d_b); return 0; } // Print from host cout<<"Answer "<<h_a<<endl; // Free memory cudaFree(d_a); cudaFree(d_b); cudaDeviceReset(); return 0; }
.file "tmpxft_00006799_00000000-6_mainErr.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3672: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3672: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z33__device_stub__Z11AddIntsCudaPiS_PiS_ .type _Z33__device_stub__Z11AddIntsCudaPiS_PiS_, @function _Z33__device_stub__Z11AddIntsCudaPiS_PiS_: .LFB3694: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movq %rsi, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 104(%rsp), %rax subq %fs:40, %rax jne .L8 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z11AddIntsCudaPiS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE3694: .size _Z33__device_stub__Z11AddIntsCudaPiS_PiS_, .-_Z33__device_stub__Z11AddIntsCudaPiS_PiS_ .globl _Z11AddIntsCudaPiS_ .type _Z11AddIntsCudaPiS_, @function _Z11AddIntsCudaPiS_: .LFB3695: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z11AddIntsCudaPiS_PiS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3695: .size _Z11AddIntsCudaPiS_, .-_Z11AddIntsCudaPiS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Error allocating memory!" .LC1: .string "Error copying memory!" .LC2: .string "Error copying to memory!" .LC3: .string "Answer " .text .globl main .type main, @function main: .LFB3669: .cfi_startproc endbr64 subq $72, %rsp .cfi_def_cfa_offset 80 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $2, 8(%rsp) movl $3, 12(%rsp) leaq 16(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT testl %eax, %eax jne .L21 leaq 24(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT testl %eax, %eax jne .L22 leaq 8(%rsp), %rsi movl $1, %ecx movl $4, %edx movq 16(%rsp), %rdi call cudaMemcpy@PLT testl %eax, %eax jne .L23 leaq 12(%rsp), %rsi movl $1, %ecx movl $4, %edx movq 24(%rsp), %rdi call cudaMemcpy@PLT testl %eax, %eax jne .L24 movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $0, %r9d movl $0, %r8d movq 44(%rsp), %rdx movl $1, %ecx movq 32(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L25 .L17: leaq 8(%rsp), %rdi movl $2, %ecx movl $4, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT testl %eax, %eax jne .L26 leaq .LC3(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 8(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT call cudaDeviceReset@PLT jmp .L13 .L21: leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT .L13: movq 56(%rsp), %rax subq %fs:40, %rax jne .L27 movl $0, %eax addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L22: .cfi_restore_state leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT jmp .L13 .L23: leaq .LC1(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT jmp .L13 .L24: leaq .LC1(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT jmp .L13 .L25: movq 24(%rsp), %rsi movq 16(%rsp), %rdi call _Z33__device_stub__Z11AddIntsCudaPiS_PiS_ jmp .L17 .L26: leaq .LC2(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT jmp .L13 .L27: call __stack_chk_fail@PLT .cfi_endproc .LFE3669: .size main, .-main .section .rodata.str1.1 .LC4: .string "_Z11AddIntsCudaPiS_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3697: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC4(%rip), %rdx movq %rdx, %rcx leaq _Z11AddIntsCudaPiS_(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3697: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <iostream> #include <cuda.h> using namespace std; __global__ void AddIntsCuda(int *a, int *b){ for(int i = 0; i<10000005; i++) a[0] +=b[0]*b[0]; } int main(){ int h_a=2, h_b=3; int *d_a, *d_b; //Device pointer // Allocate memory to device if(cudaMalloc((void**)&d_a, sizeof(int))!=cudaSuccess){ cout << "Error allocating memory!"<<endl; return 0; } if(cudaMalloc(&d_b, sizeof(int)) !=cudaSuccess){ cout << "Error allocating memory!"<<endl; cudaFree(d_a); return 0; } // Copy to device memory if(cudaMemcpy(d_a,&h_a, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess){ cout << "Error copying memory!"<<endl; cudaFree(d_a); cudaFree(d_b); return 0; } if(cudaMemcpy(d_b,&h_b, sizeof(int), cudaMemcpyHostToDevice) != cudaSuccess){ cout << "Error copying memory!"<<endl; cudaFree(d_a); cudaFree(d_b); return 0; } // Call the kernel AddIntsCuda<<<1,1>>>(d_a,d_b); // Copy answer from GPU to HOST if(cudaMemcpy(&h_a, d_a, sizeof(int), cudaMemcpyDeviceToHost) != cudaSuccess){ cout << "Error copying to memory!" << endl; cudaFree(d_a); cudaFree(d_b); return 0; } // Print from host cout<<"Answer "<<h_a<<endl; // Free memory cudaFree(d_a); cudaFree(d_b); cudaDeviceReset(); return 0; }
#include <iostream> #include <hip/hip_runtime.h> using namespace std; __global__ void AddIntsCuda(int *a, int *b){ for(int i = 0; i<10000005; i++) a[0] +=b[0]*b[0]; } int main(){ int h_a=2, h_b=3; int *d_a, *d_b; //Device pointer // Allocate memory to device if(hipMalloc((void**)&d_a, sizeof(int))!=hipSuccess){ cout << "Error allocating memory!"<<endl; return 0; } if(hipMalloc(&d_b, sizeof(int)) !=hipSuccess){ cout << "Error allocating memory!"<<endl; hipFree(d_a); return 0; } // Copy to device memory if(hipMemcpy(d_a,&h_a, sizeof(int), hipMemcpyHostToDevice) != hipSuccess){ cout << "Error copying memory!"<<endl; hipFree(d_a); hipFree(d_b); return 0; } if(hipMemcpy(d_b,&h_b, sizeof(int), hipMemcpyHostToDevice) != hipSuccess){ cout << "Error copying memory!"<<endl; hipFree(d_a); hipFree(d_b); return 0; } // Call the kernel AddIntsCuda<<<1,1>>>(d_a,d_b); // Copy answer from GPU to HOST if(hipMemcpy(&h_a, d_a, sizeof(int), hipMemcpyDeviceToHost) != hipSuccess){ cout << "Error copying to memory!" << endl; hipFree(d_a); hipFree(d_b); return 0; } // Print from host cout<<"Answer "<<h_a<<endl; // Free memory hipFree(d_a); hipFree(d_b); hipDeviceReset(); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <iostream> #include <hip/hip_runtime.h> using namespace std; __global__ void AddIntsCuda(int *a, int *b){ for(int i = 0; i<10000005; i++) a[0] +=b[0]*b[0]; } int main(){ int h_a=2, h_b=3; int *d_a, *d_b; //Device pointer // Allocate memory to device if(hipMalloc((void**)&d_a, sizeof(int))!=hipSuccess){ cout << "Error allocating memory!"<<endl; return 0; } if(hipMalloc(&d_b, sizeof(int)) !=hipSuccess){ cout << "Error allocating memory!"<<endl; hipFree(d_a); return 0; } // Copy to device memory if(hipMemcpy(d_a,&h_a, sizeof(int), hipMemcpyHostToDevice) != hipSuccess){ cout << "Error copying memory!"<<endl; hipFree(d_a); hipFree(d_b); return 0; } if(hipMemcpy(d_b,&h_b, sizeof(int), hipMemcpyHostToDevice) != hipSuccess){ cout << "Error copying memory!"<<endl; hipFree(d_a); hipFree(d_b); return 0; } // Call the kernel AddIntsCuda<<<1,1>>>(d_a,d_b); // Copy answer from GPU to HOST if(hipMemcpy(&h_a, d_a, sizeof(int), hipMemcpyDeviceToHost) != hipSuccess){ cout << "Error copying to memory!" << endl; hipFree(d_a); hipFree(d_b); return 0; } // Print from host cout<<"Answer "<<h_a<<endl; // Free memory hipFree(d_a); hipFree(d_b); hipDeviceReset(); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z11AddIntsCudaPiS_ .globl _Z11AddIntsCudaPiS_ .p2align 8 .type _Z11AddIntsCudaPiS_,@function _Z11AddIntsCudaPiS_: s_load_b128 s[0:3], s[0:1], 0x0 v_mov_b32_e32 v0, 0 s_mov_b32 s4, 0x989685 .LBB0_1: s_waitcnt lgkmcnt(0) s_clause 0x1 global_load_b32 v1, v0, s[2:3] global_load_b32 v2, v0, s[0:1] s_add_i32 s4, s4, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_1) s_cmp_eq_u32 s4, 0 s_waitcnt vmcnt(1) v_mul_lo_u32 v1, v1, v1 s_waitcnt vmcnt(0) v_add_nc_u32_e32 v1, v2, v1 global_store_b32 v0, v1, s[0:1] s_cbranch_scc0 .LBB0_1 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z11AddIntsCudaPiS_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 16 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 3 .amdhsa_next_free_sgpr 5 .amdhsa_reserve_vcc 0 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z11AddIntsCudaPiS_, .Lfunc_end0-_Z11AddIntsCudaPiS_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 16 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z11AddIntsCudaPiS_ .private_segment_fixed_size: 0 .sgpr_count: 5 .sgpr_spill_count: 0 .symbol: _Z11AddIntsCudaPiS_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 3 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <iostream> #include <hip/hip_runtime.h> using namespace std; __global__ void AddIntsCuda(int *a, int *b){ for(int i = 0; i<10000005; i++) a[0] +=b[0]*b[0]; } int main(){ int h_a=2, h_b=3; int *d_a, *d_b; //Device pointer // Allocate memory to device if(hipMalloc((void**)&d_a, sizeof(int))!=hipSuccess){ cout << "Error allocating memory!"<<endl; return 0; } if(hipMalloc(&d_b, sizeof(int)) !=hipSuccess){ cout << "Error allocating memory!"<<endl; hipFree(d_a); return 0; } // Copy to device memory if(hipMemcpy(d_a,&h_a, sizeof(int), hipMemcpyHostToDevice) != hipSuccess){ cout << "Error copying memory!"<<endl; hipFree(d_a); hipFree(d_b); return 0; } if(hipMemcpy(d_b,&h_b, sizeof(int), hipMemcpyHostToDevice) != hipSuccess){ cout << "Error copying memory!"<<endl; hipFree(d_a); hipFree(d_b); return 0; } // Call the kernel AddIntsCuda<<<1,1>>>(d_a,d_b); // Copy answer from GPU to HOST if(hipMemcpy(&h_a, d_a, sizeof(int), hipMemcpyDeviceToHost) != hipSuccess){ cout << "Error copying to memory!" << endl; hipFree(d_a); hipFree(d_b); return 0; } // Print from host cout<<"Answer "<<h_a<<endl; // Free memory hipFree(d_a); hipFree(d_b); hipDeviceReset(); return 0; }
.text .file "mainErr.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z26__device_stub__AddIntsCudaPiS_ # -- Begin function _Z26__device_stub__AddIntsCudaPiS_ .p2align 4, 0x90 .type _Z26__device_stub__AddIntsCudaPiS_,@function _Z26__device_stub__AddIntsCudaPiS_: # @_Z26__device_stub__AddIntsCudaPiS_ .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movq %rsi, 48(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 48(%rsp), %rax movq %rax, 72(%rsp) leaq 32(%rsp), %rdi leaq 16(%rsp), %rsi leaq 8(%rsp), %rdx movq %rsp, %rcx callq __hipPopCallConfiguration movq 32(%rsp), %rsi movl 40(%rsp), %edx movq 16(%rsp), %rcx movl 24(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z11AddIntsCudaPiS_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z26__device_stub__AddIntsCudaPiS_, .Lfunc_end0-_Z26__device_stub__AddIntsCudaPiS_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 movl $2, 12(%rsp) movl $3, 28(%rsp) movq %rsp, %rdi movl $4, %esi callq hipMalloc testl %eax, %eax je .LBB1_4 # %bb.1: movl $_ZSt4cout, %edi movl $.L.str, %esi movl $24, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.2: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%rbx) je .LBB1_8 # %bb.3: movzbl 67(%rbx), %eax jmp .LBB1_9 .LBB1_4: leaq 16(%rsp), %rdi movl $4, %esi callq hipMalloc testl %eax, %eax je .LBB1_10 # %bb.5: movl $_ZSt4cout, %edi movl $.L.str, %esi movl $24, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.6: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i9 cmpb $0, 56(%rbx) je .LBB1_14 # %bb.7: movzbl 67(%rbx), %eax jmp .LBB1_15 .LBB1_8: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB1_9: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv jmp .LBB1_24 .LBB1_10: movq (%rsp), %rdi leaq 12(%rsp), %rsi movl $4, %edx movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB1_16 # %bb.11: movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $21, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.12: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i14 cmpb $0, 56(%rbx) je .LBB1_20 .LBB1_13: movzbl 67(%rbx), %eax jmp .LBB1_21 .LBB1_14: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB1_15: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit12 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movq (%rsp), %rdi jmp .LBB1_23 .LBB1_16: movq 16(%rsp), %rdi leaq 28(%rsp), %rsi movl $4, %edx movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB1_25 # %bb.17: movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $21, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.18: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i19 cmpb $0, 56(%rbx) jne .LBB1_13 .LBB1_20: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB1_21: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit17 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv .LBB1_22: movq (%rsp), %rdi callq hipFree movq 16(%rsp), %rdi .LBB1_23: callq hipFree .LBB1_24: xorl %eax, %eax addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .LBB1_25: .cfi_def_cfa_offset 48 movabsq $4294967297, %rdi # imm = 0x100000001 movl $1, %esi movq %rdi, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_27 # %bb.26: movq (%rsp), %rdi movq 16(%rsp), %rsi callq _Z26__device_stub__AddIntsCudaPiS_ .LBB1_27: movq (%rsp), %rsi leaq 12(%rsp), %rdi movl $4, %edx movl $2, %ecx callq hipMemcpy movl $_ZSt4cout, %edi testl %eax, %eax je .LBB1_29 # %bb.28: movl $.L.str.2, %esi movl $24, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl $_ZSt4cout, %edi callq _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ jmp .LBB1_22 .LBB1_29: movl $.L.str.3, %esi movl $7, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 12(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %rdi callq _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ movq (%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree callq hipDeviceReset jmp .LBB1_24 .LBB1_30: callq _ZSt16__throw_bad_castv .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z11AddIntsCudaPiS_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type _Z11AddIntsCudaPiS_,@object # @_Z11AddIntsCudaPiS_ .section .rodata,"a",@progbits .globl _Z11AddIntsCudaPiS_ .p2align 3, 0x0 _Z11AddIntsCudaPiS_: .quad _Z26__device_stub__AddIntsCudaPiS_ .size _Z11AddIntsCudaPiS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Error allocating memory!" .size .L.str, 25 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Error copying memory!" .size .L.str.1, 22 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Error copying to memory!" .size .L.str.2, 25 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Answer " .size .L.str.3, 8 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z11AddIntsCudaPiS_" .size .L__unnamed_1, 20 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z26__device_stub__AddIntsCudaPiS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z11AddIntsCudaPiS_ .addrsig_sym _ZSt4cout .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z11AddIntsCudaPiS_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ MOV R2, c[0x0][0x160] ; /* 0x0000580000027a02 */ /* 0x000fe20000000f00 */ /*0020*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0030*/ MOV R3, c[0x0][0x164] ; /* 0x0000590000037a02 */ /* 0x000fe40000000f00 */ /*0040*/ MOV R4, c[0x0][0x168] ; /* 0x00005a0000047a02 */ /* 0x000fe40000000f00 */ /*0050*/ MOV R5, c[0x0][0x16c] ; /* 0x00005b0000057a02 */ /* 0x000fe20000000f00 */ /*0060*/ LDG.E R0, [R2.64] ; /* 0x0000000402007981 */ /* 0x000ea8000c1e1900 */ /*0070*/ LDG.E R7, [R4.64] ; /* 0x0000000404077981 */ /* 0x000ea4000c1e1900 */ /*0080*/ IMAD R7, R7, R7, R0 ; /* 0x0000000707077224 */ /* 0x004fca00078e0200 */ /*0090*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*00a0*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea4000c1e1900 */ /*00b0*/ IMAD R9, R0, R0, R7 ; /* 0x0000000000097224 */ /* 0x004fca00078e0207 */ /*00c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*00d0*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea4000c1e1900 */ /*00e0*/ IMAD R11, R0, R0, R9 ; /* 0x00000000000b7224 */ /* 0x004fca00078e0209 */ /*00f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0003e8000c101904 */ /*0100*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea4000c1e1900 */ /*0110*/ IMAD R13, R0, R0, R11 ; /* 0x00000000000d7224 */ /* 0x004fca00078e020b */ /*0120*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0003e8000c101904 */ /*0130*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000e24000c1e1900 */ /*0140*/ IMAD R7, R0, R0, R13 ; /* 0x0000000000077224 */ /* 0x001fe200078e020d */ /*0150*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fc800000001ff */ /*0160*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0003e8000c101904 */ /*0170*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0180*/ IMAD R7, R6, R6, R7 ; /* 0x0000000606077224 */ /* 0x016fca00078e0207 */ /*0190*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*01a0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*01b0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x004fca00078e0207 */ /*01c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*01d0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*01e0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*01f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0200*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0210*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0220*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0230*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0240*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0250*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0260*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0270*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0280*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0290*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*02a0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*02b0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*02c0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*02d0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*02e0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*02f0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0300*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0310*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0320*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0330*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0340*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0350*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0360*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0370*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0380*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0390*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*03a0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*03b0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*03c0*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*03d0*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*03e0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*03f0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0400*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0410*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0420*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0430*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0440*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0450*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0460*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0470*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0480*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0490*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*04a0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*04b0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*04c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*04d0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*04e0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*04f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0500*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0510*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0520*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0530*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0540*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0550*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0560*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0570*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0580*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0590*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*05a0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*05b0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*05c0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*05d0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*05e0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*05f0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0600*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0610*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0620*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0630*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0640*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0650*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0660*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0670*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0680*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0690*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*06a0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*06b0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*06c0*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*06d0*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*06e0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*06f0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0700*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0710*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0720*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0730*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0740*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0750*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0760*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0770*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0780*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0790*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*07a0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*07b0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*07c0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*07d0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*07e0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*07f0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0800*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0810*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0820*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0830*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0840*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0850*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0860*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0870*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0880*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0890*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*08a0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*08b0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*08c0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*08d0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*08e0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*08f0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0900*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0910*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0920*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0930*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0940*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0950*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0960*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0970*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0980*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0990*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*09a0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*09b0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*09c0*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*09d0*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*09e0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*09f0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0a00*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0a10*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0a20*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0a30*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0a40*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0a50*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0a60*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0a70*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0a80*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0a90*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0aa0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0ab0*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0ac0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0ad0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0ae0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0af0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0b00*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0b10*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0b20*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0b30*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0b40*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0b50*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0b60*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0b70*/ IMAD R9, R6, R6, R7 ; /* 0x0000000606097224 */ /* 0x002fca00078e0207 */ /*0b80*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0003e8000c101904 */ /*0b90*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0ba0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0bb0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0005e8000c101904 */ /*0bc0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee4000c1e1900 */ /*0bd0*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0be0*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0007e8000c101904 */ /*0bf0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e24000c1e1900 */ /*0c00*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0c10*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e8000c101904 */ /*0c20*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000f24000c1e1900 */ /*0c30*/ IMAD R15, R6, R6, R7 ; /* 0x00000006060f7224 */ /* 0x010fca00078e0207 */ /*0c40*/ STG.E [R2.64], R15 ; /* 0x0000000f02007986 */ /* 0x0009e8000c101904 */ /*0c50*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000f64000c1e1900 */ /*0c60*/ IMAD R17, R6, R6, R15 ; /* 0x0000000606117224 */ /* 0x020fca00078e020f */ /*0c70*/ STG.E [R2.64], R17 ; /* 0x0000001102007986 */ /* 0x0009e8000c101904 */ /*0c80*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000f64000c1e1900 */ /*0c90*/ IMAD R19, R6, R6, R17 ; /* 0x0000000606137224 */ /* 0x020fca00078e0211 */ /*0ca0*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0009e8000c101904 */ /*0cb0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e64000c1e1900 */ /*0cc0*/ IMAD R9, R6, R6, R19 ; /* 0x0000000606097224 */ /* 0x002fca00078e0213 */ /*0cd0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x0009e8000c101904 */ /*0ce0*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea4000c1e1900 */ /*0cf0*/ IMAD R11, R6, R6, R9 ; /* 0x00000006060b7224 */ /* 0x004fca00078e0209 */ /*0d00*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0009e8000c101904 */ /*0d10*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ee2000c1e1900 */ /*0d20*/ IADD3 R0, R0, 0x40, RZ ; /* 0x0000004000007810 */ /* 0x000fe20007ffe0ff */ /*0d30*/ IMAD R13, R6, R6, R11 ; /* 0x00000006060d7224 */ /* 0x008fca00078e020b */ /*0d40*/ STG.E [R2.64], R13 ; /* 0x0000000d02007986 */ /* 0x0009e8000c101904 */ /*0d50*/ LDG.E R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000e22000c1e1900 */ /*0d60*/ ISETP.NE.AND P0, PT, R0, 0x989684, PT ; /* 0x009896840000780c */ /* 0x000fe20003f05270 */ /*0d70*/ IMAD R7, R6, R6, R13 ; /* 0x0000000606077224 */ /* 0x001fca00078e020d */ /*0d80*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0009ee000c101904 */ /*0d90*/ @P0 BRA 0x170 ; /* 0xfffff3d000000947 */ /* 0x000fea000383ffff */ /*0da0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0db0*/ BRA 0xdb0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0dc0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0dd0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0de0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0df0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e00*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e10*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e20*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e30*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e40*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e50*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e60*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z11AddIntsCudaPiS_ .globl _Z11AddIntsCudaPiS_ .p2align 8 .type _Z11AddIntsCudaPiS_,@function _Z11AddIntsCudaPiS_: s_load_b128 s[0:3], s[0:1], 0x0 v_mov_b32_e32 v0, 0 s_mov_b32 s4, 0x989685 .LBB0_1: s_waitcnt lgkmcnt(0) s_clause 0x1 global_load_b32 v1, v0, s[2:3] global_load_b32 v2, v0, s[0:1] s_add_i32 s4, s4, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_1) s_cmp_eq_u32 s4, 0 s_waitcnt vmcnt(1) v_mul_lo_u32 v1, v1, v1 s_waitcnt vmcnt(0) v_add_nc_u32_e32 v1, v2, v1 global_store_b32 v0, v1, s[0:1] s_cbranch_scc0 .LBB0_1 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z11AddIntsCudaPiS_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 16 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 3 .amdhsa_next_free_sgpr 5 .amdhsa_reserve_vcc 0 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z11AddIntsCudaPiS_, .Lfunc_end0-_Z11AddIntsCudaPiS_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 16 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z11AddIntsCudaPiS_ .private_segment_fixed_size: 0 .sgpr_count: 5 .sgpr_spill_count: 0 .symbol: _Z11AddIntsCudaPiS_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 3 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00006799_00000000-6_mainErr.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3672: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3672: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z33__device_stub__Z11AddIntsCudaPiS_PiS_ .type _Z33__device_stub__Z11AddIntsCudaPiS_PiS_, @function _Z33__device_stub__Z11AddIntsCudaPiS_PiS_: .LFB3694: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movq %rsi, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 104(%rsp), %rax subq %fs:40, %rax jne .L8 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z11AddIntsCudaPiS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE3694: .size _Z33__device_stub__Z11AddIntsCudaPiS_PiS_, .-_Z33__device_stub__Z11AddIntsCudaPiS_PiS_ .globl _Z11AddIntsCudaPiS_ .type _Z11AddIntsCudaPiS_, @function _Z11AddIntsCudaPiS_: .LFB3695: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z11AddIntsCudaPiS_PiS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3695: .size _Z11AddIntsCudaPiS_, .-_Z11AddIntsCudaPiS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Error allocating memory!" .LC1: .string "Error copying memory!" .LC2: .string "Error copying to memory!" .LC3: .string "Answer " .text .globl main .type main, @function main: .LFB3669: .cfi_startproc endbr64 subq $72, %rsp .cfi_def_cfa_offset 80 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $2, 8(%rsp) movl $3, 12(%rsp) leaq 16(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT testl %eax, %eax jne .L21 leaq 24(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT testl %eax, %eax jne .L22 leaq 8(%rsp), %rsi movl $1, %ecx movl $4, %edx movq 16(%rsp), %rdi call cudaMemcpy@PLT testl %eax, %eax jne .L23 leaq 12(%rsp), %rsi movl $1, %ecx movl $4, %edx movq 24(%rsp), %rdi call cudaMemcpy@PLT testl %eax, %eax jne .L24 movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $0, %r9d movl $0, %r8d movq 44(%rsp), %rdx movl $1, %ecx movq 32(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L25 .L17: leaq 8(%rsp), %rdi movl $2, %ecx movl $4, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT testl %eax, %eax jne .L26 leaq .LC3(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 8(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT call cudaDeviceReset@PLT jmp .L13 .L21: leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT .L13: movq 56(%rsp), %rax subq %fs:40, %rax jne .L27 movl $0, %eax addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L22: .cfi_restore_state leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT jmp .L13 .L23: leaq .LC1(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT jmp .L13 .L24: leaq .LC1(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT jmp .L13 .L25: movq 24(%rsp), %rsi movq 16(%rsp), %rdi call _Z33__device_stub__Z11AddIntsCudaPiS_PiS_ jmp .L17 .L26: leaq .LC2(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT jmp .L13 .L27: call __stack_chk_fail@PLT .cfi_endproc .LFE3669: .size main, .-main .section .rodata.str1.1 .LC4: .string "_Z11AddIntsCudaPiS_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3697: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC4(%rip), %rdx movq %rdx, %rcx leaq _Z11AddIntsCudaPiS_(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3697: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "mainErr.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z26__device_stub__AddIntsCudaPiS_ # -- Begin function _Z26__device_stub__AddIntsCudaPiS_ .p2align 4, 0x90 .type _Z26__device_stub__AddIntsCudaPiS_,@function _Z26__device_stub__AddIntsCudaPiS_: # @_Z26__device_stub__AddIntsCudaPiS_ .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movq %rsi, 48(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 48(%rsp), %rax movq %rax, 72(%rsp) leaq 32(%rsp), %rdi leaq 16(%rsp), %rsi leaq 8(%rsp), %rdx movq %rsp, %rcx callq __hipPopCallConfiguration movq 32(%rsp), %rsi movl 40(%rsp), %edx movq 16(%rsp), %rcx movl 24(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z11AddIntsCudaPiS_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z26__device_stub__AddIntsCudaPiS_, .Lfunc_end0-_Z26__device_stub__AddIntsCudaPiS_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 movl $2, 12(%rsp) movl $3, 28(%rsp) movq %rsp, %rdi movl $4, %esi callq hipMalloc testl %eax, %eax je .LBB1_4 # %bb.1: movl $_ZSt4cout, %edi movl $.L.str, %esi movl $24, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.2: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%rbx) je .LBB1_8 # %bb.3: movzbl 67(%rbx), %eax jmp .LBB1_9 .LBB1_4: leaq 16(%rsp), %rdi movl $4, %esi callq hipMalloc testl %eax, %eax je .LBB1_10 # %bb.5: movl $_ZSt4cout, %edi movl $.L.str, %esi movl $24, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.6: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i9 cmpb $0, 56(%rbx) je .LBB1_14 # %bb.7: movzbl 67(%rbx), %eax jmp .LBB1_15 .LBB1_8: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB1_9: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv jmp .LBB1_24 .LBB1_10: movq (%rsp), %rdi leaq 12(%rsp), %rsi movl $4, %edx movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB1_16 # %bb.11: movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $21, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.12: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i14 cmpb $0, 56(%rbx) je .LBB1_20 .LBB1_13: movzbl 67(%rbx), %eax jmp .LBB1_21 .LBB1_14: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB1_15: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit12 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movq (%rsp), %rdi jmp .LBB1_23 .LBB1_16: movq 16(%rsp), %rdi leaq 28(%rsp), %rsi movl $4, %edx movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB1_25 # %bb.17: movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $21, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB1_30 # %bb.18: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i19 cmpb $0, 56(%rbx) jne .LBB1_13 .LBB1_20: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB1_21: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit17 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv .LBB1_22: movq (%rsp), %rdi callq hipFree movq 16(%rsp), %rdi .LBB1_23: callq hipFree .LBB1_24: xorl %eax, %eax addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .LBB1_25: .cfi_def_cfa_offset 48 movabsq $4294967297, %rdi # imm = 0x100000001 movl $1, %esi movq %rdi, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_27 # %bb.26: movq (%rsp), %rdi movq 16(%rsp), %rsi callq _Z26__device_stub__AddIntsCudaPiS_ .LBB1_27: movq (%rsp), %rsi leaq 12(%rsp), %rdi movl $4, %edx movl $2, %ecx callq hipMemcpy movl $_ZSt4cout, %edi testl %eax, %eax je .LBB1_29 # %bb.28: movl $.L.str.2, %esi movl $24, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl $_ZSt4cout, %edi callq _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ jmp .LBB1_22 .LBB1_29: movl $.L.str.3, %esi movl $7, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 12(%rsp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %rdi callq _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ movq (%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree callq hipDeviceReset jmp .LBB1_24 .LBB1_30: callq _ZSt16__throw_bad_castv .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z11AddIntsCudaPiS_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type _Z11AddIntsCudaPiS_,@object # @_Z11AddIntsCudaPiS_ .section .rodata,"a",@progbits .globl _Z11AddIntsCudaPiS_ .p2align 3, 0x0 _Z11AddIntsCudaPiS_: .quad _Z26__device_stub__AddIntsCudaPiS_ .size _Z11AddIntsCudaPiS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Error allocating memory!" .size .L.str, 25 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Error copying memory!" .size .L.str.1, 22 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Error copying to memory!" .size .L.str.2, 25 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Answer " .size .L.str.3, 8 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z11AddIntsCudaPiS_" .size .L__unnamed_1, 20 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z26__device_stub__AddIntsCudaPiS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z11AddIntsCudaPiS_ .addrsig_sym _ZSt4cout .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include <cuda.h> #include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <iostream> __global__ void RankSortKernel(float* DataIn, float* DataOut, int* rank, int size) { // Retrieve our coordinates in the block int tx = (blockIdx.x * 512) + threadIdx.x; rank[tx] = 0; if(tx < size) { for(int i=0;i<size;i++) { if(DataIn[tx]>=DataIn[i]) { rank[tx]++; } } DataOut[(rank[tx]-1)] = DataIn[tx]; } } __global__ void OddEvenSortKernel(float* Array, int size, bool Odd_Phase) { int tx = (blockIdx.x * 512) + threadIdx.x; float temp; int index = 2*tx; if(tx < (size/2)) { if(Odd_Phase == false) { if((index+1) < size) { if(Array[index]>Array[index+1]) { temp = Array[index]; Array[index] = Array[index+1]; Array[index+1] = temp; } } } else { if((index+2) < size) { if(Array[index+1]>Array[index+2]) { temp = Array[index+1]; Array[index+1] = Array[index+2]; Array[index+2] = temp; } } } } } bool RankSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value cudaError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *DataIn, *DataOut; int *rank; int bytes1 = size * sizeof(float); // Allocate memory on the device cudaMalloc((void**) &DataIn, bytes); cudaMalloc((void**) &DataOut, bytes); cudaMalloc((void**) &rank, bytes1); // Copy the host input data to the device cudaMemcpy(DataIn, InputArray, bytes, cudaMemcpyHostToDevice); // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)size/512), 1); // Launch the kernel on a size-by-size block of threads RankSortKernel<<<dimGrid, dimBlock>>>(DataIn, DataOut, rank, size); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 1: " << cudaGetErrorString(status) << std::endl; cudaFree(DataIn); cudaFree(DataOut); return false; } // Retrieve the result matrix cudaMemcpy(SortedArray, DataOut, bytes, cudaMemcpyDeviceToHost); // Free device memory cudaFree(DataIn); cudaFree(DataOut); // Success return true; } bool OddEvenSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value cudaError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *Array; bool Odd_Phase; // Allocate memory on the device cudaMalloc((void**) &Array, bytes); // Copy the host input data to the device cudaMemcpy(Array, InputArray, bytes, cudaMemcpyHostToDevice); int new_size = size/2; // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)new_size/512), 1); for(int i=0;i<size;i++) { //even phase Odd_Phase = false; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 2: " << cudaGetErrorString(status) << std::endl; cudaFree(Array); return false; } //odd phase Odd_Phase = true; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 3: " << cudaGetErrorString(status) << std::endl; cudaFree(Array); return false; } } // Retrieve the result matrix cudaMemcpy(SortedArray, Array, bytes, cudaMemcpyDeviceToHost); // Free device memory cudaFree(Array); // Success return true; }
code for sm_80 Function : _Z17OddEvenSortKernelPfib .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e220000002500 */ /*0020*/ ULDC UR4, c[0x0][0x168] ; /* 0x00005a0000047ab9 */ /* 0x000fe40000000800 */ /*0030*/ ULEA.HI UR4, UR4, UR4, URZ, 0x1 ; /* 0x0000000404047291 */ /* 0x000fe2000f8f083f */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e260000002100 */ /*0050*/ USHF.R.S32.HI UR4, URZ, 0x1, UR4 ; /* 0x000000013f047899 */ /* 0x000fe20008011404 */ /*0060*/ IMAD R0, R0, 0x200, R3 ; /* 0x0000020000007824 */ /* 0x001fca00078e0203 */ /*0070*/ ISETP.GE.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf06270 */ /*0080*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0090*/ ULDC.S8 UR4, c[0x0][0x16c] ; /* 0x00005b0000047ab9 */ /* 0x000fe20000000200 */ /*00a0*/ IMAD.SHL.U32 R0, R0, 0x2, RZ ; /* 0x0000000200007824 */ /* 0x000fe200078e00ff */ /*00b0*/ ISETP.NE.AND P0, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf05270 */ /*00c0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fe200078e00ff */ /*00d0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*00e0*/ IMAD.WIDE R2, R0, R3, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fd000078e0203 */ /*00f0*/ @!P0 BRA 0x1a0 ; /* 0x000000a000008947 */ /* 0x000fea0003800000 */ /*0100*/ IADD3 R0, R0, 0x2, RZ ; /* 0x0000000200007810 */ /* 0x000fc80007ffe0ff */ /*0110*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x168], PT ; /* 0x00005a0000007a0c */ /* 0x000fda0003f06270 */ /*0120*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0130*/ LDG.E R5, [R2.64+0x8] ; /* 0x0000080402057981 */ /* 0x000ea8000c1e1900 */ /*0140*/ LDG.E R0, [R2.64+0x4] ; /* 0x0000040402007981 */ /* 0x000ea4000c1e1900 */ /*0150*/ FSETP.GT.AND P0, PT, R0, R5, PT ; /* 0x000000050000720b */ /* 0x004fda0003f04000 */ /*0160*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*0170*/ STG.E [R2.64+0x4], R5 ; /* 0x0000040502007986 */ /* 0x000fe8000c101904 */ /*0180*/ STG.E [R2.64+0x8], R0 ; /* 0x0000080002007986 */ /* 0x000fe2000c101904 */ /*0190*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01a0*/ IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100007810 */ /* 0x000fc80007ffe0ff */ /*01b0*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x168], PT ; /* 0x00005a0000007a0c */ /* 0x000fda0003f06270 */ /*01c0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*01d0*/ LDG.E R5, [R2.64] ; /* 0x0000000402057981 */ /* 0x000ea8000c1e1900 */ /*01e0*/ LDG.E R0, [R2.64+0x4] ; /* 0x0000040402007981 */ /* 0x000ea4000c1e1900 */ /*01f0*/ FSETP.GT.AND P0, PT, R5, R0, PT ; /* 0x000000000500720b */ /* 0x004fda0003f04000 */ /*0200*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*0210*/ STG.E [R2.64], R0 ; /* 0x0000000002007986 */ /* 0x000fe8000c101904 */ /*0220*/ STG.E [R2.64+0x4], R5 ; /* 0x0000040502007986 */ /* 0x000fe2000c101904 */ /*0230*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0240*/ BRA 0x240; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0280*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0290*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z14RankSortKernelPfS_Pii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e220000002500 */ /*0020*/ ULDC.64 UR8, c[0x0][0x118] ; /* 0x0000460000087ab9 */ /* 0x000fc60000000a00 */ /*0030*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0040*/ IMAD R0, R0, 0x200, R3 ; /* 0x0000020000007824 */ /* 0x001fe400078e0203 */ /*0050*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fc600078e00ff */ /*0060*/ ISETP.GE.AND P0, PT, R0.reuse, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x040fe20003f06270 */ /*0070*/ IMAD.WIDE R2, R0, R3, c[0x0][0x170] ; /* 0x00005c0000027625 */ /* 0x000fca00078e0203 */ /*0080*/ STG.E [R2.64], RZ ; /* 0x000000ff02007986 */ /* 0x0001ee000c101908 */ /*0090*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00a0*/ SHF.R.S32.HI R5, RZ, 0x1f, R0 ; /* 0x0000001fff057819 */ /* 0x000fe40000011400 */ /*00b0*/ LEA R4, P0, R0, c[0x0][0x160], 0x2 ; /* 0x0000580000047a11 */ /* 0x000fc800078010ff */ /*00c0*/ LEA.HI.X R5, R0, c[0x0][0x164], R5, 0x2, P0 ; /* 0x0000590000057a11 */ /* 0x000fca00000f1405 */ /*00d0*/ LDG.E R0, [R4.64] ; /* 0x0000000804007981 */ /* 0x000362000c1e1900 */ /*00e0*/ IMAD.MOV.U32 R8, RZ, RZ, c[0x0][0x178] ; /* 0x00005e00ff087624 */ /* 0x000fe400078e00ff */ /*00f0*/ IMAD.MOV.U32 R9, RZ, RZ, RZ ; /* 0x000000ffff097224 */ /* 0x000fc600078e00ff */ /*0100*/ ISETP.GE.AND P0, PT, R8, 0x1, PT ; /* 0x000000010800780c */ /* 0x000fda0003f06270 */ /*0110*/ @!P0 BRA 0xd80 ; /* 0x00000c6000008947 */ /* 0x000fea0003800000 */ /*0120*/ IADD3 R6, R8.reuse, -0x1, RZ ; /* 0xffffffff08067810 */ /* 0x042fe20007ffe0ff */ /*0130*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0140*/ LOP3.LUT R8, R8, 0x3, RZ, 0xc0, !PT ; /* 0x0000000308087812 */ /* 0x000fe200078ec0ff */ /*0150*/ IMAD.MOV.U32 R9, RZ, RZ, RZ ; /* 0x000000ffff097224 */ /* 0x000fe200078e00ff */ /*0160*/ ISETP.GE.U32.AND P0, PT, R6, 0x3, PT ; /* 0x000000030600780c */ /* 0x000fda0003f06070 */ /*0170*/ @!P0 BRA 0xc70 ; /* 0x00000af000008947 */ /* 0x000fea0003800000 */ /*0180*/ IADD3 R10, -R8, c[0x0][0x178], RZ ; /* 0x00005e00080a7a10 */ /* 0x000fe20007ffe1ff */ /*0190*/ IMAD.MOV.U32 R9, RZ, RZ, RZ ; /* 0x000000ffff097224 */ /* 0x000fe400078e00ff */ /*01a0*/ IMAD.MOV.U32 R6, RZ, RZ, c[0x0][0x160] ; /* 0x00005800ff067624 */ /* 0x000fe200078e00ff */ /*01b0*/ ISETP.GT.AND P0, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fe20003f04270 */ /*01c0*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x164] ; /* 0x00005900ff077624 */ /* 0x000fd800078e00ff */ /*01d0*/ @!P0 BRA 0xad0 ; /* 0x000008f000008947 */ /* 0x000fea0003800000 */ /*01e0*/ ISETP.GT.AND P1, PT, R10, 0xc, PT ; /* 0x0000000c0a00780c */ /* 0x000fe40003f24270 */ /*01f0*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0200*/ @!P1 BRA 0x780 ; /* 0x0000057000009947 */ /* 0x000fea0003800000 */ /*0210*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0220*/ LDG.E R11, [R6.64] ; /* 0x00000008060b7981 */ /* 0x000ea4000c1e1900 */ /*0230*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x024fda0003f26000 */ /*0240*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x000fca0007ffe0ff */ /*0250*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0260*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0270*/ LDG.E R11, [R6.64+0x4] ; /* 0x00000408060b7981 */ /* 0x000ea4000c1e1900 */ /*0280*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0290*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*02a0*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*02b0*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*02c0*/ LDG.E R11, [R6.64+0x8] ; /* 0x00000808060b7981 */ /* 0x000ea4000c1e1900 */ /*02d0*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*02e0*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*02f0*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0300*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0310*/ LDG.E R11, [R6.64+0xc] ; /* 0x00000c08060b7981 */ /* 0x000ea4000c1e1900 */ /*0320*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0330*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0340*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0350*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0360*/ LDG.E R11, [R6.64+0x10] ; /* 0x00001008060b7981 */ /* 0x000ea4000c1e1900 */ /*0370*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0380*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0390*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*03a0*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*03b0*/ LDG.E R11, [R6.64+0x14] ; /* 0x00001408060b7981 */ /* 0x000ea4000c1e1900 */ /*03c0*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*03d0*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*03e0*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*03f0*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0400*/ LDG.E R11, [R6.64+0x18] ; /* 0x00001808060b7981 */ /* 0x000ea4000c1e1900 */ /*0410*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0420*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0430*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0440*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0450*/ LDG.E R11, [R6.64+0x1c] ; /* 0x00001c08060b7981 */ /* 0x000ea4000c1e1900 */ /*0460*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0470*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0480*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0490*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*04a0*/ LDG.E R11, [R6.64+0x20] ; /* 0x00002008060b7981 */ /* 0x000ea4000c1e1900 */ /*04b0*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*04c0*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*04d0*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*04e0*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*04f0*/ LDG.E R11, [R6.64+0x24] ; /* 0x00002408060b7981 */ /* 0x000ea4000c1e1900 */ /*0500*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0510*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0520*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0530*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0540*/ LDG.E R11, [R6.64+0x28] ; /* 0x00002808060b7981 */ /* 0x000ea4000c1e1900 */ /*0550*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0560*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0570*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0580*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0590*/ LDG.E R11, [R6.64+0x2c] ; /* 0x00002c08060b7981 */ /* 0x000ea4000c1e1900 */ /*05a0*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*05b0*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*05c0*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*05d0*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*05e0*/ LDG.E R11, [R6.64+0x30] ; /* 0x00003008060b7981 */ /* 0x000ea4000c1e1900 */ /*05f0*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0600*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0610*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0620*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0630*/ LDG.E R11, [R6.64+0x34] ; /* 0x00003408060b7981 */ /* 0x000ea4000c1e1900 */ /*0640*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0650*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0660*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0670*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*0680*/ LDG.E R11, [R6.64+0x38] ; /* 0x00003808060b7981 */ /* 0x000ea4000c1e1900 */ /*0690*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*06a0*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*06b0*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*06c0*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000ea8000c1e1900 */ /*06d0*/ LDG.E R11, [R6.64+0x3c] ; /* 0x00003c08060b7981 */ /* 0x0006a2000c1e1900 */ /*06e0*/ IADD3 R10, R10, -0x10, RZ ; /* 0xfffffff00a0a7810 */ /* 0x000fe20007ffe0ff */ /*06f0*/ UIADD3 UR4, UR4, 0x10, URZ ; /* 0x0000001004047890 */ /* 0x000fe2000fffe03f */ /*0700*/ IADD3 R6, P2, R6, 0x40, RZ ; /* 0x0000004006067810 */ /* 0x008fca0007f5e0ff */ /*0710*/ IMAD.X R7, RZ, RZ, R7, P2 ; /* 0x000000ffff077224 */ /* 0x000fe200010e0607 */ /*0720*/ FSETP.GE.AND P1, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f26000 */ /*0730*/ @P1 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109091810 */ /* 0x002fca0007ffe0ff */ /*0740*/ @P1 STG.E [R2.64], R9 ; /* 0x0000000902001986 */ /* 0x0003e8000c101908 */ /*0750*/ @P1 LDG.E R0, [R4.64] ; /* 0x0000000804001981 */ /* 0x000362000c1e1900 */ /*0760*/ ISETP.GT.AND P1, PT, R10, 0xc, PT ; /* 0x0000000c0a00780c */ /* 0x000fda0003f24270 */ /*0770*/ @P1 BRA 0x220 ; /* 0xfffffaa000001947 */ /* 0x002fea000383ffff */ /*0780*/ ISETP.GT.AND P1, PT, R10, 0x4, PT ; /* 0x000000040a00780c */ /* 0x000fda0003f24270 */ /*0790*/ @!P1 BRA 0xab0 ; /* 0x0000031000009947 */ /* 0x000fea0003800000 */ /*07a0*/ LDG.E R11, [R6.64] ; /* 0x00000008060b7981 */ /* 0x000ea4000c1e1900 */ /*07b0*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x024fda0003f06000 */ /*07c0*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x000fca0007ffe0ff */ /*07d0*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*07e0*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*07f0*/ LDG.E R11, [R6.64+0x4] ; /* 0x00000408060b7981 */ /* 0x000ea4000c1e1900 */ /*0800*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0810*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0820*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0830*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*0840*/ LDG.E R11, [R6.64+0x8] ; /* 0x00000808060b7981 */ /* 0x000ea4000c1e1900 */ /*0850*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0860*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0870*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0880*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*0890*/ LDG.E R11, [R6.64+0xc] ; /* 0x00000c08060b7981 */ /* 0x000ea4000c1e1900 */ /*08a0*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*08b0*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*08c0*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*08d0*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*08e0*/ LDG.E R11, [R6.64+0x10] ; /* 0x00001008060b7981 */ /* 0x000ea2000c1e1900 */ /*08f0*/ IADD3 R12, P1, R6, 0x10, RZ ; /* 0x00000010060c7810 */ /* 0x000fca0007f3e0ff */ /*0900*/ IMAD.X R13, RZ, RZ, R7, P1 ; /* 0x000000ffff0d7224 */ /* 0x000fe200008e0607 */ /*0910*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0920*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0930*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0940*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*0950*/ LDG.E R11, [R12.64+0x4] ; /* 0x000004080c0b7981 */ /* 0x000ea4000c1e1900 */ /*0960*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0970*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0980*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0990*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*09a0*/ LDG.E R7, [R12.64+0x8] ; /* 0x000008080c077981 */ /* 0x000ea4000c1e1900 */ /*09b0*/ FSETP.GE.AND P0, PT, R0, R7, PT ; /* 0x000000070000720b */ /* 0x004fda0003f06000 */ /*09c0*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*09d0*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*09e0*/ LDG.E R7, [R12.64+0xc] ; /* 0x00000c080c077981 */ /* 0x000ea8000c1e1900 */ /*09f0*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea2000c1e1900 */ /*0a00*/ IADD3 R6, P1, R12, 0x10, RZ ; /* 0x000000100c067810 */ /* 0x000fe40007f3e0ff */ /*0a10*/ IADD3 R10, R10, -0x4, RZ ; /* 0xfffffffc0a0a7810 */ /* 0x000fe20007ffe0ff */ /*0a20*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fc6000fffe03f */ /*0a30*/ IADD3 R10, R10, -0x4, RZ ; /* 0xfffffffc0a0a7810 */ /* 0x000fe20007ffe0ff */ /*0a40*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe2000fffe03f */ /*0a50*/ FSETP.GE.AND P0, PT, R0, R7, PT ; /* 0x000000070000720b */ /* 0x004fe20003f06000 */ /*0a60*/ IMAD.X R7, RZ, RZ, R13, P1 ; /* 0x000000ffff077224 */ /* 0x000fd800008e060d */ /*0a70*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0a80*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0a90*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000362000c1e1900 */ /*0aa0*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fc80003f0e170 */ /*0ab0*/ ISETP.NE.OR P0, PT, R10, RZ, P0 ; /* 0x000000ff0a00720c */ /* 0x000fda0000705670 */ /*0ac0*/ @!P0 BRA 0xc70 ; /* 0x000001a000008947 */ /* 0x000fea0003800000 */ /*0ad0*/ LDG.E R11, [R6.64] ; /* 0x00000008060b7981 */ /* 0x000ea4000c1e1900 */ /*0ae0*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x024fda0003f06000 */ /*0af0*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0b00*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0b10*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*0b20*/ LDG.E R11, [R6.64+0x4] ; /* 0x00000408060b7981 */ /* 0x000ea4000c1e1900 */ /*0b30*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0b40*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0b50*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0b60*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*0b70*/ LDG.E R11, [R6.64+0x8] ; /* 0x00000808060b7981 */ /* 0x000ea4000c1e1900 */ /*0b80*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0b90*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0ba0*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0bb0*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000ea8000c1e1900 */ /*0bc0*/ LDG.E R11, [R6.64+0xc] ; /* 0x00000c08060b7981 */ /* 0x0006a2000c1e1900 */ /*0bd0*/ IADD3 R10, R10, -0x4, RZ ; /* 0xfffffffc0a0a7810 */ /* 0x000fe20007ffe0ff */ /*0be0*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe2000fffe03f */ /*0bf0*/ IADD3 R6, P1, R6, 0x10, RZ ; /* 0x0000001006067810 */ /* 0x008fca0007f3e0ff */ /*0c00*/ IMAD.X R7, RZ, RZ, R7, P1 ; /* 0x000000ffff077224 */ /* 0x000fe200008e0607 */ /*0c10*/ FSETP.GE.AND P0, PT, R0, R11, PT ; /* 0x0000000b0000720b */ /* 0x004fda0003f06000 */ /*0c20*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0c30*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0c40*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000362000c1e1900 */ /*0c50*/ ISETP.NE.AND P0, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fda0003f05270 */ /*0c60*/ @P0 BRA 0xad0 ; /* 0xfffffe6000000947 */ /* 0x023fea000383ffff */ /*0c70*/ ISETP.NE.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fda0003f05270 */ /*0c80*/ @!P0 BRA 0xd80 ; /* 0x000000f000008947 */ /* 0x000fea0003800000 */ /*0c90*/ UMOV UR5, 0x4 ; /* 0x0000000400057882 */ /* 0x000fe40000000000 */ /*0ca0*/ ULDC.64 UR6, c[0x0][0x160] ; /* 0x0000580000067ab9 */ /* 0x000fe40000000a00 */ /*0cb0*/ UIMAD.WIDE UR4, UR4, UR5, UR6 ; /* 0x00000005040472a5 */ /* 0x000fcc000f8e0206 */ /*0cc0*/ IMAD.U32 R7, RZ, RZ, UR5 ; /* 0x00000005ff077e24 */ /* 0x000fe4000f8e00ff */ /*0cd0*/ IMAD.U32 R6, RZ, RZ, UR4 ; /* 0x00000004ff067e24 */ /* 0x000fca000f8e00ff */ /*0ce0*/ LDG.E R7, [R6.64] ; /* 0x0000000806077981 */ /* 0x000ea2000c1e1900 */ /*0cf0*/ IADD3 R8, R8, -0x1, RZ ; /* 0xffffffff08087810 */ /* 0x000fe20007ffe0ff */ /*0d00*/ UIADD3 UR4, UP0, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fc8000ff1e03f */ /*0d10*/ UIADD3.X UR5, URZ, UR5, URZ, UP0, !UPT ; /* 0x000000053f057290 */ /* 0x000fe200087fe43f */ /*0d20*/ FSETP.GE.AND P0, PT, R0, R7, PT ; /* 0x000000070000720b */ /* 0x024fda0003f06000 */ /*0d30*/ @P0 IADD3 R9, R9, 0x1, RZ ; /* 0x0000000109090810 */ /* 0x002fca0007ffe0ff */ /*0d40*/ @P0 STG.E [R2.64], R9 ; /* 0x0000000902000986 */ /* 0x0003e8000c101908 */ /*0d50*/ @P0 LDG.E R0, [R4.64] ; /* 0x0000000804000981 */ /* 0x000362000c1e1900 */ /*0d60*/ ISETP.NE.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fda0003f05270 */ /*0d70*/ @P0 BRA 0xcc0 ; /* 0xffffff4000000947 */ /* 0x002fea000383ffff */ /*0d80*/ IADD3 R2, R9, -0x1, RZ ; /* 0xffffffff09027810 */ /* 0x003fe20007ffe0ff */ /*0d90*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fc800078e00ff */ /*0da0*/ IMAD.WIDE R2, R2, R3, c[0x0][0x168] ; /* 0x00005a0002027625 */ /* 0x000fca00078e0203 */ /*0db0*/ STG.E [R2.64], R0 ; /* 0x0000000002007986 */ /* 0x020fe2000c101908 */ /*0dc0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0dd0*/ BRA 0xdd0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0de0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0df0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e00*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e10*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e20*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e30*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e40*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e50*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e60*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0e70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <cuda.h> #include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <iostream> __global__ void RankSortKernel(float* DataIn, float* DataOut, int* rank, int size) { // Retrieve our coordinates in the block int tx = (blockIdx.x * 512) + threadIdx.x; rank[tx] = 0; if(tx < size) { for(int i=0;i<size;i++) { if(DataIn[tx]>=DataIn[i]) { rank[tx]++; } } DataOut[(rank[tx]-1)] = DataIn[tx]; } } __global__ void OddEvenSortKernel(float* Array, int size, bool Odd_Phase) { int tx = (blockIdx.x * 512) + threadIdx.x; float temp; int index = 2*tx; if(tx < (size/2)) { if(Odd_Phase == false) { if((index+1) < size) { if(Array[index]>Array[index+1]) { temp = Array[index]; Array[index] = Array[index+1]; Array[index+1] = temp; } } } else { if((index+2) < size) { if(Array[index+1]>Array[index+2]) { temp = Array[index+1]; Array[index+1] = Array[index+2]; Array[index+2] = temp; } } } } } bool RankSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value cudaError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *DataIn, *DataOut; int *rank; int bytes1 = size * sizeof(float); // Allocate memory on the device cudaMalloc((void**) &DataIn, bytes); cudaMalloc((void**) &DataOut, bytes); cudaMalloc((void**) &rank, bytes1); // Copy the host input data to the device cudaMemcpy(DataIn, InputArray, bytes, cudaMemcpyHostToDevice); // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)size/512), 1); // Launch the kernel on a size-by-size block of threads RankSortKernel<<<dimGrid, dimBlock>>>(DataIn, DataOut, rank, size); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 1: " << cudaGetErrorString(status) << std::endl; cudaFree(DataIn); cudaFree(DataOut); return false; } // Retrieve the result matrix cudaMemcpy(SortedArray, DataOut, bytes, cudaMemcpyDeviceToHost); // Free device memory cudaFree(DataIn); cudaFree(DataOut); // Success return true; } bool OddEvenSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value cudaError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *Array; bool Odd_Phase; // Allocate memory on the device cudaMalloc((void**) &Array, bytes); // Copy the host input data to the device cudaMemcpy(Array, InputArray, bytes, cudaMemcpyHostToDevice); int new_size = size/2; // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)new_size/512), 1); for(int i=0;i<size;i++) { //even phase Odd_Phase = false; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 2: " << cudaGetErrorString(status) << std::endl; cudaFree(Array); return false; } //odd phase Odd_Phase = true; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 3: " << cudaGetErrorString(status) << std::endl; cudaFree(Array); return false; } } // Retrieve the result matrix cudaMemcpy(SortedArray, Array, bytes, cudaMemcpyDeviceToHost); // Free device memory cudaFree(Array); // Success return true; }
.file "tmpxft_00171d9a_00000000-6_SortingAlgorithmsGPU.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3673: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3673: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii .type _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii, @function _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii: .LFB3695: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movl %ecx, 4(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 4(%rsp), %rax movq %rax, 120(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 136(%rsp), %rax subq %fs:40, %rax jne .L8 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z14RankSortKernelPfS_Pii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE3695: .size _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii, .-_Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii .globl _Z14RankSortKernelPfS_Pii .type _Z14RankSortKernelPfS_Pii, @function _Z14RankSortKernelPfS_Pii: .LFB3696: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3696: .size _Z14RankSortKernelPfS_Pii, .-_Z14RankSortKernelPfS_Pii .section .rodata.str1.1,"aMS",@progbits,1 .LC4: .string "Kernel failed 1: " .text .globl _Z11RankSortGPUPfS_i .type _Z11RankSortGPUPfS_i, @function _Z11RankSortGPUPfS_i: .LFB3669: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $72, %rsp .cfi_def_cfa_offset 112 movq %rdi, %r13 movq %rsi, %r12 movl %edx, %ebp movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax leal 0(,%rdx,4), %ebx movslq %ebx, %rbx leaq 8(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT leaq 16(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT leaq 24(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT movl $1, %ecx movq %rbx, %rdx movq %r13, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $512, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) pxor %xmm0, %xmm0 cvtsi2ssl %ebp, %xmm0 mulss .LC0(%rip), %xmm0 movaps %xmm0, %xmm3 movss .LC5(%rip), %xmm2 movaps %xmm0, %xmm1 andps %xmm2, %xmm1 movss .LC1(%rip), %xmm4 ucomiss %xmm1, %xmm4 jbe .L12 cvttss2sil %xmm0, %eax pxor %xmm1, %xmm1 cvtsi2ssl %eax, %xmm1 cmpnless %xmm1, %xmm3 movss .LC3(%rip), %xmm4 andps %xmm4, %xmm3 addss %xmm1, %xmm3 andnps %xmm0, %xmm2 orps %xmm2, %xmm3 .L12: cvttss2sil %xmm3, %eax movl %eax, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl 40(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 32(%rsp), %rdx movq 44(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L24 .L13: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %ebp testl %eax, %eax jne .L25 movl $2, %ecx movq %rbx, %rdx movq 16(%rsp), %rsi movq %r12, %rdi call cudaMemcpy@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movl $1, %eax .L11: movq 56(%rsp), %rdx subq %fs:40, %rdx jne .L26 addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L24: .cfi_restore_state movl %ebp, %ecx movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii jmp .L13 .L25: movl $17, %edx leaq .LC4(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl %ebp, %edi call cudaGetErrorString@PLT movq %rax, %rbx testq %rax, %rax je .L27 movq %rax, %rdi call strlen@PLT movq %rax, %rdx movq %rbx, %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .L16: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rip), %rdx movq 240(%rdx,%rax), %rbx testq %rbx, %rbx je .L28 cmpb $0, 56(%rbx) je .L19 movzbl 67(%rbx), %esi .L20: movsbl %sil, %esi leaq _ZSt4cout(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movl $0, %eax jmp .L11 .L27: leaq _ZSt4cout(%rip), %rdi movq _ZSt4cout(%rip), %rax addq -24(%rax), %rdi movl 32(%rdi), %esi orl $1, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L16 .L28: movq 56(%rsp), %rax subq %fs:40, %rax jne .L29 call _ZSt16__throw_bad_castv@PLT .L29: call __stack_chk_fail@PLT .L19: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L20 .L26: call __stack_chk_fail@PLT .cfi_endproc .LFE3669: .size _Z11RankSortGPUPfS_i, .-_Z11RankSortGPUPfS_i .globl _Z39__device_stub__Z17OddEvenSortKernelPfibPfib .type _Z39__device_stub__Z17OddEvenSortKernelPfibPfib, @function _Z39__device_stub__Z17OddEvenSortKernelPfibPfib: .LFB3697: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movl %esi, 4(%rsp) movb %dl, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) movq %rsp, %rax movq %rax, 96(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L34 .L30: movq 104(%rsp), %rax subq %fs:40, %rax jne .L35 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L34: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z17OddEvenSortKernelPfib(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L30 .L35: call __stack_chk_fail@PLT .cfi_endproc .LFE3697: .size _Z39__device_stub__Z17OddEvenSortKernelPfibPfib, .-_Z39__device_stub__Z17OddEvenSortKernelPfibPfib .globl _Z17OddEvenSortKernelPfib .type _Z17OddEvenSortKernelPfib, @function _Z17OddEvenSortKernelPfib: .LFB3698: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movzbl %dl, %edx call _Z39__device_stub__Z17OddEvenSortKernelPfibPfib addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3698: .size _Z17OddEvenSortKernelPfib, .-_Z17OddEvenSortKernelPfib .section .rodata.str1.1 .LC6: .string "Kernel failed 2: " .LC7: .string "Kernel failed 3: " .text .globl _Z14OddEvenSortGPUPfS_i .type _Z14OddEvenSortGPUPfS_i, @function _Z14OddEvenSortGPUPfS_i: .LFB3670: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $48, %rsp .cfi_def_cfa_offset 96 movq %rdi, %rbx movq %rsi, %r14 movl %edx, %r12d movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax leal 0(,%rdx,4), %r13d movslq %r13d, %r13 leaq 8(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r13, %rdx movq %rbx, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $512, 16(%rsp) movl $1, 20(%rsp) movl $1, 24(%rsp) movl %r12d, %eax shrl $31, %eax addl %r12d, %eax sarl %eax pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss .LC0(%rip), %xmm0 movaps %xmm0, %xmm3 movss .LC5(%rip), %xmm2 movaps %xmm0, %xmm1 andps %xmm2, %xmm1 movss .LC1(%rip), %xmm4 ucomiss %xmm1, %xmm4 jbe .L39 cvttss2sil %xmm0, %eax pxor %xmm1, %xmm1 cvtsi2ssl %eax, %xmm1 cmpnless %xmm1, %xmm3 movss .LC3(%rip), %xmm4 andps %xmm4, %xmm3 addss %xmm1, %xmm3 andnps %xmm0, %xmm2 orps %xmm2, %xmm3 .L39: cvttss2sil %xmm3, %eax movl %eax, 28(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) testl %r12d, %r12d jle .L40 movl $0, %ebp jmp .L58 .L66: movl $0, %edx movl %r12d, %esi movq 8(%rsp), %rdi call _Z39__device_stub__Z17OddEvenSortKernelPfibPfib jmp .L41 .L67: movl $17, %edx leaq .LC6(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl %ebx, %edi call cudaGetErrorString@PLT movq %rax, %rbx testq %rax, %rax je .L62 movq %rax, %rdi call strlen@PLT movq %rax, %rdx movq %rbx, %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .L44: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rip), %rdx movq 240(%rdx,%rax), %rbx testq %rbx, %rbx je .L63 cmpb $0, 56(%rbx) je .L47 movzbl 67(%rbx), %esi .L48: movsbl %sil, %esi leaq _ZSt4cout(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movq 8(%rsp), %rdi call cudaFree@PLT movl $0, %eax jmp .L38 .L62: leaq _ZSt4cout(%rip), %rdi movq _ZSt4cout(%rip), %rax addq -24(%rax), %rdi movl 32(%rdi), %esi orl $1, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L44 .L63: movq 40(%rsp), %rax subq %fs:40, %rax jne .L64 call _ZSt16__throw_bad_castv@PLT .L64: call __stack_chk_fail@PLT .L47: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L48 .L50: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %ebx testl %eax, %eax jne .L65 addl $1, %ebp cmpl %ebp, %r12d je .L40 .L58: movl 24(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 16(%rsp), %rdx movq 28(%rsp), %rdi movl 36(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L66 .L41: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %ebx testl %eax, %eax jne .L67 movl 24(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 16(%rsp), %rdx movq 28(%rsp), %rdi movl 36(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax jne .L50 movl $1, %edx movl %r12d, %esi movq 8(%rsp), %rdi call _Z39__device_stub__Z17OddEvenSortKernelPfibPfib jmp .L50 .L65: movl $17, %edx leaq .LC7(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl %ebx, %edi call cudaGetErrorString@PLT movq %rax, %rbx testq %rax, %rax je .L68 movq %rax, %rdi call strlen@PLT movq %rax, %rdx movq %rbx, %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .L53: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rip), %rdx movq 240(%rdx,%rax), %rbx testq %rbx, %rbx je .L69 cmpb $0, 56(%rbx) je .L56 movzbl 67(%rbx), %esi .L57: movsbl %sil, %esi leaq _ZSt4cout(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movq 8(%rsp), %rdi call cudaFree@PLT movl $0, %eax jmp .L38 .L68: leaq _ZSt4cout(%rip), %rdi movq _ZSt4cout(%rip), %rax addq -24(%rax), %rdi movl 32(%rdi), %esi orl $1, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L53 .L69: movq 40(%rsp), %rax subq %fs:40, %rax jne .L70 call _ZSt16__throw_bad_castv@PLT .L70: call __stack_chk_fail@PLT .L56: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L57 .L40: movl $2, %ecx movq %r13, %rdx movq 8(%rsp), %rsi movq %r14, %rdi call cudaMemcpy@PLT movq 8(%rsp), %rdi call cudaFree@PLT movl $1, %eax .L38: movq 40(%rsp), %rdx subq %fs:40, %rdx jne .L71 addq $48, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L71: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE3670: .size _Z14OddEvenSortGPUPfS_i, .-_Z14OddEvenSortGPUPfS_i .section .rodata.str1.1 .LC8: .string "_Z17OddEvenSortKernelPfib" .LC9: .string "_Z14RankSortKernelPfS_Pii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3700: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC8(%rip), %rdx movq %rdx, %rcx leaq _Z17OddEvenSortKernelPfib(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC9(%rip), %rdx movq %rdx, %rcx leaq _Z14RankSortKernelPfS_Pii(%rip), %rsi movq %rbx, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3700: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC0: .long 989855744 .align 4 .LC1: .long 1258291200 .align 4 .LC3: .long 1065353216 .align 4 .LC5: .long 2147483647 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <cuda.h> #include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <iostream> __global__ void RankSortKernel(float* DataIn, float* DataOut, int* rank, int size) { // Retrieve our coordinates in the block int tx = (blockIdx.x * 512) + threadIdx.x; rank[tx] = 0; if(tx < size) { for(int i=0;i<size;i++) { if(DataIn[tx]>=DataIn[i]) { rank[tx]++; } } DataOut[(rank[tx]-1)] = DataIn[tx]; } } __global__ void OddEvenSortKernel(float* Array, int size, bool Odd_Phase) { int tx = (blockIdx.x * 512) + threadIdx.x; float temp; int index = 2*tx; if(tx < (size/2)) { if(Odd_Phase == false) { if((index+1) < size) { if(Array[index]>Array[index+1]) { temp = Array[index]; Array[index] = Array[index+1]; Array[index+1] = temp; } } } else { if((index+2) < size) { if(Array[index+1]>Array[index+2]) { temp = Array[index+1]; Array[index+1] = Array[index+2]; Array[index+2] = temp; } } } } } bool RankSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value cudaError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *DataIn, *DataOut; int *rank; int bytes1 = size * sizeof(float); // Allocate memory on the device cudaMalloc((void**) &DataIn, bytes); cudaMalloc((void**) &DataOut, bytes); cudaMalloc((void**) &rank, bytes1); // Copy the host input data to the device cudaMemcpy(DataIn, InputArray, bytes, cudaMemcpyHostToDevice); // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)size/512), 1); // Launch the kernel on a size-by-size block of threads RankSortKernel<<<dimGrid, dimBlock>>>(DataIn, DataOut, rank, size); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 1: " << cudaGetErrorString(status) << std::endl; cudaFree(DataIn); cudaFree(DataOut); return false; } // Retrieve the result matrix cudaMemcpy(SortedArray, DataOut, bytes, cudaMemcpyDeviceToHost); // Free device memory cudaFree(DataIn); cudaFree(DataOut); // Success return true; } bool OddEvenSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value cudaError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *Array; bool Odd_Phase; // Allocate memory on the device cudaMalloc((void**) &Array, bytes); // Copy the host input data to the device cudaMemcpy(Array, InputArray, bytes, cudaMemcpyHostToDevice); int new_size = size/2; // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)new_size/512), 1); for(int i=0;i<size;i++) { //even phase Odd_Phase = false; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 2: " << cudaGetErrorString(status) << std::endl; cudaFree(Array); return false; } //odd phase Odd_Phase = true; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion cudaThreadSynchronize(); // Check for errors status = cudaGetLastError(); if (status != cudaSuccess) { std::cout << "Kernel failed 3: " << cudaGetErrorString(status) << std::endl; cudaFree(Array); return false; } } // Retrieve the result matrix cudaMemcpy(SortedArray, Array, bytes, cudaMemcpyDeviceToHost); // Free device memory cudaFree(Array); // Success return true; }
#include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> #include <iostream> __global__ void RankSortKernel(float* DataIn, float* DataOut, int* rank, int size) { // Retrieve our coordinates in the block int tx = (blockIdx.x * 512) + threadIdx.x; rank[tx] = 0; if(tx < size) { for(int i=0;i<size;i++) { if(DataIn[tx]>=DataIn[i]) { rank[tx]++; } } DataOut[(rank[tx]-1)] = DataIn[tx]; } } __global__ void OddEvenSortKernel(float* Array, int size, bool Odd_Phase) { int tx = (blockIdx.x * 512) + threadIdx.x; float temp; int index = 2*tx; if(tx < (size/2)) { if(Odd_Phase == false) { if((index+1) < size) { if(Array[index]>Array[index+1]) { temp = Array[index]; Array[index] = Array[index+1]; Array[index+1] = temp; } } } else { if((index+2) < size) { if(Array[index+1]>Array[index+2]) { temp = Array[index+1]; Array[index+1] = Array[index+2]; Array[index+2] = temp; } } } } } bool RankSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value hipError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *DataIn, *DataOut; int *rank; int bytes1 = size * sizeof(float); // Allocate memory on the device hipMalloc((void**) &DataIn, bytes); hipMalloc((void**) &DataOut, bytes); hipMalloc((void**) &rank, bytes1); // Copy the host input data to the device hipMemcpy(DataIn, InputArray, bytes, hipMemcpyHostToDevice); // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)size/512), 1); // Launch the kernel on a size-by-size block of threads RankSortKernel<<<dimGrid, dimBlock>>>(DataIn, DataOut, rank, size); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 1: " << hipGetErrorString(status) << std::endl; hipFree(DataIn); hipFree(DataOut); return false; } // Retrieve the result matrix hipMemcpy(SortedArray, DataOut, bytes, hipMemcpyDeviceToHost); // Free device memory hipFree(DataIn); hipFree(DataOut); // Success return true; } bool OddEvenSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value hipError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *Array; bool Odd_Phase; // Allocate memory on the device hipMalloc((void**) &Array, bytes); // Copy the host input data to the device hipMemcpy(Array, InputArray, bytes, hipMemcpyHostToDevice); int new_size = size/2; // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)new_size/512), 1); for(int i=0;i<size;i++) { //even phase Odd_Phase = false; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 2: " << hipGetErrorString(status) << std::endl; hipFree(Array); return false; } //odd phase Odd_Phase = true; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 3: " << hipGetErrorString(status) << std::endl; hipFree(Array); return false; } } // Retrieve the result matrix hipMemcpy(SortedArray, Array, bytes, hipMemcpyDeviceToHost); // Free device memory hipFree(Array); // Success return true; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> #include <iostream> __global__ void RankSortKernel(float* DataIn, float* DataOut, int* rank, int size) { // Retrieve our coordinates in the block int tx = (blockIdx.x * 512) + threadIdx.x; rank[tx] = 0; if(tx < size) { for(int i=0;i<size;i++) { if(DataIn[tx]>=DataIn[i]) { rank[tx]++; } } DataOut[(rank[tx]-1)] = DataIn[tx]; } } __global__ void OddEvenSortKernel(float* Array, int size, bool Odd_Phase) { int tx = (blockIdx.x * 512) + threadIdx.x; float temp; int index = 2*tx; if(tx < (size/2)) { if(Odd_Phase == false) { if((index+1) < size) { if(Array[index]>Array[index+1]) { temp = Array[index]; Array[index] = Array[index+1]; Array[index+1] = temp; } } } else { if((index+2) < size) { if(Array[index+1]>Array[index+2]) { temp = Array[index+1]; Array[index+1] = Array[index+2]; Array[index+2] = temp; } } } } } bool RankSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value hipError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *DataIn, *DataOut; int *rank; int bytes1 = size * sizeof(float); // Allocate memory on the device hipMalloc((void**) &DataIn, bytes); hipMalloc((void**) &DataOut, bytes); hipMalloc((void**) &rank, bytes1); // Copy the host input data to the device hipMemcpy(DataIn, InputArray, bytes, hipMemcpyHostToDevice); // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)size/512), 1); // Launch the kernel on a size-by-size block of threads RankSortKernel<<<dimGrid, dimBlock>>>(DataIn, DataOut, rank, size); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 1: " << hipGetErrorString(status) << std::endl; hipFree(DataIn); hipFree(DataOut); return false; } // Retrieve the result matrix hipMemcpy(SortedArray, DataOut, bytes, hipMemcpyDeviceToHost); // Free device memory hipFree(DataIn); hipFree(DataOut); // Success return true; } bool OddEvenSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value hipError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *Array; bool Odd_Phase; // Allocate memory on the device hipMalloc((void**) &Array, bytes); // Copy the host input data to the device hipMemcpy(Array, InputArray, bytes, hipMemcpyHostToDevice); int new_size = size/2; // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)new_size/512), 1); for(int i=0;i<size;i++) { //even phase Odd_Phase = false; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 2: " << hipGetErrorString(status) << std::endl; hipFree(Array); return false; } //odd phase Odd_Phase = true; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 3: " << hipGetErrorString(status) << std::endl; hipFree(Array); return false; } } // Retrieve the result matrix hipMemcpy(SortedArray, Array, bytes, hipMemcpyDeviceToHost); // Free device memory hipFree(Array); // Success return true; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z14RankSortKernelPfS_Pii .globl _Z14RankSortKernelPfS_Pii .p2align 8 .type _Z14RankSortKernelPfS_Pii,@function _Z14RankSortKernelPfS_Pii: s_clause 0x1 s_load_b64 s[2:3], s[0:1], 0x10 s_load_b32 s6, s[0:1], 0x18 v_lshl_add_u32 v0, s15, 9, v0 v_mov_b32_e32 v4, 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[2:3], 2, v[0:1] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v2, vcc_lo, s2, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo s_mov_b32 s2, exec_lo global_store_b32 v[2:3], v4, off v_cmpx_gt_i32_e64 s6, v0 s_cbranch_execz .LBB0_7 s_load_b64 s[2:3], s[0:1], 0x0 s_cmp_lt_i32 s6, 1 s_cbranch_scc1 .LBB0_6 v_lshlrev_b64 v[4:5], 2, v[0:1] s_waitcnt lgkmcnt(0) s_mov_b64 s[4:5], s[2:3] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v4, vcc_lo, s2, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off s_branch .LBB0_4 .p2align 6 .LBB0_3: s_or_b32 exec_lo, exec_lo, s7 s_add_i32 s6, s6, -1 s_add_u32 s4, s4, 4 s_addc_u32 s5, s5, 0 s_cmp_eq_u32 s6, 0 s_cbranch_scc1 .LBB0_6 .LBB0_4: s_load_b32 s7, s[4:5], 0x0 s_waitcnt vmcnt(0) lgkmcnt(0) v_cmp_le_f32_e32 vcc_lo, s7, v4 s_and_saveexec_b32 s7, vcc_lo s_cbranch_execz .LBB0_3 global_load_b32 v5, v[2:3], off s_waitcnt vmcnt(0) v_add_nc_u32_e32 v5, 1, v5 global_store_b32 v[2:3], v5, off s_branch .LBB0_3 .LBB0_6: global_load_b32 v2, v[2:3], off v_lshlrev_b64 v[0:1], 2, v[0:1] s_load_b64 s[0:1], s[0:1], 0x8 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo global_load_b32 v4, v[0:1], off s_waitcnt vmcnt(1) v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[0:1], 2, v[2:3] v_add_co_u32 v0, vcc_lo, s0, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) global_store_b32 v[0:1], v4, off offset:-4 .LBB0_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z14RankSortKernelPfS_Pii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 28 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 6 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z14RankSortKernelPfS_Pii, .Lfunc_end0-_Z14RankSortKernelPfS_Pii .section .AMDGPU.csdata,"",@progbits .text .protected _Z17OddEvenSortKernelPfib .globl _Z17OddEvenSortKernelPfib .p2align 8 .type _Z17OddEvenSortKernelPfib,@function _Z17OddEvenSortKernelPfib: s_load_b32 s2, s[0:1], 0x8 v_lshl_add_u32 v0, s15, 9, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s3, s2, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s3, s2, s3 s_ashr_i32 s3, s3, 1 s_delay_alu instid0(SALU_CYCLE_1) v_cmp_gt_i32_e32 vcc_lo, s3, v0 s_and_saveexec_b32 s3, vcc_lo s_cbranch_execz .LBB1_10 s_clause 0x1 s_load_b32 s3, s[0:1], 0xc s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 1, v0 s_waitcnt lgkmcnt(0) s_bitcmp1_b32 s3, 0 s_cselect_b32 s3, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 vcc_lo, exec_lo, s3 s_mov_b32 s3, -1 s_cbranch_vccnz .LBB1_6 v_or_b32_e32 v2, 1, v0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e64 s2, v2 s_cbranch_execz .LBB1_5 v_ashrrev_i32_e32 v1, 31, v0 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[4:5], 2, v[0:1] v_lshlrev_b64 v[6:7], 2, v[2:3] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v1, vcc_lo, s0, v4 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v5, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v3, vcc_lo, s0, v6 v_add_co_ci_u32_e32 v4, vcc_lo, s1, v7, vcc_lo s_clause 0x1 global_load_b32 v5, v[1:2], off global_load_b32 v6, v[3:4], off s_waitcnt vmcnt(0) v_cmp_gt_f32_e32 vcc_lo, v5, v6 s_and_b32 exec_lo, exec_lo, vcc_lo s_clause 0x1 global_store_b32 v[1:2], v6, off global_store_b32 v[3:4], v5, off .LBB1_5: s_or_b32 exec_lo, exec_lo, s3 s_mov_b32 s3, 0 .LBB1_6: s_delay_alu instid0(SALU_CYCLE_1) s_and_not1_b32 vcc_lo, exec_lo, s3 s_cbranch_vccnz .LBB1_10 v_add_nc_u32_e32 v1, 2, v0 s_delay_alu instid0(VALU_DEP_1) v_cmp_gt_i32_e32 vcc_lo, s2, v1 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB1_10 v_or_b32_e32 v3, 1, v0 v_ashrrev_i32_e32 v2, 31, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[5:6], 2, v[1:2] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[3:4], 2, v[3:4] v_add_co_u32 v0, vcc_lo, s0, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_ci_u32_e32 v1, vcc_lo, s1, v4, vcc_lo v_add_co_u32 v2, vcc_lo, s0, v5 v_add_co_ci_u32_e32 v3, vcc_lo, s1, v6, vcc_lo s_clause 0x1 global_load_b32 v4, v[0:1], off global_load_b32 v5, v[2:3], off s_waitcnt vmcnt(0) v_cmp_gt_f32_e32 vcc_lo, v4, v5 s_and_b32 exec_lo, exec_lo, vcc_lo s_clause 0x1 global_store_b32 v[0:1], v5, off global_store_b32 v[2:3], v4, off .LBB1_10: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z17OddEvenSortKernelPfib .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 16 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z17OddEvenSortKernelPfib, .Lfunc_end1-_Z17OddEvenSortKernelPfib .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 28 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14RankSortKernelPfS_Pii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14RankSortKernelPfS_Pii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 6 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .offset: 8 .size: 4 .value_kind: by_value - .offset: 12 .size: 1 .value_kind: by_value .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 16 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z17OddEvenSortKernelPfib .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z17OddEvenSortKernelPfib.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> #include <iostream> __global__ void RankSortKernel(float* DataIn, float* DataOut, int* rank, int size) { // Retrieve our coordinates in the block int tx = (blockIdx.x * 512) + threadIdx.x; rank[tx] = 0; if(tx < size) { for(int i=0;i<size;i++) { if(DataIn[tx]>=DataIn[i]) { rank[tx]++; } } DataOut[(rank[tx]-1)] = DataIn[tx]; } } __global__ void OddEvenSortKernel(float* Array, int size, bool Odd_Phase) { int tx = (blockIdx.x * 512) + threadIdx.x; float temp; int index = 2*tx; if(tx < (size/2)) { if(Odd_Phase == false) { if((index+1) < size) { if(Array[index]>Array[index+1]) { temp = Array[index]; Array[index] = Array[index+1]; Array[index+1] = temp; } } } else { if((index+2) < size) { if(Array[index+1]>Array[index+2]) { temp = Array[index+1]; Array[index+1] = Array[index+2]; Array[index+2] = temp; } } } } } bool RankSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value hipError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *DataIn, *DataOut; int *rank; int bytes1 = size * sizeof(float); // Allocate memory on the device hipMalloc((void**) &DataIn, bytes); hipMalloc((void**) &DataOut, bytes); hipMalloc((void**) &rank, bytes1); // Copy the host input data to the device hipMemcpy(DataIn, InputArray, bytes, hipMemcpyHostToDevice); // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)size/512), 1); // Launch the kernel on a size-by-size block of threads RankSortKernel<<<dimGrid, dimBlock>>>(DataIn, DataOut, rank, size); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 1: " << hipGetErrorString(status) << std::endl; hipFree(DataIn); hipFree(DataOut); return false; } // Retrieve the result matrix hipMemcpy(SortedArray, DataOut, bytes, hipMemcpyDeviceToHost); // Free device memory hipFree(DataIn); hipFree(DataOut); // Success return true; } bool OddEvenSortGPU( float* InputArray, float* SortedArray, int size) { int blocksize, gridsize; // Error return value hipError_t status; // Number of bytes int bytes = size * sizeof(float); // Pointers to the device arrays float *Array; bool Odd_Phase; // Allocate memory on the device hipMalloc((void**) &Array, bytes); // Copy the host input data to the device hipMemcpy(Array, InputArray, bytes, hipMemcpyHostToDevice); int new_size = size/2; // Specify the size of the grid and the size of the block dim3 dimBlock(512, 1); dim3 dimGrid((int)ceil((float)new_size/512), 1); for(int i=0;i<size;i++) { //even phase Odd_Phase = false; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 2: " << hipGetErrorString(status) << std::endl; hipFree(Array); return false; } //odd phase Odd_Phase = true; // Launch the kernel on a size-by-size block of threads OddEvenSortKernel<<<dimGrid, dimBlock>>>(Array, size, Odd_Phase); // Wait for completion hipDeviceSynchronize(); // Check for errors status = hipGetLastError(); if (status != hipSuccess) { std::cout << "Kernel failed 3: " << hipGetErrorString(status) << std::endl; hipFree(Array); return false; } } // Retrieve the result matrix hipMemcpy(SortedArray, Array, bytes, hipMemcpyDeviceToHost); // Free device memory hipFree(Array); // Success return true; }
.text .file "SortingAlgorithmsGPU.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z29__device_stub__RankSortKernelPfS_Pii # -- Begin function _Z29__device_stub__RankSortKernelPfS_Pii .p2align 4, 0x90 .type _Z29__device_stub__RankSortKernelPfS_Pii,@function _Z29__device_stub__RankSortKernelPfS_Pii: # @_Z29__device_stub__RankSortKernelPfS_Pii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) movl %ecx, 4(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 4(%rsp), %rax movq %rax, 104(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z14RankSortKernelPfS_Pii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end0: .size _Z29__device_stub__RankSortKernelPfS_Pii, .Lfunc_end0-_Z29__device_stub__RankSortKernelPfS_Pii .cfi_endproc # -- End function .globl _Z32__device_stub__OddEvenSortKernelPfib # -- Begin function _Z32__device_stub__OddEvenSortKernelPfib .p2align 4, 0x90 .type _Z32__device_stub__OddEvenSortKernelPfib,@function _Z32__device_stub__OddEvenSortKernelPfib: # @_Z32__device_stub__OddEvenSortKernelPfib .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movl %esi, 4(%rsp) movb %dl, 3(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 4(%rsp), %rax movq %rax, 72(%rsp) leaq 3(%rsp), %rax movq %rax, 80(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z17OddEvenSortKernelPfib, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end1: .size _Z32__device_stub__OddEvenSortKernelPfib, .Lfunc_end1-_Z32__device_stub__OddEvenSortKernelPfib .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z11RankSortGPUPfS_i .LCPI2_0: .long 0x3b000000 # float 0.001953125 .text .globl _Z11RankSortGPUPfS_i .p2align 4, 0x90 .type _Z11RankSortGPUPfS_i,@function _Z11RankSortGPUPfS_i: # @_Z11RankSortGPUPfS_i .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r12 .cfi_def_cfa_offset 40 pushq %rbx .cfi_def_cfa_offset 48 subq $144, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -48 .cfi_offset %r12, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %edx, %r15d movq %rsi, %rbx movq %rdi, %r12 leal (,%r15,4), %eax movslq %eax, %r14 leaq 8(%rsp), %rdi movq %r14, %rsi callq hipMalloc leaq 16(%rsp), %rdi movq %r14, %rsi callq hipMalloc leaq 32(%rsp), %rdi movq %r14, %rsi callq hipMalloc movq 8(%rsp), %rdi movq %r12, %rsi movq %r14, %rdx movl $1, %ecx callq hipMemcpy cvtsi2ss %r15d, %xmm0 mulss .LCPI2_0(%rip), %xmm0 callq ceilf@PLT cvttss2si %xmm0, %edi movabsq $4294967296, %rdx # imm = 0x100000000 orq %rdx, %rdi orq $512, %rdx # imm = 0x200 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_2 # %bb.1: movq 8(%rsp), %rax movq 16(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movq %rdx, 88(%rsp) movl %r15d, 28(%rsp) leaq 104(%rsp), %rax movq %rax, 112(%rsp) leaq 96(%rsp), %rax movq %rax, 120(%rsp) leaq 88(%rsp), %rax movq %rax, 128(%rsp) leaq 28(%rsp), %rax movq %rax, 136(%rsp) leaq 72(%rsp), %rdi leaq 56(%rsp), %rsi leaq 48(%rsp), %rdx leaq 40(%rsp), %rcx callq __hipPopCallConfiguration movq 72(%rsp), %rsi movl 80(%rsp), %edx movq 56(%rsp), %rcx movl 64(%rsp), %r8d leaq 112(%rsp), %r9 movl $_Z14RankSortKernelPfS_Pii, %edi pushq 40(%rsp) .cfi_adjust_cfa_offset 8 pushq 56(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_2: callq hipDeviceSynchronize callq hipGetLastError movl %eax, %ebp testl %eax, %eax je .LBB2_11 # %bb.3: movl $_ZSt4cout, %edi movl $.L.str, %esi movl $17, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl %ebp, %edi callq hipGetErrorString testq %rax, %rax je .LBB2_4 # %bb.5: movq %rax, %rdi movq %rax, %rbx callq strlen movl $_ZSt4cout, %edi movq %rbx, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l jmp .LBB2_6 .LBB2_11: movq 16(%rsp), %rsi movq %rbx, %rdi movq %r14, %rdx movl $2, %ecx callq hipMemcpy jmp .LBB2_12 .LBB2_4: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rax), %rdi movl _ZSt4cout+32(%rax), %esi orl $1, %esi callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LBB2_6: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB2_13 # %bb.7: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%rbx) je .LBB2_9 # %bb.8: movzbl 67(%rbx), %eax jmp .LBB2_10 .LBB2_9: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB2_10: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv .LBB2_12: movq 8(%rsp), %rdi callq hipFree testl %ebp, %ebp sete %bl movq 16(%rsp), %rdi callq hipFree movl %ebx, %eax addq $144, %rsp .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB2_13: .cfi_def_cfa_offset 192 callq _ZSt16__throw_bad_castv .Lfunc_end2: .size _Z11RankSortGPUPfS_i, .Lfunc_end2-_Z11RankSortGPUPfS_i .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z14OddEvenSortGPUPfS_i .LCPI3_0: .long 0x3b000000 # float 0.001953125 .text .globl _Z14OddEvenSortGPUPfS_i .p2align 4, 0x90 .type _Z14OddEvenSortGPUPfS_i,@function _Z14OddEvenSortGPUPfS_i: # @_Z14OddEvenSortGPUPfS_i .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $136, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %edx, %r12d movq %rsi, 120(%rsp) # 8-byte Spill movq %rdi, %rbx leal (,%r12,4), %eax movslq %eax, %r15 leaq 16(%rsp), %rdi movq %r15, %rsi callq hipMalloc movq 16(%rsp), %rdi movl $1, %r14d movq %rbx, %rsi movq %r15, 112(%rsp) # 8-byte Spill movq %r15, %rdx movl $1, %ecx callq hipMemcpy movl %r12d, %eax shrl $31, %eax addl %r12d, %eax sarl %eax cvtsi2ss %eax, %xmm0 mulss .LCPI3_0(%rip), %xmm0 callq ceilf@PLT testl %r12d, %r12d setle %bl jle .LBB3_9 # %bb.1: # %.lr.ph cvttss2si %xmm0, %eax movabsq $4294967808, %r15 # imm = 0x100000200 leaq (%rax,%r15), %rbp addq $-512, %rbp # imm = 0xFE00 movl %r12d, %eax negl %eax movq %rax, 128(%rsp) # 8-byte Spill .p2align 4, 0x90 .LBB3_2: # =>This Inner Loop Header: Depth=1 movq %rbp, %rdi movl $1, %esi movq %r15, %r13 movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_4 # %bb.3: # in Loop: Header=BB3_2 Depth=1 movq 16(%rsp), %rax movq %rax, 72(%rsp) movl %r12d, 12(%rsp) movb $0, 11(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 11(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d movl $_Z17OddEvenSortKernelPfib, %edi leaq 80(%rsp), %r9 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB3_4: # in Loop: Header=BB3_2 Depth=1 callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB3_10 # %bb.5: # in Loop: Header=BB3_2 Depth=1 movq %rbp, %rdi movl $1, %esi movq %r13, %r15 movq %r13, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_7 # %bb.6: # in Loop: Header=BB3_2 Depth=1 movq 16(%rsp), %rax movq %rax, 72(%rsp) movl %r12d, 12(%rsp) movb $1, 11(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 11(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d movl $_Z17OddEvenSortKernelPfib, %edi leaq 80(%rsp), %r9 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB3_7: # in Loop: Header=BB3_2 Depth=1 callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB3_12 # %bb.8: # in Loop: Header=BB3_2 Depth=1 cmpl %r12d, %r14d setge %bl movq 128(%rsp), %rax # 8-byte Reload addl %r14d, %eax incl %eax movl %r14d, %ecx incl %ecx movl %ecx, %r14d cmpl $1, %eax jne .LBB3_2 .LBB3_9: # %.critedge movq 16(%rsp), %rsi movq 120(%rsp), %rdi # 8-byte Reload movq 112(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy jmp .LBB3_24 .LBB3_10: movl %eax, %r15d movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $17, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl %r15d, %edi callq hipGetErrorString testq %rax, %rax je .LBB3_14 # %bb.11: movq %rax, %rdi movq %rax, %r14 callq strlen movl $_ZSt4cout, %edi movq %r14, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l jmp .LBB3_15 .LBB3_12: movl $_ZSt4cout, %edi movl $.L.str.2, %esi movl $17, %edx movl %eax, %ebp callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl %ebp, %edi callq hipGetErrorString testq %rax, %rax je .LBB3_18 # %bb.13: movq %rax, %rdi movq %rax, %r14 callq strlen movl $_ZSt4cout, %edi movq %r14, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l jmp .LBB3_19 .LBB3_14: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rax), %rdi movl _ZSt4cout+32(%rax), %esi orl $1, %esi callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LBB3_15: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %r14 testq %r14, %r14 je .LBB3_25 # %bb.16: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%r14) je .LBB3_22 .LBB3_17: movzbl 67(%r14), %eax jmp .LBB3_23 .LBB3_18: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rax), %rdi movl _ZSt4cout+32(%rax), %esi orl $1, %esi callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LBB3_19: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit49 movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %r14 testq %r14, %r14 je .LBB3_25 # %bb.20: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i51 cmpb $0, 56(%r14) jne .LBB3_17 .LBB3_22: movq %r14, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r14), %rax movq %r14, %rdi movl $10, %esi callq *48(%rax) .LBB3_23: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv .LBB3_24: movq 16(%rsp), %rdi callq hipFree andb $1, %bl movl %ebx, %eax addq $136, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB3_25: .cfi_def_cfa_offset 192 callq _ZSt16__throw_bad_castv .Lfunc_end3: .size _Z14OddEvenSortGPUPfS_i, .Lfunc_end3-_Z14OddEvenSortGPUPfS_i .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB4_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB4_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z14RankSortKernelPfS_Pii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z17OddEvenSortKernelPfib, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end4: .size __hip_module_ctor, .Lfunc_end4-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB5_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB5_2: retq .Lfunc_end5: .size __hip_module_dtor, .Lfunc_end5-__hip_module_dtor .cfi_endproc # -- End function .type _Z14RankSortKernelPfS_Pii,@object # @_Z14RankSortKernelPfS_Pii .section .rodata,"a",@progbits .globl _Z14RankSortKernelPfS_Pii .p2align 3, 0x0 _Z14RankSortKernelPfS_Pii: .quad _Z29__device_stub__RankSortKernelPfS_Pii .size _Z14RankSortKernelPfS_Pii, 8 .type _Z17OddEvenSortKernelPfib,@object # @_Z17OddEvenSortKernelPfib .globl _Z17OddEvenSortKernelPfib .p2align 3, 0x0 _Z17OddEvenSortKernelPfib: .quad _Z32__device_stub__OddEvenSortKernelPfib .size _Z17OddEvenSortKernelPfib, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Kernel failed 1: " .size .L.str, 18 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Kernel failed 2: " .size .L.str.1, 18 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Kernel failed 3: " .size .L.str.2, 18 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z14RankSortKernelPfS_Pii" .size .L__unnamed_1, 26 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z17OddEvenSortKernelPfib" .size .L__unnamed_2, 26 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z29__device_stub__RankSortKernelPfS_Pii .addrsig_sym _Z32__device_stub__OddEvenSortKernelPfib .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14RankSortKernelPfS_Pii .addrsig_sym _Z17OddEvenSortKernelPfib .addrsig_sym _ZSt4cout .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00171d9a_00000000-6_SortingAlgorithmsGPU.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3673: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3673: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii .type _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii, @function _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii: .LFB3695: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movl %ecx, 4(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 4(%rsp), %rax movq %rax, 120(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 136(%rsp), %rax subq %fs:40, %rax jne .L8 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z14RankSortKernelPfS_Pii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE3695: .size _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii, .-_Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii .globl _Z14RankSortKernelPfS_Pii .type _Z14RankSortKernelPfS_Pii, @function _Z14RankSortKernelPfS_Pii: .LFB3696: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3696: .size _Z14RankSortKernelPfS_Pii, .-_Z14RankSortKernelPfS_Pii .section .rodata.str1.1,"aMS",@progbits,1 .LC4: .string "Kernel failed 1: " .text .globl _Z11RankSortGPUPfS_i .type _Z11RankSortGPUPfS_i, @function _Z11RankSortGPUPfS_i: .LFB3669: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $72, %rsp .cfi_def_cfa_offset 112 movq %rdi, %r13 movq %rsi, %r12 movl %edx, %ebp movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax leal 0(,%rdx,4), %ebx movslq %ebx, %rbx leaq 8(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT leaq 16(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT leaq 24(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT movl $1, %ecx movq %rbx, %rdx movq %r13, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $512, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) pxor %xmm0, %xmm0 cvtsi2ssl %ebp, %xmm0 mulss .LC0(%rip), %xmm0 movaps %xmm0, %xmm3 movss .LC5(%rip), %xmm2 movaps %xmm0, %xmm1 andps %xmm2, %xmm1 movss .LC1(%rip), %xmm4 ucomiss %xmm1, %xmm4 jbe .L12 cvttss2sil %xmm0, %eax pxor %xmm1, %xmm1 cvtsi2ssl %eax, %xmm1 cmpnless %xmm1, %xmm3 movss .LC3(%rip), %xmm4 andps %xmm4, %xmm3 addss %xmm1, %xmm3 andnps %xmm0, %xmm2 orps %xmm2, %xmm3 .L12: cvttss2sil %xmm3, %eax movl %eax, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl 40(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 32(%rsp), %rdx movq 44(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L24 .L13: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %ebp testl %eax, %eax jne .L25 movl $2, %ecx movq %rbx, %rdx movq 16(%rsp), %rsi movq %r12, %rdi call cudaMemcpy@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movl $1, %eax .L11: movq 56(%rsp), %rdx subq %fs:40, %rdx jne .L26 addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L24: .cfi_restore_state movl %ebp, %ecx movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z39__device_stub__Z14RankSortKernelPfS_PiiPfS_Pii jmp .L13 .L25: movl $17, %edx leaq .LC4(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl %ebp, %edi call cudaGetErrorString@PLT movq %rax, %rbx testq %rax, %rax je .L27 movq %rax, %rdi call strlen@PLT movq %rax, %rdx movq %rbx, %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .L16: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rip), %rdx movq 240(%rdx,%rax), %rbx testq %rbx, %rbx je .L28 cmpb $0, 56(%rbx) je .L19 movzbl 67(%rbx), %esi .L20: movsbl %sil, %esi leaq _ZSt4cout(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movl $0, %eax jmp .L11 .L27: leaq _ZSt4cout(%rip), %rdi movq _ZSt4cout(%rip), %rax addq -24(%rax), %rdi movl 32(%rdi), %esi orl $1, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L16 .L28: movq 56(%rsp), %rax subq %fs:40, %rax jne .L29 call _ZSt16__throw_bad_castv@PLT .L29: call __stack_chk_fail@PLT .L19: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L20 .L26: call __stack_chk_fail@PLT .cfi_endproc .LFE3669: .size _Z11RankSortGPUPfS_i, .-_Z11RankSortGPUPfS_i .globl _Z39__device_stub__Z17OddEvenSortKernelPfibPfib .type _Z39__device_stub__Z17OddEvenSortKernelPfibPfib, @function _Z39__device_stub__Z17OddEvenSortKernelPfibPfib: .LFB3697: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movl %esi, 4(%rsp) movb %dl, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) movq %rsp, %rax movq %rax, 96(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L34 .L30: movq 104(%rsp), %rax subq %fs:40, %rax jne .L35 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L34: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z17OddEvenSortKernelPfib(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L30 .L35: call __stack_chk_fail@PLT .cfi_endproc .LFE3697: .size _Z39__device_stub__Z17OddEvenSortKernelPfibPfib, .-_Z39__device_stub__Z17OddEvenSortKernelPfibPfib .globl _Z17OddEvenSortKernelPfib .type _Z17OddEvenSortKernelPfib, @function _Z17OddEvenSortKernelPfib: .LFB3698: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movzbl %dl, %edx call _Z39__device_stub__Z17OddEvenSortKernelPfibPfib addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3698: .size _Z17OddEvenSortKernelPfib, .-_Z17OddEvenSortKernelPfib .section .rodata.str1.1 .LC6: .string "Kernel failed 2: " .LC7: .string "Kernel failed 3: " .text .globl _Z14OddEvenSortGPUPfS_i .type _Z14OddEvenSortGPUPfS_i, @function _Z14OddEvenSortGPUPfS_i: .LFB3670: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $48, %rsp .cfi_def_cfa_offset 96 movq %rdi, %rbx movq %rsi, %r14 movl %edx, %r12d movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax leal 0(,%rdx,4), %r13d movslq %r13d, %r13 leaq 8(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r13, %rdx movq %rbx, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $512, 16(%rsp) movl $1, 20(%rsp) movl $1, 24(%rsp) movl %r12d, %eax shrl $31, %eax addl %r12d, %eax sarl %eax pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss .LC0(%rip), %xmm0 movaps %xmm0, %xmm3 movss .LC5(%rip), %xmm2 movaps %xmm0, %xmm1 andps %xmm2, %xmm1 movss .LC1(%rip), %xmm4 ucomiss %xmm1, %xmm4 jbe .L39 cvttss2sil %xmm0, %eax pxor %xmm1, %xmm1 cvtsi2ssl %eax, %xmm1 cmpnless %xmm1, %xmm3 movss .LC3(%rip), %xmm4 andps %xmm4, %xmm3 addss %xmm1, %xmm3 andnps %xmm0, %xmm2 orps %xmm2, %xmm3 .L39: cvttss2sil %xmm3, %eax movl %eax, 28(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) testl %r12d, %r12d jle .L40 movl $0, %ebp jmp .L58 .L66: movl $0, %edx movl %r12d, %esi movq 8(%rsp), %rdi call _Z39__device_stub__Z17OddEvenSortKernelPfibPfib jmp .L41 .L67: movl $17, %edx leaq .LC6(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl %ebx, %edi call cudaGetErrorString@PLT movq %rax, %rbx testq %rax, %rax je .L62 movq %rax, %rdi call strlen@PLT movq %rax, %rdx movq %rbx, %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .L44: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rip), %rdx movq 240(%rdx,%rax), %rbx testq %rbx, %rbx je .L63 cmpb $0, 56(%rbx) je .L47 movzbl 67(%rbx), %esi .L48: movsbl %sil, %esi leaq _ZSt4cout(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movq 8(%rsp), %rdi call cudaFree@PLT movl $0, %eax jmp .L38 .L62: leaq _ZSt4cout(%rip), %rdi movq _ZSt4cout(%rip), %rax addq -24(%rax), %rdi movl 32(%rdi), %esi orl $1, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L44 .L63: movq 40(%rsp), %rax subq %fs:40, %rax jne .L64 call _ZSt16__throw_bad_castv@PLT .L64: call __stack_chk_fail@PLT .L47: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L48 .L50: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %ebx testl %eax, %eax jne .L65 addl $1, %ebp cmpl %ebp, %r12d je .L40 .L58: movl 24(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 16(%rsp), %rdx movq 28(%rsp), %rdi movl 36(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L66 .L41: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %ebx testl %eax, %eax jne .L67 movl 24(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 16(%rsp), %rdx movq 28(%rsp), %rdi movl 36(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax jne .L50 movl $1, %edx movl %r12d, %esi movq 8(%rsp), %rdi call _Z39__device_stub__Z17OddEvenSortKernelPfibPfib jmp .L50 .L65: movl $17, %edx leaq .LC7(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl %ebx, %edi call cudaGetErrorString@PLT movq %rax, %rbx testq %rax, %rax je .L68 movq %rax, %rdi call strlen@PLT movq %rax, %rdx movq %rbx, %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .L53: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rip), %rdx movq 240(%rdx,%rax), %rbx testq %rbx, %rbx je .L69 cmpb $0, 56(%rbx) je .L56 movzbl 67(%rbx), %esi .L57: movsbl %sil, %esi leaq _ZSt4cout(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movq 8(%rsp), %rdi call cudaFree@PLT movl $0, %eax jmp .L38 .L68: leaq _ZSt4cout(%rip), %rdi movq _ZSt4cout(%rip), %rax addq -24(%rax), %rdi movl 32(%rdi), %esi orl $1, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L53 .L69: movq 40(%rsp), %rax subq %fs:40, %rax jne .L70 call _ZSt16__throw_bad_castv@PLT .L70: call __stack_chk_fail@PLT .L56: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L57 .L40: movl $2, %ecx movq %r13, %rdx movq 8(%rsp), %rsi movq %r14, %rdi call cudaMemcpy@PLT movq 8(%rsp), %rdi call cudaFree@PLT movl $1, %eax .L38: movq 40(%rsp), %rdx subq %fs:40, %rdx jne .L71 addq $48, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L71: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE3670: .size _Z14OddEvenSortGPUPfS_i, .-_Z14OddEvenSortGPUPfS_i .section .rodata.str1.1 .LC8: .string "_Z17OddEvenSortKernelPfib" .LC9: .string "_Z14RankSortKernelPfS_Pii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3700: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC8(%rip), %rdx movq %rdx, %rcx leaq _Z17OddEvenSortKernelPfib(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC9(%rip), %rdx movq %rdx, %rcx leaq _Z14RankSortKernelPfS_Pii(%rip), %rsi movq %rbx, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3700: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC0: .long 989855744 .align 4 .LC1: .long 1258291200 .align 4 .LC3: .long 1065353216 .align 4 .LC5: .long 2147483647 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "SortingAlgorithmsGPU.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z29__device_stub__RankSortKernelPfS_Pii # -- Begin function _Z29__device_stub__RankSortKernelPfS_Pii .p2align 4, 0x90 .type _Z29__device_stub__RankSortKernelPfS_Pii,@function _Z29__device_stub__RankSortKernelPfS_Pii: # @_Z29__device_stub__RankSortKernelPfS_Pii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) movl %ecx, 4(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 4(%rsp), %rax movq %rax, 104(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z14RankSortKernelPfS_Pii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end0: .size _Z29__device_stub__RankSortKernelPfS_Pii, .Lfunc_end0-_Z29__device_stub__RankSortKernelPfS_Pii .cfi_endproc # -- End function .globl _Z32__device_stub__OddEvenSortKernelPfib # -- Begin function _Z32__device_stub__OddEvenSortKernelPfib .p2align 4, 0x90 .type _Z32__device_stub__OddEvenSortKernelPfib,@function _Z32__device_stub__OddEvenSortKernelPfib: # @_Z32__device_stub__OddEvenSortKernelPfib .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movl %esi, 4(%rsp) movb %dl, 3(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 4(%rsp), %rax movq %rax, 72(%rsp) leaq 3(%rsp), %rax movq %rax, 80(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z17OddEvenSortKernelPfib, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end1: .size _Z32__device_stub__OddEvenSortKernelPfib, .Lfunc_end1-_Z32__device_stub__OddEvenSortKernelPfib .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z11RankSortGPUPfS_i .LCPI2_0: .long 0x3b000000 # float 0.001953125 .text .globl _Z11RankSortGPUPfS_i .p2align 4, 0x90 .type _Z11RankSortGPUPfS_i,@function _Z11RankSortGPUPfS_i: # @_Z11RankSortGPUPfS_i .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r12 .cfi_def_cfa_offset 40 pushq %rbx .cfi_def_cfa_offset 48 subq $144, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -48 .cfi_offset %r12, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %edx, %r15d movq %rsi, %rbx movq %rdi, %r12 leal (,%r15,4), %eax movslq %eax, %r14 leaq 8(%rsp), %rdi movq %r14, %rsi callq hipMalloc leaq 16(%rsp), %rdi movq %r14, %rsi callq hipMalloc leaq 32(%rsp), %rdi movq %r14, %rsi callq hipMalloc movq 8(%rsp), %rdi movq %r12, %rsi movq %r14, %rdx movl $1, %ecx callq hipMemcpy cvtsi2ss %r15d, %xmm0 mulss .LCPI2_0(%rip), %xmm0 callq ceilf@PLT cvttss2si %xmm0, %edi movabsq $4294967296, %rdx # imm = 0x100000000 orq %rdx, %rdi orq $512, %rdx # imm = 0x200 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_2 # %bb.1: movq 8(%rsp), %rax movq 16(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movq %rdx, 88(%rsp) movl %r15d, 28(%rsp) leaq 104(%rsp), %rax movq %rax, 112(%rsp) leaq 96(%rsp), %rax movq %rax, 120(%rsp) leaq 88(%rsp), %rax movq %rax, 128(%rsp) leaq 28(%rsp), %rax movq %rax, 136(%rsp) leaq 72(%rsp), %rdi leaq 56(%rsp), %rsi leaq 48(%rsp), %rdx leaq 40(%rsp), %rcx callq __hipPopCallConfiguration movq 72(%rsp), %rsi movl 80(%rsp), %edx movq 56(%rsp), %rcx movl 64(%rsp), %r8d leaq 112(%rsp), %r9 movl $_Z14RankSortKernelPfS_Pii, %edi pushq 40(%rsp) .cfi_adjust_cfa_offset 8 pushq 56(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_2: callq hipDeviceSynchronize callq hipGetLastError movl %eax, %ebp testl %eax, %eax je .LBB2_11 # %bb.3: movl $_ZSt4cout, %edi movl $.L.str, %esi movl $17, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl %ebp, %edi callq hipGetErrorString testq %rax, %rax je .LBB2_4 # %bb.5: movq %rax, %rdi movq %rax, %rbx callq strlen movl $_ZSt4cout, %edi movq %rbx, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l jmp .LBB2_6 .LBB2_11: movq 16(%rsp), %rsi movq %rbx, %rdi movq %r14, %rdx movl $2, %ecx callq hipMemcpy jmp .LBB2_12 .LBB2_4: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rax), %rdi movl _ZSt4cout+32(%rax), %esi orl $1, %esi callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LBB2_6: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %rbx testq %rbx, %rbx je .LBB2_13 # %bb.7: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%rbx) je .LBB2_9 # %bb.8: movzbl 67(%rbx), %eax jmp .LBB2_10 .LBB2_9: movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%rbx), %rax movq %rbx, %rdi movl $10, %esi callq *48(%rax) .LBB2_10: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv .LBB2_12: movq 8(%rsp), %rdi callq hipFree testl %ebp, %ebp sete %bl movq 16(%rsp), %rdi callq hipFree movl %ebx, %eax addq $144, %rsp .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB2_13: .cfi_def_cfa_offset 192 callq _ZSt16__throw_bad_castv .Lfunc_end2: .size _Z11RankSortGPUPfS_i, .Lfunc_end2-_Z11RankSortGPUPfS_i .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z14OddEvenSortGPUPfS_i .LCPI3_0: .long 0x3b000000 # float 0.001953125 .text .globl _Z14OddEvenSortGPUPfS_i .p2align 4, 0x90 .type _Z14OddEvenSortGPUPfS_i,@function _Z14OddEvenSortGPUPfS_i: # @_Z14OddEvenSortGPUPfS_i .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $136, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %edx, %r12d movq %rsi, 120(%rsp) # 8-byte Spill movq %rdi, %rbx leal (,%r12,4), %eax movslq %eax, %r15 leaq 16(%rsp), %rdi movq %r15, %rsi callq hipMalloc movq 16(%rsp), %rdi movl $1, %r14d movq %rbx, %rsi movq %r15, 112(%rsp) # 8-byte Spill movq %r15, %rdx movl $1, %ecx callq hipMemcpy movl %r12d, %eax shrl $31, %eax addl %r12d, %eax sarl %eax cvtsi2ss %eax, %xmm0 mulss .LCPI3_0(%rip), %xmm0 callq ceilf@PLT testl %r12d, %r12d setle %bl jle .LBB3_9 # %bb.1: # %.lr.ph cvttss2si %xmm0, %eax movabsq $4294967808, %r15 # imm = 0x100000200 leaq (%rax,%r15), %rbp addq $-512, %rbp # imm = 0xFE00 movl %r12d, %eax negl %eax movq %rax, 128(%rsp) # 8-byte Spill .p2align 4, 0x90 .LBB3_2: # =>This Inner Loop Header: Depth=1 movq %rbp, %rdi movl $1, %esi movq %r15, %r13 movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_4 # %bb.3: # in Loop: Header=BB3_2 Depth=1 movq 16(%rsp), %rax movq %rax, 72(%rsp) movl %r12d, 12(%rsp) movb $0, 11(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 11(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d movl $_Z17OddEvenSortKernelPfib, %edi leaq 80(%rsp), %r9 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB3_4: # in Loop: Header=BB3_2 Depth=1 callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB3_10 # %bb.5: # in Loop: Header=BB3_2 Depth=1 movq %rbp, %rdi movl $1, %esi movq %r13, %r15 movq %r13, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_7 # %bb.6: # in Loop: Header=BB3_2 Depth=1 movq 16(%rsp), %rax movq %rax, 72(%rsp) movl %r12d, 12(%rsp) movb $1, 11(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 11(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d movl $_Z17OddEvenSortKernelPfib, %edi leaq 80(%rsp), %r9 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB3_7: # in Loop: Header=BB3_2 Depth=1 callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB3_12 # %bb.8: # in Loop: Header=BB3_2 Depth=1 cmpl %r12d, %r14d setge %bl movq 128(%rsp), %rax # 8-byte Reload addl %r14d, %eax incl %eax movl %r14d, %ecx incl %ecx movl %ecx, %r14d cmpl $1, %eax jne .LBB3_2 .LBB3_9: # %.critedge movq 16(%rsp), %rsi movq 120(%rsp), %rdi # 8-byte Reload movq 112(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy jmp .LBB3_24 .LBB3_10: movl %eax, %r15d movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $17, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl %r15d, %edi callq hipGetErrorString testq %rax, %rax je .LBB3_14 # %bb.11: movq %rax, %rdi movq %rax, %r14 callq strlen movl $_ZSt4cout, %edi movq %r14, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l jmp .LBB3_15 .LBB3_12: movl $_ZSt4cout, %edi movl $.L.str.2, %esi movl $17, %edx movl %eax, %ebp callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl %ebp, %edi callq hipGetErrorString testq %rax, %rax je .LBB3_18 # %bb.13: movq %rax, %rdi movq %rax, %r14 callq strlen movl $_ZSt4cout, %edi movq %r14, %rsi movq %rax, %rdx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l jmp .LBB3_19 .LBB3_14: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rax), %rdi movl _ZSt4cout+32(%rax), %esi orl $1, %esi callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LBB3_15: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %r14 testq %r14, %r14 je .LBB3_25 # %bb.16: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%r14) je .LBB3_22 .LBB3_17: movzbl 67(%r14), %eax jmp .LBB3_23 .LBB3_18: movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax leaq _ZSt4cout(%rax), %rdi movl _ZSt4cout+32(%rax), %esi orl $1, %esi callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .LBB3_19: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit49 movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %r14 testq %r14, %r14 je .LBB3_25 # %bb.20: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i51 cmpb $0, 56(%r14) jne .LBB3_17 .LBB3_22: movq %r14, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r14), %rax movq %r14, %rdi movl $10, %esi callq *48(%rax) .LBB3_23: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv .LBB3_24: movq 16(%rsp), %rdi callq hipFree andb $1, %bl movl %ebx, %eax addq $136, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB3_25: .cfi_def_cfa_offset 192 callq _ZSt16__throw_bad_castv .Lfunc_end3: .size _Z14OddEvenSortGPUPfS_i, .Lfunc_end3-_Z14OddEvenSortGPUPfS_i .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB4_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB4_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z14RankSortKernelPfS_Pii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z17OddEvenSortKernelPfib, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end4: .size __hip_module_ctor, .Lfunc_end4-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB5_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB5_2: retq .Lfunc_end5: .size __hip_module_dtor, .Lfunc_end5-__hip_module_dtor .cfi_endproc # -- End function .type _Z14RankSortKernelPfS_Pii,@object # @_Z14RankSortKernelPfS_Pii .section .rodata,"a",@progbits .globl _Z14RankSortKernelPfS_Pii .p2align 3, 0x0 _Z14RankSortKernelPfS_Pii: .quad _Z29__device_stub__RankSortKernelPfS_Pii .size _Z14RankSortKernelPfS_Pii, 8 .type _Z17OddEvenSortKernelPfib,@object # @_Z17OddEvenSortKernelPfib .globl _Z17OddEvenSortKernelPfib .p2align 3, 0x0 _Z17OddEvenSortKernelPfib: .quad _Z32__device_stub__OddEvenSortKernelPfib .size _Z17OddEvenSortKernelPfib, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Kernel failed 1: " .size .L.str, 18 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Kernel failed 2: " .size .L.str.1, 18 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Kernel failed 3: " .size .L.str.2, 18 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z14RankSortKernelPfS_Pii" .size .L__unnamed_1, 26 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z17OddEvenSortKernelPfib" .size .L__unnamed_2, 26 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z29__device_stub__RankSortKernelPfS_Pii .addrsig_sym _Z32__device_stub__OddEvenSortKernelPfib .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14RankSortKernelPfS_Pii .addrsig_sym _Z17OddEvenSortKernelPfib .addrsig_sym _ZSt4cout .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[count], 1); c[count]=globalArray[count]; } int main(void) { int arr[20]; int count=20; int bitband[arm]={0}; for (int i = 0; i < 20; ++i) { arr[i]=i; } int *d_a,*d_c; int size = sizeof(int); cudaMalloc((void **)&d_a,size*count); cudaMalloc((void **)&d_c,size*arm); cudaMemcpy(d_a,arr,size*count,cudaMemcpyHostToDevice); add<<<1,count>>>(d_a,d_c); cudaMemcpy(bitband,d_c,size*arm,cudaMemcpyDeviceToHost); for (int i = 0; i < 20; ++i) { printf("%d\n",bitband[i]); } cudaFree(d_a); cudaFree(d_c); return 0; }
code for sm_80 Function : _Z3addPiS_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R2, SR_TID.X ; /* 0x0000000000027919 */ /* 0x000e220000002100 */ /*0020*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0040*/ IMAD.WIDE R2, R2, R3, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x001fcc00078e0203 */ /*0050*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea2000c1e1900 */ /*0060*/ BSSY B0, 0x150 ; /* 0x000000e000007945 */ /* 0x000fe20003800000 */ /*0070*/ CS2R R4, SRZ ; /* 0x0000000000047805 */ /* 0x000fe2000001ff00 */ /*0080*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x004fda0003f05270 */ /*0090*/ @!P0 BRA 0x140 ; /* 0x000000a000008947 */ /* 0x000fea0003800000 */ /*00a0*/ BSSY B1, 0x130 ; /* 0x0000008000017945 */ /* 0x000fe20003800000 */ /*00b0*/ IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff047224 */ /* 0x000fe400078e00ff */ /*00c0*/ IADD3 R0, R2.reuse, 0x1, RZ ; /* 0x0000000102007810 */ /* 0x040fe40007ffe0ff */ /*00d0*/ LEA.HI R2, R2, R2, RZ, 0x1 ; /* 0x0000000202027211 */ /* 0x000fe400078f08ff */ /*00e0*/ ISETP.GT.U32.AND P0, PT, R0, 0x2, PT ; /* 0x000000020000780c */ /* 0x000fe40003f04070 */ /*00f0*/ SHF.R.S32.HI R2, RZ, 0x1, R2 ; /* 0x00000001ff027819 */ /* 0x000fe40000011402 */ /*0100*/ IADD3 R4, R4, 0x1, RZ ; /* 0x0000000104047810 */ /* 0x000fd20007ffe0ff */ /*0110*/ @P0 BRA 0xc0 ; /* 0xffffffa000000947 */ /* 0x000fea000383ffff */ /*0120*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0130*/ SHF.R.S32.HI R5, RZ, 0x1f, R4 ; /* 0x0000001fff057819 */ /* 0x000fe40000011404 */ /*0140*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0150*/ IMAD.SHL.U32 R0, R4.reuse, 0x4, RZ ; /* 0x0000000404007824 */ /* 0x040fe200078e00ff */ /*0160*/ SHF.L.U64.HI R5, R4, 0x2, R5 ; /* 0x0000000204057819 */ /* 0x000fe20000010205 */ /*0170*/ IMAD.MOV.U32 R9, RZ, RZ, 0x1 ; /* 0x00000001ff097424 */ /* 0x000fc600078e00ff */ /*0180*/ IADD3 R2, P0, R0, c[0x4][0x0], RZ ; /* 0x0100000000027a10 */ /* 0x000fc80007f1e0ff */ /*0190*/ IADD3.X R3, R5, c[0x4][0x4], RZ, P0, !PT ; /* 0x0100010005037a10 */ /* 0x000fca00007fe4ff */ /*01a0*/ RED.E.ADD.STRONG.GPU [R2.64], R9 ; /* 0x000000090200798e */ /* 0x000fe8000c10e184 */ /*01b0*/ LDG.E R7, [R2.64] ; /* 0x0000000402077981 */ /* 0x000ea2000c1e1900 */ /*01c0*/ IADD3 R4, P0, R0, c[0x0][0x168], RZ ; /* 0x00005a0000047a10 */ /* 0x000fc80007f1e0ff */ /*01d0*/ IADD3.X R5, R5, c[0x0][0x16c], RZ, P0, !PT ; /* 0x00005b0005057a10 */ /* 0x000fca00007fe4ff */ /*01e0*/ STG.E [R4.64], R7 ; /* 0x0000000704007986 */ /* 0x004fe2000c101904 */ /*01f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0200*/ BRA 0x200; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0210*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0220*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0230*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0240*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0280*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0290*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[count], 1); c[count]=globalArray[count]; } int main(void) { int arr[20]; int count=20; int bitband[arm]={0}; for (int i = 0; i < 20; ++i) { arr[i]=i; } int *d_a,*d_c; int size = sizeof(int); cudaMalloc((void **)&d_a,size*count); cudaMalloc((void **)&d_c,size*arm); cudaMemcpy(d_a,arr,size*count,cudaMemcpyHostToDevice); add<<<1,count>>>(d_a,d_c); cudaMemcpy(bitband,d_c,size*arm,cudaMemcpyDeviceToHost); for (int i = 0; i < 20; ++i) { printf("%d\n",bitband[i]); } cudaFree(d_a); cudaFree(d_c); return 0; }
.file "tmpxft_000cb287_00000000-6_addcut.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z24__device_stub__Z3addPiS_PiS_ .type _Z24__device_stub__Z3addPiS_PiS_, @function _Z24__device_stub__Z3addPiS_PiS_: .LFB2082: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movq %rsi, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 104(%rsp), %rax subq %fs:40, %rax jne .L8 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z3addPiS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z24__device_stub__Z3addPiS_PiS_, .-_Z24__device_stub__Z3addPiS_PiS_ .globl _Z3addPiS_ .type _Z3addPiS_, @function _Z3addPiS_: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z24__device_stub__Z3addPiS_PiS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z3addPiS_, .-_Z3addPiS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %r12 .cfi_def_cfa_offset 16 .cfi_offset 12, -16 pushq %rbp .cfi_def_cfa_offset 24 .cfi_offset 6, -24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset 3, -32 subq $272, %rsp .cfi_def_cfa_offset 304 movq %fs:40, %rax movq %rax, 264(%rsp) xorl %eax, %eax leaq 128(%rsp), %rdi movl $16, %ecx rep stosq .L12: movl %eax, 48(%rsp,%rax,4) addq $1, %rax cmpq $20, %rax jne .L12 leaq 8(%rsp), %rdi movl $80, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $128, %esi call cudaMalloc@PLT leaq 48(%rsp), %rsi movl $1, %ecx movl $80, %edx movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $20, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L19 .L13: leaq 128(%rsp), %rbx movl $2, %ecx movl $128, %edx movq 16(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT leaq 208(%rsp), %r12 leaq .LC0(%rip), %rbp .L14: movl (%rbx), %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT addq $4, %rbx cmpq %r12, %rbx jne .L14 movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 264(%rsp), %rax subq %fs:40, %rax jne .L20 movl $0, %eax addq $272, %rsp .cfi_remember_state .cfi_def_cfa_offset 32 popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .L19: .cfi_restore_state movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z24__device_stub__Z3addPiS_PiS_ jmp .L13 .L20: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC1: .string "_Z3addPiS_" .LC2: .string "globalArray" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC1(%rip), %rdx movq %rdx, %rcx leaq _Z3addPiS_(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $128, %r9d movl $0, %r8d leaq .LC2(%rip), %rdx movq %rdx, %rcx leaq _ZL11globalArray(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .local _ZL11globalArray .comm _ZL11globalArray,128,32 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[count], 1); c[count]=globalArray[count]; } int main(void) { int arr[20]; int count=20; int bitband[arm]={0}; for (int i = 0; i < 20; ++i) { arr[i]=i; } int *d_a,*d_c; int size = sizeof(int); cudaMalloc((void **)&d_a,size*count); cudaMalloc((void **)&d_c,size*arm); cudaMemcpy(d_a,arr,size*count,cudaMemcpyHostToDevice); add<<<1,count>>>(d_a,d_c); cudaMemcpy(bitband,d_c,size*arm,cudaMemcpyDeviceToHost); for (int i = 0; i < 20; ++i) { printf("%d\n",bitband[i]); } cudaFree(d_a); cudaFree(d_c); return 0; }
#include <hip/hip_runtime.h> #include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[count], 1); c[count]=globalArray[count]; } int main(void) { int arr[20]; int count=20; int bitband[arm]={0}; for (int i = 0; i < 20; ++i) { arr[i]=i; } int *d_a,*d_c; int size = sizeof(int); hipMalloc((void **)&d_a,size*count); hipMalloc((void **)&d_c,size*arm); hipMemcpy(d_a,arr,size*count,hipMemcpyHostToDevice); add<<<1,count>>>(d_a,d_c); hipMemcpy(bitband,d_c,size*arm,hipMemcpyDeviceToHost); for (int i = 0; i < 20; ++i) { printf("%d\n",bitband[i]); } hipFree(d_a); hipFree(d_c); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[count], 1); c[count]=globalArray[count]; } int main(void) { int arr[20]; int count=20; int bitband[arm]={0}; for (int i = 0; i < 20; ++i) { arr[i]=i; } int *d_a,*d_c; int size = sizeof(int); hipMalloc((void **)&d_a,size*count); hipMalloc((void **)&d_c,size*arm); hipMemcpy(d_a,arr,size*count,hipMemcpyHostToDevice); add<<<1,count>>>(d_a,d_c); hipMemcpy(bitband,d_c,size*arm,hipMemcpyDeviceToHost); for (int i = 0; i < 20; ++i) { printf("%d\n",bitband[i]); } hipFree(d_a); hipFree(d_c); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z3addPiS_ .globl _Z3addPiS_ .p2align 8 .type _Z3addPiS_,@function _Z3addPiS_: s_load_b64 s[2:3], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 2, v0 s_mov_b32 s5, 0 s_mov_b32 s4, exec_lo s_waitcnt lgkmcnt(0) global_load_b32 v2, v0, s[2:3] v_mov_b32_e32 v0, 0 v_mov_b32_e32 v1, 0 s_waitcnt vmcnt(0) v_cmpx_ne_u32_e32 0, v2 s_cbranch_execz .LBB0_4 s_mov_b64 s[2:3], 0 .LBB0_2: v_lshrrev_b32_e32 v0, 31, v2 v_add_nc_u32_e32 v1, 1, v2 s_add_u32 s2, s2, 1 s_addc_u32 s3, s3, 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v0, v2, v0 v_cmp_gt_u32_e32 vcc_lo, 3, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) v_ashrrev_i32_e32 v2, 1, v0 v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3 s_or_b32 s5, vcc_lo, s5 s_and_not1_b32 exec_lo, exec_lo, s5 s_cbranch_execnz .LBB0_2 s_or_b32 exec_lo, exec_lo, s5 .LBB0_4: s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 exec_lo, exec_lo, s4 v_lshlrev_b64 v[0:1], 2, v[0:1] s_getpc_b64 s[2:3] s_add_u32 s2, s2, globalArray@rel32@lo+4 s_addc_u32 s3, s3, globalArray@rel32@hi+12 v_mov_b32_e32 v4, 1 s_load_b64 s[0:1], s[0:1], 0x8 v_add_co_u32 v2, vcc_lo, v0, s2 v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo global_atomic_add_u32 v[2:3], v4, off global_load_b32 v2, v[2:3], off s_waitcnt lgkmcnt(0) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) global_store_b32 v[0:1], v2, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z3addPiS_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 16 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 5 .amdhsa_next_free_sgpr 6 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z3addPiS_, .Lfunc_end0-_Z3addPiS_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .protected globalArray .type globalArray,@object .section .bss,"aw",@nobits .globl globalArray .p2align 4, 0x0 globalArray: .zero 128 .size globalArray, 128 .type __hip_cuid_,@object .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym globalArray .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 16 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z3addPiS_ .private_segment_fixed_size: 0 .sgpr_count: 8 .sgpr_spill_count: 0 .symbol: _Z3addPiS_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 5 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[count], 1); c[count]=globalArray[count]; } int main(void) { int arr[20]; int count=20; int bitband[arm]={0}; for (int i = 0; i < 20; ++i) { arr[i]=i; } int *d_a,*d_c; int size = sizeof(int); hipMalloc((void **)&d_a,size*count); hipMalloc((void **)&d_c,size*arm); hipMemcpy(d_a,arr,size*count,hipMemcpyHostToDevice); add<<<1,count>>>(d_a,d_c); hipMemcpy(bitband,d_c,size*arm,hipMemcpyDeviceToHost); for (int i = 0; i < 20; ++i) { printf("%d\n",bitband[i]); } hipFree(d_a); hipFree(d_c); return 0; }
.text .file "addcut.hip" .globl _Z18__device_stub__addPiS_ # -- Begin function _Z18__device_stub__addPiS_ .p2align 4, 0x90 .type _Z18__device_stub__addPiS_,@function _Z18__device_stub__addPiS_: # @_Z18__device_stub__addPiS_ .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movq %rsi, 48(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 48(%rsp), %rax movq %rax, 72(%rsp) leaq 32(%rsp), %rdi leaq 16(%rsp), %rsi leaq 8(%rsp), %rdx movq %rsp, %rcx callq __hipPopCallConfiguration movq 32(%rsp), %rsi movl 40(%rsp), %edx movq 16(%rsp), %rcx movl 24(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z3addPiS_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z18__device_stub__addPiS_, .Lfunc_end0-_Z18__device_stub__addPiS_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $304, %rsp # imm = 0x130 .cfi_def_cfa_offset 320 .cfi_offset %rbx, -16 xorps %xmm0, %xmm0 movaps %xmm0, 208(%rsp) movaps %xmm0, 192(%rsp) movaps %xmm0, 176(%rsp) movaps %xmm0, 160(%rsp) movaps %xmm0, 144(%rsp) movaps %xmm0, 128(%rsp) movaps %xmm0, 112(%rsp) movaps %xmm0, 96(%rsp) xorl %eax, %eax .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 movl %eax, 224(%rsp,%rax,4) incq %rax cmpq $20, %rax jne .LBB1_1 # %bb.2: leaq 8(%rsp), %rdi movl $80, %esi callq hipMalloc movq %rsp, %rdi movl $128, %esi callq hipMalloc movq 8(%rsp), %rdi leaq 224(%rsp), %rsi movl $80, %edx movl $1, %ecx callq hipMemcpy movabsq $4294967297, %rdi # imm = 0x100000001 leaq 19(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_4 # %bb.3: movq 8(%rsp), %rax movq (%rsp), %rcx movq %rax, 72(%rsp) movq %rcx, 64(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 48(%rsp), %rdi leaq 32(%rsp), %rsi leaq 24(%rsp), %rdx leaq 16(%rsp), %rcx callq __hipPopCallConfiguration movq 48(%rsp), %rsi movl 56(%rsp), %edx movq 32(%rsp), %rcx movl 40(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z3addPiS_, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_4: movq (%rsp), %rsi leaq 96(%rsp), %rdi movl $128, %edx movl $2, %ecx callq hipMemcpy xorl %ebx, %ebx .p2align 4, 0x90 .LBB1_5: # =>This Inner Loop Header: Depth=1 movl 96(%rsp,%rbx,4), %esi movl $.L.str, %edi xorl %eax, %eax callq printf incq %rbx cmpq $20, %rbx jne .LBB1_5 # %bb.6: movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $304, %rsp # imm = 0x130 .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z3addPiS_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $0, 8(%rsp) movl $0, (%rsp) movl $globalArray, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movl $128, %r9d movq %rbx, %rdi xorl %r8d, %r8d callq __hipRegisterVar movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type globalArray,@object # @globalArray .local globalArray .comm globalArray,128,16 .type _Z3addPiS_,@object # @_Z3addPiS_ .section .rodata,"a",@progbits .globl _Z3addPiS_ .p2align 3, 0x0 _Z3addPiS_: .quad _Z18__device_stub__addPiS_ .size _Z3addPiS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d\n" .size .L.str, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z3addPiS_" .size .L__unnamed_1, 11 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "globalArray" .size .L__unnamed_2, 12 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z18__device_stub__addPiS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym globalArray .addrsig_sym _Z3addPiS_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z3addPiS_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R2, SR_TID.X ; /* 0x0000000000027919 */ /* 0x000e220000002100 */ /*0020*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0040*/ IMAD.WIDE R2, R2, R3, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x001fcc00078e0203 */ /*0050*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea2000c1e1900 */ /*0060*/ BSSY B0, 0x150 ; /* 0x000000e000007945 */ /* 0x000fe20003800000 */ /*0070*/ CS2R R4, SRZ ; /* 0x0000000000047805 */ /* 0x000fe2000001ff00 */ /*0080*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x004fda0003f05270 */ /*0090*/ @!P0 BRA 0x140 ; /* 0x000000a000008947 */ /* 0x000fea0003800000 */ /*00a0*/ BSSY B1, 0x130 ; /* 0x0000008000017945 */ /* 0x000fe20003800000 */ /*00b0*/ IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff047224 */ /* 0x000fe400078e00ff */ /*00c0*/ IADD3 R0, R2.reuse, 0x1, RZ ; /* 0x0000000102007810 */ /* 0x040fe40007ffe0ff */ /*00d0*/ LEA.HI R2, R2, R2, RZ, 0x1 ; /* 0x0000000202027211 */ /* 0x000fe400078f08ff */ /*00e0*/ ISETP.GT.U32.AND P0, PT, R0, 0x2, PT ; /* 0x000000020000780c */ /* 0x000fe40003f04070 */ /*00f0*/ SHF.R.S32.HI R2, RZ, 0x1, R2 ; /* 0x00000001ff027819 */ /* 0x000fe40000011402 */ /*0100*/ IADD3 R4, R4, 0x1, RZ ; /* 0x0000000104047810 */ /* 0x000fd20007ffe0ff */ /*0110*/ @P0 BRA 0xc0 ; /* 0xffffffa000000947 */ /* 0x000fea000383ffff */ /*0120*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0130*/ SHF.R.S32.HI R5, RZ, 0x1f, R4 ; /* 0x0000001fff057819 */ /* 0x000fe40000011404 */ /*0140*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0150*/ IMAD.SHL.U32 R0, R4.reuse, 0x4, RZ ; /* 0x0000000404007824 */ /* 0x040fe200078e00ff */ /*0160*/ SHF.L.U64.HI R5, R4, 0x2, R5 ; /* 0x0000000204057819 */ /* 0x000fe20000010205 */ /*0170*/ IMAD.MOV.U32 R9, RZ, RZ, 0x1 ; /* 0x00000001ff097424 */ /* 0x000fc600078e00ff */ /*0180*/ IADD3 R2, P0, R0, c[0x4][0x0], RZ ; /* 0x0100000000027a10 */ /* 0x000fc80007f1e0ff */ /*0190*/ IADD3.X R3, R5, c[0x4][0x4], RZ, P0, !PT ; /* 0x0100010005037a10 */ /* 0x000fca00007fe4ff */ /*01a0*/ RED.E.ADD.STRONG.GPU [R2.64], R9 ; /* 0x000000090200798e */ /* 0x000fe8000c10e184 */ /*01b0*/ LDG.E R7, [R2.64] ; /* 0x0000000402077981 */ /* 0x000ea2000c1e1900 */ /*01c0*/ IADD3 R4, P0, R0, c[0x0][0x168], RZ ; /* 0x00005a0000047a10 */ /* 0x000fc80007f1e0ff */ /*01d0*/ IADD3.X R5, R5, c[0x0][0x16c], RZ, P0, !PT ; /* 0x00005b0005057a10 */ /* 0x000fca00007fe4ff */ /*01e0*/ STG.E [R4.64], R7 ; /* 0x0000000704007986 */ /* 0x004fe2000c101904 */ /*01f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0200*/ BRA 0x200; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0210*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0220*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0230*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0240*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0280*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0290*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z3addPiS_ .globl _Z3addPiS_ .p2align 8 .type _Z3addPiS_,@function _Z3addPiS_: s_load_b64 s[2:3], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 2, v0 s_mov_b32 s5, 0 s_mov_b32 s4, exec_lo s_waitcnt lgkmcnt(0) global_load_b32 v2, v0, s[2:3] v_mov_b32_e32 v0, 0 v_mov_b32_e32 v1, 0 s_waitcnt vmcnt(0) v_cmpx_ne_u32_e32 0, v2 s_cbranch_execz .LBB0_4 s_mov_b64 s[2:3], 0 .LBB0_2: v_lshrrev_b32_e32 v0, 31, v2 v_add_nc_u32_e32 v1, 1, v2 s_add_u32 s2, s2, 1 s_addc_u32 s3, s3, 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v0, v2, v0 v_cmp_gt_u32_e32 vcc_lo, 3, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) v_ashrrev_i32_e32 v2, 1, v0 v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3 s_or_b32 s5, vcc_lo, s5 s_and_not1_b32 exec_lo, exec_lo, s5 s_cbranch_execnz .LBB0_2 s_or_b32 exec_lo, exec_lo, s5 .LBB0_4: s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 exec_lo, exec_lo, s4 v_lshlrev_b64 v[0:1], 2, v[0:1] s_getpc_b64 s[2:3] s_add_u32 s2, s2, globalArray@rel32@lo+4 s_addc_u32 s3, s3, globalArray@rel32@hi+12 v_mov_b32_e32 v4, 1 s_load_b64 s[0:1], s[0:1], 0x8 v_add_co_u32 v2, vcc_lo, v0, s2 v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo global_atomic_add_u32 v[2:3], v4, off global_load_b32 v2, v[2:3], off s_waitcnt lgkmcnt(0) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) global_store_b32 v[0:1], v2, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z3addPiS_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 16 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 5 .amdhsa_next_free_sgpr 6 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z3addPiS_, .Lfunc_end0-_Z3addPiS_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .protected globalArray .type globalArray,@object .section .bss,"aw",@nobits .globl globalArray .p2align 4, 0x0 globalArray: .zero 128 .size globalArray, 128 .type __hip_cuid_,@object .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym globalArray .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 16 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z3addPiS_ .private_segment_fixed_size: 0 .sgpr_count: 8 .sgpr_spill_count: 0 .symbol: _Z3addPiS_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 5 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_000cb287_00000000-6_addcut.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z24__device_stub__Z3addPiS_PiS_ .type _Z24__device_stub__Z3addPiS_PiS_, @function _Z24__device_stub__Z3addPiS_PiS_: .LFB2082: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movq %rsi, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 104(%rsp), %rax subq %fs:40, %rax jne .L8 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z3addPiS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z24__device_stub__Z3addPiS_PiS_, .-_Z24__device_stub__Z3addPiS_PiS_ .globl _Z3addPiS_ .type _Z3addPiS_, @function _Z3addPiS_: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z24__device_stub__Z3addPiS_PiS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z3addPiS_, .-_Z3addPiS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %r12 .cfi_def_cfa_offset 16 .cfi_offset 12, -16 pushq %rbp .cfi_def_cfa_offset 24 .cfi_offset 6, -24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset 3, -32 subq $272, %rsp .cfi_def_cfa_offset 304 movq %fs:40, %rax movq %rax, 264(%rsp) xorl %eax, %eax leaq 128(%rsp), %rdi movl $16, %ecx rep stosq .L12: movl %eax, 48(%rsp,%rax,4) addq $1, %rax cmpq $20, %rax jne .L12 leaq 8(%rsp), %rdi movl $80, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $128, %esi call cudaMalloc@PLT leaq 48(%rsp), %rsi movl $1, %ecx movl $80, %edx movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $20, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L19 .L13: leaq 128(%rsp), %rbx movl $2, %ecx movl $128, %edx movq 16(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT leaq 208(%rsp), %r12 leaq .LC0(%rip), %rbp .L14: movl (%rbx), %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT addq $4, %rbx cmpq %r12, %rbx jne .L14 movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 264(%rsp), %rax subq %fs:40, %rax jne .L20 movl $0, %eax addq $272, %rsp .cfi_remember_state .cfi_def_cfa_offset 32 popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .L19: .cfi_restore_state movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z24__device_stub__Z3addPiS_PiS_ jmp .L13 .L20: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC1: .string "_Z3addPiS_" .LC2: .string "globalArray" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC1(%rip), %rdx movq %rdx, %rcx leaq _Z3addPiS_(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $128, %r9d movl $0, %r8d leaq .LC2(%rip), %rdx movq %rdx, %rcx leaq _ZL11globalArray(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .local _ZL11globalArray .comm _ZL11globalArray,128,32 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "addcut.hip" .globl _Z18__device_stub__addPiS_ # -- Begin function _Z18__device_stub__addPiS_ .p2align 4, 0x90 .type _Z18__device_stub__addPiS_,@function _Z18__device_stub__addPiS_: # @_Z18__device_stub__addPiS_ .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movq %rsi, 48(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 48(%rsp), %rax movq %rax, 72(%rsp) leaq 32(%rsp), %rdi leaq 16(%rsp), %rsi leaq 8(%rsp), %rdx movq %rsp, %rcx callq __hipPopCallConfiguration movq 32(%rsp), %rsi movl 40(%rsp), %edx movq 16(%rsp), %rcx movl 24(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z3addPiS_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z18__device_stub__addPiS_, .Lfunc_end0-_Z18__device_stub__addPiS_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $304, %rsp # imm = 0x130 .cfi_def_cfa_offset 320 .cfi_offset %rbx, -16 xorps %xmm0, %xmm0 movaps %xmm0, 208(%rsp) movaps %xmm0, 192(%rsp) movaps %xmm0, 176(%rsp) movaps %xmm0, 160(%rsp) movaps %xmm0, 144(%rsp) movaps %xmm0, 128(%rsp) movaps %xmm0, 112(%rsp) movaps %xmm0, 96(%rsp) xorl %eax, %eax .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 movl %eax, 224(%rsp,%rax,4) incq %rax cmpq $20, %rax jne .LBB1_1 # %bb.2: leaq 8(%rsp), %rdi movl $80, %esi callq hipMalloc movq %rsp, %rdi movl $128, %esi callq hipMalloc movq 8(%rsp), %rdi leaq 224(%rsp), %rsi movl $80, %edx movl $1, %ecx callq hipMemcpy movabsq $4294967297, %rdi # imm = 0x100000001 leaq 19(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_4 # %bb.3: movq 8(%rsp), %rax movq (%rsp), %rcx movq %rax, 72(%rsp) movq %rcx, 64(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 48(%rsp), %rdi leaq 32(%rsp), %rsi leaq 24(%rsp), %rdx leaq 16(%rsp), %rcx callq __hipPopCallConfiguration movq 48(%rsp), %rsi movl 56(%rsp), %edx movq 32(%rsp), %rcx movl 40(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z3addPiS_, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_4: movq (%rsp), %rsi leaq 96(%rsp), %rdi movl $128, %edx movl $2, %ecx callq hipMemcpy xorl %ebx, %ebx .p2align 4, 0x90 .LBB1_5: # =>This Inner Loop Header: Depth=1 movl 96(%rsp,%rbx,4), %esi movl $.L.str, %edi xorl %eax, %eax callq printf incq %rbx cmpq $20, %rbx jne .LBB1_5 # %bb.6: movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $304, %rsp # imm = 0x130 .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z3addPiS_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $0, 8(%rsp) movl $0, (%rsp) movl $globalArray, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movl $128, %r9d movq %rbx, %rdi xorl %r8d, %r8d callq __hipRegisterVar movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type globalArray,@object # @globalArray .local globalArray .comm globalArray,128,16 .type _Z3addPiS_,@object # @_Z3addPiS_ .section .rodata,"a",@progbits .globl _Z3addPiS_ .p2align 3, 0x0 _Z3addPiS_: .quad _Z18__device_stub__addPiS_ .size _Z3addPiS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d\n" .size .L.str, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z3addPiS_" .size .L__unnamed_1, 11 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "globalArray" .size .L__unnamed_2, 12 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z18__device_stub__addPiS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym globalArray .addrsig_sym _Z3addPiS_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <stdio.h> #include <stdlib.h> //#include <cuda.h> //#include <cuda_runtime_api.h> unsigned int filter_radius; #define FILTER_LENGTH (2 * filter_radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 0.00005 //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // GPU: Row convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_rows(const float *filter, const float *input, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Rows for(k = -filterR; k <= filterR; k++){ int d = idx_x + k; if(d >= 0 && d < imageW){ sum += input[idx_y * imageW + d] * filter[filterR - k]; } } output[idx] = sum; } //////////////////////////////////////////////////////////////////////////////// // GPU: Column convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_columns(const float *filter, const float *buffer, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Columns for(k = -filterR; k <= filterR; k++){ int d = idx_y + k; if(d >= 0 && d < imageH){ sum += buffer[d * imageW + idx_x] * filter[filterR - k]; } } output[idx] = sum; } // Auxiliary function for CUDA error checking void cudaCheckForErrors(){ cudaError_t error = cudaGetLastError(); if(error != cudaSuccess){ // something's gone wrong // print out the CUDA error as a string printf("CUDA Error: %s\n", cudaGetErrorString(error)); exit(1); } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(void) { float *h_Filter, *h_Input, *h_Buffer, *h_OutputCPU; // GPU float *d_Filter, *d_Input, *d_Buffer, *d_OutputGPU, *h_OutputGPU; unsigned int imageW; unsigned int imageH; unsigned int i; printf("Enter filter radius : "); scanf("%d", &filter_radius); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (float *)malloc(FILTER_LENGTH * sizeof(float)); h_Input = (float *)malloc(imageW * imageH * sizeof(float)); h_Buffer = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputCPU = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputGPU = (float *)malloc(imageW * imageH * sizeof(float)); cudaMalloc( (void **) &d_Filter, FILTER_LENGTH * sizeof(float)); cudaMalloc( (void **) &d_Input, imageW * imageH * sizeof(float)); cudaMalloc( (void **) &d_Buffer, imageW * imageH * sizeof(float)); cudaMalloc( (void **) &d_OutputGPU, imageW * imageH * sizeof(float)); if(!h_Filter || !h_Input || !h_Buffer || !h_OutputCPU || !h_OutputGPU){ printf("error allocating memory for the host\n"); exit(1); } if(!d_Filter || !d_Input || !d_Buffer || !d_OutputGPU){ printf("Error allocating memory for the device\n"); exit(1); } srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (float)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (float)rand() / ((float)RAND_MAX / 255) + (float)rand() / (float)RAND_MAX; } cudaMemcpy(d_Filter, h_Filter, FILTER_LENGTH * sizeof(float), cudaMemcpyHostToDevice); cudaMemcpy(d_Input, h_Input, imageW * imageH * sizeof(float), cudaMemcpyHostToDevice); //////////////////////////////// CPU /////////////////////////////////////// // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, filter_radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, filter_radius); // convolution kata sthles //////////////////////////////// GPU /////////////////////////////////////// dim3 block_dim; dim3 grid_dim; if(imageW < 32){ block_dim.x = imageW; block_dim.y = imageH; grid_dim.x = 1; grid_dim.y = 1; } else{ block_dim.x = 32; block_dim.y = 32; grid_dim.x = imageW / block_dim.x; grid_dim.y = imageH / block_dim.y; } printf("GPU computation...\n"); kernel_rows<<<grid_dim, block_dim>>>(d_Filter, d_Input, d_Buffer, imageW, imageH, filter_radius); cudaDeviceSynchronize(); cudaCheckForErrors(); kernel_columns<<<grid_dim, block_dim>>>(d_Filter, d_Buffer, d_OutputGPU, imageW, imageH, filter_radius); cudaDeviceSynchronize(); cudaCheckForErrors(); cudaMemcpy(h_OutputGPU, d_OutputGPU, imageW * imageH * sizeof(float), cudaMemcpyDeviceToHost); //////////////////////// RESULT COMPARISON ///////////////////////////////// // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i = 0; i < imageH * imageW; i++){ if(ABS(h_OutputGPU[i] - h_OutputCPU[i]) >= accuracy){ printf("GPU computations are not as accurate as we want.\n"); break; } } ////////////////// CPU: free all the allocated memory ////////////////////// free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); ////////////////// GPU: free all the allocated memory ////////////////////// free(h_OutputGPU); cudaFree(d_Filter); cudaFree(d_Input); cudaFree(d_Buffer); cudaFree(d_OutputGPU); // Do a device reset just in case... Bgalte to sxolio otan ylopoihsete CUDA cudaDeviceReset(); return 0; }
.file "tmpxft_00073536_00000000-6_4a_Convolution2D.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2063: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2063: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z17convolutionRowCPUPfS_S_iii .type _Z17convolutionRowCPUPfS_S_iii, @function _Z17convolutionRowCPUPfS_S_iii: .LFB2057: .cfi_startproc endbr64 testl %r8d, %r8d jle .L15 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 movq %rdi, %rax movq %rsi, %r11 movq %rdx, %rbx movl %ecx, %r10d movl %r9d, %ebp movl %r9d, %edx negl %edx leal (%r9,%r9), %r15d negl %r15d movl $0, %ecx movl %edx, %r13d movl %r8d, -4(%rsp) movl %ecx, %edi movq %rax, %rcx jmp .L5 .L18: leal (%r9,%rax), %r12d movslq %r12d, %r12 movl %r8d, %edx subl %eax, %edx movslq %edx, %rdx movss (%r11,%r12,4), %xmm1 mulss (%rbx,%rdx,4), %xmm1 addss %xmm1, %xmm0 .L7: movss %xmm0, (%r14) addl $1, %eax cmpl %esi, %eax je .L6 .L8: testl %eax, %eax js .L7 cmpl %eax, %r10d jg .L18 jmp .L7 .L6: addl $1, %esi addl $1, %r8d movl -16(%rsp), %eax cmpl %eax, %esi je .L19 .L9: cmpl %r13d, %ebp jl .L6 leal (%rdi,%rsi), %eax cltq leaq (%rcx,%rax,4), %r14 leal (%r8,%r15), %eax pxor %xmm0, %xmm0 jmp .L8 .L19: movl -12(%rsp), %edi movl -8(%rsp), %edx .L11: addl $1, %edi addl %r10d, %edx cmpl %edi, -4(%rsp) je .L3 .L5: testl %r10d, %r10d jle .L11 leal (%rdx,%rbp), %r9d leal 1(%rbp), %esi leal (%rsi,%r10), %r12d movl %ebp, %r8d leal -1(%rdx), %r14d movl %edi, -12(%rsp) movl %r12d, -16(%rsp) movl %edx, -8(%rsp) movl %r14d, %edi jmp .L9 .L3: popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .L15: .cfi_restore 3 .cfi_restore 6 .cfi_restore 12 .cfi_restore 13 .cfi_restore 14 .cfi_restore 15 ret .cfi_endproc .LFE2057: .size _Z17convolutionRowCPUPfS_S_iii, .-_Z17convolutionRowCPUPfS_S_iii .globl _Z20convolutionColumnCPUPfS_S_iii .type _Z20convolutionColumnCPUPfS_S_iii, @function _Z20convolutionColumnCPUPfS_S_iii: .LFB2058: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 movq %rdi, -16(%rsp) testl %r8d, %r8d jle .L20 movq %rsi, %rbp movq %rdx, %r12 movl %ecx, %r10d movl %r8d, %r11d movl %r9d, %esi movl %r9d, %ebx leal 1(%r9), %r8d movl %r9d, %eax negl %eax movl %eax, -20(%rsp) movl %ecx, %eax imull %r9d, %eax negl %eax movl %eax, %edx leal (%r11,%r8), %ecx movl %r10d, %r13d movl %r9d, %r15d negl %r15d movl %ecx, -4(%rsp) jmp .L22 .L35: movl %ebx, %r9d subl %eax, %r9d movslq %r9d, %r9 movslq %edx, %rcx movss (%r12,%r9,4), %xmm1 mulss 0(%rbp,%rcx,4), %xmm1 addss %xmm1, %xmm0 .L24: movss %xmm0, (%r14) addl $1, %eax addl %r10d, %edx cmpl %r8d, %eax je .L34 .L25: testl %eax, %eax js .L24 cmpl %eax, %r11d jg .L35 jmp .L24 .L34: movl -24(%rsp), %r9d .L23: addl $1, %r9d cmpl %r13d, %r9d je .L36 .L26: cmpl %r15d, %esi jl .L23 movslq %r9d, %rax movq -16(%rsp), %rdx leaq (%rdx,%rax,4), %r14 leal (%rdi,%r9), %edx movl -20(%rsp), %eax pxor %xmm0, %xmm0 movl %r9d, -24(%rsp) jmp .L25 .L36: movl -8(%rsp), %edx .L28: addl %r10d, %r13d addl $1, %r8d addl $1, %ebx addl $1, -20(%rsp) addl %r10d, %edx movl -4(%rsp), %eax cmpl %eax, %r8d je .L20 .L22: movl %r13d, %r9d subl %r10d, %r9d movl %r10d, %r14d subl %r13d, %r14d addl %edx, %r14d testl %r10d, %r10d jle .L28 movl %edx, -8(%rsp) movl %r14d, %edi jmp .L26 .L20: popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z20convolutionColumnCPUPfS_S_iii, .-_Z20convolutionColumnCPUPfS_S_iii .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "CUDA Error: %s\n" .text .globl _Z18cudaCheckForErrorsv .type _Z18cudaCheckForErrorsv, @function _Z18cudaCheckForErrorsv: .LFB2059: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call cudaGetLastError@PLT testl %eax, %eax jne .L40 addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L40: .cfi_restore_state movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .cfi_endproc .LFE2059: .size _Z18cudaCheckForErrorsv, .-_Z18cudaCheckForErrorsv .globl _Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii .type _Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii, @function _Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii: .LFB2085: .cfi_startproc endbr64 subq $184, %rsp .cfi_def_cfa_offset 192 movq %rdi, 40(%rsp) movq %rsi, 32(%rsp) movq %rdx, 24(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) movq %fs:40, %rax movq %rax, 168(%rsp) xorl %eax, %eax leaq 40(%rsp), %rax movq %rax, 112(%rsp) leaq 32(%rsp), %rax movq %rax, 120(%rsp) leaq 24(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 16(%rsp), %rax movq %rax, 144(%rsp) leaq 12(%rsp), %rax movq %rax, 152(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) leaq 56(%rsp), %rcx leaq 48(%rsp), %rdx leaq 76(%rsp), %rsi leaq 64(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L45 .L41: movq 168(%rsp), %rax subq %fs:40, %rax jne .L46 addq $184, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L45: .cfi_restore_state pushq 56(%rsp) .cfi_def_cfa_offset 200 pushq 56(%rsp) .cfi_def_cfa_offset 208 leaq 128(%rsp), %r9 movq 92(%rsp), %rcx movl 100(%rsp), %r8d movq 80(%rsp), %rsi movl 88(%rsp), %edx leaq _Z11kernel_rowsPKfS0_Pfiii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 192 jmp .L41 .L46: call __stack_chk_fail@PLT .cfi_endproc .LFE2085: .size _Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii, .-_Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii .globl _Z11kernel_rowsPKfS0_Pfiii .type _Z11kernel_rowsPKfS0_Pfiii, @function _Z11kernel_rowsPKfS0_Pfiii: .LFB2086: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2086: .size _Z11kernel_rowsPKfS0_Pfiii, .-_Z11kernel_rowsPKfS0_Pfiii .globl _Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii .type _Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii, @function _Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii: .LFB2087: .cfi_startproc endbr64 subq $184, %rsp .cfi_def_cfa_offset 192 movq %rdi, 40(%rsp) movq %rsi, 32(%rsp) movq %rdx, 24(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) movq %fs:40, %rax movq %rax, 168(%rsp) xorl %eax, %eax leaq 40(%rsp), %rax movq %rax, 112(%rsp) leaq 32(%rsp), %rax movq %rax, 120(%rsp) leaq 24(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 16(%rsp), %rax movq %rax, 144(%rsp) leaq 12(%rsp), %rax movq %rax, 152(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) leaq 56(%rsp), %rcx leaq 48(%rsp), %rdx leaq 76(%rsp), %rsi leaq 64(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L53 .L49: movq 168(%rsp), %rax subq %fs:40, %rax jne .L54 addq $184, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L53: .cfi_restore_state pushq 56(%rsp) .cfi_def_cfa_offset 200 pushq 56(%rsp) .cfi_def_cfa_offset 208 leaq 128(%rsp), %r9 movq 92(%rsp), %rcx movl 100(%rsp), %r8d movq 80(%rsp), %rsi movl 88(%rsp), %edx leaq _Z14kernel_columnsPKfS0_Pfiii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 192 jmp .L49 .L54: call __stack_chk_fail@PLT .cfi_endproc .LFE2087: .size _Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii, .-_Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii .globl _Z14kernel_columnsPKfS0_Pfiii .type _Z14kernel_columnsPKfS0_Pfiii, @function _Z14kernel_columnsPKfS0_Pfiii: .LFB2088: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2088: .size _Z14kernel_columnsPKfS0_Pfiii, .-_Z14kernel_columnsPKfS0_Pfiii .section .rodata.str1.1 .LC2: .string "Enter filter radius : " .LC3: .string "%d" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "Enter image size. Should be a power of two and greater than %d : " .align 8 .LC5: .string "Image Width x Height = %i x %i\n\n" .align 8 .LC6: .string "Allocating and initializing host arrays...\n" .align 8 .LC7: .string "error allocating memory for the host\n" .align 8 .LC8: .string "Error allocating memory for the device\n" .section .rodata.str1.1 .LC11: .string "CPU computation...\n" .LC12: .string "GPU computation...\n" .section .rodata.str1.8 .align 8 .LC15: .string "GPU computations are not as accurate as we want.\n" .text .globl main .type main, @function main: .LFB2060: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 subq $104, %rsp .cfi_def_cfa_offset 160 movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax leaq .LC2(%rip), %rsi movl $2, %edi call __printf_chk@PLT leaq filter_radius(%rip), %rsi leaq .LC3(%rip), %rbx movq %rbx, %rdi movl $0, %eax call __isoc23_scanf@PLT movl filter_radius(%rip), %eax leal 1(%rax,%rax), %edx leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 28(%rsp), %rsi movq %rbx, %rdi movl $0, %eax call __isoc23_scanf@PLT movl 28(%rsp), %ebx movl %ebx, %ecx movl %ebx, %edx leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq .LC6(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl filter_radius(%rip), %eax leal 1(%rax,%rax), %eax salq $2, %rax movq %rax, (%rsp) movq %rax, %rdi call malloc@PLT movq %rax, %r12 movl %ebx, %ebp imull 28(%rsp), %ebp salq $2, %rbp movq %rbp, %rdi call malloc@PLT movq %rax, %r13 movq %rbp, %rdi call malloc@PLT movq %rax, 8(%rsp) movq %rbp, %rdi call malloc@PLT movq %rax, %r15 movq %rbp, %rdi call malloc@PLT movq %rax, %r14 leaq 32(%rsp), %rdi movq (%rsp), %rsi call cudaMalloc@PLT movl %ebx, %esi imull 28(%rsp), %esi salq $2, %rsi leaq 40(%rsp), %rdi call cudaMalloc@PLT movl %ebx, %esi imull 28(%rsp), %esi salq $2, %rsi leaq 48(%rsp), %rdi call cudaMalloc@PLT movl %ebx, %esi imull 28(%rsp), %esi salq $2, %rsi leaq 56(%rsp), %rdi call cudaMalloc@PLT testq %r12, %r12 je .L58 testq %r13, %r13 je .L58 cmpq $0, 8(%rsp) sete %al testq %r15, %r15 sete %dl orb %dl, %al jne .L58 testq %r14, %r14 je .L58 cmpq $0, 32(%rsp) je .L61 cmpq $0, 40(%rsp) je .L61 cmpq $0, 48(%rsp) je .L61 cmpq $0, 56(%rsp) je .L61 movl $200, %edi call srand@PLT movl $0, %ebp .L63: call rand@PLT cltd shrl $28, %edx addl %edx, %eax andl $15, %eax subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 movss %xmm0, (%r12,%rbp,4) addq $1, %rbp movl filter_radius(%rip), %eax leal 1(%rax,%rax), %eax cmpl %eax, %ebp jb .L63 movl %ebx, %eax imull 28(%rsp), %eax testl %eax, %eax je .L64 movl $0, %ebp .L65: call rand@PLT pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 divss .LC9(%rip), %xmm0 movss %xmm0, (%rsp) call rand@PLT pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss .LC10(%rip), %xmm0 addss (%rsp), %xmm0 movss %xmm0, 0(%r13,%rbp,4) addq $1, %rbp movl %ebx, %eax imull 28(%rsp), %eax cmpl %eax, %ebp jb .L65 .L64: movl filter_radius(%rip), %eax leal 1(%rax,%rax), %edx salq $2, %rdx movl $1, %ecx movq %r12, %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl %ebx, %edx imull 28(%rsp), %edx salq $2, %rdx movl $1, %ecx movq %r13, %rsi movq 40(%rsp), %rdi call cudaMemcpy@PLT leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl filter_radius(%rip), %eax movl 28(%rsp), %ebp movl %eax, (%rsp) movl %eax, %r9d movl %ebx, %r8d movl %ebp, %ecx movq %r12, %rdx movq %r13, %rsi movq 8(%rsp), %rdi call _Z17convolutionRowCPUPfS_S_iii movl (%rsp), %r9d movl %ebx, %r8d movl %ebp, %ecx movq %r12, %rdx movq 8(%rsp), %rsi movq %r15, %rdi call _Z20convolutionColumnCPUPfS_S_iii movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl %ebx, (%rsp) cmpl $31, %ebp jbe .L66 shrl $5, %ebp movl %ebp, 76(%rsp) movl %ebx, %eax shrl $5, %eax movl %eax, 80(%rsp) movl $32, (%rsp) movl $32, %ebp .L66: leaq .LC12(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl %ebp, 64(%rsp) movl (%rsp), %eax movl %eax, 68(%rsp) movl 72(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 64(%rsp), %rdx movq 76(%rsp), %rdi movl 84(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L84 .L67: call cudaDeviceSynchronize@PLT call _Z18cudaCheckForErrorsv movl 72(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 64(%rsp), %rdx movq 76(%rsp), %rdi movl 84(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L85 .L68: call cudaDeviceSynchronize@PLT call _Z18cudaCheckForErrorsv movl %ebx, %edx imull 28(%rsp), %edx salq $2, %rdx movl $2, %ecx movq 56(%rsp), %rsi movq %r14, %rdi call cudaMemcpy@PLT imull 28(%rsp), %ebx testl %ebx, %ebx je .L69 movl %ebx, %ebx salq $2, %rbx movl $0, %eax pxor %xmm2, %xmm2 movss .LC13(%rip), %xmm3 movsd .LC14(%rip), %xmm1 jmp .L74 .L58: leaq .LC7(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .L61: leaq .LC8(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .L84: movl filter_radius(%rip), %r9d movl %ebx, %r8d movl 28(%rsp), %ecx movq 48(%rsp), %rdx movq 40(%rsp), %rsi movq 32(%rsp), %rdi call _Z40__device_stub__Z11kernel_rowsPKfS0_PfiiiPKfS0_Pfiii jmp .L67 .L85: movl filter_radius(%rip), %r9d movl %ebx, %r8d movl 28(%rsp), %ecx movq 56(%rsp), %rdx movq 48(%rsp), %rsi movq 32(%rsp), %rdi call _Z43__device_stub__Z14kernel_columnsPKfS0_PfiiiPKfS0_Pfiii jmp .L68 .L70: cvtss2sd %xmm0, %xmm0 comisd %xmm1, %xmm0 jnb .L86 addq $4, %rax cmpq %rbx, %rax je .L69 .L74: movss (%r14,%rax), %xmm0 subss (%r15,%rax), %xmm0 comiss %xmm0, %xmm2 jbe .L70 xorps %xmm3, %xmm0 jmp .L70 .L86: leaq .LC15(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT .L69: movq %r15, %rdi call free@PLT movq 8(%rsp), %rdi call free@PLT movq %r13, %rdi call free@PLT movq %r12, %rdi call free@PLT movq %r14, %rdi call free@PLT movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 48(%rsp), %rdi call cudaFree@PLT movq 56(%rsp), %rdi call cudaFree@PLT call cudaDeviceReset@PLT movq 88(%rsp), %rax subq %fs:40, %rax jne .L87 movl $0, %eax addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .L87: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2060: .size main, .-main .section .rodata.str1.1 .LC16: .string "_Z14kernel_columnsPKfS0_Pfiii" .LC17: .string "_Z11kernel_rowsPKfS0_Pfiii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2090: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC16(%rip), %rdx movq %rdx, %rcx leaq _Z14kernel_columnsPKfS0_Pfiii(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC17(%rip), %rdx movq %rdx, %rcx leaq _Z11kernel_rowsPKfS0_Pfiii(%rip), %rsi movq %rbx, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2090: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .globl filter_radius .bss .align 4 .type filter_radius, @object .size filter_radius, 4 filter_radius: .zero 4 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC9: .long 1258324097 .align 4 .LC10: .long 805306368 .section .rodata.cst16,"aM",@progbits,16 .align 16 .LC13: .long -2147483648 .long 0 .long 0 .long 0 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC14: .long -350469331 .long 1057634018 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <stdio.h> #include <stdlib.h> //#include <cuda.h> //#include <cuda_runtime_api.h> unsigned int filter_radius; #define FILTER_LENGTH (2 * filter_radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 0.00005 //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // GPU: Row convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_rows(const float *filter, const float *input, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Rows for(k = -filterR; k <= filterR; k++){ int d = idx_x + k; if(d >= 0 && d < imageW){ sum += input[idx_y * imageW + d] * filter[filterR - k]; } } output[idx] = sum; } //////////////////////////////////////////////////////////////////////////////// // GPU: Column convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_columns(const float *filter, const float *buffer, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Columns for(k = -filterR; k <= filterR; k++){ int d = idx_y + k; if(d >= 0 && d < imageH){ sum += buffer[d * imageW + idx_x] * filter[filterR - k]; } } output[idx] = sum; } // Auxiliary function for CUDA error checking void cudaCheckForErrors(){ cudaError_t error = cudaGetLastError(); if(error != cudaSuccess){ // something's gone wrong // print out the CUDA error as a string printf("CUDA Error: %s\n", cudaGetErrorString(error)); exit(1); } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(void) { float *h_Filter, *h_Input, *h_Buffer, *h_OutputCPU; // GPU float *d_Filter, *d_Input, *d_Buffer, *d_OutputGPU, *h_OutputGPU; unsigned int imageW; unsigned int imageH; unsigned int i; printf("Enter filter radius : "); scanf("%d", &filter_radius); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (float *)malloc(FILTER_LENGTH * sizeof(float)); h_Input = (float *)malloc(imageW * imageH * sizeof(float)); h_Buffer = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputCPU = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputGPU = (float *)malloc(imageW * imageH * sizeof(float)); cudaMalloc( (void **) &d_Filter, FILTER_LENGTH * sizeof(float)); cudaMalloc( (void **) &d_Input, imageW * imageH * sizeof(float)); cudaMalloc( (void **) &d_Buffer, imageW * imageH * sizeof(float)); cudaMalloc( (void **) &d_OutputGPU, imageW * imageH * sizeof(float)); if(!h_Filter || !h_Input || !h_Buffer || !h_OutputCPU || !h_OutputGPU){ printf("error allocating memory for the host\n"); exit(1); } if(!d_Filter || !d_Input || !d_Buffer || !d_OutputGPU){ printf("Error allocating memory for the device\n"); exit(1); } srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (float)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (float)rand() / ((float)RAND_MAX / 255) + (float)rand() / (float)RAND_MAX; } cudaMemcpy(d_Filter, h_Filter, FILTER_LENGTH * sizeof(float), cudaMemcpyHostToDevice); cudaMemcpy(d_Input, h_Input, imageW * imageH * sizeof(float), cudaMemcpyHostToDevice); //////////////////////////////// CPU /////////////////////////////////////// // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, filter_radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, filter_radius); // convolution kata sthles //////////////////////////////// GPU /////////////////////////////////////// dim3 block_dim; dim3 grid_dim; if(imageW < 32){ block_dim.x = imageW; block_dim.y = imageH; grid_dim.x = 1; grid_dim.y = 1; } else{ block_dim.x = 32; block_dim.y = 32; grid_dim.x = imageW / block_dim.x; grid_dim.y = imageH / block_dim.y; } printf("GPU computation...\n"); kernel_rows<<<grid_dim, block_dim>>>(d_Filter, d_Input, d_Buffer, imageW, imageH, filter_radius); cudaDeviceSynchronize(); cudaCheckForErrors(); kernel_columns<<<grid_dim, block_dim>>>(d_Filter, d_Buffer, d_OutputGPU, imageW, imageH, filter_radius); cudaDeviceSynchronize(); cudaCheckForErrors(); cudaMemcpy(h_OutputGPU, d_OutputGPU, imageW * imageH * sizeof(float), cudaMemcpyDeviceToHost); //////////////////////// RESULT COMPARISON ///////////////////////////////// // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i = 0; i < imageH * imageW; i++){ if(ABS(h_OutputGPU[i] - h_OutputCPU[i]) >= accuracy){ printf("GPU computations are not as accurate as we want.\n"); break; } } ////////////////// CPU: free all the allocated memory ////////////////////// free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); ////////////////// GPU: free all the allocated memory ////////////////////// free(h_OutputGPU); cudaFree(d_Filter); cudaFree(d_Input); cudaFree(d_Buffer); cudaFree(d_OutputGPU); // Do a device reset just in case... Bgalte to sxolio otan ylopoihsete CUDA cudaDeviceReset(); return 0; }
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> //#include <cuda.h> //#include <cuda_runtime_api.h> unsigned int filter_radius; #define FILTER_LENGTH (2 * filter_radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 0.00005 //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // GPU: Row convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_rows(const float *filter, const float *input, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Rows for(k = -filterR; k <= filterR; k++){ int d = idx_x + k; if(d >= 0 && d < imageW){ sum += input[idx_y * imageW + d] * filter[filterR - k]; } } output[idx] = sum; } //////////////////////////////////////////////////////////////////////////////// // GPU: Column convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_columns(const float *filter, const float *buffer, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Columns for(k = -filterR; k <= filterR; k++){ int d = idx_y + k; if(d >= 0 && d < imageH){ sum += buffer[d * imageW + idx_x] * filter[filterR - k]; } } output[idx] = sum; } // Auxiliary function for CUDA error checking void cudaCheckForErrors(){ hipError_t error = hipGetLastError(); if(error != hipSuccess){ // something's gone wrong // print out the CUDA error as a string printf("CUDA Error: %s\n", hipGetErrorString(error)); exit(1); } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(void) { float *h_Filter, *h_Input, *h_Buffer, *h_OutputCPU; // GPU float *d_Filter, *d_Input, *d_Buffer, *d_OutputGPU, *h_OutputGPU; unsigned int imageW; unsigned int imageH; unsigned int i; printf("Enter filter radius : "); scanf("%d", &filter_radius); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (float *)malloc(FILTER_LENGTH * sizeof(float)); h_Input = (float *)malloc(imageW * imageH * sizeof(float)); h_Buffer = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputCPU = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputGPU = (float *)malloc(imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_Filter, FILTER_LENGTH * sizeof(float)); hipMalloc( (void **) &d_Input, imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_Buffer, imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_OutputGPU, imageW * imageH * sizeof(float)); if(!h_Filter || !h_Input || !h_Buffer || !h_OutputCPU || !h_OutputGPU){ printf("error allocating memory for the host\n"); exit(1); } if(!d_Filter || !d_Input || !d_Buffer || !d_OutputGPU){ printf("Error allocating memory for the device\n"); exit(1); } srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (float)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (float)rand() / ((float)RAND_MAX / 255) + (float)rand() / (float)RAND_MAX; } hipMemcpy(d_Filter, h_Filter, FILTER_LENGTH * sizeof(float), hipMemcpyHostToDevice); hipMemcpy(d_Input, h_Input, imageW * imageH * sizeof(float), hipMemcpyHostToDevice); //////////////////////////////// CPU /////////////////////////////////////// // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, filter_radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, filter_radius); // convolution kata sthles //////////////////////////////// GPU /////////////////////////////////////// dim3 block_dim; dim3 grid_dim; if(imageW < 32){ block_dim.x = imageW; block_dim.y = imageH; grid_dim.x = 1; grid_dim.y = 1; } else{ block_dim.x = 32; block_dim.y = 32; grid_dim.x = imageW / block_dim.x; grid_dim.y = imageH / block_dim.y; } printf("GPU computation...\n"); kernel_rows<<<grid_dim, block_dim>>>(d_Filter, d_Input, d_Buffer, imageW, imageH, filter_radius); hipDeviceSynchronize(); cudaCheckForErrors(); kernel_columns<<<grid_dim, block_dim>>>(d_Filter, d_Buffer, d_OutputGPU, imageW, imageH, filter_radius); hipDeviceSynchronize(); cudaCheckForErrors(); hipMemcpy(h_OutputGPU, d_OutputGPU, imageW * imageH * sizeof(float), hipMemcpyDeviceToHost); //////////////////////// RESULT COMPARISON ///////////////////////////////// // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i = 0; i < imageH * imageW; i++){ if(ABS(h_OutputGPU[i] - h_OutputCPU[i]) >= accuracy){ printf("GPU computations are not as accurate as we want.\n"); break; } } ////////////////// CPU: free all the allocated memory ////////////////////// free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); ////////////////// GPU: free all the allocated memory ////////////////////// free(h_OutputGPU); hipFree(d_Filter); hipFree(d_Input); hipFree(d_Buffer); hipFree(d_OutputGPU); // Do a device reset just in case... Bgalte to sxolio otan ylopoihsete CUDA hipDeviceReset(); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> //#include <cuda.h> //#include <cuda_runtime_api.h> unsigned int filter_radius; #define FILTER_LENGTH (2 * filter_radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 0.00005 //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // GPU: Row convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_rows(const float *filter, const float *input, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Rows for(k = -filterR; k <= filterR; k++){ int d = idx_x + k; if(d >= 0 && d < imageW){ sum += input[idx_y * imageW + d] * filter[filterR - k]; } } output[idx] = sum; } //////////////////////////////////////////////////////////////////////////////// // GPU: Column convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_columns(const float *filter, const float *buffer, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Columns for(k = -filterR; k <= filterR; k++){ int d = idx_y + k; if(d >= 0 && d < imageH){ sum += buffer[d * imageW + idx_x] * filter[filterR - k]; } } output[idx] = sum; } // Auxiliary function for CUDA error checking void cudaCheckForErrors(){ hipError_t error = hipGetLastError(); if(error != hipSuccess){ // something's gone wrong // print out the CUDA error as a string printf("CUDA Error: %s\n", hipGetErrorString(error)); exit(1); } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(void) { float *h_Filter, *h_Input, *h_Buffer, *h_OutputCPU; // GPU float *d_Filter, *d_Input, *d_Buffer, *d_OutputGPU, *h_OutputGPU; unsigned int imageW; unsigned int imageH; unsigned int i; printf("Enter filter radius : "); scanf("%d", &filter_radius); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (float *)malloc(FILTER_LENGTH * sizeof(float)); h_Input = (float *)malloc(imageW * imageH * sizeof(float)); h_Buffer = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputCPU = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputGPU = (float *)malloc(imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_Filter, FILTER_LENGTH * sizeof(float)); hipMalloc( (void **) &d_Input, imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_Buffer, imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_OutputGPU, imageW * imageH * sizeof(float)); if(!h_Filter || !h_Input || !h_Buffer || !h_OutputCPU || !h_OutputGPU){ printf("error allocating memory for the host\n"); exit(1); } if(!d_Filter || !d_Input || !d_Buffer || !d_OutputGPU){ printf("Error allocating memory for the device\n"); exit(1); } srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (float)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (float)rand() / ((float)RAND_MAX / 255) + (float)rand() / (float)RAND_MAX; } hipMemcpy(d_Filter, h_Filter, FILTER_LENGTH * sizeof(float), hipMemcpyHostToDevice); hipMemcpy(d_Input, h_Input, imageW * imageH * sizeof(float), hipMemcpyHostToDevice); //////////////////////////////// CPU /////////////////////////////////////// // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, filter_radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, filter_radius); // convolution kata sthles //////////////////////////////// GPU /////////////////////////////////////// dim3 block_dim; dim3 grid_dim; if(imageW < 32){ block_dim.x = imageW; block_dim.y = imageH; grid_dim.x = 1; grid_dim.y = 1; } else{ block_dim.x = 32; block_dim.y = 32; grid_dim.x = imageW / block_dim.x; grid_dim.y = imageH / block_dim.y; } printf("GPU computation...\n"); kernel_rows<<<grid_dim, block_dim>>>(d_Filter, d_Input, d_Buffer, imageW, imageH, filter_radius); hipDeviceSynchronize(); cudaCheckForErrors(); kernel_columns<<<grid_dim, block_dim>>>(d_Filter, d_Buffer, d_OutputGPU, imageW, imageH, filter_radius); hipDeviceSynchronize(); cudaCheckForErrors(); hipMemcpy(h_OutputGPU, d_OutputGPU, imageW * imageH * sizeof(float), hipMemcpyDeviceToHost); //////////////////////// RESULT COMPARISON ///////////////////////////////// // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i = 0; i < imageH * imageW; i++){ if(ABS(h_OutputGPU[i] - h_OutputCPU[i]) >= accuracy){ printf("GPU computations are not as accurate as we want.\n"); break; } } ////////////////// CPU: free all the allocated memory ////////////////////// free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); ////////////////// GPU: free all the allocated memory ////////////////////// free(h_OutputGPU); hipFree(d_Filter); hipFree(d_Input); hipFree(d_Buffer); hipFree(d_OutputGPU); // Do a device reset just in case... Bgalte to sxolio otan ylopoihsete CUDA hipDeviceReset(); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z11kernel_rowsPKfS0_Pfiii .globl _Z11kernel_rowsPKfS0_Pfiii .p2align 8 .type _Z11kernel_rowsPKfS0_Pfiii,@function _Z11kernel_rowsPKfS0_Pfiii: s_clause 0x2 s_load_b32 s4, s[0:1], 0x34 s_load_b32 s2, s[0:1], 0x20 s_load_b32 s3, s[0:1], 0x28 v_bfe_u32 v3, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s5, s4, 16 s_and_b32 s10, s4, 0xffff v_mad_u64_u32 v[1:2], null, s15, s5, v[3:4] v_mov_b32_e32 v2, 0 s_cmp_lt_i32 s2, 0 s_mul_i32 s14, s14, s10 s_cbranch_scc1 .LBB0_5 s_clause 0x1 s_load_b32 s11, s[0:1], 0x18 s_load_b128 s[4:7], s[0:1], 0x0 v_add_nc_u32_e32 v2, s14, v0 s_lshl_b32 s8, s2, 1 s_delay_alu instid0(VALU_DEP_1) v_subrev_nc_u32_e32 v4, s2, v2 v_mov_b32_e32 v2, 0 s_waitcnt lgkmcnt(0) v_mul_lo_u32 v3, v1, s11 s_set_inst_prefetch_distance 0x1 s_branch .LBB0_3 .p2align 6 .LBB0_2: s_or_b32 exec_lo, exec_lo, s2 v_add_nc_u32_e32 v4, 1, v4 s_add_i32 s8, s8, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s8, -1 s_cbranch_scc0 .LBB0_5 .LBB0_3: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_cmp_lt_i32_e32 vcc_lo, -1, v4 v_cmp_gt_i32_e64 s2, s11, v4 s_and_b32 s9, vcc_lo, s2 s_delay_alu instid0(SALU_CYCLE_1) s_and_saveexec_b32 s2, s9 s_cbranch_execz .LBB0_2 v_add_nc_u32_e32 v5, v3, v4 s_ashr_i32 s9, s8, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[12:13], s[8:9], 2 s_add_u32 s12, s4, s12 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v6, 31, v5 s_addc_u32 s13, s5, s13 s_load_b32 s9, s[12:13], 0x0 v_lshlrev_b64 v[5:6], 2, v[5:6] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s6, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s7, v6, vcc_lo global_load_b32 v5, v[5:6], off s_waitcnt vmcnt(0) lgkmcnt(0) v_fmac_f32_e32 v2, s9, v5 s_branch .LBB0_2 .LBB0_5: s_set_inst_prefetch_distance 0x2 s_mul_i32 s3, s3, s10 s_load_b64 s[0:1], s[0:1], 0x10 v_mul_lo_u32 v1, s3, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add3_u32 v0, s14, v0, v1 v_ashrrev_i32_e32 v1, 31, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[0:1], 2, v[0:1] s_waitcnt lgkmcnt(0) v_add_co_u32 v0, vcc_lo, s0, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_store_b32 v[0:1], v2, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z11kernel_rowsPKfS0_Pfiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 296 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 7 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z11kernel_rowsPKfS0_Pfiii, .Lfunc_end0-_Z11kernel_rowsPKfS0_Pfiii .section .AMDGPU.csdata,"",@progbits .text .protected _Z14kernel_columnsPKfS0_Pfiii .globl _Z14kernel_columnsPKfS0_Pfiii .p2align 8 .type _Z14kernel_columnsPKfS0_Pfiii,@function _Z14kernel_columnsPKfS0_Pfiii: s_clause 0x2 s_load_b32 s4, s[0:1], 0x34 s_load_b32 s2, s[0:1], 0x20 s_load_b32 s3, s[0:1], 0x28 v_mov_b32_e32 v4, 0 v_and_b32_e32 v2, 0x3ff, v0 v_bfe_u32 v3, v0, 10, 10 s_waitcnt lgkmcnt(0) s_and_b32 s12, s4, 0xffff s_lshr_b32 s4, s4, 16 s_cmp_lt_i32 s2, 0 s_mul_i32 s14, s14, s12 s_mul_i32 s15, s15, s4 s_cbranch_scc1 .LBB1_5 s_clause 0x1 s_load_b64 s[8:9], s[0:1], 0x18 s_load_b128 s[4:7], s[0:1], 0x0 v_add_nc_u32_e32 v0, s15, v3 v_mov_b32_e32 v4, 0 s_lshl_b32 s10, s2, 1 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_subrev_nc_u32_e32 v5, s2, v0 s_waitcnt lgkmcnt(0) v_mul_lo_u32 v0, s8, v5 s_delay_alu instid0(VALU_DEP_1) v_add3_u32 v0, v2, v0, s14 s_set_inst_prefetch_distance 0x1 s_branch .LBB1_3 .p2align 6 .LBB1_2: s_or_b32 exec_lo, exec_lo, s2 v_add_nc_u32_e32 v5, 1, v5 v_add_nc_u32_e32 v0, s8, v0 s_add_i32 s10, s10, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s10, -1 s_cbranch_scc0 .LBB1_5 .LBB1_3: v_cmp_lt_i32_e32 vcc_lo, -1, v5 v_cmp_gt_i32_e64 s2, s9, v5 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s11, vcc_lo, s2 s_and_saveexec_b32 s2, s11 s_cbranch_execz .LBB1_2 v_ashrrev_i32_e32 v1, 31, v0 s_ashr_i32 s11, s10, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[16:17], s[10:11], 2 s_add_u32 s16, s4, s16 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_lshlrev_b64 v[6:7], 2, v[0:1] s_addc_u32 s17, s5, s17 s_load_b32 s11, s[16:17], 0x0 v_add_co_u32 v6, vcc_lo, s6, v6 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v7, vcc_lo, s7, v7, vcc_lo global_load_b32 v1, v[6:7], off s_waitcnt vmcnt(0) lgkmcnt(0) v_fmac_f32_e32 v4, s11, v1 s_branch .LBB1_2 .LBB1_5: s_set_inst_prefetch_distance 0x2 v_add_nc_u32_e32 v0, s15, v3 s_mul_i32 s3, s3, s12 s_load_b64 s[0:1], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_lo_u32 v0, s3, v0 v_add3_u32 v0, s14, v2, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[0:1], 2, v[0:1] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_store_b32 v[0:1], v4, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z14kernel_columnsPKfS0_Pfiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 296 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 18 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z14kernel_columnsPKfS0_Pfiii, .Lfunc_end1-_Z14kernel_columnsPKfS0_Pfiii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: hidden_block_count_x - .offset: 44 .size: 4 .value_kind: hidden_block_count_y - .offset: 48 .size: 4 .value_kind: hidden_block_count_z - .offset: 52 .size: 2 .value_kind: hidden_group_size_x - .offset: 54 .size: 2 .value_kind: hidden_group_size_y - .offset: 56 .size: 2 .value_kind: hidden_group_size_z - .offset: 58 .size: 2 .value_kind: hidden_remainder_x - .offset: 60 .size: 2 .value_kind: hidden_remainder_y - .offset: 62 .size: 2 .value_kind: hidden_remainder_z - .offset: 80 .size: 8 .value_kind: hidden_global_offset_x - .offset: 88 .size: 8 .value_kind: hidden_global_offset_y - .offset: 96 .size: 8 .value_kind: hidden_global_offset_z - .offset: 104 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 296 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z11kernel_rowsPKfS0_Pfiii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z11kernel_rowsPKfS0_Pfiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 7 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: hidden_block_count_x - .offset: 44 .size: 4 .value_kind: hidden_block_count_y - .offset: 48 .size: 4 .value_kind: hidden_block_count_z - .offset: 52 .size: 2 .value_kind: hidden_group_size_x - .offset: 54 .size: 2 .value_kind: hidden_group_size_y - .offset: 56 .size: 2 .value_kind: hidden_group_size_z - .offset: 58 .size: 2 .value_kind: hidden_remainder_x - .offset: 60 .size: 2 .value_kind: hidden_remainder_y - .offset: 62 .size: 2 .value_kind: hidden_remainder_z - .offset: 80 .size: 8 .value_kind: hidden_global_offset_x - .offset: 88 .size: 8 .value_kind: hidden_global_offset_y - .offset: 96 .size: 8 .value_kind: hidden_global_offset_z - .offset: 104 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 296 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14kernel_columnsPKfS0_Pfiii .private_segment_fixed_size: 0 .sgpr_count: 20 .sgpr_spill_count: 0 .symbol: _Z14kernel_columnsPKfS0_Pfiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> //#include <cuda.h> //#include <cuda_runtime_api.h> unsigned int filter_radius; #define FILTER_LENGTH (2 * filter_radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 0.00005 //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(float *h_Dst, float *h_Src, float *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { float sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // GPU: Row convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_rows(const float *filter, const float *input, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Rows for(k = -filterR; k <= filterR; k++){ int d = idx_x + k; if(d >= 0 && d < imageW){ sum += input[idx_y * imageW + d] * filter[filterR - k]; } } output[idx] = sum; } //////////////////////////////////////////////////////////////////////////////// // GPU: Column convolution Kernel //////////////////////////////////////////////////////////////////////////////// __global__ void kernel_columns(const float *filter, const float *buffer, float *output, int imageW, int imageH, int filterR){ int idx_x = threadIdx.x + blockDim.x * blockIdx.x; int idx_y = threadIdx.y + blockDim.y * blockIdx.y; int grid_width = gridDim.x * blockDim.x; int idx = grid_width * idx_y + idx_x; float sum = 0; int k; // Columns for(k = -filterR; k <= filterR; k++){ int d = idx_y + k; if(d >= 0 && d < imageH){ sum += buffer[d * imageW + idx_x] * filter[filterR - k]; } } output[idx] = sum; } // Auxiliary function for CUDA error checking void cudaCheckForErrors(){ hipError_t error = hipGetLastError(); if(error != hipSuccess){ // something's gone wrong // print out the CUDA error as a string printf("CUDA Error: %s\n", hipGetErrorString(error)); exit(1); } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(void) { float *h_Filter, *h_Input, *h_Buffer, *h_OutputCPU; // GPU float *d_Filter, *d_Input, *d_Buffer, *d_OutputGPU, *h_OutputGPU; unsigned int imageW; unsigned int imageH; unsigned int i; printf("Enter filter radius : "); scanf("%d", &filter_radius); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (float *)malloc(FILTER_LENGTH * sizeof(float)); h_Input = (float *)malloc(imageW * imageH * sizeof(float)); h_Buffer = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputCPU = (float *)malloc(imageW * imageH * sizeof(float)); h_OutputGPU = (float *)malloc(imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_Filter, FILTER_LENGTH * sizeof(float)); hipMalloc( (void **) &d_Input, imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_Buffer, imageW * imageH * sizeof(float)); hipMalloc( (void **) &d_OutputGPU, imageW * imageH * sizeof(float)); if(!h_Filter || !h_Input || !h_Buffer || !h_OutputCPU || !h_OutputGPU){ printf("error allocating memory for the host\n"); exit(1); } if(!d_Filter || !d_Input || !d_Buffer || !d_OutputGPU){ printf("Error allocating memory for the device\n"); exit(1); } srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (float)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (float)rand() / ((float)RAND_MAX / 255) + (float)rand() / (float)RAND_MAX; } hipMemcpy(d_Filter, h_Filter, FILTER_LENGTH * sizeof(float), hipMemcpyHostToDevice); hipMemcpy(d_Input, h_Input, imageW * imageH * sizeof(float), hipMemcpyHostToDevice); //////////////////////////////// CPU /////////////////////////////////////// // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, filter_radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, filter_radius); // convolution kata sthles //////////////////////////////// GPU /////////////////////////////////////// dim3 block_dim; dim3 grid_dim; if(imageW < 32){ block_dim.x = imageW; block_dim.y = imageH; grid_dim.x = 1; grid_dim.y = 1; } else{ block_dim.x = 32; block_dim.y = 32; grid_dim.x = imageW / block_dim.x; grid_dim.y = imageH / block_dim.y; } printf("GPU computation...\n"); kernel_rows<<<grid_dim, block_dim>>>(d_Filter, d_Input, d_Buffer, imageW, imageH, filter_radius); hipDeviceSynchronize(); cudaCheckForErrors(); kernel_columns<<<grid_dim, block_dim>>>(d_Filter, d_Buffer, d_OutputGPU, imageW, imageH, filter_radius); hipDeviceSynchronize(); cudaCheckForErrors(); hipMemcpy(h_OutputGPU, d_OutputGPU, imageW * imageH * sizeof(float), hipMemcpyDeviceToHost); //////////////////////// RESULT COMPARISON ///////////////////////////////// // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i = 0; i < imageH * imageW; i++){ if(ABS(h_OutputGPU[i] - h_OutputCPU[i]) >= accuracy){ printf("GPU computations are not as accurate as we want.\n"); break; } } ////////////////// CPU: free all the allocated memory ////////////////////// free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); ////////////////// GPU: free all the allocated memory ////////////////////// free(h_OutputGPU); hipFree(d_Filter); hipFree(d_Input); hipFree(d_Buffer); hipFree(d_OutputGPU); // Do a device reset just in case... Bgalte to sxolio otan ylopoihsete CUDA hipDeviceReset(); return 0; }
.text .file "4a_Convolution2D.hip" .globl _Z17convolutionRowCPUPfS_S_iii # -- Begin function _Z17convolutionRowCPUPfS_S_iii .p2align 4, 0x90 .type _Z17convolutionRowCPUPfS_S_iii,@function _Z17convolutionRowCPUPfS_S_iii: # @_Z17convolutionRowCPUPfS_S_iii .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq %rdi, -16(%rsp) # 8-byte Spill testl %r8d, %r8d jle .LBB0_11 # %bb.1: # %.preheader.lr.ph movq %rdx, %rax movl %r9d, %edx negl %edx movq %rdx, -24(%rsp) # 8-byte Spill movslq %edx, %rdx movslq %r9d, %r10 movslq %ecx, %r14 movl %r8d, %edi movq %rdi, -8(%rsp) # 8-byte Spill movl %r14d, %ebx leaq (,%r10,4), %rdi leaq (,%rdx,4), %r11 subq %r11, %rdi addq %rdi, %rax leaq (%rsi,%rdx,4), %rsi movq %r14, -32(%rsp) # 8-byte Spill leaq (,%r14,4), %r14 addl %r10d, %r10d orq $1, %r10 xorl %r15d, %r15d jmp .LBB0_2 .p2align 4, 0x90 .LBB0_10: # %._crit_edge38 # in Loop: Header=BB0_2 Depth=1 incq %r15 addq %r14, %rsi cmpq -8(%rsp), %r15 # 8-byte Folded Reload je .LBB0_11 .LBB0_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB0_4 Depth 2 # Child Loop BB0_6 Depth 3 testl %ecx, %ecx jle .LBB0_10 # %bb.3: # %.lr.ph37 # in Loop: Header=BB0_2 Depth=1 movq %r15, %rdx imulq -32(%rsp), %rdx # 8-byte Folded Reload movq -16(%rsp), %rdi # 8-byte Reload leaq (%rdi,%rdx,4), %r12 movq -24(%rsp), %r13 # 8-byte Reload movq %rsi, %rbp xorl %r11d, %r11d jmp .LBB0_4 .p2align 4, 0x90 .LBB0_9: # %._crit_edge # in Loop: Header=BB0_4 Depth=2 incq %r11 addq $4, %rbp incq %r13 cmpq %rbx, %r11 je .LBB0_10 .LBB0_4: # Parent Loop BB0_2 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB0_6 Depth 3 testl %r9d, %r9d js .LBB0_9 # %bb.5: # %.lr.ph # in Loop: Header=BB0_4 Depth=2 xorps %xmm0, %xmm0 xorl %edi, %edi movq %rax, %rdx jmp .LBB0_6 .p2align 4, 0x90 .LBB0_8: # in Loop: Header=BB0_6 Depth=3 movss %xmm0, (%r12,%r11,4) addq $-4, %rdx incq %rdi cmpl %edi, %r10d je .LBB0_9 .LBB0_6: # Parent Loop BB0_2 Depth=1 # Parent Loop BB0_4 Depth=2 # => This Inner Loop Header: Depth=3 leal (%rdi,%r13), %r8d cmpl %ecx, %r8d jae .LBB0_8 # %bb.7: # in Loop: Header=BB0_6 Depth=3 movss (%rbp,%rdi,4), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%rdx), %xmm1 addss %xmm1, %xmm0 jmp .LBB0_8 .LBB0_11: # %._crit_edge40 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z17convolutionRowCPUPfS_S_iii, .Lfunc_end0-_Z17convolutionRowCPUPfS_S_iii .cfi_endproc # -- End function .globl _Z20convolutionColumnCPUPfS_S_iii # -- Begin function _Z20convolutionColumnCPUPfS_S_iii .p2align 4, 0x90 .type _Z20convolutionColumnCPUPfS_S_iii,@function _Z20convolutionColumnCPUPfS_S_iii: # @_Z20convolutionColumnCPUPfS_S_iii .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %ecx, -36(%rsp) # 4-byte Spill movq %rdi, -16(%rsp) # 8-byte Spill testl %r8d, %r8d jle .LBB1_11 # %bb.1: # %.preheader.lr.ph movq %rdx, %r11 movl %r9d, %ecx negl %ecx movslq %ecx, %rax movslq -36(%rsp), %r14 # 4-byte Folded Reload movslq %r9d, %rdx movl %r8d, %edi movq %rdi, -8(%rsp) # 8-byte Spill movl %r14d, %ebx leaq (,%rdx,4), %rdi leaq (,%rax,4), %r10 subq %r10, %rdi addq %rdi, %r11 imulq %r14, %rax leaq (%rsi,%rax,4), %rax movq %rax, -32(%rsp) # 8-byte Spill movq %r14, -24(%rsp) # 8-byte Spill leaq (,%r14,4), %r14 leal 1(,%rdx,2), %edi xorl %r15d, %r15d jmp .LBB1_2 .p2align 4, 0x90 .LBB1_10: # %._crit_edge39 # in Loop: Header=BB1_2 Depth=1 incq %r15 incl %ecx addq %r14, -32(%rsp) # 8-byte Folded Spill cmpq -8(%rsp), %r15 # 8-byte Folded Reload je .LBB1_11 .LBB1_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 # Child Loop BB1_6 Depth 3 cmpl $0, -36(%rsp) # 4-byte Folded Reload jle .LBB1_10 # %bb.3: # %.lr.ph38 # in Loop: Header=BB1_2 Depth=1 movq %r15, %rax imulq -24(%rsp), %rax # 8-byte Folded Reload movq -16(%rsp), %rdx # 8-byte Reload leaq (%rdx,%rax,4), %r12 movq -32(%rsp), %rsi # 8-byte Reload xorl %r10d, %r10d jmp .LBB1_4 .p2align 4, 0x90 .LBB1_9: # %._crit_edge # in Loop: Header=BB1_4 Depth=2 incq %r10 addq $4, %rsi cmpq %rbx, %r10 je .LBB1_10 .LBB1_4: # Parent Loop BB1_2 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB1_6 Depth 3 testl %r9d, %r9d js .LBB1_9 # %bb.5: # %.lr.ph # in Loop: Header=BB1_4 Depth=2 xorps %xmm0, %xmm0 movl %edi, %ebp movq %rsi, %r13 movl %ecx, %eax movq %r11, %rdx jmp .LBB1_6 .p2align 4, 0x90 .LBB1_8: # in Loop: Header=BB1_6 Depth=3 movss %xmm0, (%r12,%r10,4) addq $-4, %rdx incl %eax addq %r14, %r13 decl %ebp je .LBB1_9 .LBB1_6: # Parent Loop BB1_2 Depth=1 # Parent Loop BB1_4 Depth=2 # => This Inner Loop Header: Depth=3 cmpl %r8d, %eax jae .LBB1_8 # %bb.7: # in Loop: Header=BB1_6 Depth=3 movss (%r13), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%rdx), %xmm1 addss %xmm1, %xmm0 jmp .LBB1_8 .LBB1_11: # %._crit_edge41 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size _Z20convolutionColumnCPUPfS_S_iii, .Lfunc_end1-_Z20convolutionColumnCPUPfS_S_iii .cfi_endproc # -- End function .globl _Z26__device_stub__kernel_rowsPKfS0_Pfiii # -- Begin function _Z26__device_stub__kernel_rowsPKfS0_Pfiii .p2align 4, 0x90 .type _Z26__device_stub__kernel_rowsPKfS0_Pfiii,@function _Z26__device_stub__kernel_rowsPKfS0_Pfiii: # @_Z26__device_stub__kernel_rowsPKfS0_Pfiii .cfi_startproc # %bb.0: subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 20(%rsp), %rax movq %rax, 120(%rsp) leaq 16(%rsp), %rax movq %rax, 128(%rsp) leaq 12(%rsp), %rax movq %rax, 136(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z11kernel_rowsPKfS0_Pfiii, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $168, %rsp .cfi_adjust_cfa_offset -168 retq .Lfunc_end2: .size _Z26__device_stub__kernel_rowsPKfS0_Pfiii, .Lfunc_end2-_Z26__device_stub__kernel_rowsPKfS0_Pfiii .cfi_endproc # -- End function .globl _Z29__device_stub__kernel_columnsPKfS0_Pfiii # -- Begin function _Z29__device_stub__kernel_columnsPKfS0_Pfiii .p2align 4, 0x90 .type _Z29__device_stub__kernel_columnsPKfS0_Pfiii,@function _Z29__device_stub__kernel_columnsPKfS0_Pfiii: # @_Z29__device_stub__kernel_columnsPKfS0_Pfiii .cfi_startproc # %bb.0: subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movl %ecx, 20(%rsp) movl %r8d, 16(%rsp) movl %r9d, 12(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 20(%rsp), %rax movq %rax, 120(%rsp) leaq 16(%rsp), %rax movq %rax, 128(%rsp) leaq 12(%rsp), %rax movq %rax, 136(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z14kernel_columnsPKfS0_Pfiii, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $168, %rsp .cfi_adjust_cfa_offset -168 retq .Lfunc_end3: .size _Z29__device_stub__kernel_columnsPKfS0_Pfiii, .Lfunc_end3-_Z29__device_stub__kernel_columnsPKfS0_Pfiii .cfi_endproc # -- End function .globl _Z18cudaCheckForErrorsv # -- Begin function _Z18cudaCheckForErrorsv .p2align 4, 0x90 .type _Z18cudaCheckForErrorsv,@function _Z18cudaCheckForErrorsv: # @_Z18cudaCheckForErrorsv .cfi_startproc # %bb.0: pushq %rax .cfi_def_cfa_offset 16 callq hipGetLastError testl %eax, %eax jne .LBB4_2 # %bb.1: popq %rax .cfi_def_cfa_offset 8 retq .LBB4_2: .cfi_def_cfa_offset 16 movl %eax, %edi callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi xorl %eax, %eax callq printf movl $1, %edi callq exit .Lfunc_end4: .size _Z18cudaCheckForErrorsv, .Lfunc_end4-_Z18cudaCheckForErrorsv .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI5_0: .long 0x4b008081 # float 8421505 .LCPI5_1: .long 0x30000000 # float 4.65661287E-10 .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 .LCPI5_2: .long 0x80000000 # float -0 .long 0x80000000 # float -0 .long 0x80000000 # float -0 .long 0x80000000 # float -0 .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 .LCPI5_3: .quad 0x3f0a36e2eb1c432d # double 5.0000000000000002E-5 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $248, %rsp .cfi_def_cfa_offset 304 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl $.L.str.1, %edi xorl %eax, %eax callq printf movl $.L.str.2, %edi movl $filter_radius, %esi xorl %eax, %eax callq __isoc23_scanf movl filter_radius(%rip), %eax leal 1(,%rax,2), %esi movl $.L.str.3, %edi xorl %eax, %eax callq printf leaq 4(%rsp), %rsi movl $.L.str.2, %edi xorl %eax, %eax callq __isoc23_scanf movl 4(%rsp), %r13d movl $.L.str.4, %edi movl %r13d, %esi movl %r13d, %edx xorl %eax, %eax callq printf movl $.Lstr, %edi callq puts@PLT movl filter_radius(%rip), %eax addl %eax, %eax leaq 4(,%rax,4), %r15 movq %r15, %rdi callq malloc movq %rax, %r14 movl 4(%rsp), %r12d imull %r13d, %r12d shlq $2, %r12 movq %r12, %rdi callq malloc movq %rax, %rbx movq %r12, %rdi callq malloc movq %rax, 40(%rsp) # 8-byte Spill movq %r12, %rdi callq malloc movq %rax, 88(%rsp) # 8-byte Spill movq %r12, %rdi callq malloc movq %rax, %r12 leaq 32(%rsp), %rdi movq %r15, %rsi movq %rbx, %r15 callq hipMalloc movl 4(%rsp), %esi imull %r13d, %esi shlq $2, %rsi leaq 72(%rsp), %rdi callq hipMalloc movl 4(%rsp), %esi imull %r13d, %esi shlq $2, %rsi leaq 64(%rsp), %rdi callq hipMalloc movl 4(%rsp), %esi imull %r13d, %esi shlq $2, %rsi leaq 56(%rsp), %rdi callq hipMalloc testq %r14, %r14 je .LBB5_5 # %bb.1: testq %r15, %r15 je .LBB5_5 # %bb.2: cmpq $0, 40(%rsp) # 8-byte Folded Reload je .LBB5_5 # %bb.3: cmpq $0, 88(%rsp) # 8-byte Folded Reload je .LBB5_5 # %bb.4: testq %r12, %r12 je .LBB5_5 # %bb.7: cmpq $0, 32(%rsp) je .LBB5_11 # %bb.8: cmpq $0, 72(%rsp) je .LBB5_11 # %bb.9: cmpq $0, 64(%rsp) je .LBB5_11 # %bb.10: cmpq $0, 56(%rsp) je .LBB5_11 # %bb.41: movl $200, %edi callq srand movq $-1, %rbx .p2align 4, 0x90 .LBB5_42: # =>This Inner Loop Header: Depth=1 callq rand # kill: def $eax killed $eax def $rax leal 15(%rax), %ecx testl %eax, %eax cmovnsl %eax, %ecx andl $-16, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, 4(%r14,%rbx,4) movl filter_radius(%rip), %eax addl %eax, %eax incq %rbx cmpq %rax, %rbx jb .LBB5_42 # %bb.12: # %.preheader movq %r12, 240(%rsp) # 8-byte Spill movl 4(%rsp), %eax imull %r13d, %eax testl %eax, %eax je .LBB5_15 # %bb.13: # %.lr.ph.preheader xorl %ebx, %ebx .p2align 4, 0x90 .LBB5_14: # %.lr.ph # =>This Inner Loop Header: Depth=1 callq rand xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 divss .LCPI5_0(%rip), %xmm0 movss %xmm0, 8(%rsp) # 4-byte Spill callq rand xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 mulss .LCPI5_1(%rip), %xmm0 addss 8(%rsp), %xmm0 # 4-byte Folded Reload movss %xmm0, (%r15,%rbx,4) incq %rbx movl 4(%rsp), %eax imull %r13d, %eax cmpq %rax, %rbx jb .LBB5_14 .LBB5_15: # %._crit_edge movq 32(%rsp), %rdi movl filter_radius(%rip), %eax addl %eax, %eax leaq 4(,%rax,4), %rdx movq %r14, 80(%rsp) # 8-byte Spill movq %r14, %rsi movl $1, %ecx callq hipMemcpy movq 72(%rsp), %rdi movl 4(%rsp), %edx imull %r13d, %edx shlq $2, %rdx movq %r15, 168(%rsp) # 8-byte Spill movq %r15, %rsi movl $1, %ecx callq hipMemcpy movl $.Lstr.3, %edi callq puts@PLT movslq 4(%rsp), %rcx movq %rcx, %rax movq %rcx, 8(%rsp) # 8-byte Spill movl %ecx, %eax testl %r13d, %r13d jle .LBB5_39 # %bb.16: # %.preheader.lr.ph.i movslq filter_radius(%rip), %rdx movl %edx, %ecx negl %ecx movq %rcx, 48(%rsp) # 8-byte Spill movslq %ecx, %rcx leaq (,%rdx,4), %r9 leaq (,%rcx,4), %rsi movq %r9, 232(%rsp) # 8-byte Spill subq %rsi, %r9 addq 80(%rsp), %r9 # 8-byte Folded Reload leal (%rdx,%rdx), %r10d orq $1, %r10 movq 168(%rsp), %rsi # 8-byte Reload leaq (%rsi,%rcx,4), %rbp movq 8(%rsp), %rcx # 8-byte Reload leaq (,%rcx,4), %rsi xorl %r15d, %r15d jmp .LBB5_17 .p2align 4, 0x90 .LBB5_26: # %._crit_edge38.i # in Loop: Header=BB5_17 Depth=1 incq %r15 addq %rsi, %rbp cmpq %r13, %r15 je .LBB5_27 .LBB5_17: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB5_19 Depth 2 # Child Loop BB5_21 Depth 3 cmpl $0, 8(%rsp) # 4-byte Folded Reload jle .LBB5_26 # %bb.18: # %.lr.ph37.i # in Loop: Header=BB5_17 Depth=1 movq %r15, %rcx imulq 8(%rsp), %rcx # 8-byte Folded Reload movq 40(%rsp), %rdi # 8-byte Reload leaq (%rdi,%rcx,4), %r12 movq 48(%rsp), %r8 # 8-byte Reload movq %rbp, %r11 xorl %r14d, %r14d jmp .LBB5_19 .p2align 4, 0x90 .LBB5_24: # %._crit_edge.i.loopexit # in Loop: Header=BB5_19 Depth=2 movss %xmm0, (%r12,%r14,4) .LBB5_25: # %._crit_edge.i # in Loop: Header=BB5_19 Depth=2 incq %r14 addq $4, %r11 incq %r8 cmpq %rax, %r14 je .LBB5_26 .LBB5_19: # Parent Loop BB5_17 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB5_21 Depth 3 testl %edx, %edx js .LBB5_25 # %bb.20: # %.lr.ph.i.preheader # in Loop: Header=BB5_19 Depth=2 xorps %xmm0, %xmm0 xorl %ecx, %ecx movq %r9, %rbx jmp .LBB5_21 .p2align 4, 0x90 .LBB5_23: # in Loop: Header=BB5_21 Depth=3 addq $-4, %rbx incq %rcx cmpl %ecx, %r10d je .LBB5_24 .LBB5_21: # %.lr.ph.i # Parent Loop BB5_17 Depth=1 # Parent Loop BB5_19 Depth=2 # => This Inner Loop Header: Depth=3 leal (%r8,%rcx), %edi cmpl %edi, %eax jbe .LBB5_23 # %bb.22: # in Loop: Header=BB5_21 Depth=3 movss (%r11,%rcx,4), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%rbx), %xmm1 addss %xmm1, %xmm0 jmp .LBB5_23 .LBB5_27: # %_Z17convolutionRowCPUPfS_S_iii.exit testl %r13d, %r13d jle .LBB5_39 # %bb.28: # %.preheader.lr.ph.i97 movl %edx, %r8d negl %r8d movslq %r8d, %rdi leaq (,%rdi,4), %rcx movq 232(%rsp), %r9 # 8-byte Reload subq %rcx, %r9 movq 80(%rsp), %rbx # 8-byte Reload addq %r9, %rbx leal 1(,%rdx,2), %ecx imulq 8(%rsp), %rdi # 8-byte Folded Reload movq 40(%rsp), %r9 # 8-byte Reload leaq (%r9,%rdi,4), %rdi movq %rdi, 48(%rsp) # 8-byte Spill xorl %r11d, %r11d jmp .LBB5_29 .p2align 4, 0x90 .LBB5_38: # %._crit_edge39.i # in Loop: Header=BB5_29 Depth=1 incq %r11 addq %rsi, 48(%rsp) # 8-byte Folded Spill incl %r8d cmpq %r13, %r11 je .LBB5_39 .LBB5_29: # %.preheader.i98 # =>This Loop Header: Depth=1 # Child Loop BB5_31 Depth 2 # Child Loop BB5_33 Depth 3 cmpl $0, 8(%rsp) # 4-byte Folded Reload jle .LBB5_38 # %bb.30: # %.lr.ph38.i # in Loop: Header=BB5_29 Depth=1 movq %r11, %rdi imulq 8(%rsp), %rdi # 8-byte Folded Reload movq 88(%rsp), %r9 # 8-byte Reload leaq (%r9,%rdi,4), %r15 movq 48(%rsp), %r10 # 8-byte Reload xorl %r12d, %r12d jmp .LBB5_31 .p2align 4, 0x90 .LBB5_36: # %._crit_edge.i107.loopexit # in Loop: Header=BB5_31 Depth=2 movss %xmm0, (%r15,%r12,4) .LBB5_37: # %._crit_edge.i107 # in Loop: Header=BB5_31 Depth=2 incq %r12 addq $4, %r10 cmpq %rax, %r12 je .LBB5_38 .LBB5_31: # Parent Loop BB5_29 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB5_33 Depth 3 testl %edx, %edx js .LBB5_37 # %bb.32: # %.lr.ph.i100 # in Loop: Header=BB5_31 Depth=2 xorps %xmm0, %xmm0 movl %r8d, %ebp movq %r10, %r14 movl %ecx, %edi movq %rbx, %r9 jmp .LBB5_33 .p2align 4, 0x90 .LBB5_35: # in Loop: Header=BB5_33 Depth=3 addq $-4, %r9 addq %rsi, %r14 incl %ebp decl %edi je .LBB5_36 .LBB5_33: # Parent Loop BB5_29 Depth=1 # Parent Loop BB5_31 Depth=2 # => This Inner Loop Header: Depth=3 cmpl %ebp, %r13d jbe .LBB5_35 # %bb.34: # in Loop: Header=BB5_33 Depth=3 movss (%r14), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%r9), %xmm1 addss %xmm1, %xmm0 jmp .LBB5_35 .LBB5_39: # %_Z20convolutionColumnCPUPfS_S_iii.exit cmpl $31, %eax ja .LBB5_43 # %bb.40: movq %r13, %r12 shlq $32, %r12 orq %rax, %r12 movabsq $4294967297, %r15 # imm = 0x100000001 jmp .LBB5_44 .LBB5_43: shrl $5, %eax movl %r13d, %r15d shrl $5, %r15d shlq $32, %r15 orq %rax, %r15 movabsq $137438953504, %r12 # imm = 0x2000000020 .LBB5_44: movl $.Lstr.4, %edi callq puts@PLT movq %r15, %rdi movl $1, %esi movq %r12, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB5_46 # %bb.45: movq 32(%rsp), %rax movq 72(%rsp), %rcx movq 64(%rsp), %rdx movl 4(%rsp), %esi movl filter_radius(%rip), %edi movq %rax, 160(%rsp) movq %rcx, 152(%rsp) movq %rdx, 144(%rsp) movl %esi, 28(%rsp) movl %r13d, 24(%rsp) movl %edi, 20(%rsp) leaq 160(%rsp), %rax movq %rax, 176(%rsp) leaq 152(%rsp), %rax movq %rax, 184(%rsp) leaq 144(%rsp), %rax movq %rax, 192(%rsp) leaq 28(%rsp), %rax movq %rax, 200(%rsp) leaq 24(%rsp), %rax movq %rax, 208(%rsp) leaq 20(%rsp), %rax movq %rax, 216(%rsp) leaq 128(%rsp), %rdi leaq 112(%rsp), %rsi leaq 104(%rsp), %rdx leaq 96(%rsp), %rcx callq __hipPopCallConfiguration movq 128(%rsp), %rsi movl 136(%rsp), %edx movq 112(%rsp), %rcx movl 120(%rsp), %r8d leaq 176(%rsp), %r9 movl $_Z11kernel_rowsPKfS0_Pfiii, %edi pushq 96(%rsp) .cfi_adjust_cfa_offset 8 pushq 112(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB5_46: callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB5_56 # %bb.47: # %_Z18cudaCheckForErrorsv.exit movq %r15, %rdi movl $1, %esi movq %r12, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB5_49 # %bb.48: movq 32(%rsp), %rax movq 64(%rsp), %rcx movq 56(%rsp), %rdx movl 4(%rsp), %esi movl filter_radius(%rip), %edi movq %rax, 160(%rsp) movq %rcx, 152(%rsp) movq %rdx, 144(%rsp) movl %esi, 28(%rsp) movl %r13d, 24(%rsp) movl %edi, 20(%rsp) leaq 160(%rsp), %rax movq %rax, 176(%rsp) leaq 152(%rsp), %rax movq %rax, 184(%rsp) leaq 144(%rsp), %rax movq %rax, 192(%rsp) leaq 28(%rsp), %rax movq %rax, 200(%rsp) leaq 24(%rsp), %rax movq %rax, 208(%rsp) leaq 20(%rsp), %rax movq %rax, 216(%rsp) leaq 128(%rsp), %rdi leaq 112(%rsp), %rsi leaq 104(%rsp), %rdx leaq 96(%rsp), %rcx callq __hipPopCallConfiguration movq 128(%rsp), %rsi movl 136(%rsp), %edx movq 112(%rsp), %rcx movl 120(%rsp), %r8d leaq 176(%rsp), %r9 movl $_Z14kernel_columnsPKfS0_Pfiii, %edi pushq 96(%rsp) .cfi_adjust_cfa_offset 8 pushq 112(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB5_49: callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax movq 80(%rsp), %rbx # 8-byte Reload movq 168(%rsp), %r14 # 8-byte Reload movq 240(%rsp), %r15 # 8-byte Reload movq 88(%rsp), %r12 # 8-byte Reload jne .LBB5_56 # %bb.50: # %_Z18cudaCheckForErrorsv.exit115 movq 56(%rsp), %rsi movl 4(%rsp), %edx imull %r13d, %edx shlq $2, %rdx movq %r15, %rdi movl $2, %ecx callq hipMemcpy imull 4(%rsp), %r13d testl %r13d, %r13d je .LBB5_55 # %bb.51: # %.lr.ph155.preheader movl %r13d, %eax xorl %ecx, %ecx movaps .LCPI5_2(%rip), %xmm0 # xmm0 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0] movsd .LCPI5_3(%rip), %xmm1 # xmm1 = mem[0],zero .p2align 4, 0x90 .LBB5_53: # %.lr.ph155 # =>This Inner Loop Header: Depth=1 movss (%r15,%rcx,4), %xmm2 # xmm2 = mem[0],zero,zero,zero subss (%r12,%rcx,4), %xmm2 movaps %xmm2, %xmm3 xorps %xmm0, %xmm3 maxss %xmm2, %xmm3 xorps %xmm2, %xmm2 cvtss2sd %xmm3, %xmm2 ucomisd %xmm1, %xmm2 jae .LBB5_54 # %bb.52: # in Loop: Header=BB5_53 Depth=1 incq %rcx cmpq %rcx, %rax jne .LBB5_53 jmp .LBB5_55 .LBB5_54: movl $.Lstr.5, %edi callq puts@PLT .LBB5_55: # %.loopexit movq %r12, %rdi callq free movq 40(%rsp), %rdi # 8-byte Reload callq free movq %r14, %rdi callq free movq %rbx, %rdi callq free movq %r15, %rdi callq free movq 32(%rsp), %rdi callq hipFree movq 72(%rsp), %rdi callq hipFree movq 64(%rsp), %rdi callq hipFree movq 56(%rsp), %rdi callq hipFree callq hipDeviceReset xorl %eax, %eax addq $248, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB5_56: .cfi_def_cfa_offset 304 movl %eax, %edi callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi xorl %eax, %eax callq printf movl $1, %edi callq exit .LBB5_5: movl $.Lstr.1, %edi jmp .LBB5_6 .LBB5_11: movl $.Lstr.2, %edi .LBB5_6: callq puts@PLT movl $1, %edi callq exit .Lfunc_end5: .size main, .Lfunc_end5-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB6_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB6_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z11kernel_rowsPKfS0_Pfiii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z14kernel_columnsPKfS0_Pfiii, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end6: .size __hip_module_ctor, .Lfunc_end6-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB7_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB7_2: retq .Lfunc_end7: .size __hip_module_dtor, .Lfunc_end7-__hip_module_dtor .cfi_endproc # -- End function .type filter_radius,@object # @filter_radius .bss .globl filter_radius .p2align 2, 0x0 filter_radius: .long 0 # 0x0 .size filter_radius, 4 .type _Z11kernel_rowsPKfS0_Pfiii,@object # @_Z11kernel_rowsPKfS0_Pfiii .section .rodata,"a",@progbits .globl _Z11kernel_rowsPKfS0_Pfiii .p2align 3, 0x0 _Z11kernel_rowsPKfS0_Pfiii: .quad _Z26__device_stub__kernel_rowsPKfS0_Pfiii .size _Z11kernel_rowsPKfS0_Pfiii, 8 .type _Z14kernel_columnsPKfS0_Pfiii,@object # @_Z14kernel_columnsPKfS0_Pfiii .globl _Z14kernel_columnsPKfS0_Pfiii .p2align 3, 0x0 _Z14kernel_columnsPKfS0_Pfiii: .quad _Z29__device_stub__kernel_columnsPKfS0_Pfiii .size _Z14kernel_columnsPKfS0_Pfiii, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "CUDA Error: %s\n" .size .L.str, 16 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Enter filter radius : " .size .L.str.1, 23 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "%d" .size .L.str.2, 3 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Enter image size. Should be a power of two and greater than %d : " .size .L.str.3, 66 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "Image Width x Height = %i x %i\n\n" .size .L.str.4, 33 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z11kernel_rowsPKfS0_Pfiii" .size .L__unnamed_1, 27 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z14kernel_columnsPKfS0_Pfiii" .size .L__unnamed_2, 30 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Allocating and initializing host arrays..." .size .Lstr, 43 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "error allocating memory for the host" .size .Lstr.1, 37 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "Error allocating memory for the device" .size .Lstr.2, 39 .type .Lstr.3,@object # @str.3 .Lstr.3: .asciz "CPU computation..." .size .Lstr.3, 19 .type .Lstr.4,@object # @str.4 .Lstr.4: .asciz "GPU computation..." .size .Lstr.4, 19 .type .Lstr.5,@object # @str.5 .Lstr.5: .asciz "GPU computations are not as accurate as we want." .size .Lstr.5, 49 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z26__device_stub__kernel_rowsPKfS0_Pfiii .addrsig_sym _Z29__device_stub__kernel_columnsPKfS0_Pfiii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym filter_radius .addrsig_sym _Z11kernel_rowsPKfS0_Pfiii .addrsig_sym _Z14kernel_columnsPKfS0_Pfiii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refer to "Detailed Numerical Analyses of the Aliev-Panfilov Model on GPGPU" * https://www.simula.no/publications/detailed-numerical-analyses-aliev-panfilov-model-gpgpu * by Xing Cai, Didem Unat and Scott Baden * */ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <string.h> #include <math.h> #include <sys/time.h> #include <getopt.h> using namespace std; // External functions extern "C" void splot(double *E, double T, int niter, int m, int n); void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads); // Utilities // // Timer // Make successive calls and take a difference to get the elapsed time. static const double kMicro = 1.0e-6; double getTime() { struct timeval TV; struct timezone TZ; const int RC = gettimeofday(&TV, &TZ); if (RC == -1) { cerr << "ERROR: Bad call to gettimeofday" << endl; return (-1); } return (((double) TV.tv_sec) + kMicro * ((double) TV.tv_usec)); } // end getTime() // Reports statistics about the computation // These values should not vary (except to within roundoff) // when we use different numbers of processes to solve the problem double stats(double *E, int m, int n, double *_mx) { double mx = -1; double l2norm = 0; int i, j; for (j = 1; j <= m; j++) { for (i = 1; i <= n; i++) { l2norm += E[j * (n+2) + i] * E[j * (n+2) + i]; if (E[j * (n+2) + i] > mx) mx = E[j * (n+2) + i]; } } *_mx = mx; l2norm /= (double) ((m) * (n)); l2norm = sqrt(l2norm); return l2norm; } __global__ void ghosts(const int n, const int m, double *E_prev) { int j = threadIdx.x + 1; E_prev[j * (n+2)] = E_prev[j * (n+2) + 2]; E_prev[j * (n+2) + (n + 1)] = E_prev[j * (n + 2) + (n - 1)]; E_prev[j] = E_prev[2 * (n + 2) + j]; E_prev[(m + 1) * (n + 2) + j] = E_prev[(m - 1) * (n + 2) + j]; } __global__ void ode(const double a, const double kk, const double dt, const int n, const int m, double *E, double *R, const double epsilon, const double M1, const double M2, const double b) { /* * Solve the ODE, advancing excitation and recovery to the * next timtestep */ int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E[index] - dt * (kk * E[index] * (E[index] - a) * (E[index] - 1) + E[index] * R[index]); R[index] = R[index] + dt * (epsilon + M1 * R[index] / (E[index] + M2)) * (-R[index] - kk * E[index] * (E[index] - b - 1)); } __global__ void pde(const int n, const int m, double *E, double *E_prev, const double alpha) { int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E_prev[index] + alpha * (E_prev[index + 1] + E_prev[index - 1] - 4 * E_prev[index] + E_prev[index + m + 2] + E_prev[index - (m + 2)]); } void simulate(double *E, double *E_prev, double *R, const double alpha, const int n, const int m, const double kk, const double dt, const double a, const double epsilon, const double M1, const double M2, const double b) { /* * Copy data from boundary of the computational box * to the padding region, set up for differencing * on the boundary of the computational box * Using mirror boundaries */ ghosts<<<1, n>>>(n, m, E_prev); pde<<<m, n>>>(n, m, E, E_prev, alpha); ode<<<m, n>>>(a, kk, dt, n, m, E, R, epsilon, M1, M2, b); } // Define Kernels // __global__ void // __device__ // Main program int main(int argc, char **argv) { /* * Solution arrays * E is the "Excitation" variable, a voltage * R is the "Recovery" variable * E_prev is the Excitation variable for the previous timestep, * and is used in time integration */ double *E, *R, *E_prev; // Various constants - these definitions shouldn't change const double a = 0.1, b = 0.1, kk = 8.0, M1 = 0.07, M2 = 0.3, epsilon = 0.01, d = 5e-5; double T = 1000.0; int m = 200, n = 200; int plot_freq = 0; int px = 1, py = 1; int no_comm = 0; int num_threads = 1; cmdLine(argc, argv, T, n, px, py, plot_freq, no_comm, num_threads); m = n; // Allocate contiguous memory for solution arrays // The computational box is defined on [1:m+1,1:n+1] // We pad the arrays in order to facilitate differencing on the // boundaries of the computation box E = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); E_prev = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); R = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); int i, j; // Initialization for (j = 1; j <= m; j++) for (i = 1; i <= n; i++) E_prev[j * (n+2) + i] = R[j * (n+2) + i] = 0; for (j = 1; j <= m; j++) for (i = n / 2 + 1; i <= n; i++) E_prev[j * (n+2) + i] = 1.0; for (j = m / 2 + 1; j <= m; j++) for (i = 1; i <= n; i++) R[j * (n+2) + i] = 1.0; double dx = 1.0 / n; // For time integration, these values shouldn't change double rp = kk * (b + 1) * (b + 1) / 4; double dte = (dx * dx) / (d * 4 + ((dx * dx)) * (rp + kk)); double dtr = 1 / (epsilon + ((M1 / M2) * rp)); double dt = (dte < dtr) ? 0.95 * dte : 0.95 * dtr; double alpha = d * dt / (dx * dx); cout << "Grid Size : " << n << endl; cout << "Duration of Sim : " << T << endl; cout << "Time step dt : " << dt << endl; cout << "Process geometry: " << px << " x " << py << endl; if (no_comm) cout << "Communication : DISABLED" << endl; cout << endl; // Start the timer double t0 = getTime(); // Simulated time is different from the integer timestep number // Simulated time double t = 0.0; // Integer timestep number int niter = 0; double *d_E, *d_E_prev, *d_R; cudaMalloc((void **) &d_E, sizeof(double) * (m + 2) * (n + 2)); cudaMalloc((void **) &d_E_prev, sizeof(double) * (m + 2) * (n + 2)); cudaMalloc((void **) &d_R, sizeof(double) * (m + 2) * (n + 2)); cudaMemcpy(d_E, E, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); cudaMemcpy(d_E_prev, E_prev, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); cudaMemcpy(d_R, R, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); while (t < T) { t += dt; niter++; simulate(d_E, d_E_prev, d_R, alpha, n, m, kk, dt, a, epsilon, M1, M2, b); //swap current E with previous E double *tmp = d_E; d_E = d_E_prev; d_E_prev = tmp; if (plot_freq) { int k = (int) (t / plot_freq); if ((t - k * plot_freq) < dt) { cudaMemcpy(E, d_E, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyDeviceToHost); splot(E, t, niter, m + 2, n + 2); } } }//end of while loop cudaMemcpy(E_prev, d_E_prev, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyDeviceToHost); cudaFree(d_E); cudaFree(d_E_prev); cudaFree(d_R); double time_elapsed = getTime() - t0; double Gflops = (double) (niter * (1E-9 * n * n) * 28.0) / time_elapsed; double BW = (double) (niter * 1E-9 * (n * n * sizeof(double) * 4.0)) / time_elapsed; cout << "Number of Iterations : " << niter << endl; cout << "Elapsed Time (sec) : " << time_elapsed << endl; cout << "Sustained Gflops Rate : " << Gflops << endl; cout << "Sustained Bandwidth (GB/sec): " << BW << endl << endl; double mx; double l2norm = stats(E_prev, m, n, &mx); cout << "Max: " << mx << " L2norm: " << l2norm << endl; if (plot_freq) { cout << "\n\nEnter any input to close the program and the plot..." << endl; getchar(); } free(E); free(E_prev); free(R); return 0; } void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads) { /// Command line arguments // Default value of the domain sizes static struct option long_options[] = { {"n", required_argument, 0, 'n'}, {"px", required_argument, 0, 'x'}, {"py", required_argument, 0, 'y'}, {"tfinal", required_argument, 0, 't'}, {"plot", required_argument, 0, 'p'}, {"nocomm", no_argument, 0, 'k'}, {"numthreads", required_argument, 0, 'o'}, }; // Process command line arguments int ac; for (ac = 1; ac < argc; ac++) { int c; while ((c = getopt_long(argc, argv, "n:x:y:t:kp:o:", long_options, NULL)) != -1) { switch (c) { // Size of the computational box case 'n': n = atoi(optarg); break; // X processor geometry case 'x': px = atoi(optarg); // Y processor geometry case 'y': py = atoi(optarg); // Length of simulation, in simulated time units case 't': T = atof(optarg); break; // Turn off communication case 'k': no_comm = 1; break; // Plot the excitation variable case 'p': plot_freq = atoi(optarg); break; // Plot the excitation variable case 'o': num_threads = atoi(optarg); break; // Error default: printf("Usage: a.out [-n <domain size>] [-t <final time >]\n\t [-p <plot frequency>]\n\t[-px <x processor geometry> [-py <y proc. geometry] [-k turn off communication] [-o <Number of OpenMP threads>]\n"); exit(-1); } } } } /* ********************************************************** * Author : Urvashi R.V. [04/06/2004] * Modified by Didem Unat [03/23/18] *************************************************************/ #include <stdio.h> /* Function to plot the 2D array * 'gnuplot' is instantiated via a pipe and * the values to be plotted are passed through, along * with gnuplot commands */ FILE *gnu = NULL; void splot(double *U, double T, int niter, int m, int n) { int i, j; if (gnu == NULL) gnu = popen("gnuplot", "w"); double mx = -1, mn = 32768; for (j = 0; j < m; j++) for (i = 0; i < n; i++) { if (U[j * m + i] > mx) mx = U[j * m + i]; if (U[j * m + i] < mn) mn = U[j * m + i]; } fprintf(gnu, "set title \"T = %f [niter = %d]\"\n", T, niter); fprintf(gnu, "set size square\n"); fprintf(gnu, "set key off\n"); fprintf(gnu, "set pm3d map\n"); // Various color schemes fprintf(gnu, "set palette defined (-3 \"blue\", 0 \"white\", 1 \"red\")\n"); // fprintf(gnu,"set palette rgbformulae 22, 13, 31\n"); // fprintf(gnu,"set palette rgbformulae 30, 31, 32\n"); fprintf(gnu, "splot [0:%d] [0:%d][%f:%f] \"-\"\n", m - 1, n - 1, mn, mx); for (j = 0; j < m; j++) { for (i = 0; i < n; i++) { fprintf(gnu, "%d %d %f\n", i, j, U[i * m + j]); } fprintf(gnu, "\n"); } fprintf(gnu, "e\n"); fflush(gnu); return; }
code for sm_80 Function : _Z3pdeiiPdS_d .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2UR UR4, SR_CTAID.X ; /* 0x00000000000479c3 */ /* 0x000e220000002500 */ /*0020*/ S2R R2, SR_TID.X ; /* 0x0000000000027919 */ /* 0x000e620000002100 */ /*0030*/ MOV R3, c[0x0][0x160] ; /* 0x0000580000037a02 */ /* 0x000fe20000000f00 */ /*0040*/ HFMA2.MMA R0, -RZ, RZ, 0, 4.76837158203125e-07 ; /* 0x00000008ff007435 */ /* 0x000fc600000001ff */ /*0050*/ IADD3 R3, R3, 0x2, RZ ; /* 0x0000000203037810 */ /* 0x000fe20007ffe0ff */ /*0060*/ UIADD3 UR4, UR4, 0x1, URZ ; /* 0x0000000104047890 */ /* 0x001fcc000fffe03f */ /*0070*/ IMAD R3, R3, UR4, R2 ; /* 0x0000000403037c24 */ /* 0x002fe2000f8e0202 */ /*0080*/ HFMA2.MMA R2, -RZ, RZ, 0, 1.1920928955078125e-07 ; /* 0x00000002ff027435 */ /* 0x000fe200000001ff */ /*0090*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*00a0*/ IMAD.WIDE R6, R3.reuse, R0, c[0x0][0x170] ; /* 0x00005c0003067625 */ /* 0x040fe200078e0200 */ /*00b0*/ IADD3 R13, R3, c[0x0][0x164], RZ ; /* 0x00005900030d7a10 */ /* 0x000fc80007ffe0ff */ /*00c0*/ LDG.E.64 R8, [R6.64+0x10] ; /* 0x0000100406087981 */ /* 0x000ea8000c1e1b00 */ /*00d0*/ LDG.E.64 R10, [R6.64] ; /* 0x00000004060a7981 */ /* 0x000ea2000c1e1b00 */ /*00e0*/ IADD3 R2, R3, -c[0x0][0x164], -R2 ; /* 0x8000590003027a10 */ /* 0x000fe20007ffe802 */ /*00f0*/ IMAD.WIDE R12, R13, R0, c[0x0][0x170] ; /* 0x00005c000d0c7625 */ /* 0x000fe400078e0200 */ /*0100*/ LDG.E.64 R4, [R6.64+0x8] ; /* 0x0000080406047981 */ /* 0x000ee2000c1e1b00 */ /*0110*/ IADD3 R15, R2, 0x1, RZ ; /* 0x00000001020f7810 */ /* 0x000fc60007ffe0ff */ /*0120*/ LDG.E.64 R12, [R12.64+0x18] ; /* 0x000018040c0c7981 */ /* 0x000f24000c1e1b00 */ /*0130*/ IMAD.WIDE R14, R15, R0, c[0x0][0x170] ; /* 0x00005c000f0e7625 */ /* 0x000fcc00078e0200 */ /*0140*/ LDG.E.64 R14, [R14.64] ; /* 0x000000040e0e7981 */ /* 0x000f62000c1e1b00 */ /*0150*/ IMAD.WIDE R2, R3, R0, c[0x0][0x168] ; /* 0x00005a0003027625 */ /* 0x000fe200078e0200 */ /*0160*/ DADD R8, R8, R10 ; /* 0x0000000008087229 */ /* 0x004ecc000000000a */ /*0170*/ DFMA R8, R4, -4, R8 ; /* 0xc01000000408782b */ /* 0x008f0c0000000008 */ /*0180*/ DADD R8, R8, R12 ; /* 0x0000000008087229 */ /* 0x010f4c000000000c */ /*0190*/ DADD R8, R8, R14 ; /* 0x0000000008087229 */ /* 0x020e0c000000000e */ /*01a0*/ DFMA R8, R8, c[0x0][0x178], R4 ; /* 0x00005e0008087a2b */ /* 0x001e0e0000000004 */ /*01b0*/ STG.E.64 [R2.64+0x8], R8 ; /* 0x0000080802007986 */ /* 0x001fe2000c101b04 */ /*01c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01d0*/ BRA 0x1d0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0200*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0210*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0220*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0230*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0240*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z3odedddiiPdS_dddd .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2UR UR4, SR_CTAID.X ; /* 0x00000000000479c3 */ /* 0x000e220000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e620000002100 */ /*0030*/ IMAD.MOV.U32 R0, RZ, RZ, c[0x0][0x178] ; /* 0x00005e00ff007624 */ /* 0x000fe400078e00ff */ /*0040*/ IMAD.MOV.U32 R15, RZ, RZ, 0x8 ; /* 0x00000008ff0f7424 */ /* 0x000fc600078e00ff */ /*0050*/ IADD3 R0, R0, 0x2, RZ ; /* 0x0000000200007810 */ /* 0x000fe20007ffe0ff */ /*0060*/ UIADD3 UR4, UR4, 0x1, URZ ; /* 0x0000000104047890 */ /* 0x001fcc000fffe03f */ /*0070*/ IMAD R0, R0, UR4, R3 ; /* 0x0000000400007c24 */ /* 0x002fe2000f8e0203 */ /*0080*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0090*/ IMAD.WIDE R6, R0, R15, c[0x0][0x180] ; /* 0x0000600000067625 */ /* 0x000fca00078e020f */ /*00a0*/ LDG.E.64 R12, [R6.64+0x8] ; /* 0x00000804060c7981 */ /* 0x000ea2000c1e1b00 */ /*00b0*/ IMAD.WIDE R14, R0, R15, c[0x0][0x188] ; /* 0x00006200000e7625 */ /* 0x000fca00078e020f */ /*00c0*/ LDG.E.64 R10, [R14.64+0x8] ; /* 0x000008040e0a7981 */ /* 0x000ee2000c1e1b00 */ /*00d0*/ DMUL R2, R12, c[0x0][0x168] ; /* 0x00005a000c027a28 */ /* 0x004fc80000000000 */ /*00e0*/ DADD R4, R12, -c[0x0][0x160] ; /* 0x800058000c047629 */ /* 0x000e080000000000 */ /*00f0*/ DADD R8, R12, -1 ; /* 0xbff000000c087429 */ /* 0x000fc80000000000 */ /*0100*/ DMUL R2, R2, R4 ; /* 0x0000000402027228 */ /* 0x001e0c0000000000 */ /*0110*/ DMUL R2, R2, R8 ; /* 0x0000000802027228 */ /* 0x001ecc0000000000 */ /*0120*/ DFMA R2, R12, R10, R2 ; /* 0x0000000a0c02722b */ /* 0x008e0c0000000002 */ /*0130*/ DFMA R12, -R2, c[0x0][0x170], R12 ; /* 0x00005c00020c7a2b */ /* 0x001e0e000000010c */ /*0140*/ STG.E.64 [R6.64+0x8], R12 ; /* 0x0000080c06007986 */ /* 0x0011e8000c101b04 */ /*0150*/ LDG.E.64 R10, [R14.64+0x8] ; /* 0x000008040e0a7981 */ /* 0x000ea2000c1e1b00 */ /*0160*/ DADD R2, R12, c[0x0][0x1a0] ; /* 0x000068000c027629 */ /* 0x000e620000000000 */ /*0170*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x000fe200078e00ff */ /*0180*/ BSSY B0, 0x2a0 ; /* 0x0000011000007945 */ /* 0x000fe80003800000 */ /*0190*/ MUFU.RCP64H R5, R3 ; /* 0x0000000300057308 */ /* 0x002e640000001800 */ /*01a0*/ DFMA R8, -R2, R4, 1 ; /* 0x3ff000000208742b */ /* 0x002e4c0000000104 */ /*01b0*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x002e4c0000000008 */ /*01c0*/ DFMA R8, R4, R8, R4 ; /* 0x000000080408722b */ /* 0x002e4c0000000004 */ /*01d0*/ DFMA R16, -R2, R8, 1 ; /* 0x3ff000000210742b */ /* 0x002e4c0000000108 */ /*01e0*/ DFMA R16, R8, R16, R8 ; /* 0x000000100810722b */ /* 0x002fc80000000008 */ /*01f0*/ DMUL R4, R10, c[0x0][0x198] ; /* 0x000066000a047a28 */ /* 0x004e0c0000000000 */ /*0200*/ DMUL R6, R4, R16 ; /* 0x0000001004067228 */ /* 0x001e080000000000 */ /*0210*/ FSETP.GEU.AND P1, PT, |R5|, 6.5827683646048100446e-37, PT ; /* 0x036000000500780b */ /* 0x000fe40003f2e200 */ /*0220*/ DFMA R8, -R2, R6, R4 ; /* 0x000000060208722b */ /* 0x001e0c0000000104 */ /*0230*/ DFMA R6, R16, R8, R6 ; /* 0x000000081006722b */ /* 0x001e140000000006 */ /*0240*/ FFMA R0, RZ, R3, R7 ; /* 0x00000003ff007223 */ /* 0x001fca0000000007 */ /*0250*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0260*/ @P0 BRA P1, 0x290 ; /* 0x0000002000000947 */ /* 0x000fea0000800000 */ /*0270*/ MOV R0, 0x290 ; /* 0x0000029000007802 */ /* 0x000fe40000000f00 */ /*0280*/ CALL.REL.NOINC 0x330 ; /* 0x000000a000007944 */ /* 0x000fea0003c00000 */ /*0290*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*02a0*/ DADD R2, R12, -c[0x0][0x1a8] ; /* 0x80006a000c027629 */ /* 0x000e080000000000 */ /*02b0*/ DADD R6, R6, c[0x0][0x190] ; /* 0x0000640006067629 */ /* 0x000e480000000000 */ /*02c0*/ DMUL R12, R12, c[0x0][0x168] ; /* 0x00005a000c0c7a28 */ /* 0x000fc80000000000 */ /*02d0*/ DADD R2, R2, -1 ; /* 0xbff0000002027429 */ /* 0x001e080000000000 */ /*02e0*/ DMUL R6, R6, c[0x0][0x170] ; /* 0x00005c0006067a28 */ /* 0x002fc80000000000 */ /*02f0*/ DFMA R2, -R12, R2, -R10 ; /* 0x000000020c02722b */ /* 0x001e0c000000090a */ /*0300*/ DFMA R2, R6, R2, R10 ; /* 0x000000020602722b */ /* 0x001e0e000000000a */ /*0310*/ STG.E.64 [R14.64+0x8], R2 ; /* 0x000008020e007986 */ /* 0x001fe2000c101b04 */ /*0320*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0330*/ FSETP.GEU.AND P0, PT, |R3|.reuse, 1.469367938527859385e-39, PT ; /* 0x001000000300780b */ /* 0x040fe20003f0e200 */ /*0340*/ IMAD.MOV.U32 R6, RZ, RZ, R2.reuse ; /* 0x000000ffff067224 */ /* 0x100fe200078e0002 */ /*0350*/ LOP3.LUT R8, R3, 0x800fffff, RZ, 0xc0, !PT ; /* 0x800fffff03087812 */ /* 0x000fe200078ec0ff */ /*0360*/ IMAD.MOV.U32 R7, RZ, RZ, R3 ; /* 0x000000ffff077224 */ /* 0x000fe200078e0003 */ /*0370*/ FSETP.GEU.AND P2, PT, |R5|.reuse, 1.469367938527859385e-39, PT ; /* 0x001000000500780b */ /* 0x040fe20003f4e200 */ /*0380*/ IMAD.MOV.U32 R18, RZ, RZ, 0x1 ; /* 0x00000001ff127424 */ /* 0x000fe200078e00ff */ /*0390*/ LOP3.LUT R9, R8, 0x3ff00000, RZ, 0xfc, !PT ; /* 0x3ff0000008097812 */ /* 0x000fe200078efcff */ /*03a0*/ IMAD.MOV.U32 R8, RZ, RZ, R2 ; /* 0x000000ffff087224 */ /* 0x000fe200078e0002 */ /*03b0*/ LOP3.LUT R16, R5, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff0000005107812 */ /* 0x000fe200078ec0ff */ /*03c0*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe200078e0004 */ /*03d0*/ LOP3.LUT R23, R3, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff0000003177812 */ /* 0x000fe200078ec0ff */ /*03e0*/ BSSY B1, 0x8f0 ; /* 0x0000050000017945 */ /* 0x000fe40003800000 */ /*03f0*/ @!P0 DMUL R8, R6, 8.98846567431157953865e+307 ; /* 0x7fe0000006088828 */ /* 0x000e220000000000 */ /*0400*/ ISETP.GE.U32.AND P1, PT, R16, R23, PT ; /* 0x000000171000720c */ /* 0x000fc60003f26070 */ /*0410*/ @!P2 LOP3.LUT R17, R7, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000711a812 */ /* 0x000fe200078ec0ff */ /*0420*/ @!P2 IMAD.MOV.U32 R20, RZ, RZ, RZ ; /* 0x000000ffff14a224 */ /* 0x000fe200078e00ff */ /*0430*/ MUFU.RCP64H R19, R9 ; /* 0x0000000900137308 */ /* 0x001e240000001800 */ /*0440*/ @!P2 ISETP.GE.U32.AND P3, PT, R16, R17, PT ; /* 0x000000111000a20c */ /* 0x000fe20003f66070 */ /*0450*/ IMAD.MOV.U32 R17, RZ, RZ, 0x1ca00000 ; /* 0x1ca00000ff117424 */ /* 0x000fca00078e00ff */ /*0460*/ @!P2 SEL R21, R17.reuse, 0x63400000, !P3 ; /* 0x634000001115a807 */ /* 0x040fe40005800000 */ /*0470*/ SEL R3, R17, 0x63400000, !P1 ; /* 0x6340000011037807 */ /* 0x000fe40004800000 */ /*0480*/ @!P2 LOP3.LUT R21, R21, 0x80000000, R5.reuse, 0xf8, !PT ; /* 0x800000001515a812 */ /* 0x100fe400078ef805 */ /*0490*/ LOP3.LUT R3, R3, 0x800fffff, R5, 0xf8, !PT ; /* 0x800fffff03037812 */ /* 0x000fe200078ef805 */ /*04a0*/ DFMA R24, R18, -R8, 1 ; /* 0x3ff000001218742b */ /* 0x001e220000000808 */ /*04b0*/ @!P2 LOP3.LUT R21, R21, 0x100000, RZ, 0xfc, !PT ; /* 0x001000001515a812 */ /* 0x000fca00078efcff */ /*04c0*/ DFMA R24, R24, R24, R24 ; /* 0x000000181818722b */ /* 0x001e080000000018 */ /*04d0*/ @!P2 DFMA R2, R2, 2, -R20 ; /* 0x400000000202a82b */ /* 0x0003e40000000814 */ /*04e0*/ IMAD.MOV.U32 R20, RZ, RZ, R16 ; /* 0x000000ffff147224 */ /* 0x002fe400078e0010 */ /*04f0*/ DFMA R18, R18, R24, R18 ; /* 0x000000181212722b */ /* 0x001e220000000012 */ /*0500*/ IMAD.MOV.U32 R21, RZ, RZ, R23 ; /* 0x000000ffff157224 */ /* 0x000fe200078e0017 */ /*0510*/ @!P0 LOP3.LUT R21, R9, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff0000009158812 */ /* 0x000fc800078ec0ff */ /*0520*/ DFMA R24, R18, -R8, 1 ; /* 0x3ff000001218742b */ /* 0x001e220000000808 */ /*0530*/ @!P2 LOP3.LUT R20, R3, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000314a812 */ /* 0x000fe400078ec0ff */ /*0540*/ IADD3 R26, R21, -0x1, RZ ; /* 0xffffffff151a7810 */ /* 0x000fc60007ffe0ff */ /*0550*/ DFMA R18, R18, R24, R18 ; /* 0x000000181212722b */ /* 0x0010640000000012 */ /*0560*/ IADD3 R24, R20, -0x1, RZ ; /* 0xffffffff14187810 */ /* 0x001fc80007ffe0ff */ /*0570*/ ISETP.GT.U32.AND P0, PT, R24, 0x7feffffe, PT ; /* 0x7feffffe1800780c */ /* 0x000fe20003f04070 */ /*0580*/ DMUL R22, R18, R2 ; /* 0x0000000212167228 */ /* 0x002e060000000000 */ /*0590*/ ISETP.GT.U32.OR P0, PT, R26, 0x7feffffe, P0 ; /* 0x7feffffe1a00780c */ /* 0x000fc60000704470 */ /*05a0*/ DFMA R24, R22, -R8, R2 ; /* 0x800000081618722b */ /* 0x001e0c0000000002 */ /*05b0*/ DFMA R18, R18, R24, R22 ; /* 0x000000181212722b */ /* 0x0010480000000016 */ /*05c0*/ @P0 BRA 0x790 ; /* 0x000001c000000947 */ /* 0x000fea0003800000 */ /*05d0*/ LOP3.LUT R5, R7, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff0000007057812 */ /* 0x003fe200078ec0ff */ /*05e0*/ IMAD.MOV.U32 R20, RZ, RZ, RZ ; /* 0x000000ffff147224 */ /* 0x000fc600078e00ff */ /*05f0*/ ISETP.GE.U32.AND P0, PT, R16.reuse, R5, PT ; /* 0x000000051000720c */ /* 0x040fe20003f06070 */ /*0600*/ IMAD.IADD R4, R16, 0x1, -R5 ; /* 0x0000000110047824 */ /* 0x000fc600078e0a05 */ /*0610*/ SEL R17, R17, 0x63400000, !P0 ; /* 0x6340000011117807 */ /* 0x000fe40004000000 */ /*0620*/ IMNMX R4, R4, -0x46a00000, !PT ; /* 0xb960000004047817 */ /* 0x000fc80007800200 */ /*0630*/ IMNMX R4, R4, 0x46a00000, PT ; /* 0x46a0000004047817 */ /* 0x000fca0003800200 */ /*0640*/ IMAD.IADD R4, R4, 0x1, -R17 ; /* 0x0000000104047824 */ /* 0x000fca00078e0a11 */ /*0650*/ IADD3 R21, R4, 0x7fe00000, RZ ; /* 0x7fe0000004157810 */ /* 0x000fcc0007ffe0ff */ /*0660*/ DMUL R16, R18, R20 ; /* 0x0000001412107228 */ /* 0x000e140000000000 */ /*0670*/ FSETP.GTU.AND P0, PT, |R17|, 1.469367938527859385e-39, PT ; /* 0x001000001100780b */ /* 0x001fda0003f0c200 */ /*0680*/ @P0 BRA 0x8e0 ; /* 0x0000025000000947 */ /* 0x000fea0003800000 */ /*0690*/ DFMA R2, R18, -R8, R2 ; /* 0x800000081202722b */ /* 0x000e220000000002 */ /*06a0*/ IMAD.MOV.U32 R20, RZ, RZ, RZ ; /* 0x000000ffff147224 */ /* 0x000fd200078e00ff */ /*06b0*/ FSETP.NEU.AND P0, PT, R3.reuse, RZ, PT ; /* 0x000000ff0300720b */ /* 0x041fe40003f0d000 */ /*06c0*/ LOP3.LUT R7, R3, 0x80000000, R7, 0x48, !PT ; /* 0x8000000003077812 */ /* 0x000fc800078e4807 */ /*06d0*/ LOP3.LUT R21, R7, R21, RZ, 0xfc, !PT ; /* 0x0000001507157212 */ /* 0x000fce00078efcff */ /*06e0*/ @!P0 BRA 0x8e0 ; /* 0x000001f000008947 */ /* 0x000fea0003800000 */ /*06f0*/ IMAD.MOV R3, RZ, RZ, -R4 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0a04 */ /*0700*/ IMAD.MOV.U32 R2, RZ, RZ, RZ ; /* 0x000000ffff027224 */ /* 0x000fcc00078e00ff */ /*0710*/ DFMA R2, R16, -R2, R18 ; /* 0x800000021002722b */ /* 0x000e080000000012 */ /*0720*/ DMUL.RP R18, R18, R20 ; /* 0x0000001412127228 */ /* 0x000e640000008000 */ /*0730*/ IADD3 R2, -R4, -0x43300000, RZ ; /* 0xbcd0000004027810 */ /* 0x001fc80007ffe1ff */ /*0740*/ FSETP.NEU.AND P0, PT, |R3|, R2, PT ; /* 0x000000020300720b */ /* 0x000fc80003f0d200 */ /*0750*/ LOP3.LUT R7, R19, R7, RZ, 0x3c, !PT ; /* 0x0000000713077212 */ /* 0x002fe400078e3cff */ /*0760*/ FSEL R16, R18, R16, !P0 ; /* 0x0000001012107208 */ /* 0x000fe40004000000 */ /*0770*/ FSEL R17, R7, R17, !P0 ; /* 0x0000001107117208 */ /* 0x000fe20004000000 */ /*0780*/ BRA 0x8e0 ; /* 0x0000015000007947 */ /* 0x000fea0003800000 */ /*0790*/ DSETP.NAN.AND P0, PT, R4, R4, PT ; /* 0x000000040400722a */ /* 0x003e1c0003f08000 */ /*07a0*/ @P0 BRA 0x8c0 ; /* 0x0000011000000947 */ /* 0x001fea0003800000 */ /*07b0*/ DSETP.NAN.AND P0, PT, R6, R6, PT ; /* 0x000000060600722a */ /* 0x000e1c0003f08000 */ /*07c0*/ @P0 BRA 0x890 ; /* 0x000000c000000947 */ /* 0x001fea0003800000 */ /*07d0*/ ISETP.NE.AND P0, PT, R20, R21, PT ; /* 0x000000151400720c */ /* 0x000fe20003f05270 */ /*07e0*/ IMAD.MOV.U32 R16, RZ, RZ, 0x0 ; /* 0x00000000ff107424 */ /* 0x000fe400078e00ff */ /*07f0*/ IMAD.MOV.U32 R17, RZ, RZ, -0x80000 ; /* 0xfff80000ff117424 */ /* 0x000fd400078e00ff */ /*0800*/ @!P0 BRA 0x8e0 ; /* 0x000000d000008947 */ /* 0x000fea0003800000 */ /*0810*/ ISETP.NE.AND P0, PT, R20, 0x7ff00000, PT ; /* 0x7ff000001400780c */ /* 0x000fe40003f05270 */ /*0820*/ LOP3.LUT R17, R5, 0x80000000, R7, 0x48, !PT ; /* 0x8000000005117812 */ /* 0x000fe400078e4807 */ /*0830*/ ISETP.EQ.OR P0, PT, R21, RZ, !P0 ; /* 0x000000ff1500720c */ /* 0x000fda0004702670 */ /*0840*/ @P0 LOP3.LUT R2, R17, 0x7ff00000, RZ, 0xfc, !PT ; /* 0x7ff0000011020812 */ /* 0x000fe200078efcff */ /*0850*/ @!P0 IMAD.MOV.U32 R16, RZ, RZ, RZ ; /* 0x000000ffff108224 */ /* 0x000fe400078e00ff */ /*0860*/ @P0 IMAD.MOV.U32 R16, RZ, RZ, RZ ; /* 0x000000ffff100224 */ /* 0x000fe400078e00ff */ /*0870*/ @P0 IMAD.MOV.U32 R17, RZ, RZ, R2 ; /* 0x000000ffff110224 */ /* 0x000fe200078e0002 */ /*0880*/ BRA 0x8e0 ; /* 0x0000005000007947 */ /* 0x000fea0003800000 */ /*0890*/ LOP3.LUT R17, R7, 0x80000, RZ, 0xfc, !PT ; /* 0x0008000007117812 */ /* 0x000fe200078efcff */ /*08a0*/ IMAD.MOV.U32 R16, RZ, RZ, R6 ; /* 0x000000ffff107224 */ /* 0x000fe200078e0006 */ /*08b0*/ BRA 0x8e0 ; /* 0x0000002000007947 */ /* 0x000fea0003800000 */ /*08c0*/ LOP3.LUT R17, R5, 0x80000, RZ, 0xfc, !PT ; /* 0x0008000005117812 */ /* 0x000fe200078efcff */ /*08d0*/ IMAD.MOV.U32 R16, RZ, RZ, R4 ; /* 0x000000ffff107224 */ /* 0x000fe400078e0004 */ /*08e0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*08f0*/ IMAD.MOV.U32 R2, RZ, RZ, R0 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0000 */ /*0900*/ IMAD.MOV.U32 R3, RZ, RZ, 0x0 ; /* 0x00000000ff037424 */ /* 0x000fc400078e00ff */ /*0910*/ IMAD.MOV.U32 R6, RZ, RZ, R16 ; /* 0x000000ffff067224 */ /* 0x000fe400078e0010 */ /*0920*/ IMAD.MOV.U32 R7, RZ, RZ, R17 ; /* 0x000000ffff077224 */ /* 0x000fe200078e0011 */ /*0930*/ RET.REL.NODEC R2 0x0 ; /* 0xfffff6c002007950 */ /* 0x000fec0003c3ffff */ /*0940*/ BRA 0x940; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0950*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0960*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0970*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0980*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0990*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z6ghostsiiPd .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R13, SR_TID.X ; /* 0x00000000000d7919 */ /* 0x000e220000002100 */ /*0020*/ MOV R10, c[0x0][0x160] ; /* 0x00005800000a7a02 */ /* 0x000fe20000000f00 */ /*0030*/ HFMA2.MMA R0, -RZ, RZ, 0, 4.76837158203125e-07 ; /* 0x00000008ff007435 */ /* 0x000fe200000001ff */ /*0040*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*0050*/ IADD3 R12, R10, 0x2, RZ ; /* 0x000000020a0c7810 */ /* 0x000fe40007ffe0ff */ /*0060*/ IADD3 R15, R13, 0x1, RZ ; /* 0x000000010d0f7810 */ /* 0x001fca0007ffe0ff */ /*0070*/ IMAD R3, R15, R12, RZ ; /* 0x0000000c0f037224 */ /* 0x000fc800078e02ff */ /*0080*/ IMAD.WIDE R2, R3, R0, c[0x0][0x168] ; /* 0x00005a0003027625 */ /* 0x000fca00078e0200 */ /*0090*/ LDG.E.64 R4, [R2.64+0x10] ; /* 0x0000100602047981 */ /* 0x000ea2000c1e1b00 */ /*00a0*/ IADD3 R7, R10, -0x1, RZ ; /* 0xffffffff0a077810 */ /* 0x000fca0007ffe0ff */ /*00b0*/ IMAD.WIDE R6, R7, 0x8, R2 ; /* 0x0000000807067825 */ /* 0x000fe200078e0202 */ /*00c0*/ LEA R17, R10, R13, 0x1 ; /* 0x0000000d0a117211 */ /* 0x000fe200078e08ff */ /*00d0*/ STG.E.64 [R2.64], R4 ; /* 0x0000000402007986 */ /* 0x0041e8000c101b06 */ /*00e0*/ LDG.E.64 R8, [R6.64] ; /* 0x0000000606087981 */ /* 0x000ea2000c1e1b00 */ /*00f0*/ IMAD.WIDE R10, R17, R0.reuse, c[0x0][0x168] ; /* 0x00005a00110a7625 */ /* 0x080fe200078e0200 */ /*0100*/ ULDC UR4, c[0x0][0x164] ; /* 0x0000590000047ab9 */ /* 0x000fe40000000800 */ /*0110*/ UIADD3 UR4, UR4, -0x1, URZ ; /* 0xffffffff04047890 */ /* 0x000fe2000fffe03f */ /*0120*/ IMAD.WIDE R14, R15, R0, c[0x0][0x168] ; /* 0x00005a000f0e7625 */ /* 0x000fe200078e0200 */ /*0130*/ STG.E.64 [R6.64+0x10], R8 ; /* 0x0000100806007986 */ /* 0x004fe8000c101b06 */ /*0140*/ LDG.E.64 R10, [R10.64+0x28] ; /* 0x000028060a0a7981 */ /* 0x000ea2000c1e1b00 */ /*0150*/ IMAD R16, R12, UR4, RZ ; /* 0x000000040c107c24 */ /* 0x000fc4000f8e02ff */ /*0160*/ IMAD.WIDE R12, R13, R0, c[0x0][0x168] ; /* 0x00005a000d0c7625 */ /* 0x000fc800078e0200 */ /*0170*/ IMAD.WIDE R14, R16, 0x8, R14 ; /* 0x00000008100e7825 */ /* 0x000fe200078e020e */ /*0180*/ IADD3 R3, R17, 0x5, R16 ; /* 0x0000000511037810 */ /* 0x001fe20007ffe010 */ /*0190*/ STG.E.64 [R12.64+0x8], R10 ; /* 0x0000080a0c007986 */ /* 0x004fe8000c101b06 */ /*01a0*/ LDG.E.64 R14, [R14.64] ; /* 0x000000060e0e7981 */ /* 0x000ea2000c1e1b00 */ /*01b0*/ IMAD.WIDE R2, R3, R0, c[0x0][0x168] ; /* 0x00005a0003027625 */ /* 0x000fca00078e0200 */ /*01c0*/ STG.E.64 [R2.64], R14 ; /* 0x0000000e02007986 */ /* 0x004fe2000c101b06 */ /*01d0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01e0*/ BRA 0x1e0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0200*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0210*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0220*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0230*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0240*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refer to "Detailed Numerical Analyses of the Aliev-Panfilov Model on GPGPU" * https://www.simula.no/publications/detailed-numerical-analyses-aliev-panfilov-model-gpgpu * by Xing Cai, Didem Unat and Scott Baden * */ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <string.h> #include <math.h> #include <sys/time.h> #include <getopt.h> using namespace std; // External functions extern "C" void splot(double *E, double T, int niter, int m, int n); void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads); // Utilities // // Timer // Make successive calls and take a difference to get the elapsed time. static const double kMicro = 1.0e-6; double getTime() { struct timeval TV; struct timezone TZ; const int RC = gettimeofday(&TV, &TZ); if (RC == -1) { cerr << "ERROR: Bad call to gettimeofday" << endl; return (-1); } return (((double) TV.tv_sec) + kMicro * ((double) TV.tv_usec)); } // end getTime() // Reports statistics about the computation // These values should not vary (except to within roundoff) // when we use different numbers of processes to solve the problem double stats(double *E, int m, int n, double *_mx) { double mx = -1; double l2norm = 0; int i, j; for (j = 1; j <= m; j++) { for (i = 1; i <= n; i++) { l2norm += E[j * (n+2) + i] * E[j * (n+2) + i]; if (E[j * (n+2) + i] > mx) mx = E[j * (n+2) + i]; } } *_mx = mx; l2norm /= (double) ((m) * (n)); l2norm = sqrt(l2norm); return l2norm; } __global__ void ghosts(const int n, const int m, double *E_prev) { int j = threadIdx.x + 1; E_prev[j * (n+2)] = E_prev[j * (n+2) + 2]; E_prev[j * (n+2) + (n + 1)] = E_prev[j * (n + 2) + (n - 1)]; E_prev[j] = E_prev[2 * (n + 2) + j]; E_prev[(m + 1) * (n + 2) + j] = E_prev[(m - 1) * (n + 2) + j]; } __global__ void ode(const double a, const double kk, const double dt, const int n, const int m, double *E, double *R, const double epsilon, const double M1, const double M2, const double b) { /* * Solve the ODE, advancing excitation and recovery to the * next timtestep */ int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E[index] - dt * (kk * E[index] * (E[index] - a) * (E[index] - 1) + E[index] * R[index]); R[index] = R[index] + dt * (epsilon + M1 * R[index] / (E[index] + M2)) * (-R[index] - kk * E[index] * (E[index] - b - 1)); } __global__ void pde(const int n, const int m, double *E, double *E_prev, const double alpha) { int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E_prev[index] + alpha * (E_prev[index + 1] + E_prev[index - 1] - 4 * E_prev[index] + E_prev[index + m + 2] + E_prev[index - (m + 2)]); } void simulate(double *E, double *E_prev, double *R, const double alpha, const int n, const int m, const double kk, const double dt, const double a, const double epsilon, const double M1, const double M2, const double b) { /* * Copy data from boundary of the computational box * to the padding region, set up for differencing * on the boundary of the computational box * Using mirror boundaries */ ghosts<<<1, n>>>(n, m, E_prev); pde<<<m, n>>>(n, m, E, E_prev, alpha); ode<<<m, n>>>(a, kk, dt, n, m, E, R, epsilon, M1, M2, b); } // Define Kernels // __global__ void // __device__ // Main program int main(int argc, char **argv) { /* * Solution arrays * E is the "Excitation" variable, a voltage * R is the "Recovery" variable * E_prev is the Excitation variable for the previous timestep, * and is used in time integration */ double *E, *R, *E_prev; // Various constants - these definitions shouldn't change const double a = 0.1, b = 0.1, kk = 8.0, M1 = 0.07, M2 = 0.3, epsilon = 0.01, d = 5e-5; double T = 1000.0; int m = 200, n = 200; int plot_freq = 0; int px = 1, py = 1; int no_comm = 0; int num_threads = 1; cmdLine(argc, argv, T, n, px, py, plot_freq, no_comm, num_threads); m = n; // Allocate contiguous memory for solution arrays // The computational box is defined on [1:m+1,1:n+1] // We pad the arrays in order to facilitate differencing on the // boundaries of the computation box E = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); E_prev = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); R = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); int i, j; // Initialization for (j = 1; j <= m; j++) for (i = 1; i <= n; i++) E_prev[j * (n+2) + i] = R[j * (n+2) + i] = 0; for (j = 1; j <= m; j++) for (i = n / 2 + 1; i <= n; i++) E_prev[j * (n+2) + i] = 1.0; for (j = m / 2 + 1; j <= m; j++) for (i = 1; i <= n; i++) R[j * (n+2) + i] = 1.0; double dx = 1.0 / n; // For time integration, these values shouldn't change double rp = kk * (b + 1) * (b + 1) / 4; double dte = (dx * dx) / (d * 4 + ((dx * dx)) * (rp + kk)); double dtr = 1 / (epsilon + ((M1 / M2) * rp)); double dt = (dte < dtr) ? 0.95 * dte : 0.95 * dtr; double alpha = d * dt / (dx * dx); cout << "Grid Size : " << n << endl; cout << "Duration of Sim : " << T << endl; cout << "Time step dt : " << dt << endl; cout << "Process geometry: " << px << " x " << py << endl; if (no_comm) cout << "Communication : DISABLED" << endl; cout << endl; // Start the timer double t0 = getTime(); // Simulated time is different from the integer timestep number // Simulated time double t = 0.0; // Integer timestep number int niter = 0; double *d_E, *d_E_prev, *d_R; cudaMalloc((void **) &d_E, sizeof(double) * (m + 2) * (n + 2)); cudaMalloc((void **) &d_E_prev, sizeof(double) * (m + 2) * (n + 2)); cudaMalloc((void **) &d_R, sizeof(double) * (m + 2) * (n + 2)); cudaMemcpy(d_E, E, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); cudaMemcpy(d_E_prev, E_prev, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); cudaMemcpy(d_R, R, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); while (t < T) { t += dt; niter++; simulate(d_E, d_E_prev, d_R, alpha, n, m, kk, dt, a, epsilon, M1, M2, b); //swap current E with previous E double *tmp = d_E; d_E = d_E_prev; d_E_prev = tmp; if (plot_freq) { int k = (int) (t / plot_freq); if ((t - k * plot_freq) < dt) { cudaMemcpy(E, d_E, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyDeviceToHost); splot(E, t, niter, m + 2, n + 2); } } }//end of while loop cudaMemcpy(E_prev, d_E_prev, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyDeviceToHost); cudaFree(d_E); cudaFree(d_E_prev); cudaFree(d_R); double time_elapsed = getTime() - t0; double Gflops = (double) (niter * (1E-9 * n * n) * 28.0) / time_elapsed; double BW = (double) (niter * 1E-9 * (n * n * sizeof(double) * 4.0)) / time_elapsed; cout << "Number of Iterations : " << niter << endl; cout << "Elapsed Time (sec) : " << time_elapsed << endl; cout << "Sustained Gflops Rate : " << Gflops << endl; cout << "Sustained Bandwidth (GB/sec): " << BW << endl << endl; double mx; double l2norm = stats(E_prev, m, n, &mx); cout << "Max: " << mx << " L2norm: " << l2norm << endl; if (plot_freq) { cout << "\n\nEnter any input to close the program and the plot..." << endl; getchar(); } free(E); free(E_prev); free(R); return 0; } void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads) { /// Command line arguments // Default value of the domain sizes static struct option long_options[] = { {"n", required_argument, 0, 'n'}, {"px", required_argument, 0, 'x'}, {"py", required_argument, 0, 'y'}, {"tfinal", required_argument, 0, 't'}, {"plot", required_argument, 0, 'p'}, {"nocomm", no_argument, 0, 'k'}, {"numthreads", required_argument, 0, 'o'}, }; // Process command line arguments int ac; for (ac = 1; ac < argc; ac++) { int c; while ((c = getopt_long(argc, argv, "n:x:y:t:kp:o:", long_options, NULL)) != -1) { switch (c) { // Size of the computational box case 'n': n = atoi(optarg); break; // X processor geometry case 'x': px = atoi(optarg); // Y processor geometry case 'y': py = atoi(optarg); // Length of simulation, in simulated time units case 't': T = atof(optarg); break; // Turn off communication case 'k': no_comm = 1; break; // Plot the excitation variable case 'p': plot_freq = atoi(optarg); break; // Plot the excitation variable case 'o': num_threads = atoi(optarg); break; // Error default: printf("Usage: a.out [-n <domain size>] [-t <final time >]\n\t [-p <plot frequency>]\n\t[-px <x processor geometry> [-py <y proc. geometry] [-k turn off communication] [-o <Number of OpenMP threads>]\n"); exit(-1); } } } } /* ********************************************************** * Author : Urvashi R.V. [04/06/2004] * Modified by Didem Unat [03/23/18] *************************************************************/ #include <stdio.h> /* Function to plot the 2D array * 'gnuplot' is instantiated via a pipe and * the values to be plotted are passed through, along * with gnuplot commands */ FILE *gnu = NULL; void splot(double *U, double T, int niter, int m, int n) { int i, j; if (gnu == NULL) gnu = popen("gnuplot", "w"); double mx = -1, mn = 32768; for (j = 0; j < m; j++) for (i = 0; i < n; i++) { if (U[j * m + i] > mx) mx = U[j * m + i]; if (U[j * m + i] < mn) mn = U[j * m + i]; } fprintf(gnu, "set title \"T = %f [niter = %d]\"\n", T, niter); fprintf(gnu, "set size square\n"); fprintf(gnu, "set key off\n"); fprintf(gnu, "set pm3d map\n"); // Various color schemes fprintf(gnu, "set palette defined (-3 \"blue\", 0 \"white\", 1 \"red\")\n"); // fprintf(gnu,"set palette rgbformulae 22, 13, 31\n"); // fprintf(gnu,"set palette rgbformulae 30, 31, 32\n"); fprintf(gnu, "splot [0:%d] [0:%d][%f:%f] \"-\"\n", m - 1, n - 1, mn, mx); for (j = 0; j < m; j++) { for (i = 0; i < n; i++) { fprintf(gnu, "%d %d %f\n", i, j, U[i * m + j]); } fprintf(gnu, "\n"); } fprintf(gnu, "e\n"); fflush(gnu); return; }
.file "tmpxft_0014befd_00000000-6_cardiacsim_kernels_v1.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3957: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3957: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC1: .string "ERROR: Bad call to gettimeofday" .text .globl _Z7getTimev .type _Z7getTimev, @function _Z7getTimev: .LFB3949: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $48, %rsp .cfi_def_cfa_offset 64 movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax leaq 8(%rsp), %rsi leaq 16(%rsp), %rdi call gettimeofday@PLT cmpl $-1, %eax je .L12 pxor %xmm0, %xmm0 cvtsi2sdq 24(%rsp), %xmm0 mulsd .LC2(%rip), %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq 16(%rsp), %xmm1 addsd %xmm1, %xmm0 .L3: movq 40(%rsp), %rax subq %fs:40, %rax jne .L13 addq $48, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L12: .cfi_restore_state movl $31, %edx leaq .LC1(%rip), %rsi leaq _ZSt4cerr(%rip), %rbx movq %rbx, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq _ZSt4cerr(%rip), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %rbx testq %rbx, %rbx je .L14 cmpb $0, 56(%rbx) je .L7 movzbl 67(%rbx), %esi .L8: movsbl %sil, %esi leaq _ZSt4cerr(%rip), %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT movsd .LC0(%rip), %xmm0 jmp .L3 .L14: movq 40(%rsp), %rax subq %fs:40, %rax jne .L15 call _ZSt16__throw_bad_castv@PLT .L15: call __stack_chk_fail@PLT .L7: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi jmp .L8 .L13: call __stack_chk_fail@PLT .cfi_endproc .LFE3949: .size _Z7getTimev, .-_Z7getTimev .globl _Z5statsPdiiS_ .type _Z5statsPdiiS_, @function _Z5statsPdiiS_: .LFB3950: .cfi_startproc endbr64 pushq %r12 .cfi_def_cfa_offset 16 .cfi_offset 12, -16 pushq %rbp .cfi_def_cfa_offset 24 .cfi_offset 6, -24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset 3, -32 movl %esi, %ebp movl %edx, %r8d movq %rcx, %r12 testl %esi, %esi jle .L17 movq %rdi, %r9 leal 2(%rdx), %r10d leal 1(%rsi), %r11d movl %r10d, %edi movl $1, %esi pxor %xmm0, %xmm0 movsd .LC0(%rip), %xmm2 leal -1(%rdx), %ebx leaq 8(%r9), %rcx jmp .L18 .L22: movslq %edi, %rdx leaq (%r9,%rdx,8), %rax addq %rbx, %rdx leaq (%rcx,%rdx,8), %rdx .L20: movsd 8(%rax), %xmm1 movapd %xmm1, %xmm3 mulsd %xmm1, %xmm3 addsd %xmm3, %xmm0 maxsd %xmm2, %xmm1 movapd %xmm1, %xmm2 addq $8, %rax cmpq %rdx, %rax jne .L20 .L23: addl $1, %esi addl %r10d, %edi cmpl %r11d, %esi je .L21 .L18: testl %r8d, %r8d jg .L22 jmp .L23 .L21: movsd %xmm2, (%r12) imull %ebp, %r8d pxor %xmm1, %xmm1 cvtsi2sdl %r8d, %xmm1 divsd %xmm1, %xmm0 pxor %xmm1, %xmm1 ucomisd %xmm0, %xmm1 ja .L30 .L27: sqrtsd %xmm0, %xmm0 .L16: popq %rbx .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .L30: .cfi_restore_state call sqrt@PLT jmp .L16 .L17: movq .LC0(%rip), %rax movq %rax, (%rcx) imull %edx, %ebp pxor %xmm1, %xmm1 cvtsi2sdl %ebp, %xmm1 pxor %xmm0, %xmm0 divsd %xmm1, %xmm0 jmp .L27 .cfi_endproc .LFE3950: .size _Z5statsPdiiS_, .-_Z5statsPdiiS_ .section .rodata.str1.8 .align 8 .LC4: .string "Usage: a.out [-n <domain size>] [-t <final time >]\n\t [-p <plot frequency>]\n\t[-px <x processor geometry> [-py <y proc. geometry] [-k turn off communication] [-o <Number of OpenMP threads>]\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC5: .string "n:x:y:t:kp:o:" .text .globl _Z7cmdLineiPPcRdRiS2_S2_S2_S2_S2_ .type _Z7cmdLineiPPcRdRiS2_S2_S2_S2_S2_, @function _Z7cmdLineiPPcRdRiS2_S2_S2_S2_S2_: .LFB3953: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 subq $40, %rsp .cfi_def_cfa_offset 96 movl %edi, %ebp movq %rsi, %r12 movq %rdx, %r15 movq %rcx, 16(%rsp) movq %r8, 24(%rsp) movq %r9, (%rsp) movl $1, 12(%rsp) leaq _ZZ7cmdLineiPPcRdRiS2_S2_S2_S2_S2_E12long_options(%rip), %r14 leaq .LC5(%rip), %r13 leaq .L37(%rip), %rbx cmpl $1, %edi jg .L46 jmp .L32 .L42: movl $10, %edx movl $0, %esi movq optarg(%rip), %rdi call __isoc23_strtol@PLT movq 16(%rsp), %rcx movl %eax, (%rcx) jmp .L46 .L38: movl $10, %edx movl $0, %esi movq optarg(%rip), %rdi call __isoc23_strtol@PLT movq 24(%rsp), %rdx movl %eax, (%rdx) .L36: movl $10, %edx movl $0, %esi movq optarg(%rip), %rdi call __isoc23_strtol@PLT movq (%rsp), %rcx movl %eax, (%rcx) .L39: movl $0, %esi movq optarg(%rip), %rdi call strtod@PLT movsd %xmm0, (%r15) .L46: movl $0, %r8d movq %r14, %rcx movq %r13, %rdx movq %r12, %rsi movl %ebp, %edi call getopt_long@PLT cmpl $-1, %eax je .L51 subl $107, %eax cmpl $14, %eax ja .L35 movl %eax, %eax movslq (%rbx,%rax,4), %rax addq %rbx, %rax notrack jmp *%rax .section .rodata .align 4 .align 4 .L37: .long .L43-.L37 .long .L35-.L37 .long .L35-.L37 .long .L42-.L37 .long .L41-.L37 .long .L40-.L37 .long .L35-.L37 .long .L35-.L37 .long .L35-.L37 .long .L39-.L37 .long .L35-.L37 .long .L35-.L37 .long .L35-.L37 .long .L38-.L37 .long .L36-.L37 .text .L43: movq 104(%rsp), %rax movl $1, (%rax) jmp .L46 .L40: movl $10, %edx movl $0, %esi movq optarg(%rip), %rdi call __isoc23_strtol@PLT movq 96(%rsp), %rcx movl %eax, (%rcx) jmp .L46 .L41: movl $10, %edx movl $0, %esi movq optarg(%rip), %rdi call __isoc23_strtol@PLT movq 112(%rsp), %rdx movl %eax, (%rdx) jmp .L46 .L35: leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $-1, %edi call exit@PLT .L51: addl $1, 12(%rsp) movl 12(%rsp), %eax cmpl %eax, %ebp jne .L46 .L32: addq $40, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3953: .size _Z7cmdLineiPPcRdRiS2_S2_S2_S2_S2_, .-_Z7cmdLineiPPcRdRiS2_S2_S2_S2_S2_ .section .rodata.str1.1 .LC7: .string "w" .LC8: .string "gnuplot" .section .rodata.str1.8 .align 8 .LC9: .string "set title \"T = %f [niter = %d]\"\n" .section .rodata.str1.1 .LC10: .string "set size square\n" .LC11: .string "set key off\n" .LC12: .string "set pm3d map\n" .section .rodata.str1.8 .align 8 .LC13: .string "set palette defined (-3 \"blue\", 0 \"white\", 1 \"red\")\n" .align 8 .LC14: .string "splot [0:%d] [0:%d][%f:%f] \"-\"\n" .section .rodata.str1.1 .LC15: .string "%d %d %f\n" .LC16: .string "\n" .LC17: .string "e\n" .text .globl splot .type splot, @function splot: .LFB3954: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 subq $40, %rsp .cfi_def_cfa_offset 96 movq %rdi, 16(%rsp) movsd %xmm0, 24(%rsp) movl %esi, %r13d movl %edx, %ebx movl %ecx, %r12d cmpq $0, gnu(%rip) je .L75 .L53: testl %ebx, %ebx jle .L54 movl $0, %ecx movsd .LC6(%rip), %xmm5 movsd %xmm5, 8(%rsp) movsd .LC0(%rip), %xmm6 movsd %xmm6, (%rsp) movl $0, %ebp movslq %r12d, %rsi movq 16(%rsp), %rdi jmp .L55 .L75: leaq .LC7(%rip), %rsi leaq .LC8(%rip), %rdi call popen@PLT movq %rax, gnu(%rip) jmp .L53 .L60: movslq %ecx, %rdx leaq (%rdi,%rdx,8), %rax addq %rsi, %rdx leaq (%rdi,%rdx,8), %rdx .L58: movsd (%rax), %xmm0 movapd %xmm0, %xmm2 maxsd (%rsp), %xmm2 movsd %xmm2, (%rsp) minsd 8(%rsp), %xmm0 movsd %xmm0, 8(%rsp) addq $8, %rax cmpq %rdx, %rax jne .L58 .L61: leal 1(%rbp), %r14d addl %ebx, %ecx cmpl %r14d, %ebx je .L59 movl %r14d, %ebp .L55: testl %r12d, %r12d jg .L60 jmp .L61 .L59: movl %r13d, %ecx movsd 24(%rsp), %xmm0 leaq .LC9(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $1, %eax call __fprintf_chk@PLT leaq .LC10(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leaq .LC11(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leaq .LC12(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leaq .LC13(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movsd (%rsp), %xmm1 movsd 8(%rsp), %xmm0 leal -1(%r12), %r8d movl %ebp, %ecx leaq .LC14(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $2, %eax call __fprintf_chk@PLT movslq %r14d, %rax leaq 0(,%rax,8), %r15 movq $0, (%rsp) leaq .LC15(%rip), %r14 movq %rax, 8(%rsp) jmp .L62 .L63: movsd 0(%rbp), %xmm0 movl %r13d, %r8d movl %ebx, %ecx movq %r14, %rdx movl $2, %esi movq gnu(%rip), %rdi movl $1, %eax call __fprintf_chk@PLT addl $1, %ebx addq %r15, %rbp cmpl %ebx, %r12d jne .L63 .L66: leaq .LC16(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT addq $1, (%rsp) movq (%rsp), %rax movq 8(%rsp), %rcx cmpq %rcx, %rax je .L64 .L62: movq (%rsp), %rax movl %eax, %r13d movq 16(%rsp), %rsi leaq (%rsi,%rax,8), %rbp movl $0, %ebx testl %r12d, %r12d jg .L63 jmp .L66 .L54: movl %r13d, %ecx movsd 24(%rsp), %xmm0 leaq .LC9(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $1, %eax call __fprintf_chk@PLT leaq .LC10(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leaq .LC11(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leaq .LC12(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leaq .LC13(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT leal -1(%rbx), %ecx movsd .LC0(%rip), %xmm1 movsd .LC6(%rip), %xmm0 leal -1(%r12), %r8d leaq .LC14(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $2, %eax call __fprintf_chk@PLT .L64: leaq .LC17(%rip), %rdx movl $2, %esi movq gnu(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movq gnu(%rip), %rdi call fflush@PLT addq $40, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3954: .size splot, .-splot .globl _Z27__device_stub__Z6ghostsiiPdiiPd .type _Z27__device_stub__Z6ghostsiiPdiiPd, @function _Z27__device_stub__Z6ghostsiiPdiiPd: .LFB3979: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movl %edi, 12(%rsp) movl %esi, 8(%rsp) movq %rdx, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 12(%rsp), %rax movq %rax, 80(%rsp) leaq 8(%rsp), %rax movq %rax, 88(%rsp) movq %rsp, %rax movq %rax, 96(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L80 .L76: movq 104(%rsp), %rax subq %fs:40, %rax jne .L81 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L80: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z6ghostsiiPd(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L76 .L81: call __stack_chk_fail@PLT .cfi_endproc .LFE3979: .size _Z27__device_stub__Z6ghostsiiPdiiPd, .-_Z27__device_stub__Z6ghostsiiPdiiPd .globl _Z6ghostsiiPd .type _Z6ghostsiiPd, @function _Z6ghostsiiPd: .LFB3980: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z27__device_stub__Z6ghostsiiPdiiPd addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3980: .size _Z6ghostsiiPd, .-_Z6ghostsiiPd .globl _Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd .type _Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd, @function _Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd: .LFB3981: .cfi_startproc endbr64 subq $248, %rsp .cfi_def_cfa_offset 256 movsd %xmm0, 72(%rsp) movsd %xmm1, 64(%rsp) movsd %xmm2, 56(%rsp) movl %edi, 52(%rsp) movl %esi, 48(%rsp) movq %rdx, 40(%rsp) movq %rcx, 32(%rsp) movsd %xmm3, 24(%rsp) movsd %xmm4, 16(%rsp) movsd %xmm5, 8(%rsp) movsd %xmm6, (%rsp) movq %fs:40, %rax movq %rax, 232(%rsp) xorl %eax, %eax leaq 72(%rsp), %rax movq %rax, 144(%rsp) leaq 64(%rsp), %rax movq %rax, 152(%rsp) leaq 56(%rsp), %rax movq %rax, 160(%rsp) leaq 52(%rsp), %rax movq %rax, 168(%rsp) leaq 48(%rsp), %rax movq %rax, 176(%rsp) leaq 40(%rsp), %rax movq %rax, 184(%rsp) leaq 32(%rsp), %rax movq %rax, 192(%rsp) leaq 24(%rsp), %rax movq %rax, 200(%rsp) leaq 16(%rsp), %rax movq %rax, 208(%rsp) leaq 8(%rsp), %rax movq %rax, 216(%rsp) movq %rsp, %rax movq %rax, 224(%rsp) movl $1, 96(%rsp) movl $1, 100(%rsp) movl $1, 104(%rsp) movl $1, 108(%rsp) movl $1, 112(%rsp) movl $1, 116(%rsp) leaq 88(%rsp), %rcx leaq 80(%rsp), %rdx leaq 108(%rsp), %rsi leaq 96(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L88 .L84: movq 232(%rsp), %rax subq %fs:40, %rax jne .L89 addq $248, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L88: .cfi_restore_state pushq 88(%rsp) .cfi_def_cfa_offset 264 pushq 88(%rsp) .cfi_def_cfa_offset 272 leaq 160(%rsp), %r9 movq 124(%rsp), %rcx movl 132(%rsp), %r8d movq 112(%rsp), %rsi movl 120(%rsp), %edx leaq _Z3odedddiiPdS_dddd(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 256 jmp .L84 .L89: call __stack_chk_fail@PLT .cfi_endproc .LFE3981: .size _Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd, .-_Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd .globl _Z3odedddiiPdS_dddd .type _Z3odedddiiPdS_dddd, @function _Z3odedddiiPdS_dddd: .LFB3982: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3982: .size _Z3odedddiiPdS_dddd, .-_Z3odedddiiPdS_dddd .globl _Z27__device_stub__Z3pdeiiPdS_diiPdS_d .type _Z27__device_stub__Z3pdeiiPdS_diiPdS_d, @function _Z27__device_stub__Z3pdeiiPdS_diiPdS_d: .LFB3983: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movl %edi, 28(%rsp) movl %esi, 24(%rsp) movq %rdx, 16(%rsp) movq %rcx, 8(%rsp) movsd %xmm0, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 28(%rsp), %rax movq %rax, 96(%rsp) leaq 24(%rsp), %rax movq %rax, 104(%rsp) leaq 16(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) movq %rsp, %rax movq %rax, 128(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L96 .L92: movq 136(%rsp), %rax subq %fs:40, %rax jne .L97 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L96: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z3pdeiiPdS_d(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L92 .L97: call __stack_chk_fail@PLT .cfi_endproc .LFE3983: .size _Z27__device_stub__Z3pdeiiPdS_diiPdS_d, .-_Z27__device_stub__Z3pdeiiPdS_diiPdS_d .globl _Z3pdeiiPdS_d .type _Z3pdeiiPdS_d, @function _Z3pdeiiPdS_d: .LFB3984: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z27__device_stub__Z3pdeiiPdS_diiPdS_d addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3984: .size _Z3pdeiiPdS_d, .-_Z3pdeiiPdS_d .globl _Z8simulatePdS_S_diiddddddd .type _Z8simulatePdS_S_diiddddddd, @function _Z8simulatePdS_S_diiddddddd: .LFB3951: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $96, %rsp .cfi_def_cfa_offset 144 movq %rdi, %r12 movq %rsi, %r13 movq %rdx, %r14 movsd %xmm0, (%rsp) movl %ecx, %ebx movl %r8d, %ebp movsd %xmm1, 8(%rsp) movsd %xmm2, 16(%rsp) movsd %xmm3, 24(%rsp) movsd %xmm4, 32(%rsp) movsd %xmm5, 40(%rsp) movsd %xmm6, 48(%rsp) movsd %xmm7, 56(%rsp) movl %ecx, 84(%rsp) movl $1, 88(%rsp) movl $1, 92(%rsp) movl $1, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $0, %r9d movl $0, %r8d movq 84(%rsp), %rdx movl $1, %ecx movq 72(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L105 .L101: movl %ebx, 84(%rsp) movl $1, 88(%rsp) movl $1, 92(%rsp) movl %ebp, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $0, %r9d movl $0, %r8d movq 84(%rsp), %rdx movl $1, %ecx movq 72(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L106 .L102: movl %ebx, 84(%rsp) movl $1, 88(%rsp) movl $1, 92(%rsp) movl %ebp, 72(%rsp) movl $1, 76(%rsp) movl $1, 80(%rsp) movl $0, %r9d movl $0, %r8d movq 84(%rsp), %rdx movl $1, %ecx movq 72(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L107 .L100: addq $96, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L105: .cfi_restore_state movq %r13, %rdx movl %ebp, %esi movl %ebx, %edi call _Z27__device_stub__Z6ghostsiiPdiiPd jmp .L101 .L106: movsd (%rsp), %xmm0 movq %r13, %rcx movq %r12, %rdx movl %ebp, %esi movl %ebx, %edi call _Z27__device_stub__Z3pdeiiPdS_diiPdS_d jmp .L102 .L107: movsd 56(%rsp), %xmm6 movsd 48(%rsp), %xmm5 movsd 40(%rsp), %xmm4 movsd 32(%rsp), %xmm3 movq %r14, %rcx movq %r12, %rdx movl %ebp, %esi movl %ebx, %edi movsd 16(%rsp), %xmm2 movsd 8(%rsp), %xmm1 movsd 24(%rsp), %xmm0 call _Z33__device_stub__Z3odedddiiPdS_dddddddiiPdS_dddd jmp .L100 .cfi_endproc .LFE3951: .size _Z8simulatePdS_S_diiddddddd, .-_Z8simulatePdS_S_diiddddddd .section .rodata.str1.1 .LC26: .string "Grid Size : " .LC27: .string "Duration of Sim : " .LC28: .string "Time step dt : " .LC29: .string "Process geometry: " .LC30: .string " x " .LC31: .string "Communication : DISABLED" .section .rodata.str1.8 .align 8 .LC40: .string "Number of Iterations : " .align 8 .LC41: .string "Elapsed Time (sec) : " .align 8 .LC42: .string "Sustained Gflops Rate : " .align 8 .LC43: .string "Sustained Bandwidth (GB/sec): " .section .rodata.str1.1 .LC44: .string "Max: " .LC45: .string " L2norm: " .section .rodata.str1.8 .align 8 .LC46: .string "\n\nEnter any input to close the program and the plot..." .text .globl main .type main, @function main: .LFB3952: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 subq $152, %rsp .cfi_def_cfa_offset 208 movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax movq .LC19(%rip), %rax movq %rax, 96(%rsp) movl $200, 72(%rsp) movl $0, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl $0, 88(%rsp) movl $1, 92(%rsp) leaq 72(%rsp), %rcx leaq 96(%rsp), %rdx subq $8, %rsp .cfi_def_cfa_offset 216 leaq 100(%rsp), %rax pushq %rax .cfi_def_cfa_offset 224 leaq 104(%rsp), %rax pushq %rax .cfi_def_cfa_offset 232 leaq 100(%rsp), %rax pushq %rax .cfi_def_cfa_offset 240 leaq 116(%rsp), %r9 leaq 112(%rsp), %r8 call _Z7cmdLineiPPcRdRiS2_S2_S2_S2_S2_ movl 104(%rsp), %r12d leal 2(%r12), %r13d movl %r13d, %ebp imull %r13d, %ebp movslq %ebp, %rbp salq $3, %rbp addq $32, %rsp .cfi_def_cfa_offset 208 movq %rbp, %rdi call malloc@PLT movq %rax, 40(%rsp) movq %rbp, %rdi call malloc@PLT movq %rax, %rbx movq %rbp, %rdi call malloc@PLT movq %rax, %rbp testl %r12d, %r12d jle .L109 movslq %r13d, %rax leaq 0(,%rax,8), %rsi leal -1(%r12), %r8d movl %r8d, %edx leaq 2(%rax,%rdx), %rdx salq $3, %rdx leal 1(%r12), %r9d movl $1, %edi movl %r12d, %ecx negq %rcx salq $3, %rcx .L110: leaq (%rcx,%rdx), %rax .L111: movq $0x000000000, 0(%rbp,%rax) movq $0x000000000, (%rbx,%rax) addq $8, %rax cmpq %rdx, %rax jne .L111 leal 1(%rdi), %eax addq %rsi, %rdx cmpl %r9d, %eax je .L112 movl %eax, %edi jmp .L110 .L112: movl %r12d, %eax shrl $31, %eax addl %r12d, %eax sarl %eax leal 1(%rax), %r9d movl %r13d, %esi movl $1, %ecx movslq %r9d, %r11 subl %eax, %r8d cltq addq %rax, %r8 leaq 16(%rbx), %r10 movsd .LC20(%rip), %xmm0 jmp .L115 .L133: movl %eax, %ecx .L115: cmpl %r9d, %r12d jl .L113 movslq %esi, %rdx leaq (%r11,%rdx), %rax leaq (%rbx,%rax,8), %rax addq %r8, %rdx leaq (%r10,%rdx,8), %rdx .L114: movsd %xmm0, (%rax) addq $8, %rax cmpq %rdx, %rax jne .L114 .L113: leal 1(%rcx), %eax addl %r13d, %esi cmpl %ecx, %edi jne .L133 .L109: movl %r12d, %ecx shrl $31, %ecx addl %r12d, %ecx sarl %ecx addl $1, %ecx cmpl %ecx, %r12d jl .L116 movl %ecx, %esi imull %r13d, %esi leal 1(%r12), %edi leal -1(%r12), %r9d leaq 8(%rbp), %r8 movsd .LC20(%rip), %xmm0 jmp .L117 .L119: movslq %esi, %rdx leaq 0(%rbp,%rdx,8), %rax addq %r9, %rdx leaq (%r8,%rdx,8), %rdx .L118: movsd %xmm0, 8(%rax) addq $8, %rax cmpq %rdx, %rax jne .L118 .L120: addl $1, %ecx addl %r13d, %esi cmpl %edi, %ecx je .L116 .L117: testl %r12d, %r12d jg .L119 jmp .L120 .L116: pxor %xmm7, %xmm7 cvtsi2sdl %r12d, %xmm7 movsd %xmm7, 48(%rsp) movsd .LC20(%rip), %xmm0 divsd %xmm7, %xmm0 mulsd %xmm0, %xmm0 movapd %xmm0, %xmm1 mulsd .LC21(%rip), %xmm1 addsd .LC22(%rip), %xmm1 movapd %xmm0, %xmm2 divsd %xmm1, %xmm2 movsd .LC23(%rip), %xmm1 comisd %xmm2, %xmm1 jbe .L144 mulsd .LC24(%rip), %xmm2 movsd %xmm2, 16(%rsp) jmp .L121 .L144: movsd .LC18(%rip), %xmm5 movsd %xmm5, 16(%rsp) .L121: movsd 16(%rsp), %xmm1 mulsd .LC25(%rip), %xmm1 movapd %xmm1, %xmm6 divsd %xmm0, %xmm6 movsd %xmm6, 32(%rsp) leaq .LC26(%rip), %rsi leaq _ZSt4cout(%rip), %r14 movq %r14, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl %r12d, %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC27(%rip), %rsi movq %r14, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movsd 96(%rsp), %xmm6 movsd %xmm6, 24(%rsp) movapd %xmm6, %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC28(%rip), %rsi movq %r14, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movsd 16(%rsp), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC29(%rip), %rsi movq %r14, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 80(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC30(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 84(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT cmpl $0, 88(%rsp) jne .L147 .L123: leaq _ZSt4cout(%rip), %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT call _Z7getTimev movsd %xmm0, 56(%rsp) movslq %r13d, %r15 imulq %r15, %r15 salq $3, %r15 leaq 104(%rsp), %rdi movq %r15, %rsi call cudaMalloc@PLT leaq 112(%rsp), %rdi movq %r15, %rsi call cudaMalloc@PLT leaq 120(%rsp), %rdi movq %r15, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r15, %rdx movq 40(%rsp), %rsi movq 104(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r15, %rdx movq %rbx, %rsi movq 112(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r15, %rdx movq %rbp, %rsi movq 120(%rsp), %rdi call cudaMemcpy@PLT movl $0, %r14d movq $0x000000000, 8(%rsp) pxor %xmm0, %xmm0 movsd 24(%rsp), %xmm7 comisd %xmm0, %xmm7 ja .L128 movl $0, %r14d .L124: movl $2, %ecx movq %r15, %rdx movq 112(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT movq 104(%rsp), %rdi call cudaFree@PLT movq 112(%rsp), %rdi call cudaFree@PLT movq 120(%rsp), %rdi call cudaFree@PLT call _Z7getTimev movapd %xmm0, %xmm6 subsd 56(%rsp), %xmm6 movsd %xmm6, 8(%rsp) pxor %xmm1, %xmm1 cvtsi2sdl %r14d, %xmm1 movsd 48(%rsp), %xmm7 movapd %xmm7, %xmm0 mulsd .LC37(%rip), %xmm0 mulsd %xmm7, %xmm0 mulsd %xmm1, %xmm0 mulsd .LC38(%rip), %xmm0 divsd %xmm6, %xmm0 movsd %xmm0, 16(%rsp) movl %r12d, %eax imull %r12d, %eax cltq salq $3, %rax js .L129 pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 .L130: mulsd .LC39(%rip), %xmm0 mulsd .LC37(%rip), %xmm1 mulsd %xmm1, %xmm0 movapd %xmm0, %xmm7 divsd 8(%rsp), %xmm7 movq %xmm7, %r13 leaq .LC40(%rip), %rsi leaq _ZSt4cout(%rip), %r15 movq %r15, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl %r14d, %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC41(%rip), %rsi movq %r15, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movsd 8(%rsp), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC42(%rip), %rsi movq %r15, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movsd 16(%rsp), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC43(%rip), %rsi movq %r15, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq %r13, %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq 128(%rsp), %rcx movl %r12d, %edx movl %r12d, %esi movq %rbx, %rdi call _Z5statsPdiiS_ movsd %xmm0, 8(%rsp) leaq .LC44(%rip), %rsi movq %r15, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movsd 128(%rsp), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi leaq .LC45(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movsd 8(%rsp), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT cmpl $0, 76(%rsp) jne .L148 .L131: movq 40(%rsp), %rdi call free@PLT movq %rbx, %rdi call free@PLT movq %rbp, %rdi call free@PLT movq 136(%rsp), %rax subq %fs:40, %rax jne .L149 movl $0, %eax addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .L147: .cfi_restore_state leaq .LC31(%rip), %rsi movq %r14, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT jmp .L123 .L126: movsd 24(%rsp), %xmm4 comisd 8(%rsp), %xmm4 jbe .L124 .L128: movsd 8(%rsp), %xmm3 movsd 16(%rsp), %xmm2 addsd %xmm2, %xmm3 movsd %xmm3, 8(%rsp) addl $1, %r14d movsd .LC32(%rip), %xmm7 movsd .LC33(%rip), %xmm6 movsd .LC34(%rip), %xmm5 movsd .LC35(%rip), %xmm4 movapd %xmm7, %xmm3 movsd .LC36(%rip), %xmm1 movl %r12d, %r8d movl %r12d, %ecx movsd 32(%rsp), %xmm0 movq 120(%rsp), %rdx movq 112(%rsp), %rsi movq 104(%rsp), %rdi call _Z8simulatePdS_S_diiddddddd movq 104(%rsp), %rax movq 112(%rsp), %rsi movq %rsi, 104(%rsp) movq %rax, 112(%rsp) movl 76(%rsp), %eax testl %eax, %eax je .L126 pxor %xmm1, %xmm1 cvtsi2sdl %eax, %xmm1 movsd 8(%rsp), %xmm3 movapd %xmm3, %xmm0 divsd %xmm1, %xmm0 cvttsd2sil %xmm0, %edx imull %edx, %eax pxor %xmm1, %xmm1 cvtsi2sdl %eax, %xmm1 subsd %xmm1, %xmm3 movsd 16(%rsp), %xmm2 comisd %xmm3, %xmm2 jbe .L126 movl $2, %ecx movq %r15, %rdx movq 40(%rsp), %rdi call cudaMemcpy@PLT movl %r13d, %ecx movl %r13d, %edx movl %r14d, %esi movsd 8(%rsp), %xmm0 movq 40(%rsp), %rdi call splot jmp .L126 .L129: shrq %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 addsd %xmm0, %xmm0 jmp .L130 .L148: leaq .LC46(%rip), %rsi movq %r15, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq stdin(%rip), %rdi call getc@PLT jmp .L131 .L149: call __stack_chk_fail@PLT .cfi_endproc .LFE3952: .size main, .-main .section .rodata.str1.1 .LC47: .string "_Z3pdeiiPdS_d" .LC48: .string "_Z3odedddiiPdS_dddd" .LC49: .string "_Z6ghostsiiPd" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3986: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC47(%rip), %rdx movq %rdx, %rcx leaq _Z3pdeiiPdS_d(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC48(%rip), %rdx movq %rdx, %rcx leaq _Z3odedddiiPdS_dddd(%rip), %rsi movq %rbx, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC49(%rip), %rdx movq %rdx, %rcx leaq _Z6ghostsiiPd(%rip), %rsi movq %rbx, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3986: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .globl gnu .bss .align 8 .type gnu, @object .size gnu, 8 gnu: .zero 8 .section .rodata.str1.1 .LC50: .string "n" .LC51: .string "px" .LC52: .string "py" .LC53: .string "tfinal" .LC54: .string "plot" .LC55: .string "nocomm" .LC56: .string "numthreads" .section .data.rel.local,"aw" .align 32 .type _ZZ7cmdLineiPPcRdRiS2_S2_S2_S2_S2_E12long_options, @object .size _ZZ7cmdLineiPPcRdRiS2_S2_S2_S2_S2_E12long_options, 224 _ZZ7cmdLineiPPcRdRiS2_S2_S2_S2_S2_E12long_options: .quad .LC50 .long 1 .zero 4 .quad 0 .long 110 .zero 4 .quad .LC51 .long 1 .zero 4 .quad 0 .long 120 .zero 4 .quad .LC52 .long 1 .zero 4 .quad 0 .long 121 .zero 4 .quad .LC53 .long 1 .zero 4 .quad 0 .long 116 .zero 4 .quad .LC54 .long 1 .zero 4 .quad 0 .long 112 .zero 4 .quad .LC55 .long 0 .zero 4 .quad 0 .long 107 .zero 4 .quad .LC56 .long 1 .zero 4 .quad 0 .long 111 .zero 4 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC0: .long 0 .long -1074790400 .align 8 .LC2: .long -1598689907 .long 1051772663 .align 8 .LC6: .long 0 .long 1088421888 .align 8 .LC18: .long -847035317 .long 1073378106 .align 8 .LC19: .long 0 .long 1083129856 .align 8 .LC20: .long 0 .long 1072693248 .align 8 .LC21: .long 1030792151 .long 1076156170 .align 8 .LC22: .long -350469331 .long 1059731170 .align 8 .LC23: .long 916791160 .long 1073469340 .align 8 .LC24: .long 1717986918 .long 1072588390 .align 8 .LC25: .long -350469331 .long 1057634018 .align 8 .LC32: .long -1717986918 .long 1069128089 .align 8 .LC33: .long 858993459 .long 1070805811 .align 8 .LC34: .long 515396076 .long 1068624773 .align 8 .LC35: .long 1202590843 .long 1065646817 .align 8 .LC36: .long 0 .long 1075838976 .align 8 .LC37: .long -400107883 .long 1041313291 .align 8 .LC38: .long 0 .long 1077673984 .align 8 .LC39: .long 0 .long 1074790400 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refer to "Detailed Numerical Analyses of the Aliev-Panfilov Model on GPGPU" * https://www.simula.no/publications/detailed-numerical-analyses-aliev-panfilov-model-gpgpu * by Xing Cai, Didem Unat and Scott Baden * */ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <string.h> #include <math.h> #include <sys/time.h> #include <getopt.h> using namespace std; // External functions extern "C" void splot(double *E, double T, int niter, int m, int n); void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads); // Utilities // // Timer // Make successive calls and take a difference to get the elapsed time. static const double kMicro = 1.0e-6; double getTime() { struct timeval TV; struct timezone TZ; const int RC = gettimeofday(&TV, &TZ); if (RC == -1) { cerr << "ERROR: Bad call to gettimeofday" << endl; return (-1); } return (((double) TV.tv_sec) + kMicro * ((double) TV.tv_usec)); } // end getTime() // Reports statistics about the computation // These values should not vary (except to within roundoff) // when we use different numbers of processes to solve the problem double stats(double *E, int m, int n, double *_mx) { double mx = -1; double l2norm = 0; int i, j; for (j = 1; j <= m; j++) { for (i = 1; i <= n; i++) { l2norm += E[j * (n+2) + i] * E[j * (n+2) + i]; if (E[j * (n+2) + i] > mx) mx = E[j * (n+2) + i]; } } *_mx = mx; l2norm /= (double) ((m) * (n)); l2norm = sqrt(l2norm); return l2norm; } __global__ void ghosts(const int n, const int m, double *E_prev) { int j = threadIdx.x + 1; E_prev[j * (n+2)] = E_prev[j * (n+2) + 2]; E_prev[j * (n+2) + (n + 1)] = E_prev[j * (n + 2) + (n - 1)]; E_prev[j] = E_prev[2 * (n + 2) + j]; E_prev[(m + 1) * (n + 2) + j] = E_prev[(m - 1) * (n + 2) + j]; } __global__ void ode(const double a, const double kk, const double dt, const int n, const int m, double *E, double *R, const double epsilon, const double M1, const double M2, const double b) { /* * Solve the ODE, advancing excitation and recovery to the * next timtestep */ int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E[index] - dt * (kk * E[index] * (E[index] - a) * (E[index] - 1) + E[index] * R[index]); R[index] = R[index] + dt * (epsilon + M1 * R[index] / (E[index] + M2)) * (-R[index] - kk * E[index] * (E[index] - b - 1)); } __global__ void pde(const int n, const int m, double *E, double *E_prev, const double alpha) { int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E_prev[index] + alpha * (E_prev[index + 1] + E_prev[index - 1] - 4 * E_prev[index] + E_prev[index + m + 2] + E_prev[index - (m + 2)]); } void simulate(double *E, double *E_prev, double *R, const double alpha, const int n, const int m, const double kk, const double dt, const double a, const double epsilon, const double M1, const double M2, const double b) { /* * Copy data from boundary of the computational box * to the padding region, set up for differencing * on the boundary of the computational box * Using mirror boundaries */ ghosts<<<1, n>>>(n, m, E_prev); pde<<<m, n>>>(n, m, E, E_prev, alpha); ode<<<m, n>>>(a, kk, dt, n, m, E, R, epsilon, M1, M2, b); } // Define Kernels // __global__ void // __device__ // Main program int main(int argc, char **argv) { /* * Solution arrays * E is the "Excitation" variable, a voltage * R is the "Recovery" variable * E_prev is the Excitation variable for the previous timestep, * and is used in time integration */ double *E, *R, *E_prev; // Various constants - these definitions shouldn't change const double a = 0.1, b = 0.1, kk = 8.0, M1 = 0.07, M2 = 0.3, epsilon = 0.01, d = 5e-5; double T = 1000.0; int m = 200, n = 200; int plot_freq = 0; int px = 1, py = 1; int no_comm = 0; int num_threads = 1; cmdLine(argc, argv, T, n, px, py, plot_freq, no_comm, num_threads); m = n; // Allocate contiguous memory for solution arrays // The computational box is defined on [1:m+1,1:n+1] // We pad the arrays in order to facilitate differencing on the // boundaries of the computation box E = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); E_prev = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); R = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); int i, j; // Initialization for (j = 1; j <= m; j++) for (i = 1; i <= n; i++) E_prev[j * (n+2) + i] = R[j * (n+2) + i] = 0; for (j = 1; j <= m; j++) for (i = n / 2 + 1; i <= n; i++) E_prev[j * (n+2) + i] = 1.0; for (j = m / 2 + 1; j <= m; j++) for (i = 1; i <= n; i++) R[j * (n+2) + i] = 1.0; double dx = 1.0 / n; // For time integration, these values shouldn't change double rp = kk * (b + 1) * (b + 1) / 4; double dte = (dx * dx) / (d * 4 + ((dx * dx)) * (rp + kk)); double dtr = 1 / (epsilon + ((M1 / M2) * rp)); double dt = (dte < dtr) ? 0.95 * dte : 0.95 * dtr; double alpha = d * dt / (dx * dx); cout << "Grid Size : " << n << endl; cout << "Duration of Sim : " << T << endl; cout << "Time step dt : " << dt << endl; cout << "Process geometry: " << px << " x " << py << endl; if (no_comm) cout << "Communication : DISABLED" << endl; cout << endl; // Start the timer double t0 = getTime(); // Simulated time is different from the integer timestep number // Simulated time double t = 0.0; // Integer timestep number int niter = 0; double *d_E, *d_E_prev, *d_R; cudaMalloc((void **) &d_E, sizeof(double) * (m + 2) * (n + 2)); cudaMalloc((void **) &d_E_prev, sizeof(double) * (m + 2) * (n + 2)); cudaMalloc((void **) &d_R, sizeof(double) * (m + 2) * (n + 2)); cudaMemcpy(d_E, E, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); cudaMemcpy(d_E_prev, E_prev, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); cudaMemcpy(d_R, R, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyHostToDevice); while (t < T) { t += dt; niter++; simulate(d_E, d_E_prev, d_R, alpha, n, m, kk, dt, a, epsilon, M1, M2, b); //swap current E with previous E double *tmp = d_E; d_E = d_E_prev; d_E_prev = tmp; if (plot_freq) { int k = (int) (t / plot_freq); if ((t - k * plot_freq) < dt) { cudaMemcpy(E, d_E, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyDeviceToHost); splot(E, t, niter, m + 2, n + 2); } } }//end of while loop cudaMemcpy(E_prev, d_E_prev, sizeof(double) * (m + 2) * (n + 2), cudaMemcpyDeviceToHost); cudaFree(d_E); cudaFree(d_E_prev); cudaFree(d_R); double time_elapsed = getTime() - t0; double Gflops = (double) (niter * (1E-9 * n * n) * 28.0) / time_elapsed; double BW = (double) (niter * 1E-9 * (n * n * sizeof(double) * 4.0)) / time_elapsed; cout << "Number of Iterations : " << niter << endl; cout << "Elapsed Time (sec) : " << time_elapsed << endl; cout << "Sustained Gflops Rate : " << Gflops << endl; cout << "Sustained Bandwidth (GB/sec): " << BW << endl << endl; double mx; double l2norm = stats(E_prev, m, n, &mx); cout << "Max: " << mx << " L2norm: " << l2norm << endl; if (plot_freq) { cout << "\n\nEnter any input to close the program and the plot..." << endl; getchar(); } free(E); free(E_prev); free(R); return 0; } void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads) { /// Command line arguments // Default value of the domain sizes static struct option long_options[] = { {"n", required_argument, 0, 'n'}, {"px", required_argument, 0, 'x'}, {"py", required_argument, 0, 'y'}, {"tfinal", required_argument, 0, 't'}, {"plot", required_argument, 0, 'p'}, {"nocomm", no_argument, 0, 'k'}, {"numthreads", required_argument, 0, 'o'}, }; // Process command line arguments int ac; for (ac = 1; ac < argc; ac++) { int c; while ((c = getopt_long(argc, argv, "n:x:y:t:kp:o:", long_options, NULL)) != -1) { switch (c) { // Size of the computational box case 'n': n = atoi(optarg); break; // X processor geometry case 'x': px = atoi(optarg); // Y processor geometry case 'y': py = atoi(optarg); // Length of simulation, in simulated time units case 't': T = atof(optarg); break; // Turn off communication case 'k': no_comm = 1; break; // Plot the excitation variable case 'p': plot_freq = atoi(optarg); break; // Plot the excitation variable case 'o': num_threads = atoi(optarg); break; // Error default: printf("Usage: a.out [-n <domain size>] [-t <final time >]\n\t [-p <plot frequency>]\n\t[-px <x processor geometry> [-py <y proc. geometry] [-k turn off communication] [-o <Number of OpenMP threads>]\n"); exit(-1); } } } } /* ********************************************************** * Author : Urvashi R.V. [04/06/2004] * Modified by Didem Unat [03/23/18] *************************************************************/ #include <stdio.h> /* Function to plot the 2D array * 'gnuplot' is instantiated via a pipe and * the values to be plotted are passed through, along * with gnuplot commands */ FILE *gnu = NULL; void splot(double *U, double T, int niter, int m, int n) { int i, j; if (gnu == NULL) gnu = popen("gnuplot", "w"); double mx = -1, mn = 32768; for (j = 0; j < m; j++) for (i = 0; i < n; i++) { if (U[j * m + i] > mx) mx = U[j * m + i]; if (U[j * m + i] < mn) mn = U[j * m + i]; } fprintf(gnu, "set title \"T = %f [niter = %d]\"\n", T, niter); fprintf(gnu, "set size square\n"); fprintf(gnu, "set key off\n"); fprintf(gnu, "set pm3d map\n"); // Various color schemes fprintf(gnu, "set palette defined (-3 \"blue\", 0 \"white\", 1 \"red\")\n"); // fprintf(gnu,"set palette rgbformulae 22, 13, 31\n"); // fprintf(gnu,"set palette rgbformulae 30, 31, 32\n"); fprintf(gnu, "splot [0:%d] [0:%d][%f:%f] \"-\"\n", m - 1, n - 1, mn, mx); for (j = 0; j < m; j++) { for (i = 0; i < n; i++) { fprintf(gnu, "%d %d %f\n", i, j, U[i * m + j]); } fprintf(gnu, "\n"); } fprintf(gnu, "e\n"); fflush(gnu); return; }
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refer to "Detailed Numerical Analyses of the Aliev-Panfilov Model on GPGPU" * https://www.simula.no/publications/detailed-numerical-analyses-aliev-panfilov-model-gpgpu * by Xing Cai, Didem Unat and Scott Baden * */ #include <hip/hip_runtime.h> #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <string.h> #include <math.h> #include <sys/time.h> #include <getopt.h> using namespace std; // External functions extern "C" void splot(double *E, double T, int niter, int m, int n); void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads); // Utilities // // Timer // Make successive calls and take a difference to get the elapsed time. static const double kMicro = 1.0e-6; double getTime() { struct timeval TV; struct timezone TZ; const int RC = gettimeofday(&TV, &TZ); if (RC == -1) { cerr << "ERROR: Bad call to gettimeofday" << endl; return (-1); } return (((double) TV.tv_sec) + kMicro * ((double) TV.tv_usec)); } // end getTime() // Reports statistics about the computation // These values should not vary (except to within roundoff) // when we use different numbers of processes to solve the problem double stats(double *E, int m, int n, double *_mx) { double mx = -1; double l2norm = 0; int i, j; for (j = 1; j <= m; j++) { for (i = 1; i <= n; i++) { l2norm += E[j * (n+2) + i] * E[j * (n+2) + i]; if (E[j * (n+2) + i] > mx) mx = E[j * (n+2) + i]; } } *_mx = mx; l2norm /= (double) ((m) * (n)); l2norm = sqrt(l2norm); return l2norm; } __global__ void ghosts(const int n, const int m, double *E_prev) { int j = threadIdx.x + 1; E_prev[j * (n+2)] = E_prev[j * (n+2) + 2]; E_prev[j * (n+2) + (n + 1)] = E_prev[j * (n + 2) + (n - 1)]; E_prev[j] = E_prev[2 * (n + 2) + j]; E_prev[(m + 1) * (n + 2) + j] = E_prev[(m - 1) * (n + 2) + j]; } __global__ void ode(const double a, const double kk, const double dt, const int n, const int m, double *E, double *R, const double epsilon, const double M1, const double M2, const double b) { /* * Solve the ODE, advancing excitation and recovery to the * next timtestep */ int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E[index] - dt * (kk * E[index] * (E[index] - a) * (E[index] - 1) + E[index] * R[index]); R[index] = R[index] + dt * (epsilon + M1 * R[index] / (E[index] + M2)) * (-R[index] - kk * E[index] * (E[index] - b - 1)); } __global__ void pde(const int n, const int m, double *E, double *E_prev, const double alpha) { int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E_prev[index] + alpha * (E_prev[index + 1] + E_prev[index - 1] - 4 * E_prev[index] + E_prev[index + m + 2] + E_prev[index - (m + 2)]); } void simulate(double *E, double *E_prev, double *R, const double alpha, const int n, const int m, const double kk, const double dt, const double a, const double epsilon, const double M1, const double M2, const double b) { /* * Copy data from boundary of the computational box * to the padding region, set up for differencing * on the boundary of the computational box * Using mirror boundaries */ ghosts<<<1, n>>>(n, m, E_prev); pde<<<m, n>>>(n, m, E, E_prev, alpha); ode<<<m, n>>>(a, kk, dt, n, m, E, R, epsilon, M1, M2, b); } // Define Kernels // __global__ void // __device__ // Main program int main(int argc, char **argv) { /* * Solution arrays * E is the "Excitation" variable, a voltage * R is the "Recovery" variable * E_prev is the Excitation variable for the previous timestep, * and is used in time integration */ double *E, *R, *E_prev; // Various constants - these definitions shouldn't change const double a = 0.1, b = 0.1, kk = 8.0, M1 = 0.07, M2 = 0.3, epsilon = 0.01, d = 5e-5; double T = 1000.0; int m = 200, n = 200; int plot_freq = 0; int px = 1, py = 1; int no_comm = 0; int num_threads = 1; cmdLine(argc, argv, T, n, px, py, plot_freq, no_comm, num_threads); m = n; // Allocate contiguous memory for solution arrays // The computational box is defined on [1:m+1,1:n+1] // We pad the arrays in order to facilitate differencing on the // boundaries of the computation box E = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); E_prev = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); R = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); int i, j; // Initialization for (j = 1; j <= m; j++) for (i = 1; i <= n; i++) E_prev[j * (n+2) + i] = R[j * (n+2) + i] = 0; for (j = 1; j <= m; j++) for (i = n / 2 + 1; i <= n; i++) E_prev[j * (n+2) + i] = 1.0; for (j = m / 2 + 1; j <= m; j++) for (i = 1; i <= n; i++) R[j * (n+2) + i] = 1.0; double dx = 1.0 / n; // For time integration, these values shouldn't change double rp = kk * (b + 1) * (b + 1) / 4; double dte = (dx * dx) / (d * 4 + ((dx * dx)) * (rp + kk)); double dtr = 1 / (epsilon + ((M1 / M2) * rp)); double dt = (dte < dtr) ? 0.95 * dte : 0.95 * dtr; double alpha = d * dt / (dx * dx); cout << "Grid Size : " << n << endl; cout << "Duration of Sim : " << T << endl; cout << "Time step dt : " << dt << endl; cout << "Process geometry: " << px << " x " << py << endl; if (no_comm) cout << "Communication : DISABLED" << endl; cout << endl; // Start the timer double t0 = getTime(); // Simulated time is different from the integer timestep number // Simulated time double t = 0.0; // Integer timestep number int niter = 0; double *d_E, *d_E_prev, *d_R; hipMalloc((void **) &d_E, sizeof(double) * (m + 2) * (n + 2)); hipMalloc((void **) &d_E_prev, sizeof(double) * (m + 2) * (n + 2)); hipMalloc((void **) &d_R, sizeof(double) * (m + 2) * (n + 2)); hipMemcpy(d_E, E, sizeof(double) * (m + 2) * (n + 2), hipMemcpyHostToDevice); hipMemcpy(d_E_prev, E_prev, sizeof(double) * (m + 2) * (n + 2), hipMemcpyHostToDevice); hipMemcpy(d_R, R, sizeof(double) * (m + 2) * (n + 2), hipMemcpyHostToDevice); while (t < T) { t += dt; niter++; simulate(d_E, d_E_prev, d_R, alpha, n, m, kk, dt, a, epsilon, M1, M2, b); //swap current E with previous E double *tmp = d_E; d_E = d_E_prev; d_E_prev = tmp; if (plot_freq) { int k = (int) (t / plot_freq); if ((t - k * plot_freq) < dt) { hipMemcpy(E, d_E, sizeof(double) * (m + 2) * (n + 2), hipMemcpyDeviceToHost); splot(E, t, niter, m + 2, n + 2); } } }//end of while loop hipMemcpy(E_prev, d_E_prev, sizeof(double) * (m + 2) * (n + 2), hipMemcpyDeviceToHost); hipFree(d_E); hipFree(d_E_prev); hipFree(d_R); double time_elapsed = getTime() - t0; double Gflops = (double) (niter * (1E-9 * n * n) * 28.0) / time_elapsed; double BW = (double) (niter * 1E-9 * (n * n * sizeof(double) * 4.0)) / time_elapsed; cout << "Number of Iterations : " << niter << endl; cout << "Elapsed Time (sec) : " << time_elapsed << endl; cout << "Sustained Gflops Rate : " << Gflops << endl; cout << "Sustained Bandwidth (GB/sec): " << BW << endl << endl; double mx; double l2norm = stats(E_prev, m, n, &mx); cout << "Max: " << mx << " L2norm: " << l2norm << endl; if (plot_freq) { cout << "\n\nEnter any input to close the program and the plot..." << endl; getchar(); } free(E); free(E_prev); free(R); return 0; } void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads) { /// Command line arguments // Default value of the domain sizes static struct option long_options[] = { {"n", required_argument, 0, 'n'}, {"px", required_argument, 0, 'x'}, {"py", required_argument, 0, 'y'}, {"tfinal", required_argument, 0, 't'}, {"plot", required_argument, 0, 'p'}, {"nocomm", no_argument, 0, 'k'}, {"numthreads", required_argument, 0, 'o'}, }; // Process command line arguments int ac; for (ac = 1; ac < argc; ac++) { int c; while ((c = getopt_long(argc, argv, "n:x:y:t:kp:o:", long_options, NULL)) != -1) { switch (c) { // Size of the computational box case 'n': n = atoi(optarg); break; // X processor geometry case 'x': px = atoi(optarg); // Y processor geometry case 'y': py = atoi(optarg); // Length of simulation, in simulated time units case 't': T = atof(optarg); break; // Turn off communication case 'k': no_comm = 1; break; // Plot the excitation variable case 'p': plot_freq = atoi(optarg); break; // Plot the excitation variable case 'o': num_threads = atoi(optarg); break; // Error default: printf("Usage: a.out [-n <domain size>] [-t <final time >]\n\t [-p <plot frequency>]\n\t[-px <x processor geometry> [-py <y proc. geometry] [-k turn off communication] [-o <Number of OpenMP threads>]\n"); exit(-1); } } } } /* ********************************************************** * Author : Urvashi R.V. [04/06/2004] * Modified by Didem Unat [03/23/18] *************************************************************/ #include <stdio.h> /* Function to plot the 2D array * 'gnuplot' is instantiated via a pipe and * the values to be plotted are passed through, along * with gnuplot commands */ FILE *gnu = NULL; void splot(double *U, double T, int niter, int m, int n) { int i, j; if (gnu == NULL) gnu = popen("gnuplot", "w"); double mx = -1, mn = 32768; for (j = 0; j < m; j++) for (i = 0; i < n; i++) { if (U[j * m + i] > mx) mx = U[j * m + i]; if (U[j * m + i] < mn) mn = U[j * m + i]; } fprintf(gnu, "set title \"T = %f [niter = %d]\"\n", T, niter); fprintf(gnu, "set size square\n"); fprintf(gnu, "set key off\n"); fprintf(gnu, "set pm3d map\n"); // Various color schemes fprintf(gnu, "set palette defined (-3 \"blue\", 0 \"white\", 1 \"red\")\n"); // fprintf(gnu,"set palette rgbformulae 22, 13, 31\n"); // fprintf(gnu,"set palette rgbformulae 30, 31, 32\n"); fprintf(gnu, "splot [0:%d] [0:%d][%f:%f] \"-\"\n", m - 1, n - 1, mn, mx); for (j = 0; j < m; j++) { for (i = 0; i < n; i++) { fprintf(gnu, "%d %d %f\n", i, j, U[i * m + j]); } fprintf(gnu, "\n"); } fprintf(gnu, "e\n"); fflush(gnu); return; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refer to "Detailed Numerical Analyses of the Aliev-Panfilov Model on GPGPU" * https://www.simula.no/publications/detailed-numerical-analyses-aliev-panfilov-model-gpgpu * by Xing Cai, Didem Unat and Scott Baden * */ #include <hip/hip_runtime.h> #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <string.h> #include <math.h> #include <sys/time.h> #include <getopt.h> using namespace std; // External functions extern "C" void splot(double *E, double T, int niter, int m, int n); void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads); // Utilities // // Timer // Make successive calls and take a difference to get the elapsed time. static const double kMicro = 1.0e-6; double getTime() { struct timeval TV; struct timezone TZ; const int RC = gettimeofday(&TV, &TZ); if (RC == -1) { cerr << "ERROR: Bad call to gettimeofday" << endl; return (-1); } return (((double) TV.tv_sec) + kMicro * ((double) TV.tv_usec)); } // end getTime() // Reports statistics about the computation // These values should not vary (except to within roundoff) // when we use different numbers of processes to solve the problem double stats(double *E, int m, int n, double *_mx) { double mx = -1; double l2norm = 0; int i, j; for (j = 1; j <= m; j++) { for (i = 1; i <= n; i++) { l2norm += E[j * (n+2) + i] * E[j * (n+2) + i]; if (E[j * (n+2) + i] > mx) mx = E[j * (n+2) + i]; } } *_mx = mx; l2norm /= (double) ((m) * (n)); l2norm = sqrt(l2norm); return l2norm; } __global__ void ghosts(const int n, const int m, double *E_prev) { int j = threadIdx.x + 1; E_prev[j * (n+2)] = E_prev[j * (n+2) + 2]; E_prev[j * (n+2) + (n + 1)] = E_prev[j * (n + 2) + (n - 1)]; E_prev[j] = E_prev[2 * (n + 2) + j]; E_prev[(m + 1) * (n + 2) + j] = E_prev[(m - 1) * (n + 2) + j]; } __global__ void ode(const double a, const double kk, const double dt, const int n, const int m, double *E, double *R, const double epsilon, const double M1, const double M2, const double b) { /* * Solve the ODE, advancing excitation and recovery to the * next timtestep */ int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E[index] - dt * (kk * E[index] * (E[index] - a) * (E[index] - 1) + E[index] * R[index]); R[index] = R[index] + dt * (epsilon + M1 * R[index] / (E[index] + M2)) * (-R[index] - kk * E[index] * (E[index] - b - 1)); } __global__ void pde(const int n, const int m, double *E, double *E_prev, const double alpha) { int i = threadIdx.x + 1; int j = blockIdx.x + 1; int index = j * (n + 2) + i; E[index] = E_prev[index] + alpha * (E_prev[index + 1] + E_prev[index - 1] - 4 * E_prev[index] + E_prev[index + m + 2] + E_prev[index - (m + 2)]); } void simulate(double *E, double *E_prev, double *R, const double alpha, const int n, const int m, const double kk, const double dt, const double a, const double epsilon, const double M1, const double M2, const double b) { /* * Copy data from boundary of the computational box * to the padding region, set up for differencing * on the boundary of the computational box * Using mirror boundaries */ ghosts<<<1, n>>>(n, m, E_prev); pde<<<m, n>>>(n, m, E, E_prev, alpha); ode<<<m, n>>>(a, kk, dt, n, m, E, R, epsilon, M1, M2, b); } // Define Kernels // __global__ void // __device__ // Main program int main(int argc, char **argv) { /* * Solution arrays * E is the "Excitation" variable, a voltage * R is the "Recovery" variable * E_prev is the Excitation variable for the previous timestep, * and is used in time integration */ double *E, *R, *E_prev; // Various constants - these definitions shouldn't change const double a = 0.1, b = 0.1, kk = 8.0, M1 = 0.07, M2 = 0.3, epsilon = 0.01, d = 5e-5; double T = 1000.0; int m = 200, n = 200; int plot_freq = 0; int px = 1, py = 1; int no_comm = 0; int num_threads = 1; cmdLine(argc, argv, T, n, px, py, plot_freq, no_comm, num_threads); m = n; // Allocate contiguous memory for solution arrays // The computational box is defined on [1:m+1,1:n+1] // We pad the arrays in order to facilitate differencing on the // boundaries of the computation box E = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); E_prev = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); R = (double *) malloc(sizeof(double) * size_t((m + 2) * (n + 2))); int i, j; // Initialization for (j = 1; j <= m; j++) for (i = 1; i <= n; i++) E_prev[j * (n+2) + i] = R[j * (n+2) + i] = 0; for (j = 1; j <= m; j++) for (i = n / 2 + 1; i <= n; i++) E_prev[j * (n+2) + i] = 1.0; for (j = m / 2 + 1; j <= m; j++) for (i = 1; i <= n; i++) R[j * (n+2) + i] = 1.0; double dx = 1.0 / n; // For time integration, these values shouldn't change double rp = kk * (b + 1) * (b + 1) / 4; double dte = (dx * dx) / (d * 4 + ((dx * dx)) * (rp + kk)); double dtr = 1 / (epsilon + ((M1 / M2) * rp)); double dt = (dte < dtr) ? 0.95 * dte : 0.95 * dtr; double alpha = d * dt / (dx * dx); cout << "Grid Size : " << n << endl; cout << "Duration of Sim : " << T << endl; cout << "Time step dt : " << dt << endl; cout << "Process geometry: " << px << " x " << py << endl; if (no_comm) cout << "Communication : DISABLED" << endl; cout << endl; // Start the timer double t0 = getTime(); // Simulated time is different from the integer timestep number // Simulated time double t = 0.0; // Integer timestep number int niter = 0; double *d_E, *d_E_prev, *d_R; hipMalloc((void **) &d_E, sizeof(double) * (m + 2) * (n + 2)); hipMalloc((void **) &d_E_prev, sizeof(double) * (m + 2) * (n + 2)); hipMalloc((void **) &d_R, sizeof(double) * (m + 2) * (n + 2)); hipMemcpy(d_E, E, sizeof(double) * (m + 2) * (n + 2), hipMemcpyHostToDevice); hipMemcpy(d_E_prev, E_prev, sizeof(double) * (m + 2) * (n + 2), hipMemcpyHostToDevice); hipMemcpy(d_R, R, sizeof(double) * (m + 2) * (n + 2), hipMemcpyHostToDevice); while (t < T) { t += dt; niter++; simulate(d_E, d_E_prev, d_R, alpha, n, m, kk, dt, a, epsilon, M1, M2, b); //swap current E with previous E double *tmp = d_E; d_E = d_E_prev; d_E_prev = tmp; if (plot_freq) { int k = (int) (t / plot_freq); if ((t - k * plot_freq) < dt) { hipMemcpy(E, d_E, sizeof(double) * (m + 2) * (n + 2), hipMemcpyDeviceToHost); splot(E, t, niter, m + 2, n + 2); } } }//end of while loop hipMemcpy(E_prev, d_E_prev, sizeof(double) * (m + 2) * (n + 2), hipMemcpyDeviceToHost); hipFree(d_E); hipFree(d_E_prev); hipFree(d_R); double time_elapsed = getTime() - t0; double Gflops = (double) (niter * (1E-9 * n * n) * 28.0) / time_elapsed; double BW = (double) (niter * 1E-9 * (n * n * sizeof(double) * 4.0)) / time_elapsed; cout << "Number of Iterations : " << niter << endl; cout << "Elapsed Time (sec) : " << time_elapsed << endl; cout << "Sustained Gflops Rate : " << Gflops << endl; cout << "Sustained Bandwidth (GB/sec): " << BW << endl << endl; double mx; double l2norm = stats(E_prev, m, n, &mx); cout << "Max: " << mx << " L2norm: " << l2norm << endl; if (plot_freq) { cout << "\n\nEnter any input to close the program and the plot..." << endl; getchar(); } free(E); free(E_prev); free(R); return 0; } void cmdLine(int argc, char *argv[], double &T, int &n, int &px, int &py, int &plot_freq, int &no_comm, int &num_threads) { /// Command line arguments // Default value of the domain sizes static struct option long_options[] = { {"n", required_argument, 0, 'n'}, {"px", required_argument, 0, 'x'}, {"py", required_argument, 0, 'y'}, {"tfinal", required_argument, 0, 't'}, {"plot", required_argument, 0, 'p'}, {"nocomm", no_argument, 0, 'k'}, {"numthreads", required_argument, 0, 'o'}, }; // Process command line arguments int ac; for (ac = 1; ac < argc; ac++) { int c; while ((c = getopt_long(argc, argv, "n:x:y:t:kp:o:", long_options, NULL)) != -1) { switch (c) { // Size of the computational box case 'n': n = atoi(optarg); break; // X processor geometry case 'x': px = atoi(optarg); // Y processor geometry case 'y': py = atoi(optarg); // Length of simulation, in simulated time units case 't': T = atof(optarg); break; // Turn off communication case 'k': no_comm = 1; break; // Plot the excitation variable case 'p': plot_freq = atoi(optarg); break; // Plot the excitation variable case 'o': num_threads = atoi(optarg); break; // Error default: printf("Usage: a.out [-n <domain size>] [-t <final time >]\n\t [-p <plot frequency>]\n\t[-px <x processor geometry> [-py <y proc. geometry] [-k turn off communication] [-o <Number of OpenMP threads>]\n"); exit(-1); } } } } /* ********************************************************** * Author : Urvashi R.V. [04/06/2004] * Modified by Didem Unat [03/23/18] *************************************************************/ #include <stdio.h> /* Function to plot the 2D array * 'gnuplot' is instantiated via a pipe and * the values to be plotted are passed through, along * with gnuplot commands */ FILE *gnu = NULL; void splot(double *U, double T, int niter, int m, int n) { int i, j; if (gnu == NULL) gnu = popen("gnuplot", "w"); double mx = -1, mn = 32768; for (j = 0; j < m; j++) for (i = 0; i < n; i++) { if (U[j * m + i] > mx) mx = U[j * m + i]; if (U[j * m + i] < mn) mn = U[j * m + i]; } fprintf(gnu, "set title \"T = %f [niter = %d]\"\n", T, niter); fprintf(gnu, "set size square\n"); fprintf(gnu, "set key off\n"); fprintf(gnu, "set pm3d map\n"); // Various color schemes fprintf(gnu, "set palette defined (-3 \"blue\", 0 \"white\", 1 \"red\")\n"); // fprintf(gnu,"set palette rgbformulae 22, 13, 31\n"); // fprintf(gnu,"set palette rgbformulae 30, 31, 32\n"); fprintf(gnu, "splot [0:%d] [0:%d][%f:%f] \"-\"\n", m - 1, n - 1, mn, mx); for (j = 0; j < m; j++) { for (i = 0; i < n; i++) { fprintf(gnu, "%d %d %f\n", i, j, U[i * m + j]); } fprintf(gnu, "\n"); } fprintf(gnu, "e\n"); fflush(gnu); return; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6ghostsiiPd .globl _Z6ghostsiiPd .p2align 8 .type _Z6ghostsiiPd,@function _Z6ghostsiiPd: s_load_b128 s[0:3], s[0:1], 0x0 v_add_nc_u32_e32 v0, 1, v0 s_waitcnt lgkmcnt(0) s_add_i32 s4, s0, 2 s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1) v_mul_lo_u32 v1, s4, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v2, 31, v1 v_add_nc_u32_e32 v8, s0, v1 s_add_i32 s0, s1, -1 v_lshlrev_b64 v[2:3], 3, v[1:2] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v6, -1, v8 v_ashrrev_i32_e32 v7, 31, v6 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v2, vcc_lo, s2, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo s_delay_alu instid0(VALU_DEP_3) v_lshlrev_b64 v[6:7], 3, v[6:7] global_load_b64 v[4:5], v[2:3], off offset:16 v_add_co_u32 v6, vcc_lo, s2, v6 v_add_co_ci_u32_e32 v7, vcc_lo, s3, v7, vcc_lo s_waitcnt vmcnt(0) global_store_b64 v[2:3], v[4:5], off global_load_b64 v[1:2], v[6:7], off v_add_nc_u32_e32 v3, 1, v8 v_lshl_add_u32 v5, s4, 1, v0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v4, 31, v3 v_ashrrev_i32_e32 v6, 31, v5 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[3:4], 3, v[3:4] v_lshlrev_b64 v[5:6], 3, v[5:6] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v3, vcc_lo, s2, v3 v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v5, vcc_lo, s2, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo s_waitcnt vmcnt(0) global_store_b64 v[3:4], v[1:2], off global_load_b64 v[1:2], v[5:6], off v_lshlrev_b32_e32 v5, 3, v0 s_waitcnt vmcnt(0) v_mad_u64_u32 v[3:4], null, s0, s4, v[0:1] global_store_b64 v5, v[1:2], s[2:3] s_add_i32 s0, s1, 1 v_ashrrev_i32_e32 v4, 31, v3 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[3:4], 3, v[3:4] v_add_co_u32 v3, vcc_lo, s2, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo global_load_b64 v[1:2], v[3:4], off s_waitcnt vmcnt(0) v_mad_u64_u32 v[3:4], null, s0, s4, v[0:1] v_ashrrev_i32_e32 v4, 31, v3 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[3:4], 3, v[3:4] v_add_co_u32 v3, vcc_lo, s2, v3 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo global_store_b64 v[3:4], v[1:2], off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6ghostsiiPd .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 16 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 9 .amdhsa_next_free_sgpr 5 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z6ghostsiiPd, .Lfunc_end0-_Z6ghostsiiPd .section .AMDGPU.csdata,"",@progbits .text .protected _Z3odedddiiPdS_dddd .globl _Z3odedddiiPdS_dddd .p2align 8 .type _Z3odedddiiPdS_dddd,@function _Z3odedddiiPdS_dddd: s_clause 0x1 s_load_b32 s2, s[0:1], 0x18 s_load_b256 s[4:11], s[0:1], 0x20 s_add_i32 s15, s15, 1 s_waitcnt lgkmcnt(0) s_add_i32 s2, s2, 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_mul_i32 s2, s2, s15 v_add3_u32 v0, v0, s2, 1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[0:1], 3, v[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v2, vcc_lo, s4, v0 v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo global_load_b64 v[4:5], v[2:3], off global_load_b64 v[6:7], v[0:1], off s_clause 0x2 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[12:13], s[0:1], 0x10 s_load_b128 s[0:3], s[0:1], 0x40 s_waitcnt vmcnt(1) lgkmcnt(0) v_mul_f64 v[8:9], v[4:5], s[6:7] v_add_f64 v[10:11], v[4:5], -s[4:5] v_add_f64 v[12:13], v[4:5], -1.0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f64 v[8:9], v[8:9], v[10:11] v_mul_f64 v[8:9], v[12:13], v[8:9] s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[6:7], v[4:5], v[6:7], v[8:9] v_fma_f64 v[4:5], -v[6:7], s[12:13], v[4:5] global_store_b64 v[2:3], v[4:5], off global_load_b64 v[2:3], v[0:1], off v_add_f64 v[6:7], v[4:5], s[0:1] s_waitcnt vmcnt(0) v_mul_f64 v[8:9], v[2:3], s[10:11] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_div_scale_f64 v[10:11], null, v[6:7], v[6:7], v[8:9] v_div_scale_f64 v[16:17], vcc_lo, v[8:9], v[6:7], v[8:9] v_rcp_f64_e32 v[12:13], v[10:11] s_waitcnt_depctr 0xfff v_fma_f64 v[14:15], -v[10:11], v[12:13], 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[12:13], v[12:13], v[14:15], v[12:13] v_fma_f64 v[14:15], -v[10:11], v[12:13], 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[12:13], v[12:13], v[14:15], v[12:13] v_mul_f64 v[14:15], v[16:17], v[12:13] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[10:11], -v[10:11], v[14:15], v[16:17] v_div_fmas_f64 v[10:11], v[10:11], v[12:13], v[14:15] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_div_fixup_f64 v[6:7], v[10:11], v[6:7], v[8:9] v_add_f64 v[8:9], v[4:5], -s[2:3] v_mul_f64 v[4:5], v[4:5], s[6:7] v_add_f64 v[6:7], v[6:7], s[8:9] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_f64 v[8:9], v[8:9], -1.0 v_mul_f64 v[6:7], v[6:7], s[12:13] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[4:5], -v[4:5], v[8:9], -v[2:3] v_fma_f64 v[2:3], v[6:7], v[4:5], v[2:3] global_store_b64 v[0:1], v[2:3], off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z3odedddiiPdS_dddd .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 80 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 18 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z3odedddiiPdS_dddd, .Lfunc_end1-_Z3odedddiiPdS_dddd .section .AMDGPU.csdata,"",@progbits .text .protected _Z3pdeiiPdS_d .globl _Z3pdeiiPdS_d .p2align 8 .type _Z3pdeiiPdS_d,@function _Z3pdeiiPdS_d: s_load_b256 s[0:7], s[0:1], 0x0 s_add_i32 s15, s15, 1 s_waitcnt lgkmcnt(0) s_add_i32 s0, s0, 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[4:5], null, s0, s15, v[0:1] v_add_nc_u32_e32 v6, 1, v4 v_ashrrev_i32_e32 v5, 31, v4 v_xad_u32 v11, s1, -1, v4 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v7, 31, v6 v_lshlrev_b64 v[0:1], 3, v[4:5] v_add_nc_u32_e32 v5, s1, v6 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_ashrrev_i32_e32 v12, 31, v11 v_lshlrev_b64 v[7:8], 3, v[6:7] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v6, 31, v5 v_lshlrev_b64 v[11:12], 3, v[11:12] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v2, vcc_lo, s4, v7 v_add_co_ci_u32_e32 v3, vcc_lo, s5, v8, vcc_lo v_add_co_u32 v9, vcc_lo, s4, v0 v_add_co_ci_u32_e32 v10, vcc_lo, s5, v1, vcc_lo v_lshlrev_b64 v[5:6], 3, v[5:6] s_clause 0x1 global_load_b128 v[0:3], v[2:3], off global_load_b64 v[9:10], v[9:10], off v_add_co_u32 v5, vcc_lo, s4, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo v_add_co_u32 v11, vcc_lo, s4, v11 v_add_co_ci_u32_e32 v12, vcc_lo, s5, v12, vcc_lo s_clause 0x1 global_load_b64 v[5:6], v[5:6], off offset:16 global_load_b64 v[11:12], v[11:12], off s_waitcnt vmcnt(2) v_add_f64 v[2:3], v[2:3], v[9:10] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_fma_f64 v[2:3], v[0:1], -4.0, v[2:3] s_waitcnt vmcnt(1) v_add_f64 v[2:3], v[5:6], v[2:3] s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_f64 v[2:3], v[11:12], v[2:3] v_fma_f64 v[0:1], v[2:3], s[6:7], v[0:1] v_add_co_u32 v2, vcc_lo, s2, v7 v_add_co_ci_u32_e32 v3, vcc_lo, s3, v8, vcc_lo global_store_b64 v[2:3], v[0:1], off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z3pdeiiPdS_d .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 32 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 13 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end2: .size _Z3pdeiiPdS_d, .Lfunc_end2-_Z3pdeiiPdS_d .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .offset: 0 .size: 4 .value_kind: by_value - .offset: 4 .size: 4 .value_kind: by_value - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 16 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z6ghostsiiPd .private_segment_fixed_size: 0 .sgpr_count: 7 .sgpr_spill_count: 0 .symbol: _Z6ghostsiiPd.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 9 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .offset: 0 .size: 8 .value_kind: by_value - .offset: 8 .size: 8 .value_kind: by_value - .offset: 16 .size: 8 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .address_space: global .offset: 32 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 40 .size: 8 .value_kind: global_buffer - .offset: 48 .size: 8 .value_kind: by_value - .offset: 56 .size: 8 .value_kind: by_value - .offset: 64 .size: 8 .value_kind: by_value - .offset: 72 .size: 8 .value_kind: by_value .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 80 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z3odedddiiPdS_dddd .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z3odedddiiPdS_dddd.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 18 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .offset: 0 .size: 4 .value_kind: by_value - .offset: 4 .size: 4 .value_kind: by_value - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 8 .value_kind: by_value .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 32 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z3pdeiiPdS_d .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z3pdeiiPdS_d.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 13 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <fstream> #include <iostream> #include <curand.h> #include <curand_kernel.h> #define Infinity 65536 /* pow (2, 16) */ /* randdouble() Retorna um numero (double) aleatorio entre 0.0f e 1.0f. Parametros: Saida: numero aleaorio entre 0.0 e 1.0. */ #define randdouble() ((double)rand()/(double)RAND_MAX) /* randomize() Atualiza o gerador de numeros pseudo-aletatorios. Parametros: Saida: */ #define randomize() srand((unsigned)time(NULL)) /* index() Mapeia uma posicao de uma matriz (2D) para um indice de um vetor (1D). Parametros: length: numero de colunas da matriz line: indice da linha column: indice da coluna Saída: indice mapeado */ #define index(length,line,column) (column + line * length) using namespace std; const int NUMBER_OF_ITERATIONS = 100; const double INIT_PHEROMONE_AMOUNT = 1.0; const double EVAPORATION_RATE = 0.5; const double ALFA = 1; /* Influencia da trilha de feromonios */ const double BETA = 2; /* Influencia da informacao heuristica */ int threads ( int n_ants ); int thread_per_block ( int n_ants ); /* load_instance() Inicializa uma instancia ( numero de cidades e matriz de distancias ) do TSP. Parametros: filename: nome do arquivo n_cities: numero de cidades ( passagem por referencia ) Saida: matriz de distancias ( distancias euclidianas ) */ int *load_instance ( char const *filename, int &n_cities ); /* calculate_pathcost() Calcula o custo (soma dos custos de todas as arestas) de um caminho . Parametros: distances: matriz de distancias path: caminho ( solucao ) n_cities: numero de cidades Saida: custo ( soma de todas as distancias ) do caminho */ int calculate_pathcost ( int *distances, int *path, int n_cities ); /* best_solution() Retorna a melhor entre as solucoes geradas. Parametros: ants: matriz de solucoes distances: matriz de distancias ( entre cidades ) n_ants: numero de formigas n_cities: numero de cidades Saida: melhor solucao encontrada */ int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ); /* evaporate() Atualiza a matriz de feromonios aplicando evaporacao. Para cada vertice, multiplica-se a taxa de evaporacao ( EVAPORATION_RATE ). Parametros: pheromones: matriz de feromonios n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void evaporate ( double *pheromones, int n_cities ); /* reinforce() Atualiza a matriz de feromonios. Para cada vertice da melhor solucao corrente, adiciona-se uma quantidade de feromonios. Parametros: pheromones: matriz de feromonios distances: matriz de distancias min_path: caminho minimo ( melhor solucao ) encontrado n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void reinforce ( double *pheromones, int *distances, int *min_path, int n_cities ); /* run() Executa o algoritmo de colonia de formigas Parametros: distances: matriz de distancias n_cities: numero de cidades n_ants: numero de formigas Saida: melhor entre as solucoes encontradas por todas as formigas */ int *run ( int *distances, int n_cities, int n_ants ); __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ); __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ); __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ); int main ( int argc, char *argv[] ) { randomize(); char const *inputname, *outputname; if ( argc < 2 ) { cout << "Missing input arguments!" << endl; cout << "Program " << argv[0] << " takes exactly 3 arguments." << endl; return 1; } if ( argc > 3 ) { cout << "Too many arguments in program " << argv[0] << "!" << endl; cout << "It takes exactly 3 arguments." << endl; return 1; } cout << "Running " << argv[0] << " with arguments: "; for (int i = 1; i < argc; i++) cout << argv[i] << " "; cout << endl; inputname = argv[1]; if ( !argv[2] ) { outputname = "results/output.txt"; } else { outputname = argv[2]; } int n_cities; /* Numero de cidades */ int *distances; /* Matriz de distancias (distancia euclidiana) */ /* Inicializa a instancia. Executa o algoritmo e calcula do custo da solucao. */ distances = load_instance ( inputname, n_cities ); int *solution = run ( distances, n_cities, threads ( n_cities ) ); int cost = calculate_pathcost ( distances, solution, n_cities ); cout << "Writing results in file " << outputname << "!\n"; ofstream output; output.open(outputname); output << "Custo: " << cost << endl; output << "Melhor solucao encontrada:\n"; for(int i=0; i<n_cities; i++) output << solution[i] << endl; cout << argv[0] << " exited with no errors."; return 0; } __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ) { int edge_id = threadIdx.x + blockIdx.x * blockDim.x; pheromones[ edge_id ] *= evap_rate; } __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ) { int col_id = threadIdx.x + blockIdx.x * blockDim.x; int origin = path[col_id]; int dest = path[col_id+1]; pheromones[ index( n_cities, origin, dest ) ] += amount; pheromones[ index( n_cities, dest, origin ) ] += amount; } __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ) { int line_id = blockDim.x * blockIdx.x + threadIdx.x; for (int step = 1; step < n_cities; step++) { int current = tours[ index ( n_cities, line_id, step - 1 ) ]; double sum_probs = 0.0; for(int i = 0; i < n_cities; i++) { if ( visited[ index ( n_cities, line_id, i) ] == 1 ) probs[ index ( n_cities, line_id, i ) ] = 0.0; else { double current_prob = choiceinfo[ index( n_cities, current, i ) ]; probs[ index ( n_cities, line_id, i ) ] = current_prob; sum_probs += current_prob; } } double random; curandState_t state; curand_init ( (unsigned long long) clock(), 0, 0, &state ); random = curand_uniform ( &state ); random *= sum_probs; int next; double sum = probs[ index ( n_cities, line_id, 0 ) ]; for(next = 0; sum < random; next++) { sum += probs[ index ( n_cities, line_id, next + 1 ) ]; } tours[ index ( n_cities, line_id, step ) ] = next; visited[ index ( n_cities, line_id, next) ] = 1; } } int threads ( int n_ants ) { int n_threds = 1; while ( n_threds * 2 < n_ants ) { n_threds *= 2; } return n_threds; } int thread_per_block ( int n_ants ) { int blocks = log(n_ants); return pow (2, blocks); } int *load_instance ( char const *filename, int &n_cities ) { cout << "Opening file " << filename << endl; ifstream tsp; tsp.open (filename); /*if ( ifstream == NULL ) { cout << "File " << filename << " not found!\n"; exit(1); }*/ tsp >> n_cities; int* distances = (int *) malloc ( n_cities * n_cities * sizeof(int) ); for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) tsp >> distances[ index(n_cities, i, j) ]; return distances; } int calculate_pathcost ( int *distances, int *path, int n_cities ) { int cost = 0; for (int i = 0; i < (n_cities - 1); i++) cost += distances[ index(n_cities, path[i], path[i+1]) ]; return cost; } int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ) { int *best_tour = &tours[0]; for (int tour = 0; tour < n_ants; tour++) if (calculate_pathcost(distances, &tours[index(n_cities, tour, 0)], n_cities) < calculate_pathcost(distances, best_tour, n_cities)) best_tour = &tours[index(n_cities, tour, 0)]; return best_tour; } void evaporate ( double *pheromones, int n_cities ) { int size = n_cities * n_cities * sizeof(double); double *pheromones_device; cudaMalloc ( (void**) &pheromones_device, size); cudaMemcpy (pheromones_device, pheromones, size, cudaMemcpyHostToDevice); cuda_evaporate <<< n_cities, n_cities >>> ( pheromones_device, n_cities, EVAPORATION_RATE ); cudaMemcpy (pheromones, pheromones_device, size, cudaMemcpyDeviceToHost); cudaFree (pheromones_device); } void reinforce ( double *pheromones, int *distances, int *path, int n_cities ) { double amount = (double) ( 1.0f / (double) calculate_pathcost ( distances, path, n_cities ) ); int size_path = n_cities * sizeof(int); int size_int = n_cities * n_cities * sizeof(int); int size_double = n_cities * n_cities * sizeof(double); int *path_device; int *distances_device; double *pheromones_device; cudaMalloc((void**)&path_device, size_path); cudaMalloc((void**)&distances_device, size_int); cudaMalloc((void**)&pheromones_device, size_double); cudaMemcpy (path_device, path, size_path, cudaMemcpyHostToDevice); cudaMemcpy (distances_device, distances, size_int, cudaMemcpyHostToDevice); cudaMemcpy (pheromones_device, pheromones, size_double, cudaMemcpyHostToDevice); cuda_reinforce <<< 1, n_cities - 1 >>> (pheromones_device, distances_device, path_device, n_cities, amount); cudaMemcpy (distances, distances_device, size_int, cudaMemcpyDeviceToHost); cudaMemcpy (pheromones, pheromones_device, size_double, cudaMemcpyDeviceToHost); cudaFree (path_device); cudaFree (distances_device); cudaFree (pheromones_device); } int *run ( int *distances, int n_cities, int n_ants) { int ph_size = n_cities * n_cities * sizeof(double); int tours_size = n_ants * n_cities * sizeof(int); int dist_size = n_cities * n_cities * sizeof(int); double *pheromones = (double*) malloc ( ph_size ); int *tours = (int*) malloc ( tours_size ); /* Solucoes */ int *visited = (int*) malloc ( tours_size ); /* Lista de cidades visitadas */ double *choiceinfo = (double*) malloc ( ph_size ); int *distances_device; /* Copia da GPU da matriz de distancias */ int *tours_device; /* Copia da GPU da matriz de solucoes */ int *visited_device; /* Copia da GPU da matriz de cidades visitadas */ double *choiceinfo_device; /* Copia da GPU da matriz de probabilidades (numeraodor) */ double *probs; /* Matriz de probabilidades */ cudaMalloc ( (void**) &distances_device, dist_size ); cudaMalloc ( (void**) &tours_device, tours_size ); cudaMalloc ( (void**) &visited_device, tours_size ); cudaMalloc ( (void**) &choiceinfo_device, ph_size ); cudaMalloc ( (void**) &probs, ph_size); cudaMemcpy ( distances_device, distances, dist_size, cudaMemcpyHostToDevice ); /* Instancia-se a matriz de feromonios. Inicialmente, todas as arestas possuem a mesma quantidade de feromonios ( INIT_PHEROMONE_AMOUNT ). */ for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) pheromones[ index(n_cities, i, j) ] = INIT_PHEROMONE_AMOUNT; for (int iteration = 0; iteration < NUMBER_OF_ITERATIONS; iteration++) { /* Reseta todos os caminhos ao inicio de cada iteracao. Inicialmente, todas as posicoes encontram-se no infinito. */ for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) tours[ index(n_cities, i, j) ] = Infinity; for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) visited[ index(n_cities, i, j) ] = 0; /* Calcula o numerador da funcao de probabilidade. Em cada iteracao, este valor eh o mesmo para cada formiga, o que encoraja sua execucao aqui, aumentando o desempenho do algoritmo. */ for (int i = 0; i < n_cities; i++) { for (int j = 0; j < n_cities; j++) { double edge_pherom = pheromones[ index(n_cities, i, j) ]; double edge_weight = distances[index(n_cities, i, j) ]; double prob = 0.0f; if ( edge_weight != 0.0f ) { prob = pow ( edge_pherom, ALFA ) * pow ( (1/edge_weight), BETA ); } else { prob = pow ( edge_pherom, ALFA ) * pow ( Infinity, BETA ); } choiceinfo[index(n_cities, i, j)] = prob; } } cudaMemcpy ( choiceinfo_device, choiceinfo, ph_size, cudaMemcpyHostToDevice ); for (int ant = 0; ant < n_ants; ant++) { int step = 0; /* Uma cidade inicial eh selecionada aleatoriamente. */ int init = rand() % n_cities; /* Atualiza o tour ( para cada formiga ). */ tours [ index ( n_cities, ant, step ) ] = init; /* Atualiza a memoria da formiga. */ visited [ index ( n_cities, ant, init ) ] = 1; } cudaMemcpy ( visited_device, visited, tours_size, cudaMemcpyHostToDevice ); cudaMemcpy ( tours_device, tours, tours_size, cudaMemcpyHostToDevice ); int gridDim = n_ants / thread_per_block (n_ants); int antsPerBlock = thread_per_block (n_ants); cuda_construct_tour <<< gridDim, antsPerBlock >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); //cuda_construct_tour <<< 1, n_ants >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); cudaMemcpy ( tours, tours_device, tours_size, cudaMemcpyDeviceToHost ); cudaMemcpy ( visited, visited_device, tours_size, cudaMemcpyDeviceToHost ); evaporate ( pheromones, n_cities ); int *best = best_solution ( tours, distances, n_ants, n_cities ); reinforce ( pheromones, distances, best, n_cities ); } cudaFree ( distances_device ); cudaFree ( tours_device ); cudaFree ( visited_device ); cudaFree ( choiceinfo_device ); cudaFree ( probs ); int *best = best_solution ( tours, distances, n_ants, n_cities ); return best; }
code for sm_80 Function : _Z19cuda_construct_tourPiS_PdS0_i .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ IMAD.MOV.U32 R4, RZ, RZ, c[0x0][0x180] ; /* 0x00006000ff047624 */ /* 0x000fca00078e00ff */ /*0020*/ ISETP.GE.AND P0, PT, R4, 0x2, PT ; /* 0x000000020400780c */ /* 0x000fda0003f06270 */ /*0030*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*0040*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e220000002100 */ /*0050*/ IMAD.MOV.U32 R9, RZ, RZ, 0x8 ; /* 0x00000008ff097424 */ /* 0x000fe200078e00ff */ /*0060*/ HFMA2.MMA R11, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff0b7435 */ /* 0x000fe200000001ff */ /*0070*/ LOP3.LUT R2, R4.reuse, 0x3, RZ, 0xc0, !PT ; /* 0x0000000304027812 */ /* 0x040fe200078ec0ff */ /*0080*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000e220000002500 */ /*0090*/ IADD3 R4, R4, -0x1, RZ ; /* 0xffffffff04047810 */ /* 0x000fe20007ffe0ff */ /*00a0*/ IMAD.MOV.U32 R5, RZ, RZ, 0x1 ; /* 0x00000001ff057424 */ /* 0x000fe200078e00ff */ /*00b0*/ IADD3 R6, -R2, c[0x0][0x180], RZ ; /* 0x0000600002067a10 */ /* 0x000fe20007ffe1ff */ /*00c0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*00d0*/ IMAD R0, R3, c[0x0][0x0], R0 ; /* 0x0000000003007a24 */ /* 0x001fc800078e0200 */ /*00e0*/ IMAD R0, R0, c[0x0][0x180], RZ ; /* 0x0000600000007a24 */ /* 0x000fc800078e02ff */ /*00f0*/ IMAD.WIDE R8, R0.reuse, R9, c[0x0][0x178] ; /* 0x00005e0000087625 */ /* 0x040fe200078e0209 */ /*0100*/ IADD3 R26, R0, -0x1, RZ ; /* 0xffffffff001a7810 */ /* 0x000fc60007ffe0ff */ /*0110*/ IMAD.WIDE R10, R0, R11, c[0x0][0x168] ; /* 0x00005a00000a7625 */ /* 0x000fe200078e020b */ /*0120*/ IADD3 R3, P0, R8, 0x10, RZ ; /* 0x0000001008037810 */ /* 0x000fca0007f1e0ff */ /*0130*/ IMAD.X R7, RZ, RZ, R9, P0 ; /* 0x000000ffff077224 */ /* 0x000fe400000e0609 */ /*0140*/ MOV R13, 0x4 ; /* 0x00000004000d7802 */ /* 0x001fe20000000f00 */ /*0150*/ IMAD.IADD R12, R26, 0x1, R5 ; /* 0x000000011a0c7824 */ /* 0x000fc800078e0205 */ /*0160*/ IMAD.WIDE R12, R12, R13, c[0x0][0x160] ; /* 0x000058000c0c7625 */ /* 0x000fca00078e020d */ /*0170*/ LDG.E R28, [R12.64] ; /* 0x000000040c1c7981 */ /* 0x000ea2000c1e1900 */ /*0180*/ ISETP.GE.U32.AND P1, PT, R4, 0x3, PT ; /* 0x000000030400780c */ /* 0x000fe20003f26070 */ /*0190*/ IMAD.MOV.U32 R29, RZ, RZ, RZ ; /* 0x000000ffff1d7224 */ /* 0x000fe200078e00ff */ /*01a0*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fe20003f05270 */ /*01b0*/ CS2R R14, SRZ ; /* 0x00000000000e7805 */ /* 0x000fe2000001ff00 */ /*01c0*/ IMAD R28, R28, c[0x0][0x180], RZ ; /* 0x000060001c1c7a24 */ /* 0x004fd200078e02ff */ /*01d0*/ @!P1 BRA 0x4d0 ; /* 0x000002f000009947 */ /* 0x000fea0003800000 */ /*01e0*/ IMAD.MOV.U32 R29, RZ, RZ, RZ ; /* 0x000000ffff1d7224 */ /* 0x000fe200078e00ff */ /*01f0*/ MOV R19, R11 ; /* 0x0000000b00137202 */ /* 0x000fe20000000f00 */ /*0200*/ IMAD.MOV.U32 R18, RZ, RZ, R10 ; /* 0x000000ffff127224 */ /* 0x000fe200078e000a */ /*0210*/ CS2R R14, SRZ ; /* 0x00000000000e7805 */ /* 0x000fe2000001ff00 */ /*0220*/ IMAD.MOV.U32 R22, RZ, RZ, R3 ; /* 0x000000ffff167224 */ /* 0x000fe200078e0003 */ /*0230*/ ULDC.64 UR6, c[0x0][0x170] ; /* 0x00005c0000067ab9 */ /* 0x000fe20000000a00 */ /*0240*/ IMAD.MOV.U32 R23, RZ, RZ, R7 ; /* 0x000000ffff177224 */ /* 0x000fe400078e0007 */ /*0250*/ IMAD.MOV.U32 R27, RZ, RZ, R6 ; /* 0x000000ffff1b7224 */ /* 0x000fe400078e0006 */ /*0260*/ LDG.E R16, [R18.64] ; /* 0x0000000412107981 */ /* 0x004ea2000c1e1900 */ /*0270*/ MOV R20, UR6 ; /* 0x0000000600147c02 */ /* 0x000fe20008000f00 */ /*0280*/ IMAD.U32 R21, RZ, RZ, UR7 ; /* 0x00000007ff157e24 */ /* 0x000fc8000f8e00ff */ /*0290*/ IMAD.WIDE R20, R28, 0x8, R20 ; /* 0x000000081c147825 */ /* 0x000fe200078e0214 */ /*02a0*/ ISETP.NE.AND P1, PT, R16, 0x1, PT ; /* 0x000000011000780c */ /* 0x004fda0003f25270 */ /*02b0*/ @P1 LDG.E.64 R24, [R20.64] ; /* 0x0000000414181981 */ /* 0x000ea2000c1e1b00 */ /*02c0*/ IMAD.MOV.U32 R16, RZ, RZ, R22 ; /* 0x000000ffff107224 */ /* 0x000fe400078e0016 */ /*02d0*/ IMAD.MOV.U32 R17, RZ, RZ, R23 ; /* 0x000000ffff117224 */ /* 0x000fca00078e0017 */ /*02e0*/ @P1 STG.E.64 [R16.64+-0x10], R24 ; /* 0xfffff01810001986 */ /* 0x004fe2000c101b04 */ /*02f0*/ @P1 DADD R14, R14, R24 ; /* 0x000000000e0e1229 */ /* 0x000e060000000018 */ /*0300*/ @!P1 STG.E.64 [R16.64+-0x10], RZ ; /* 0xfffff0ff10009986 */ /* 0x000fe8000c101b04 */ /*0310*/ LDG.E R22, [R18.64+0x4] ; /* 0x0000040412167981 */ /* 0x000ea4000c1e1900 */ /*0320*/ ISETP.NE.AND P1, PT, R22, 0x1, PT ; /* 0x000000011600780c */ /* 0x004fda0003f25270 */ /*0330*/ @P1 LDG.E.64 R22, [R20.64+0x8] ; /* 0x0000080414161981 */ /* 0x000ea8000c1e1b00 */ /*0340*/ @P1 STG.E.64 [R16.64+-0x8], R22 ; /* 0xfffff81610001986 */ /* 0x0043e2000c101b04 */ /*0350*/ @P1 DADD R14, R14, R22 ; /* 0x000000000e0e1229 */ /* 0x0012060000000016 */ /*0360*/ @!P1 STG.E.64 [R16.64+-0x8], RZ ; /* 0xfffff8ff10009986 */ /* 0x0005e8000c101b04 */ /*0370*/ LDG.E R22, [R18.64+0x8] ; /* 0x0000080412167981 */ /* 0x002ee4000c1e1900 */ /*0380*/ ISETP.NE.AND P1, PT, R22, 0x1, PT ; /* 0x000000011600780c */ /* 0x008fda0003f25270 */ /*0390*/ @P1 LDG.E.64 R24, [R20.64+0x10] ; /* 0x0000100414181981 */ /* 0x000ee8000c1e1b00 */ /*03a0*/ @P1 STG.E.64 [R16.64], R24 ; /* 0x0000001810001986 */ /* 0x0085e2000c101b04 */ /*03b0*/ @P1 DADD R14, R14, R24 ; /* 0x000000000e0e1229 */ /* 0x001e060000000018 */ /*03c0*/ @!P1 STG.E.64 [R16.64], RZ ; /* 0x000000ff10009986 */ /* 0x0005e8000c101b04 */ /*03d0*/ LDG.E R22, [R18.64+0xc] ; /* 0x00000c0412167981 */ /* 0x000ee4000c1e1900 */ /*03e0*/ ISETP.NE.AND P1, PT, R22, 0x1, PT ; /* 0x000000011600780c */ /* 0x008fda0003f25270 */ /*03f0*/ @P1 LDG.E.64 R20, [R20.64+0x18] ; /* 0x0000180414141981 */ /* 0x000ee2000c1e1b00 */ /*0400*/ IADD3 R27, R27, -0x4, RZ ; /* 0xfffffffc1b1b7810 */ /* 0x000fe20007ffe0ff */ /*0410*/ UIADD3 UR6, UP0, UR6, 0x20, URZ ; /* 0x0000002006067890 */ /* 0x000fe2000ff1e03f */ /*0420*/ IADD3 R18, P2, R18, 0x10, RZ ; /* 0x0000001012127810 */ /* 0x000fe40007f5e0ff */ /*0430*/ ISETP.NE.AND P3, PT, R27, RZ, PT ; /* 0x000000ff1b00720c */ /* 0x000fe20003f65270 */ /*0440*/ UIADD3.X UR7, URZ, UR7, URZ, UP0, !UPT ; /* 0x000000073f077290 */ /* 0x000fe200087fe43f */ /*0450*/ IADD3 R29, R29, 0x4, RZ ; /* 0x000000041d1d7810 */ /* 0x000fe20007ffe0ff */ /*0460*/ IMAD.X R19, RZ, RZ, R19, P2 ; /* 0x000000ffff137224 */ /* 0x000fe200010e0613 */ /*0470*/ @P1 STG.E.64 [R16.64+0x8], R20 ; /* 0x0000081410001986 */ /* 0x0085e2000c101b04 */ /*0480*/ @P1 DADD R14, R14, R20 ; /* 0x000000000e0e1229 */ /* 0x0014060000000014 */ /*0490*/ @!P1 STG.E.64 [R16.64+0x8], RZ ; /* 0x000008ff10009986 */ /* 0x0005e2000c101b04 */ /*04a0*/ IADD3 R22, P1, R16, 0x20, RZ ; /* 0x0000002010167810 */ /* 0x000fc80007f3e0ff */ /*04b0*/ IADD3.X R23, RZ, R17, RZ, P1, !PT ; /* 0x00000011ff177210 */ /* 0x000fe20000ffe4ff */ /*04c0*/ @P3 BRA 0x260 ; /* 0xfffffd9000003947 */ /* 0x001fea000383ffff */ /*04d0*/ IMAD.MOV.U32 R16, RZ, RZ, R14 ; /* 0x000000ffff107224 */ /* 0x004fe400078e000e */ /*04e0*/ IMAD.MOV.U32 R17, RZ, RZ, R15 ; /* 0x000000ffff117224 */ /* 0x000fe200078e000f */ /*04f0*/ @!P0 BRA 0x790 ; /* 0x0000029000008947 */ /* 0x000fea0003800000 */ /*0500*/ IADD3 R14, R0, R29, RZ ; /* 0x0000001d000e7210 */ /* 0x000fe20007ffe0ff */ /*0510*/ IMAD.MOV.U32 R15, RZ, RZ, 0x4 ; /* 0x00000004ff0f7424 */ /* 0x000fc800078e00ff */ /*0520*/ IMAD.WIDE R14, R14, R15, c[0x0][0x168] ; /* 0x00005a000e0e7625 */ /* 0x000fca00078e020f */ /*0530*/ LDG.E R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000ea2000c1e1900 */ /*0540*/ IMAD.IADD R20, R28, 0x1, R29 ; /* 0x000000011c147824 */ /* 0x000fe200078e021d */ /*0550*/ BSSY B0, 0x610 ; /* 0x000000b000007945 */ /* 0x000fe20003800000 */ /*0560*/ IMAD.MOV.U32 R21, RZ, RZ, 0x8 ; /* 0x00000008ff157424 */ /* 0x000fc800078e00ff */ /*0570*/ IMAD.WIDE R20, R20, R21, c[0x0][0x170] ; /* 0x00005c0014147625 */ /* 0x000fe200078e0215 */ /*0580*/ ISETP.NE.AND P0, PT, R18, 0x1, PT ; /* 0x000000011200780c */ /* 0x004fc60003f05270 */ /*0590*/ IMAD.WIDE R18, R29, 0x8, R8 ; /* 0x000000081d127825 */ /* 0x000fd400078e0208 */ /*05a0*/ @!P0 BRA 0x5f0 ; /* 0x0000004000008947 */ /* 0x000fea0003800000 */ /*05b0*/ LDG.E.64 R22, [R20.64] ; /* 0x0000000414167981 */ /* 0x000ea8000c1e1b00 */ /*05c0*/ STG.E.64 [R18.64], R22 ; /* 0x0000001612007986 */ /* 0x0041e2000c101b04 */ /*05d0*/ DADD R16, R22, R16 ; /* 0x0000000016107229 */ /* 0x0000620000000010 */ /*05e0*/ BRA 0x600 ; /* 0x0000001000007947 */ /* 0x000fea0003800000 */ /*05f0*/ STG.E.64 [R18.64], RZ ; /* 0x000000ff12007986 */ /* 0x0001e4000c101b04 */ /*0600*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0610*/ ISETP.NE.AND P0, PT, R2, 0x1, PT ; /* 0x000000010200780c */ /* 0x000fda0003f05270 */ /*0620*/ @!P0 BRA 0x790 ; /* 0x0000016000008947 */ /* 0x000fea0003800000 */ /*0630*/ LDG.E R22, [R14.64+0x4] ; /* 0x000004040e167981 */ /* 0x001ea2000c1e1900 */ /*0640*/ BSSY B0, 0x6d0 ; /* 0x0000008000007945 */ /* 0x000fe20003800000 */ /*0650*/ ISETP.NE.AND P0, PT, R22, 0x1, PT ; /* 0x000000011600780c */ /* 0x004fda0003f05270 */ /*0660*/ @!P0 BRA 0x6b0 ; /* 0x0000004000008947 */ /* 0x000fea0003800000 */ /*0670*/ LDG.E.64 R22, [R20.64+0x8] ; /* 0x0000080414167981 */ /* 0x000ea8000c1e1b00 */ /*0680*/ STG.E.64 [R18.64+0x8], R22 ; /* 0x0000081612007986 */ /* 0x0041e2000c101b04 */ /*0690*/ DADD R16, R22, R16 ; /* 0x0000000016107229 */ /* 0x0020620000000010 */ /*06a0*/ BRA 0x6c0 ; /* 0x0000001000007947 */ /* 0x000fea0003800000 */ /*06b0*/ STG.E.64 [R18.64+0x8], RZ ; /* 0x000008ff12007986 */ /* 0x0001e4000c101b04 */ /*06c0*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*06d0*/ ISETP.NE.AND P0, PT, R2, 0x2, PT ; /* 0x000000020200780c */ /* 0x000fda0003f05270 */ /*06e0*/ @!P0 BRA 0x790 ; /* 0x000000a000008947 */ /* 0x000fea0003800000 */ /*06f0*/ LDG.E R14, [R14.64+0x8] ; /* 0x000008040e0e7981 */ /* 0x000ea2000c1e1900 */ /*0700*/ BSSY B0, 0x790 ; /* 0x0000008000007945 */ /* 0x000fe20003800000 */ /*0710*/ ISETP.NE.AND P0, PT, R14, 0x1, PT ; /* 0x000000010e00780c */ /* 0x004fda0003f05270 */ /*0720*/ @!P0 BRA 0x770 ; /* 0x0000004000008947 */ /* 0x000fea0003800000 */ /*0730*/ LDG.E.64 R20, [R20.64+0x10] ; /* 0x0000100414147981 */ /* 0x000ea8000c1e1b00 */ /*0740*/ STG.E.64 [R18.64+0x10], R20 ; /* 0x0000101412007986 */ /* 0x0045e2000c101b04 */ /*0750*/ DADD R16, R20, R16 ; /* 0x0000000014107229 */ /* 0x0024620000000010 */ /*0760*/ BRA 0x780 ; /* 0x0000001000007947 */ /* 0x000fea0003800000 */ /*0770*/ STG.E.64 [R18.64+0x10], RZ ; /* 0x000010ff12007986 */ /* 0x0005e4000c101b04 */ /*0780*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0790*/ CS2R R18, SR_CLOCKLO ; /* 0x0000000000127805 */ /* 0x005fca0000015000 */ /*07a0*/ LDG.E.64 R14, [R8.64] ; /* 0x00000004080e7981 */ /* 0x000ea2000c1e1b00 */ /*07b0*/ LOP3.LUT R18, R18, 0xaad26b49, RZ, 0x3c, !PT ; /* 0xaad26b4912127812 */ /* 0x000fe200078e3cff */ /*07c0*/ BSSY B0, 0x990 ; /* 0x000001c000007945 */ /* 0x000fe20003800000 */ /*07d0*/ LOP3.LUT R19, R19, 0xf7dcefdd, RZ, 0x3c, !PT ; /* 0xf7dcefdd13137812 */ /* 0x000fc600078e3cff */ /*07e0*/ IMAD R18, R18, 0x4182bed5, RZ ; /* 0x4182bed512127824 */ /* 0x000fc800078e02ff */ /*07f0*/ IMAD R19, R19, -0x658354e5, R18 ; /* 0x9a7cab1b13137824 */ /* 0x000fe200078e0212 */ /*0800*/ IADD3 R20, R18.reuse, 0x75bcd15, RZ ; /* 0x075bcd1512147810 */ /* 0x040fe40007ffe0ff */ /*0810*/ IADD3 R21, R18, 0x583f19, RZ ; /* 0x00583f1912157810 */ /* 0x000fe40007ffe0ff */ /*0820*/ SHF.R.U32.HI R23, RZ, 0x2, R20 ; /* 0x00000002ff177819 */ /* 0x000fe40000011614 */ /*0830*/ SHF.L.U32 R22, R21, 0x4, RZ ; /* 0x0000000415167819 */ /* 0x000fe400000006ff */ /*0840*/ LOP3.LUT R20, R23, R20, RZ, 0x3c, !PT ; /* 0x0000001417147212 */ /* 0x000fc800078e3cff */ /*0850*/ LOP3.LUT R21, R20.reuse, R22, R21, 0x96, !PT ; /* 0x0000001614157212 */ /* 0x040fe200078e9615 */ /*0860*/ IMAD.SHL.U32 R20, R20, 0x2, RZ ; /* 0x0000000214147824 */ /* 0x000fca00078e00ff */ /*0870*/ LOP3.LUT R20, R21, R20, RZ, 0x3c, !PT ; /* 0x0000001415147212 */ /* 0x000fe400078e3cff */ /*0880*/ MOV R21, RZ ; /* 0x000000ff00157202 */ /* 0x000fe40000000f00 */ /*0890*/ IADD3 R20, R19, 0x6a788e, R20 ; /* 0x006a788e13147810 */ /* 0x000fe20007ffe014 */ /*08a0*/ IMAD.MOV.U32 R19, RZ, RZ, 0x2f800000 ; /* 0x2f800000ff137424 */ /* 0x000fca00078e00ff */ /*08b0*/ I2F.U32 R20, R20 ; /* 0x0000001400147306 */ /* 0x000e240000201000 */ /*08c0*/ FFMA R18, R20, R19, 1.1641532182693481445e-10 ; /* 0x2f00000014127423 */ /* 0x001fcc0000000013 */ /*08d0*/ F2F.F64.F32 R18, R18 ; /* 0x0000001200127310 */ /* 0x000e240000201800 */ /*08e0*/ DMUL R16, R18, R16 ; /* 0x0000001012107228 */ /* 0x003e8c0000000000 */ /*08f0*/ DSETP.GEU.AND P0, PT, R14, R16, PT ; /* 0x000000100e00722a */ /* 0x004e1c0003f0e000 */ /*0900*/ @P0 BRA 0x980 ; /* 0x0000007000000947 */ /* 0x001fea0003800000 */ /*0910*/ IMAD.MOV.U32 R21, RZ, RZ, RZ ; /* 0x000000ffff157224 */ /* 0x000fca00078e00ff */ /*0920*/ IADD3 R21, R21, 0x1, RZ ; /* 0x0000000115157810 */ /* 0x000fca0007ffe0ff */ /*0930*/ IMAD.WIDE R18, R21, 0x8, R8 ; /* 0x0000000815127825 */ /* 0x000fcc00078e0208 */ /*0940*/ LDG.E.64 R18, [R18.64] ; /* 0x0000000412127981 */ /* 0x000ea4000c1e1b00 */ /*0950*/ DADD R14, R18, R14 ; /* 0x00000000120e7229 */ /* 0x004e0c000000000e */ /*0960*/ DSETP.GEU.AND P0, PT, R14, R16, PT ; /* 0x000000100e00722a */ /* 0x001e1c0003f0e000 */ /*0970*/ @!P0 BRA 0x920 ; /* 0xffffffa000008947 */ /* 0x001fea000383ffff */ /*0980*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0990*/ MOV R15, 0x4 ; /* 0x00000004000f7802 */ /* 0x000fe20000000f00 */ /*09a0*/ IMAD.IADD R14, R0, 0x1, R21 ; /* 0x00000001000e7824 */ /* 0x000fe200078e0215 */ /*09b0*/ STG.E [R12.64+0x4], R21 ; /* 0x000004150c007986 */ /* 0x0001e2000c101904 */ /*09c0*/ IMAD.MOV.U32 R17, RZ, RZ, 0x1 ; /* 0x00000001ff117424 */ /* 0x000fe200078e00ff */ /*09d0*/ IADD3 R5, R5, 0x1, RZ ; /* 0x0000000105057810 */ /* 0x000fe20007ffe0ff */ /*09e0*/ IMAD.WIDE R14, R14, R15, c[0x0][0x168] ; /* 0x00005a000e0e7625 */ /* 0x000fc600078e020f */ /*09f0*/ ISETP.GE.AND P0, PT, R5, c[0x0][0x180], PT ; /* 0x0000600005007a0c */ /* 0x000fe40003f06270 */ /*0a00*/ STG.E [R14.64], R17 ; /* 0x000000110e007986 */ /* 0x0001f6000c101904 */ /*0a10*/ @!P0 BRA 0x140 ; /* 0xfffff72000008947 */ /* 0x000fea000383ffff */ /*0a20*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0a30*/ BRA 0xa30; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0a40*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0a50*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0a60*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0a70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0a80*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0a90*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0aa0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ab0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ac0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ad0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0ae0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0af0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z14cuda_reinforcePdPiS0_id .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R2, SR_TID.X ; /* 0x0000000000027919 */ /* 0x000e220000002100 */ /*0020*/ HFMA2.MMA R5, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff057435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000e240000002500 */ /*0050*/ IMAD R2, R3, c[0x0][0x0], R2 ; /* 0x0000000003027a24 */ /* 0x001fca00078e0202 */ /*0060*/ IMAD.WIDE R2, R2, R5, c[0x0][0x170] ; /* 0x00005c0002027625 */ /* 0x000fca00078e0205 */ /*0070*/ LDG.E R0, [R2.64] ; /* 0x0000000402007981 */ /* 0x000ea8000c1e1900 */ /*0080*/ LDG.E R9, [R2.64+0x4] ; /* 0x0000040402097981 */ /* 0x000ea2000c1e1900 */ /*0090*/ HFMA2.MMA R8, -RZ, RZ, 0, 4.76837158203125e-07 ; /* 0x00000008ff087435 */ /* 0x000fe200000001ff */ /*00a0*/ IMAD R4, R0, c[0x0][0x178], R9 ; /* 0x00005e0000047a24 */ /* 0x004fd200078e0209 */ /*00b0*/ IMAD.WIDE R4, R4, R8, c[0x0][0x160] ; /* 0x0000580004047625 */ /* 0x000fca00078e0208 */ /*00c0*/ LDG.E.64 R6, [R4.64] ; /* 0x0000000404067981 */ /* 0x000ea2000c1e1b00 */ /*00d0*/ IMAD R9, R9, c[0x0][0x178], R0 ; /* 0x00005e0009097a24 */ /* 0x000fc800078e0200 */ /*00e0*/ IMAD.WIDE R8, R9, R8, c[0x0][0x160] ; /* 0x0000580009087625 */ /* 0x000fe200078e0208 */ /*00f0*/ DADD R6, R6, c[0x0][0x180] ; /* 0x0000600006067629 */ /* 0x004e0e0000000000 */ /*0100*/ STG.E.64 [R4.64], R6 ; /* 0x0000000604007986 */ /* 0x001fe8000c101b04 */ /*0110*/ LDG.E.64 R10, [R8.64] ; /* 0x00000004080a7981 */ /* 0x000ea4000c1e1b00 */ /*0120*/ DADD R10, R10, c[0x0][0x180] ; /* 0x000060000a0a7629 */ /* 0x004e0e0000000000 */ /*0130*/ STG.E.64 [R8.64], R10 ; /* 0x0000000a08007986 */ /* 0x001fe2000c101b04 */ /*0140*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0150*/ BRA 0x150; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z14cuda_evaporatePdid .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R2, SR_TID.X ; /* 0x0000000000027919 */ /* 0x000e220000002100 */ /*0020*/ HFMA2.MMA R5, -RZ, RZ, 0, 4.76837158203125e-07 ; /* 0x00000008ff057435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000e240000002500 */ /*0050*/ IMAD R2, R3, c[0x0][0x0], R2 ; /* 0x0000000003027a24 */ /* 0x001fca00078e0202 */ /*0060*/ IMAD.WIDE R2, R2, R5, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x000fca00078e0205 */ /*0070*/ LDG.E.64 R4, [R2.64] ; /* 0x0000000402047981 */ /* 0x000ea4000c1e1b00 */ /*0080*/ DMUL R4, R4, c[0x0][0x170] ; /* 0x00005c0004047a28 */ /* 0x004e0e0000000000 */ /*0090*/ STG.E.64 [R2.64], R4 ; /* 0x0000000402007986 */ /* 0x001fe2000c101b04 */ /*00a0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00b0*/ BRA 0xb0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*00c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0100*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0110*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0120*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0130*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0140*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <fstream> #include <iostream> #include <curand.h> #include <curand_kernel.h> #define Infinity 65536 /* pow (2, 16) */ /* randdouble() Retorna um numero (double) aleatorio entre 0.0f e 1.0f. Parametros: Saida: numero aleaorio entre 0.0 e 1.0. */ #define randdouble() ((double)rand()/(double)RAND_MAX) /* randomize() Atualiza o gerador de numeros pseudo-aletatorios. Parametros: Saida: */ #define randomize() srand((unsigned)time(NULL)) /* index() Mapeia uma posicao de uma matriz (2D) para um indice de um vetor (1D). Parametros: length: numero de colunas da matriz line: indice da linha column: indice da coluna Saída: indice mapeado */ #define index(length,line,column) (column + line * length) using namespace std; const int NUMBER_OF_ITERATIONS = 100; const double INIT_PHEROMONE_AMOUNT = 1.0; const double EVAPORATION_RATE = 0.5; const double ALFA = 1; /* Influencia da trilha de feromonios */ const double BETA = 2; /* Influencia da informacao heuristica */ int threads ( int n_ants ); int thread_per_block ( int n_ants ); /* load_instance() Inicializa uma instancia ( numero de cidades e matriz de distancias ) do TSP. Parametros: filename: nome do arquivo n_cities: numero de cidades ( passagem por referencia ) Saida: matriz de distancias ( distancias euclidianas ) */ int *load_instance ( char const *filename, int &n_cities ); /* calculate_pathcost() Calcula o custo (soma dos custos de todas as arestas) de um caminho . Parametros: distances: matriz de distancias path: caminho ( solucao ) n_cities: numero de cidades Saida: custo ( soma de todas as distancias ) do caminho */ int calculate_pathcost ( int *distances, int *path, int n_cities ); /* best_solution() Retorna a melhor entre as solucoes geradas. Parametros: ants: matriz de solucoes distances: matriz de distancias ( entre cidades ) n_ants: numero de formigas n_cities: numero de cidades Saida: melhor solucao encontrada */ int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ); /* evaporate() Atualiza a matriz de feromonios aplicando evaporacao. Para cada vertice, multiplica-se a taxa de evaporacao ( EVAPORATION_RATE ). Parametros: pheromones: matriz de feromonios n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void evaporate ( double *pheromones, int n_cities ); /* reinforce() Atualiza a matriz de feromonios. Para cada vertice da melhor solucao corrente, adiciona-se uma quantidade de feromonios. Parametros: pheromones: matriz de feromonios distances: matriz de distancias min_path: caminho minimo ( melhor solucao ) encontrado n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void reinforce ( double *pheromones, int *distances, int *min_path, int n_cities ); /* run() Executa o algoritmo de colonia de formigas Parametros: distances: matriz de distancias n_cities: numero de cidades n_ants: numero de formigas Saida: melhor entre as solucoes encontradas por todas as formigas */ int *run ( int *distances, int n_cities, int n_ants ); __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ); __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ); __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ); int main ( int argc, char *argv[] ) { randomize(); char const *inputname, *outputname; if ( argc < 2 ) { cout << "Missing input arguments!" << endl; cout << "Program " << argv[0] << " takes exactly 3 arguments." << endl; return 1; } if ( argc > 3 ) { cout << "Too many arguments in program " << argv[0] << "!" << endl; cout << "It takes exactly 3 arguments." << endl; return 1; } cout << "Running " << argv[0] << " with arguments: "; for (int i = 1; i < argc; i++) cout << argv[i] << " "; cout << endl; inputname = argv[1]; if ( !argv[2] ) { outputname = "results/output.txt"; } else { outputname = argv[2]; } int n_cities; /* Numero de cidades */ int *distances; /* Matriz de distancias (distancia euclidiana) */ /* Inicializa a instancia. Executa o algoritmo e calcula do custo da solucao. */ distances = load_instance ( inputname, n_cities ); int *solution = run ( distances, n_cities, threads ( n_cities ) ); int cost = calculate_pathcost ( distances, solution, n_cities ); cout << "Writing results in file " << outputname << "!\n"; ofstream output; output.open(outputname); output << "Custo: " << cost << endl; output << "Melhor solucao encontrada:\n"; for(int i=0; i<n_cities; i++) output << solution[i] << endl; cout << argv[0] << " exited with no errors."; return 0; } __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ) { int edge_id = threadIdx.x + blockIdx.x * blockDim.x; pheromones[ edge_id ] *= evap_rate; } __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ) { int col_id = threadIdx.x + blockIdx.x * blockDim.x; int origin = path[col_id]; int dest = path[col_id+1]; pheromones[ index( n_cities, origin, dest ) ] += amount; pheromones[ index( n_cities, dest, origin ) ] += amount; } __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ) { int line_id = blockDim.x * blockIdx.x + threadIdx.x; for (int step = 1; step < n_cities; step++) { int current = tours[ index ( n_cities, line_id, step - 1 ) ]; double sum_probs = 0.0; for(int i = 0; i < n_cities; i++) { if ( visited[ index ( n_cities, line_id, i) ] == 1 ) probs[ index ( n_cities, line_id, i ) ] = 0.0; else { double current_prob = choiceinfo[ index( n_cities, current, i ) ]; probs[ index ( n_cities, line_id, i ) ] = current_prob; sum_probs += current_prob; } } double random; curandState_t state; curand_init ( (unsigned long long) clock(), 0, 0, &state ); random = curand_uniform ( &state ); random *= sum_probs; int next; double sum = probs[ index ( n_cities, line_id, 0 ) ]; for(next = 0; sum < random; next++) { sum += probs[ index ( n_cities, line_id, next + 1 ) ]; } tours[ index ( n_cities, line_id, step ) ] = next; visited[ index ( n_cities, line_id, next) ] = 1; } } int threads ( int n_ants ) { int n_threds = 1; while ( n_threds * 2 < n_ants ) { n_threds *= 2; } return n_threds; } int thread_per_block ( int n_ants ) { int blocks = log(n_ants); return pow (2, blocks); } int *load_instance ( char const *filename, int &n_cities ) { cout << "Opening file " << filename << endl; ifstream tsp; tsp.open (filename); /*if ( ifstream == NULL ) { cout << "File " << filename << " not found!\n"; exit(1); }*/ tsp >> n_cities; int* distances = (int *) malloc ( n_cities * n_cities * sizeof(int) ); for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) tsp >> distances[ index(n_cities, i, j) ]; return distances; } int calculate_pathcost ( int *distances, int *path, int n_cities ) { int cost = 0; for (int i = 0; i < (n_cities - 1); i++) cost += distances[ index(n_cities, path[i], path[i+1]) ]; return cost; } int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ) { int *best_tour = &tours[0]; for (int tour = 0; tour < n_ants; tour++) if (calculate_pathcost(distances, &tours[index(n_cities, tour, 0)], n_cities) < calculate_pathcost(distances, best_tour, n_cities)) best_tour = &tours[index(n_cities, tour, 0)]; return best_tour; } void evaporate ( double *pheromones, int n_cities ) { int size = n_cities * n_cities * sizeof(double); double *pheromones_device; cudaMalloc ( (void**) &pheromones_device, size); cudaMemcpy (pheromones_device, pheromones, size, cudaMemcpyHostToDevice); cuda_evaporate <<< n_cities, n_cities >>> ( pheromones_device, n_cities, EVAPORATION_RATE ); cudaMemcpy (pheromones, pheromones_device, size, cudaMemcpyDeviceToHost); cudaFree (pheromones_device); } void reinforce ( double *pheromones, int *distances, int *path, int n_cities ) { double amount = (double) ( 1.0f / (double) calculate_pathcost ( distances, path, n_cities ) ); int size_path = n_cities * sizeof(int); int size_int = n_cities * n_cities * sizeof(int); int size_double = n_cities * n_cities * sizeof(double); int *path_device; int *distances_device; double *pheromones_device; cudaMalloc((void**)&path_device, size_path); cudaMalloc((void**)&distances_device, size_int); cudaMalloc((void**)&pheromones_device, size_double); cudaMemcpy (path_device, path, size_path, cudaMemcpyHostToDevice); cudaMemcpy (distances_device, distances, size_int, cudaMemcpyHostToDevice); cudaMemcpy (pheromones_device, pheromones, size_double, cudaMemcpyHostToDevice); cuda_reinforce <<< 1, n_cities - 1 >>> (pheromones_device, distances_device, path_device, n_cities, amount); cudaMemcpy (distances, distances_device, size_int, cudaMemcpyDeviceToHost); cudaMemcpy (pheromones, pheromones_device, size_double, cudaMemcpyDeviceToHost); cudaFree (path_device); cudaFree (distances_device); cudaFree (pheromones_device); } int *run ( int *distances, int n_cities, int n_ants) { int ph_size = n_cities * n_cities * sizeof(double); int tours_size = n_ants * n_cities * sizeof(int); int dist_size = n_cities * n_cities * sizeof(int); double *pheromones = (double*) malloc ( ph_size ); int *tours = (int*) malloc ( tours_size ); /* Solucoes */ int *visited = (int*) malloc ( tours_size ); /* Lista de cidades visitadas */ double *choiceinfo = (double*) malloc ( ph_size ); int *distances_device; /* Copia da GPU da matriz de distancias */ int *tours_device; /* Copia da GPU da matriz de solucoes */ int *visited_device; /* Copia da GPU da matriz de cidades visitadas */ double *choiceinfo_device; /* Copia da GPU da matriz de probabilidades (numeraodor) */ double *probs; /* Matriz de probabilidades */ cudaMalloc ( (void**) &distances_device, dist_size ); cudaMalloc ( (void**) &tours_device, tours_size ); cudaMalloc ( (void**) &visited_device, tours_size ); cudaMalloc ( (void**) &choiceinfo_device, ph_size ); cudaMalloc ( (void**) &probs, ph_size); cudaMemcpy ( distances_device, distances, dist_size, cudaMemcpyHostToDevice ); /* Instancia-se a matriz de feromonios. Inicialmente, todas as arestas possuem a mesma quantidade de feromonios ( INIT_PHEROMONE_AMOUNT ). */ for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) pheromones[ index(n_cities, i, j) ] = INIT_PHEROMONE_AMOUNT; for (int iteration = 0; iteration < NUMBER_OF_ITERATIONS; iteration++) { /* Reseta todos os caminhos ao inicio de cada iteracao. Inicialmente, todas as posicoes encontram-se no infinito. */ for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) tours[ index(n_cities, i, j) ] = Infinity; for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) visited[ index(n_cities, i, j) ] = 0; /* Calcula o numerador da funcao de probabilidade. Em cada iteracao, este valor eh o mesmo para cada formiga, o que encoraja sua execucao aqui, aumentando o desempenho do algoritmo. */ for (int i = 0; i < n_cities; i++) { for (int j = 0; j < n_cities; j++) { double edge_pherom = pheromones[ index(n_cities, i, j) ]; double edge_weight = distances[index(n_cities, i, j) ]; double prob = 0.0f; if ( edge_weight != 0.0f ) { prob = pow ( edge_pherom, ALFA ) * pow ( (1/edge_weight), BETA ); } else { prob = pow ( edge_pherom, ALFA ) * pow ( Infinity, BETA ); } choiceinfo[index(n_cities, i, j)] = prob; } } cudaMemcpy ( choiceinfo_device, choiceinfo, ph_size, cudaMemcpyHostToDevice ); for (int ant = 0; ant < n_ants; ant++) { int step = 0; /* Uma cidade inicial eh selecionada aleatoriamente. */ int init = rand() % n_cities; /* Atualiza o tour ( para cada formiga ). */ tours [ index ( n_cities, ant, step ) ] = init; /* Atualiza a memoria da formiga. */ visited [ index ( n_cities, ant, init ) ] = 1; } cudaMemcpy ( visited_device, visited, tours_size, cudaMemcpyHostToDevice ); cudaMemcpy ( tours_device, tours, tours_size, cudaMemcpyHostToDevice ); int gridDim = n_ants / thread_per_block (n_ants); int antsPerBlock = thread_per_block (n_ants); cuda_construct_tour <<< gridDim, antsPerBlock >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); //cuda_construct_tour <<< 1, n_ants >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); cudaMemcpy ( tours, tours_device, tours_size, cudaMemcpyDeviceToHost ); cudaMemcpy ( visited, visited_device, tours_size, cudaMemcpyDeviceToHost ); evaporate ( pheromones, n_cities ); int *best = best_solution ( tours, distances, n_ants, n_cities ); reinforce ( pheromones, distances, best, n_cities ); } cudaFree ( distances_device ); cudaFree ( tours_device ); cudaFree ( visited_device ); cudaFree ( choiceinfo_device ); cudaFree ( probs ); int *best = best_solution ( tours, distances, n_ants, n_cities ); return best; }
#include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <fstream> #include <iostream> #include <hiprand/hiprand.h> #include <hiprand/hiprand_kernel.h> #define Infinity 65536 /* pow (2, 16) */ /* randdouble() Retorna um numero (double) aleatorio entre 0.0f e 1.0f. Parametros: Saida: numero aleaorio entre 0.0 e 1.0. */ #define randdouble() ((double)rand()/(double)RAND_MAX) /* randomize() Atualiza o gerador de numeros pseudo-aletatorios. Parametros: Saida: */ #define randomize() srand((unsigned)time(NULL)) /* index() Mapeia uma posicao de uma matriz (2D) para um indice de um vetor (1D). Parametros: length: numero de colunas da matriz line: indice da linha column: indice da coluna Saída: indice mapeado */ #define index(length,line,column) (column + line * length) using namespace std; const int NUMBER_OF_ITERATIONS = 100; const double INIT_PHEROMONE_AMOUNT = 1.0; const double EVAPORATION_RATE = 0.5; const double ALFA = 1; /* Influencia da trilha de feromonios */ const double BETA = 2; /* Influencia da informacao heuristica */ int threads ( int n_ants ); int thread_per_block ( int n_ants ); /* load_instance() Inicializa uma instancia ( numero de cidades e matriz de distancias ) do TSP. Parametros: filename: nome do arquivo n_cities: numero de cidades ( passagem por referencia ) Saida: matriz de distancias ( distancias euclidianas ) */ int *load_instance ( char const *filename, int &n_cities ); /* calculate_pathcost() Calcula o custo (soma dos custos de todas as arestas) de um caminho . Parametros: distances: matriz de distancias path: caminho ( solucao ) n_cities: numero de cidades Saida: custo ( soma de todas as distancias ) do caminho */ int calculate_pathcost ( int *distances, int *path, int n_cities ); /* best_solution() Retorna a melhor entre as solucoes geradas. Parametros: ants: matriz de solucoes distances: matriz de distancias ( entre cidades ) n_ants: numero de formigas n_cities: numero de cidades Saida: melhor solucao encontrada */ int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ); /* evaporate() Atualiza a matriz de feromonios aplicando evaporacao. Para cada vertice, multiplica-se a taxa de evaporacao ( EVAPORATION_RATE ). Parametros: pheromones: matriz de feromonios n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void evaporate ( double *pheromones, int n_cities ); /* reinforce() Atualiza a matriz de feromonios. Para cada vertice da melhor solucao corrente, adiciona-se uma quantidade de feromonios. Parametros: pheromones: matriz de feromonios distances: matriz de distancias min_path: caminho minimo ( melhor solucao ) encontrado n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void reinforce ( double *pheromones, int *distances, int *min_path, int n_cities ); /* run() Executa o algoritmo de colonia de formigas Parametros: distances: matriz de distancias n_cities: numero de cidades n_ants: numero de formigas Saida: melhor entre as solucoes encontradas por todas as formigas */ int *run ( int *distances, int n_cities, int n_ants ); __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ); __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ); __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ); int main ( int argc, char *argv[] ) { randomize(); char const *inputname, *outputname; if ( argc < 2 ) { cout << "Missing input arguments!" << endl; cout << "Program " << argv[0] << " takes exactly 3 arguments." << endl; return 1; } if ( argc > 3 ) { cout << "Too many arguments in program " << argv[0] << "!" << endl; cout << "It takes exactly 3 arguments." << endl; return 1; } cout << "Running " << argv[0] << " with arguments: "; for (int i = 1; i < argc; i++) cout << argv[i] << " "; cout << endl; inputname = argv[1]; if ( !argv[2] ) { outputname = "results/output.txt"; } else { outputname = argv[2]; } int n_cities; /* Numero de cidades */ int *distances; /* Matriz de distancias (distancia euclidiana) */ /* Inicializa a instancia. Executa o algoritmo e calcula do custo da solucao. */ distances = load_instance ( inputname, n_cities ); int *solution = run ( distances, n_cities, threads ( n_cities ) ); int cost = calculate_pathcost ( distances, solution, n_cities ); cout << "Writing results in file " << outputname << "!\n"; ofstream output; output.open(outputname); output << "Custo: " << cost << endl; output << "Melhor solucao encontrada:\n"; for(int i=0; i<n_cities; i++) output << solution[i] << endl; cout << argv[0] << " exited with no errors."; return 0; } __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ) { int edge_id = threadIdx.x + blockIdx.x * blockDim.x; pheromones[ edge_id ] *= evap_rate; } __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ) { int col_id = threadIdx.x + blockIdx.x * blockDim.x; int origin = path[col_id]; int dest = path[col_id+1]; pheromones[ index( n_cities, origin, dest ) ] += amount; pheromones[ index( n_cities, dest, origin ) ] += amount; } __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ) { int line_id = blockDim.x * blockIdx.x + threadIdx.x; for (int step = 1; step < n_cities; step++) { int current = tours[ index ( n_cities, line_id, step - 1 ) ]; double sum_probs = 0.0; for(int i = 0; i < n_cities; i++) { if ( visited[ index ( n_cities, line_id, i) ] == 1 ) probs[ index ( n_cities, line_id, i ) ] = 0.0; else { double current_prob = choiceinfo[ index( n_cities, current, i ) ]; probs[ index ( n_cities, line_id, i ) ] = current_prob; sum_probs += current_prob; } } double random; hiprandState_t state; hiprand_init ( (unsigned long long) clock(), 0, 0, &state ); random = hiprand_uniform ( &state ); random *= sum_probs; int next; double sum = probs[ index ( n_cities, line_id, 0 ) ]; for(next = 0; sum < random; next++) { sum += probs[ index ( n_cities, line_id, next + 1 ) ]; } tours[ index ( n_cities, line_id, step ) ] = next; visited[ index ( n_cities, line_id, next) ] = 1; } } int threads ( int n_ants ) { int n_threds = 1; while ( n_threds * 2 < n_ants ) { n_threds *= 2; } return n_threds; } int thread_per_block ( int n_ants ) { int blocks = log(n_ants); return pow (2, blocks); } int *load_instance ( char const *filename, int &n_cities ) { cout << "Opening file " << filename << endl; ifstream tsp; tsp.open (filename); /*if ( ifstream == NULL ) { cout << "File " << filename << " not found!\n"; exit(1); }*/ tsp >> n_cities; int* distances = (int *) malloc ( n_cities * n_cities * sizeof(int) ); for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) tsp >> distances[ index(n_cities, i, j) ]; return distances; } int calculate_pathcost ( int *distances, int *path, int n_cities ) { int cost = 0; for (int i = 0; i < (n_cities - 1); i++) cost += distances[ index(n_cities, path[i], path[i+1]) ]; return cost; } int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ) { int *best_tour = &tours[0]; for (int tour = 0; tour < n_ants; tour++) if (calculate_pathcost(distances, &tours[index(n_cities, tour, 0)], n_cities) < calculate_pathcost(distances, best_tour, n_cities)) best_tour = &tours[index(n_cities, tour, 0)]; return best_tour; } void evaporate ( double *pheromones, int n_cities ) { int size = n_cities * n_cities * sizeof(double); double *pheromones_device; hipMalloc ( (void**) &pheromones_device, size); hipMemcpy (pheromones_device, pheromones, size, hipMemcpyHostToDevice); cuda_evaporate <<< n_cities, n_cities >>> ( pheromones_device, n_cities, EVAPORATION_RATE ); hipMemcpy (pheromones, pheromones_device, size, hipMemcpyDeviceToHost); hipFree (pheromones_device); } void reinforce ( double *pheromones, int *distances, int *path, int n_cities ) { double amount = (double) ( 1.0f / (double) calculate_pathcost ( distances, path, n_cities ) ); int size_path = n_cities * sizeof(int); int size_int = n_cities * n_cities * sizeof(int); int size_double = n_cities * n_cities * sizeof(double); int *path_device; int *distances_device; double *pheromones_device; hipMalloc((void**)&path_device, size_path); hipMalloc((void**)&distances_device, size_int); hipMalloc((void**)&pheromones_device, size_double); hipMemcpy (path_device, path, size_path, hipMemcpyHostToDevice); hipMemcpy (distances_device, distances, size_int, hipMemcpyHostToDevice); hipMemcpy (pheromones_device, pheromones, size_double, hipMemcpyHostToDevice); cuda_reinforce <<< 1, n_cities - 1 >>> (pheromones_device, distances_device, path_device, n_cities, amount); hipMemcpy (distances, distances_device, size_int, hipMemcpyDeviceToHost); hipMemcpy (pheromones, pheromones_device, size_double, hipMemcpyDeviceToHost); hipFree (path_device); hipFree (distances_device); hipFree (pheromones_device); } int *run ( int *distances, int n_cities, int n_ants) { int ph_size = n_cities * n_cities * sizeof(double); int tours_size = n_ants * n_cities * sizeof(int); int dist_size = n_cities * n_cities * sizeof(int); double *pheromones = (double*) malloc ( ph_size ); int *tours = (int*) malloc ( tours_size ); /* Solucoes */ int *visited = (int*) malloc ( tours_size ); /* Lista de cidades visitadas */ double *choiceinfo = (double*) malloc ( ph_size ); int *distances_device; /* Copia da GPU da matriz de distancias */ int *tours_device; /* Copia da GPU da matriz de solucoes */ int *visited_device; /* Copia da GPU da matriz de cidades visitadas */ double *choiceinfo_device; /* Copia da GPU da matriz de probabilidades (numeraodor) */ double *probs; /* Matriz de probabilidades */ hipMalloc ( (void**) &distances_device, dist_size ); hipMalloc ( (void**) &tours_device, tours_size ); hipMalloc ( (void**) &visited_device, tours_size ); hipMalloc ( (void**) &choiceinfo_device, ph_size ); hipMalloc ( (void**) &probs, ph_size); hipMemcpy ( distances_device, distances, dist_size, hipMemcpyHostToDevice ); /* Instancia-se a matriz de feromonios. Inicialmente, todas as arestas possuem a mesma quantidade de feromonios ( INIT_PHEROMONE_AMOUNT ). */ for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) pheromones[ index(n_cities, i, j) ] = INIT_PHEROMONE_AMOUNT; for (int iteration = 0; iteration < NUMBER_OF_ITERATIONS; iteration++) { /* Reseta todos os caminhos ao inicio de cada iteracao. Inicialmente, todas as posicoes encontram-se no infinito. */ for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) tours[ index(n_cities, i, j) ] = Infinity; for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) visited[ index(n_cities, i, j) ] = 0; /* Calcula o numerador da funcao de probabilidade. Em cada iteracao, este valor eh o mesmo para cada formiga, o que encoraja sua execucao aqui, aumentando o desempenho do algoritmo. */ for (int i = 0; i < n_cities; i++) { for (int j = 0; j < n_cities; j++) { double edge_pherom = pheromones[ index(n_cities, i, j) ]; double edge_weight = distances[index(n_cities, i, j) ]; double prob = 0.0f; if ( edge_weight != 0.0f ) { prob = pow ( edge_pherom, ALFA ) * pow ( (1/edge_weight), BETA ); } else { prob = pow ( edge_pherom, ALFA ) * pow ( Infinity, BETA ); } choiceinfo[index(n_cities, i, j)] = prob; } } hipMemcpy ( choiceinfo_device, choiceinfo, ph_size, hipMemcpyHostToDevice ); for (int ant = 0; ant < n_ants; ant++) { int step = 0; /* Uma cidade inicial eh selecionada aleatoriamente. */ int init = rand() % n_cities; /* Atualiza o tour ( para cada formiga ). */ tours [ index ( n_cities, ant, step ) ] = init; /* Atualiza a memoria da formiga. */ visited [ index ( n_cities, ant, init ) ] = 1; } hipMemcpy ( visited_device, visited, tours_size, hipMemcpyHostToDevice ); hipMemcpy ( tours_device, tours, tours_size, hipMemcpyHostToDevice ); int gridDim = n_ants / thread_per_block (n_ants); int antsPerBlock = thread_per_block (n_ants); cuda_construct_tour <<< gridDim, antsPerBlock >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); //cuda_construct_tour <<< 1, n_ants >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); hipMemcpy ( tours, tours_device, tours_size, hipMemcpyDeviceToHost ); hipMemcpy ( visited, visited_device, tours_size, hipMemcpyDeviceToHost ); evaporate ( pheromones, n_cities ); int *best = best_solution ( tours, distances, n_ants, n_cities ); reinforce ( pheromones, distances, best, n_cities ); } hipFree ( distances_device ); hipFree ( tours_device ); hipFree ( visited_device ); hipFree ( choiceinfo_device ); hipFree ( probs ); int *best = best_solution ( tours, distances, n_ants, n_cities ); return best; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <fstream> #include <iostream> #include <hiprand/hiprand.h> #include <hiprand/hiprand_kernel.h> #define Infinity 65536 /* pow (2, 16) */ /* randdouble() Retorna um numero (double) aleatorio entre 0.0f e 1.0f. Parametros: Saida: numero aleaorio entre 0.0 e 1.0. */ #define randdouble() ((double)rand()/(double)RAND_MAX) /* randomize() Atualiza o gerador de numeros pseudo-aletatorios. Parametros: Saida: */ #define randomize() srand((unsigned)time(NULL)) /* index() Mapeia uma posicao de uma matriz (2D) para um indice de um vetor (1D). Parametros: length: numero de colunas da matriz line: indice da linha column: indice da coluna Saída: indice mapeado */ #define index(length,line,column) (column + line * length) using namespace std; const int NUMBER_OF_ITERATIONS = 100; const double INIT_PHEROMONE_AMOUNT = 1.0; const double EVAPORATION_RATE = 0.5; const double ALFA = 1; /* Influencia da trilha de feromonios */ const double BETA = 2; /* Influencia da informacao heuristica */ int threads ( int n_ants ); int thread_per_block ( int n_ants ); /* load_instance() Inicializa uma instancia ( numero de cidades e matriz de distancias ) do TSP. Parametros: filename: nome do arquivo n_cities: numero de cidades ( passagem por referencia ) Saida: matriz de distancias ( distancias euclidianas ) */ int *load_instance ( char const *filename, int &n_cities ); /* calculate_pathcost() Calcula o custo (soma dos custos de todas as arestas) de um caminho . Parametros: distances: matriz de distancias path: caminho ( solucao ) n_cities: numero de cidades Saida: custo ( soma de todas as distancias ) do caminho */ int calculate_pathcost ( int *distances, int *path, int n_cities ); /* best_solution() Retorna a melhor entre as solucoes geradas. Parametros: ants: matriz de solucoes distances: matriz de distancias ( entre cidades ) n_ants: numero de formigas n_cities: numero de cidades Saida: melhor solucao encontrada */ int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ); /* evaporate() Atualiza a matriz de feromonios aplicando evaporacao. Para cada vertice, multiplica-se a taxa de evaporacao ( EVAPORATION_RATE ). Parametros: pheromones: matriz de feromonios n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void evaporate ( double *pheromones, int n_cities ); /* reinforce() Atualiza a matriz de feromonios. Para cada vertice da melhor solucao corrente, adiciona-se uma quantidade de feromonios. Parametros: pheromones: matriz de feromonios distances: matriz de distancias min_path: caminho minimo ( melhor solucao ) encontrado n_cities: numero de cidades Saida: matriz de feromonios atualizada */ void reinforce ( double *pheromones, int *distances, int *min_path, int n_cities ); /* run() Executa o algoritmo de colonia de formigas Parametros: distances: matriz de distancias n_cities: numero de cidades n_ants: numero de formigas Saida: melhor entre as solucoes encontradas por todas as formigas */ int *run ( int *distances, int n_cities, int n_ants ); __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ); __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ); __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ); int main ( int argc, char *argv[] ) { randomize(); char const *inputname, *outputname; if ( argc < 2 ) { cout << "Missing input arguments!" << endl; cout << "Program " << argv[0] << " takes exactly 3 arguments." << endl; return 1; } if ( argc > 3 ) { cout << "Too many arguments in program " << argv[0] << "!" << endl; cout << "It takes exactly 3 arguments." << endl; return 1; } cout << "Running " << argv[0] << " with arguments: "; for (int i = 1; i < argc; i++) cout << argv[i] << " "; cout << endl; inputname = argv[1]; if ( !argv[2] ) { outputname = "results/output.txt"; } else { outputname = argv[2]; } int n_cities; /* Numero de cidades */ int *distances; /* Matriz de distancias (distancia euclidiana) */ /* Inicializa a instancia. Executa o algoritmo e calcula do custo da solucao. */ distances = load_instance ( inputname, n_cities ); int *solution = run ( distances, n_cities, threads ( n_cities ) ); int cost = calculate_pathcost ( distances, solution, n_cities ); cout << "Writing results in file " << outputname << "!\n"; ofstream output; output.open(outputname); output << "Custo: " << cost << endl; output << "Melhor solucao encontrada:\n"; for(int i=0; i<n_cities; i++) output << solution[i] << endl; cout << argv[0] << " exited with no errors."; return 0; } __global__ void cuda_evaporate ( double *pheromones, int n_cities, double evap_rate ) { int edge_id = threadIdx.x + blockIdx.x * blockDim.x; pheromones[ edge_id ] *= evap_rate; } __global__ void cuda_reinforce ( double *pheromones, int *distances, int *path, int n_cities, double amount ) { int col_id = threadIdx.x + blockIdx.x * blockDim.x; int origin = path[col_id]; int dest = path[col_id+1]; pheromones[ index( n_cities, origin, dest ) ] += amount; pheromones[ index( n_cities, dest, origin ) ] += amount; } __global__ void cuda_construct_tour (int *tours, int *visited, double *choiceinfo, double *probs, int n_cities ) { int line_id = blockDim.x * blockIdx.x + threadIdx.x; for (int step = 1; step < n_cities; step++) { int current = tours[ index ( n_cities, line_id, step - 1 ) ]; double sum_probs = 0.0; for(int i = 0; i < n_cities; i++) { if ( visited[ index ( n_cities, line_id, i) ] == 1 ) probs[ index ( n_cities, line_id, i ) ] = 0.0; else { double current_prob = choiceinfo[ index( n_cities, current, i ) ]; probs[ index ( n_cities, line_id, i ) ] = current_prob; sum_probs += current_prob; } } double random; hiprandState_t state; hiprand_init ( (unsigned long long) clock(), 0, 0, &state ); random = hiprand_uniform ( &state ); random *= sum_probs; int next; double sum = probs[ index ( n_cities, line_id, 0 ) ]; for(next = 0; sum < random; next++) { sum += probs[ index ( n_cities, line_id, next + 1 ) ]; } tours[ index ( n_cities, line_id, step ) ] = next; visited[ index ( n_cities, line_id, next) ] = 1; } } int threads ( int n_ants ) { int n_threds = 1; while ( n_threds * 2 < n_ants ) { n_threds *= 2; } return n_threds; } int thread_per_block ( int n_ants ) { int blocks = log(n_ants); return pow (2, blocks); } int *load_instance ( char const *filename, int &n_cities ) { cout << "Opening file " << filename << endl; ifstream tsp; tsp.open (filename); /*if ( ifstream == NULL ) { cout << "File " << filename << " not found!\n"; exit(1); }*/ tsp >> n_cities; int* distances = (int *) malloc ( n_cities * n_cities * sizeof(int) ); for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) tsp >> distances[ index(n_cities, i, j) ]; return distances; } int calculate_pathcost ( int *distances, int *path, int n_cities ) { int cost = 0; for (int i = 0; i < (n_cities - 1); i++) cost += distances[ index(n_cities, path[i], path[i+1]) ]; return cost; } int *best_solution ( int *tours, int *distances, int n_ants, int n_cities ) { int *best_tour = &tours[0]; for (int tour = 0; tour < n_ants; tour++) if (calculate_pathcost(distances, &tours[index(n_cities, tour, 0)], n_cities) < calculate_pathcost(distances, best_tour, n_cities)) best_tour = &tours[index(n_cities, tour, 0)]; return best_tour; } void evaporate ( double *pheromones, int n_cities ) { int size = n_cities * n_cities * sizeof(double); double *pheromones_device; hipMalloc ( (void**) &pheromones_device, size); hipMemcpy (pheromones_device, pheromones, size, hipMemcpyHostToDevice); cuda_evaporate <<< n_cities, n_cities >>> ( pheromones_device, n_cities, EVAPORATION_RATE ); hipMemcpy (pheromones, pheromones_device, size, hipMemcpyDeviceToHost); hipFree (pheromones_device); } void reinforce ( double *pheromones, int *distances, int *path, int n_cities ) { double amount = (double) ( 1.0f / (double) calculate_pathcost ( distances, path, n_cities ) ); int size_path = n_cities * sizeof(int); int size_int = n_cities * n_cities * sizeof(int); int size_double = n_cities * n_cities * sizeof(double); int *path_device; int *distances_device; double *pheromones_device; hipMalloc((void**)&path_device, size_path); hipMalloc((void**)&distances_device, size_int); hipMalloc((void**)&pheromones_device, size_double); hipMemcpy (path_device, path, size_path, hipMemcpyHostToDevice); hipMemcpy (distances_device, distances, size_int, hipMemcpyHostToDevice); hipMemcpy (pheromones_device, pheromones, size_double, hipMemcpyHostToDevice); cuda_reinforce <<< 1, n_cities - 1 >>> (pheromones_device, distances_device, path_device, n_cities, amount); hipMemcpy (distances, distances_device, size_int, hipMemcpyDeviceToHost); hipMemcpy (pheromones, pheromones_device, size_double, hipMemcpyDeviceToHost); hipFree (path_device); hipFree (distances_device); hipFree (pheromones_device); } int *run ( int *distances, int n_cities, int n_ants) { int ph_size = n_cities * n_cities * sizeof(double); int tours_size = n_ants * n_cities * sizeof(int); int dist_size = n_cities * n_cities * sizeof(int); double *pheromones = (double*) malloc ( ph_size ); int *tours = (int*) malloc ( tours_size ); /* Solucoes */ int *visited = (int*) malloc ( tours_size ); /* Lista de cidades visitadas */ double *choiceinfo = (double*) malloc ( ph_size ); int *distances_device; /* Copia da GPU da matriz de distancias */ int *tours_device; /* Copia da GPU da matriz de solucoes */ int *visited_device; /* Copia da GPU da matriz de cidades visitadas */ double *choiceinfo_device; /* Copia da GPU da matriz de probabilidades (numeraodor) */ double *probs; /* Matriz de probabilidades */ hipMalloc ( (void**) &distances_device, dist_size ); hipMalloc ( (void**) &tours_device, tours_size ); hipMalloc ( (void**) &visited_device, tours_size ); hipMalloc ( (void**) &choiceinfo_device, ph_size ); hipMalloc ( (void**) &probs, ph_size); hipMemcpy ( distances_device, distances, dist_size, hipMemcpyHostToDevice ); /* Instancia-se a matriz de feromonios. Inicialmente, todas as arestas possuem a mesma quantidade de feromonios ( INIT_PHEROMONE_AMOUNT ). */ for (int i = 0; i < n_cities; i++) for (int j = 0; j < n_cities; j++) pheromones[ index(n_cities, i, j) ] = INIT_PHEROMONE_AMOUNT; for (int iteration = 0; iteration < NUMBER_OF_ITERATIONS; iteration++) { /* Reseta todos os caminhos ao inicio de cada iteracao. Inicialmente, todas as posicoes encontram-se no infinito. */ for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) tours[ index(n_cities, i, j) ] = Infinity; for (int i = 0; i < n_ants; i++) for (int j = 0; j < n_cities; j++) visited[ index(n_cities, i, j) ] = 0; /* Calcula o numerador da funcao de probabilidade. Em cada iteracao, este valor eh o mesmo para cada formiga, o que encoraja sua execucao aqui, aumentando o desempenho do algoritmo. */ for (int i = 0; i < n_cities; i++) { for (int j = 0; j < n_cities; j++) { double edge_pherom = pheromones[ index(n_cities, i, j) ]; double edge_weight = distances[index(n_cities, i, j) ]; double prob = 0.0f; if ( edge_weight != 0.0f ) { prob = pow ( edge_pherom, ALFA ) * pow ( (1/edge_weight), BETA ); } else { prob = pow ( edge_pherom, ALFA ) * pow ( Infinity, BETA ); } choiceinfo[index(n_cities, i, j)] = prob; } } hipMemcpy ( choiceinfo_device, choiceinfo, ph_size, hipMemcpyHostToDevice ); for (int ant = 0; ant < n_ants; ant++) { int step = 0; /* Uma cidade inicial eh selecionada aleatoriamente. */ int init = rand() % n_cities; /* Atualiza o tour ( para cada formiga ). */ tours [ index ( n_cities, ant, step ) ] = init; /* Atualiza a memoria da formiga. */ visited [ index ( n_cities, ant, init ) ] = 1; } hipMemcpy ( visited_device, visited, tours_size, hipMemcpyHostToDevice ); hipMemcpy ( tours_device, tours, tours_size, hipMemcpyHostToDevice ); int gridDim = n_ants / thread_per_block (n_ants); int antsPerBlock = thread_per_block (n_ants); cuda_construct_tour <<< gridDim, antsPerBlock >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); //cuda_construct_tour <<< 1, n_ants >>> ( tours_device, visited_device, choiceinfo_device, probs, n_cities ); hipMemcpy ( tours, tours_device, tours_size, hipMemcpyDeviceToHost ); hipMemcpy ( visited, visited_device, tours_size, hipMemcpyDeviceToHost ); evaporate ( pheromones, n_cities ); int *best = best_solution ( tours, distances, n_ants, n_cities ); reinforce ( pheromones, distances, best, n_cities ); } hipFree ( distances_device ); hipFree ( tours_device ); hipFree ( visited_device ); hipFree ( choiceinfo_device ); hipFree ( probs ); int *best = best_solution ( tours, distances, n_ants, n_cities ); return best; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z14cuda_evaporatePdid .globl _Z14cuda_evaporatePdid .p2align 8 .type _Z14cuda_evaporatePdid,@function _Z14cuda_evaporatePdid: s_load_b32 s2, s[0:1], 0x24 s_waitcnt lgkmcnt(0) s_and_b32 s4, s2, 0xffff s_load_b64 s[2:3], s[0:1], 0x0 v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1] s_load_b64 s[0:1], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v2, 31, v1 v_lshlrev_b64 v[0:1], 3, v[1:2] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo global_load_b64 v[2:3], v[0:1], off s_waitcnt vmcnt(0) v_mul_f64 v[2:3], v[2:3], s[0:1] global_store_b64 v[0:1], v[2:3], off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z14cuda_evaporatePdid .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 4 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z14cuda_evaporatePdid, .Lfunc_end0-_Z14cuda_evaporatePdid .section .AMDGPU.csdata,"",@progbits .text .protected _Z14cuda_reinforcePdPiS0_id .globl _Z14cuda_reinforcePdPiS0_id .p2align 8 .type _Z14cuda_reinforcePdPiS0_id,@function _Z14cuda_reinforcePdPiS0_id: s_load_b32 s2, s[0:1], 0x34 s_waitcnt lgkmcnt(0) s_and_b32 s4, s2, 0xffff s_load_b64 s[2:3], s[0:1], 0x10 v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1] s_clause 0x2 s_load_b32 s6, s[0:1], 0x18 s_load_b64 s[4:5], s[0:1], 0x20 s_load_b64 s[0:1], s[0:1], 0x0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v2, 31, v1 v_lshlrev_b64 v[0:1], 2, v[1:2] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo global_load_b64 v[0:1], v[0:1], off s_waitcnt vmcnt(0) v_mov_b32_e32 v2, v1 v_mad_u64_u32 v[6:7], null, v1, s6, v[0:1] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_mad_u64_u32 v[3:4], null, v0, s6, v[2:3] v_ashrrev_i32_e32 v7, 31, v6 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[0:1], 3, v[6:7] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 3, v[3:4] v_add_co_u32 v2, vcc_lo, s0, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_load_b64 v[4:5], v[2:3], off s_waitcnt vmcnt(0) v_add_f64 v[4:5], v[4:5], s[4:5] global_store_b64 v[2:3], v[4:5], off global_load_b64 v[2:3], v[0:1], off s_waitcnt vmcnt(0) v_add_f64 v[2:3], v[2:3], s[4:5] global_store_b64 v[0:1], v[2:3], off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z14cuda_reinforcePdPiS0_id .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 296 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z14cuda_reinforcePdPiS0_id, .Lfunc_end1-_Z14cuda_reinforcePdPiS0_id .section .AMDGPU.csdata,"",@progbits .text .protected _Z19cuda_construct_tourPiS_PdS0_i .globl _Z19cuda_construct_tourPiS_PdS0_i .p2align 8 .type _Z19cuda_construct_tourPiS_PdS0_i,@function _Z19cuda_construct_tourPiS_PdS0_i: s_load_b32 s2, s[0:1], 0x20 s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s2, 2 s_cbranch_scc1 .LBB2_13 s_clause 0x1 s_load_b32 s3, s[0:1], 0x34 s_load_b256 s[4:11], s[0:1], 0x0 s_mov_b32 s1, 1 v_mov_b32_e32 v14, 1 s_waitcnt lgkmcnt(0) s_and_b32 s3, s3, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s3, v[0:1] v_mul_lo_u32 v0, v1, s2 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v1, 31, v0 v_add_nc_u32_e32 v2, 1, v0 v_add_nc_u32_e32 v13, -1, v0 v_lshlrev_b64 v[4:5], 3, v[0:1] s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v3, 31, v2 v_lshlrev_b64 v[6:7], 2, v[0:1] v_lshlrev_b64 v[8:9], 3, v[2:3] s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4) v_add_co_u32 v1, vcc_lo, s10, v4 v_add_co_ci_u32_e32 v2, vcc_lo, s11, v5, vcc_lo v_add_co_u32 v3, vcc_lo, s6, v6 v_add_co_ci_u32_e32 v4, vcc_lo, s7, v7, vcc_lo v_add_co_u32 v5, vcc_lo, s10, v8 v_add_co_ci_u32_e32 v6, vcc_lo, s11, v9, vcc_lo s_branch .LBB2_3 .LBB2_2: s_or_b32 exec_lo, exec_lo, s3 v_add_nc_u32_e32 v7, s1, v0 v_add_nc_u32_e32 v9, v15, v0 s_add_i32 s1, s1, 1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2) s_cmp_eq_u32 s1, s2 v_ashrrev_i32_e32 v8, 31, v7 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v10, 31, v9 v_lshlrev_b64 v[7:8], 2, v[7:8] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[9:10], 2, v[9:10] v_add_co_u32 v7, vcc_lo, s4, v7 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo v_add_co_u32 v9, vcc_lo, s6, v9 s_delay_alu instid0(VALU_DEP_4) v_add_co_ci_u32_e32 v10, vcc_lo, s7, v10, vcc_lo global_store_b32 v[7:8], v15, off global_store_b32 v[9:10], v14, off s_cbranch_scc1 .LBB2_13 .LBB2_3: v_dual_mov_b32 v10, v2 :: v_dual_add_nc_u32 v7, s1, v13 s_mov_b32 s0, 0 v_dual_mov_b32 v12, v4 :: v_dual_mov_b32 v9, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v8, 31, v7 v_mov_b32_e32 v11, v3 v_lshlrev_b64 v[7:8], 2, v[7:8] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v7, vcc_lo, s4, v7 v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo global_load_b32 v7, v[7:8], off s_waitcnt vmcnt(0) v_mul_lo_u32 v15, v7, s2 v_mov_b32_e32 v7, 0 v_mov_b32_e32 v8, 0 s_set_inst_prefetch_distance 0x1 s_branch .LBB2_5 .p2align 6 .LBB2_4: s_or_b32 exec_lo, exec_lo, s3 v_add_co_u32 v11, vcc_lo, v11, 4 v_add_co_ci_u32_e32 v12, vcc_lo, 0, v12, vcc_lo v_add_co_u32 v9, vcc_lo, v9, 8 v_add_co_ci_u32_e32 v10, vcc_lo, 0, v10, vcc_lo s_add_i32 s0, s0, 1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_eq_u32 s2, s0 s_cbranch_scc1 .LBB2_9 .LBB2_5: global_load_b32 v16, v[11:12], off s_mov_b32 s3, exec_lo s_waitcnt vmcnt(0) v_cmpx_ne_u32_e32 1, v16 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB2_7 v_add_nc_u32_e32 v16, s0, v15 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v17, 31, v16 v_lshlrev_b64 v[16:17], 3, v[16:17] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v16, vcc_lo, s8, v16 v_add_co_ci_u32_e32 v17, vcc_lo, s9, v17, vcc_lo global_load_b64 v[16:17], v[16:17], off s_waitcnt vmcnt(0) v_add_f64 v[7:8], v[7:8], v[16:17] global_store_b64 v[9:10], v[16:17], off .LBB2_7: s_and_not1_saveexec_b32 s3, s3 s_cbranch_execz .LBB2_4 v_mov_b32_e32 v16, 0 s_delay_alu instid0(VALU_DEP_1) v_mov_b32_e32 v17, v16 global_store_b64 v[9:10], v[16:17], off s_branch .LBB2_4 .LBB2_9: s_set_inst_prefetch_distance 0x2 s_getreg_b32 s0, hwreg(HW_REG_SHADER_CYCLES, 0, 20) global_load_b64 v[9:10], v[1:2], off s_xor_b32 s0, s0, 0x2c7f967f v_mov_b32_e32 v15, 0 s_mul_i32 s0, s0, 0x493c4aa1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) s_add_i32 s3, s0, 0x75bcd15 s_add_i32 s11, s0, 0x583f19 s_lshr_b32 s10, s3, 2 s_xor_b32 s3, s10, s3 s_lshl_b32 s10, s11, 4 s_lshl_b32 s12, s3, 1 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s10, s10, s12 s_mov_b32 s12, 0xa03697cb s_xor_b32 s10, s10, s11 s_mul_i32 s12, s12, 0x7b99840d s_xor_b32 s3, s10, s3 s_add_i32 s0, s0, s12 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) s_add_i32 s0, s0, s3 s_mov_b32 s3, exec_lo s_add_i32 s0, s0, 0x6a788e v_cvt_f32_u32_e32 v11, s0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fmaak_f32 v11, 0x2f800000, v11, 0x2f800000 v_cvt_f64_f32_e32 v[11:12], v11 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mul_f64 v[7:8], v[7:8], v[11:12] s_waitcnt vmcnt(0) v_cmpx_lt_f64_e32 v[9:10], v[7:8] s_cbranch_execz .LBB2_2 v_dual_mov_b32 v12, v6 :: v_dual_mov_b32 v11, v5 s_mov_b32 s10, 0 s_mov_b32 s11, 0 .LBB2_11: global_load_b64 v[15:16], v[11:12], off s_add_i32 s11, s11, 1 v_add_co_u32 v11, s0, v11, 8 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2) v_add_co_ci_u32_e64 v12, s0, 0, v12, s0 s_waitcnt vmcnt(0) v_add_f64 v[9:10], v[9:10], v[15:16] v_mov_b32_e32 v15, s11 v_cmp_nlt_f64_e32 vcc_lo, v[9:10], v[7:8] s_or_b32 s10, vcc_lo, s10 s_delay_alu instid0(SALU_CYCLE_1) s_and_not1_b32 exec_lo, exec_lo, s10 s_cbranch_execnz .LBB2_11 s_or_b32 exec_lo, exec_lo, s10 s_branch .LBB2_2 .LBB2_13: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z19cuda_construct_tourPiS_PdS0_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 296 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 18 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end2: .size _Z19cuda_construct_tourPiS_PdS0_i, .Lfunc_end2-_Z19cuda_construct_tourPiS_PdS0_i .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .offset: 8 .size: 4 .value_kind: by_value - .offset: 16 .size: 8 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14cuda_evaporatePdid .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14cuda_evaporatePdid.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 4 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 32 .size: 8 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: hidden_block_count_x - .offset: 44 .size: 4 .value_kind: hidden_block_count_y - .offset: 48 .size: 4 .value_kind: hidden_block_count_z - .offset: 52 .size: 2 .value_kind: hidden_group_size_x - .offset: 54 .size: 2 .value_kind: hidden_group_size_y - .offset: 56 .size: 2 .value_kind: hidden_group_size_z - .offset: 58 .size: 2 .value_kind: hidden_remainder_x - .offset: 60 .size: 2 .value_kind: hidden_remainder_y - .offset: 62 .size: 2 .value_kind: hidden_remainder_z - .offset: 80 .size: 8 .value_kind: hidden_global_offset_x - .offset: 88 .size: 8 .value_kind: hidden_global_offset_y - .offset: 96 .size: 8 .value_kind: hidden_global_offset_z - .offset: 104 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 296 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14cuda_reinforcePdPiS0_id .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14cuda_reinforcePdPiS0_id.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 24 .size: 8 .value_kind: global_buffer - .offset: 32 .size: 4 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: hidden_block_count_x - .offset: 44 .size: 4 .value_kind: hidden_block_count_y - .offset: 48 .size: 4 .value_kind: hidden_block_count_z - .offset: 52 .size: 2 .value_kind: hidden_group_size_x - .offset: 54 .size: 2 .value_kind: hidden_group_size_y - .offset: 56 .size: 2 .value_kind: hidden_group_size_z - .offset: 58 .size: 2 .value_kind: hidden_remainder_x - .offset: 60 .size: 2 .value_kind: hidden_remainder_y - .offset: 62 .size: 2 .value_kind: hidden_remainder_z - .offset: 80 .size: 8 .value_kind: hidden_global_offset_x - .offset: 88 .size: 8 .value_kind: hidden_global_offset_y - .offset: 96 .size: 8 .value_kind: hidden_global_offset_z - .offset: 104 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 296 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z19cuda_construct_tourPiS_PdS0_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z19cuda_construct_tourPiS_PdS0_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 18 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
/****************************************************** * CUDA Sum Reduction * By: Sairam Krishnan * Date: May 6, 2014 * Compile command: nvcc -arch=sm_20 reduction.cu ******************************************************/ #include <cuda.h> #include <stdio.h> #define N 10 #define NTHRDS 4 #define NBLKS (((N) + (NTHRDS-1)) / (NTHRDS)) __global__ void sumReduction(int *input, int *output) { int index = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0, i; __shared__ int temp[NTHRDS]; //Load the values into shared memory. temp[threadIdx.x] = input[index]; //Wait for all threads in the current block to finish loading values. __syncthreads(); //Offload the reduction work for this block to thread 0. if (threadIdx.x != 0) return; for (i = 0; i<blockDim.x; i++) { if (index+i >= N) break; sum += temp[i]; } //Atomic add to prevent inteference from threads outside this block atomicAdd(output, sum); } int main() { int input[N], output, i; int *devInput, *devOutput; for (i = 0; i<N; i++) input[i] = i+1; cudaMalloc(&devInput, N*sizeof(int)); cudaMalloc(&devOutput, sizeof(int)); cudaMemcpy(devInput, input, N*sizeof(int), cudaMemcpyHostToDevice); cudaMemset(devOutput, 0, sizeof(int)); sumReduction <<<NBLKS, NTHRDS>>>(devInput, devOutput); cudaMemcpy(&output, devOutput, sizeof(int), cudaMemcpyDeviceToHost); printf("%d\n", output); cudaFree(devOutput); cudaFree(devInput); return 0; }
code for sm_80 Function : _Z12sumReductionPiS_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R4, SR_CTAID.X ; /* 0x0000000000047919 */ /* 0x000e220000002500 */ /*0020*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R5, SR_TID.X ; /* 0x0000000000057919 */ /* 0x000e240000002100 */ /*0050*/ IMAD R0, R4, c[0x0][0x0], R5 ; /* 0x0000000004007a24 */ /* 0x001fc800078e0205 */ /*0060*/ IMAD.WIDE R2, R0, R3, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fcc00078e0203 */ /*0070*/ LDG.E R2, [R2.64] ; /* 0x0000000602027981 */ /* 0x000ea2000c1e1900 */ /*0080*/ ISETP.NE.AND P0, PT, R5, RZ, PT ; /* 0x000000ff0500720c */ /* 0x000fc60003f05270 */ /*0090*/ STS [R5.X4], R2 ; /* 0x0000000205007388 */ /* 0x0041e80000004800 */ /*00a0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*00b0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00c0*/ ISETP.GT.AND P0, PT, R0, 0x9, PT ; /* 0x000000090000780c */ /* 0x001fe20003f04270 */ /*00d0*/ BSSY B0, 0x560 ; /* 0x0000048000007945 */ /* 0x000fe20003800000 */ /*00e0*/ IMAD.MOV.U32 R0, RZ, RZ, RZ ; /* 0x000000ffff007224 */ /* 0x000fc400078e00ff */ /*00f0*/ ISETP.EQ.OR P0, PT, RZ, c[0x0][0x0], P0 ; /* 0x00000000ff007a0c */ /* 0x000fda0000702670 */ /*0100*/ @P0 BRA 0x550 ; /* 0x0000044000000947 */ /* 0x000fea0003800000 */ /*0110*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff037624 */ /* 0x000fe200078e00ff */ /*0120*/ ULDC UR4, c[0x0][0x0] ; /* 0x0000000000047ab9 */ /* 0x000fe40000000800 */ /*0130*/ UIADD3 UR4, -UR4, URZ, URZ ; /* 0x0000003f04047290 */ /* 0x000fe2000fffe13f */ /*0140*/ IMAD R0, R4, R3, -0xa ; /* 0xfffffff604007424 */ /* 0x000fca00078e0203 */ /*0150*/ IMNMX.U32 R3, R0, UR4, !PT ; /* 0x0000000400037c17 */ /* 0x000fe2000f800000 */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ IMAD.MOV.U32 R0, RZ, RZ, RZ ; /* 0x000000ffff007224 */ /* 0x000fe400078e00ff */ /*0180*/ ISETP.GT.U32.AND P0, PT, R3, -0x4, PT ; /* 0xfffffffc0300780c */ /* 0x000fe20003f04070 */ /*0190*/ IMAD.MOV R2, RZ, RZ, -R3 ; /* 0x000000ffff027224 */ /* 0x000fca00078e0a03 */ /*01a0*/ LOP3.LUT R2, R2, 0x3, RZ, 0xc0, !PT ; /* 0x0000000302027812 */ /* 0x000fce00078ec0ff */ /*01b0*/ @P0 BRA 0x4c0 ; /* 0x0000030000000947 */ /* 0x000fea0003800000 */ /*01c0*/ IADD3 R3, RZ, -R3, -R2 ; /* 0x80000003ff037210 */ /* 0x000fe20007ffe802 */ /*01d0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe40008000000 */ /*01e0*/ UMOV UR5, URZ ; /* 0x0000003f00057c82 */ /* 0x000fe20008000000 */ /*01f0*/ ISETP.GT.AND P0, PT, R3, RZ, PT ; /* 0x000000ff0300720c */ /* 0x000fda0003f04270 */ /*0200*/ @!P0 BRA 0x440 ; /* 0x0000023000008947 */ /* 0x000fea0003800000 */ /*0210*/ ISETP.GT.AND P1, PT, R3, 0xc, PT ; /* 0x0000000c0300780c */ /* 0x000fe40003f24270 */ /*0220*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0230*/ @!P1 BRA 0x360 ; /* 0x0000012000009947 */ /* 0x000fea0003800000 */ /*0240*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0250*/ LDS.128 R4, [UR5] ; /* 0x00000005ff047984 */ /* 0x000e220008000c00 */ /*0260*/ IADD3 R3, R3, -0x10, RZ ; /* 0xfffffff003037810 */ /* 0x000fe20007ffe0ff */ /*0270*/ UIADD3 UR4, UR4, 0x10, URZ ; /* 0x0000001004047890 */ /* 0x000fe4000fffe03f */ /*0280*/ LDS.128 R8, [UR5+0x10] ; /* 0x00001005ff087984 */ /* 0x000e620008000c00 */ /*0290*/ ISETP.GT.AND P1, PT, R3, 0xc, PT ; /* 0x0000000c0300780c */ /* 0x000fc60003f24270 */ /*02a0*/ LDS.128 R12, [UR5+0x20] ; /* 0x00002005ff0c7984 */ /* 0x000ea80008000c00 */ /*02b0*/ LDS.128 R16, [UR5+0x30] ; /* 0x00003005ff107984 */ /* 0x000ee20008000c00 */ /*02c0*/ UIADD3 UR5, UR5, 0x40, URZ ; /* 0x0000004005057890 */ /* 0x000fe2000fffe03f */ /*02d0*/ IADD3 R4, R5, R4, R0 ; /* 0x0000000405047210 */ /* 0x001fc80007ffe000 */ /*02e0*/ IADD3 R4, R7, R6, R4 ; /* 0x0000000607047210 */ /* 0x000fc80007ffe004 */ /*02f0*/ IADD3 R4, R9, R8, R4 ; /* 0x0000000809047210 */ /* 0x002fc80007ffe004 */ /*0300*/ IADD3 R4, R11, R10, R4 ; /* 0x0000000a0b047210 */ /* 0x000fc80007ffe004 */ /*0310*/ IADD3 R4, R13, R12, R4 ; /* 0x0000000c0d047210 */ /* 0x004fc80007ffe004 */ /*0320*/ IADD3 R4, R15, R14, R4 ; /* 0x0000000e0f047210 */ /* 0x000fc80007ffe004 */ /*0330*/ IADD3 R4, R17, R16, R4 ; /* 0x0000001011047210 */ /* 0x008fc80007ffe004 */ /*0340*/ IADD3 R0, R19, R18, R4 ; /* 0x0000001213007210 */ /* 0x000fe20007ffe004 */ /*0350*/ @P1 BRA 0x250 ; /* 0xfffffef000001947 */ /* 0x000fea000383ffff */ /*0360*/ ISETP.GT.AND P1, PT, R3, 0x4, PT ; /* 0x000000040300780c */ /* 0x000fda0003f24270 */ /*0370*/ @!P1 BRA 0x420 ; /* 0x000000a000009947 */ /* 0x000fea0003800000 */ /*0380*/ LDS.128 R8, [UR5] ; /* 0x00000005ff087984 */ /* 0x000e220008000c00 */ /*0390*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe20003f0e170 */ /*03a0*/ UIADD3 UR4, UR4, 0x8, URZ ; /* 0x0000000804047890 */ /* 0x000fe2000fffe03f */ /*03b0*/ IADD3 R3, R3, -0x8, RZ ; /* 0xfffffff803037810 */ /* 0x000fe20007ffe0ff */ /*03c0*/ LDS.128 R4, [UR5+0x10] ; /* 0x00001005ff047984 */ /* 0x000e620008000c00 */ /*03d0*/ UIADD3 UR5, UR5, 0x20, URZ ; /* 0x0000002005057890 */ /* 0x000fe2000fffe03f */ /*03e0*/ IADD3 R8, R9, R8, R0 ; /* 0x0000000809087210 */ /* 0x001fc80007ffe000 */ /*03f0*/ IADD3 R8, R11, R10, R8 ; /* 0x0000000a0b087210 */ /* 0x000fc80007ffe008 */ /*0400*/ IADD3 R4, R5, R4, R8 ; /* 0x0000000405047210 */ /* 0x002fc80007ffe008 */ /*0410*/ IADD3 R0, R7, R6, R4 ; /* 0x0000000607007210 */ /* 0x000fe40007ffe004 */ /*0420*/ ISETP.NE.OR P0, PT, R3, RZ, P0 ; /* 0x000000ff0300720c */ /* 0x000fda0000705670 */ /*0430*/ @!P0 BRA 0x4c0 ; /* 0x0000008000008947 */ /* 0x000fea0003800000 */ /*0440*/ LDS.128 R4, [UR5] ; /* 0x00000005ff047984 */ /* 0x000e220008000c00 */ /*0450*/ IADD3 R3, R3, -0x4, RZ ; /* 0xfffffffc03037810 */ /* 0x000fe20007ffe0ff */ /*0460*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*0470*/ UIADD3 UR5, UR5, 0x10, URZ ; /* 0x0000001005057890 */ /* 0x000fe2000fffe03f */ /*0480*/ ISETP.NE.AND P0, PT, R3, RZ, PT ; /* 0x000000ff0300720c */ /* 0x000fe40003f05270 */ /*0490*/ IADD3 R0, R5, R4, R0 ; /* 0x0000000405007210 */ /* 0x001fc80007ffe000 */ /*04a0*/ IADD3 R0, R7, R6, R0 ; /* 0x0000000607007210 */ /* 0x000fce0007ffe000 */ /*04b0*/ @P0 BRA 0x440 ; /* 0xffffff8000000947 */ /* 0x000fea000383ffff */ /*04c0*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fda0003f05270 */ /*04d0*/ @!P0 BRA 0x550 ; /* 0x0000007000008947 */ /* 0x000fea0003800000 */ /*04e0*/ USHF.L.U32 UR4, UR4, 0x2, URZ ; /* 0x0000000204047899 */ /* 0x000fd2000800063f */ /*04f0*/ LDS R3, [UR4] ; /* 0x00000004ff037984 */ /* 0x000e220008000800 */ /*0500*/ IADD3 R2, R2, -0x1, RZ ; /* 0xffffffff02027810 */ /* 0x000fe20007ffe0ff */ /*0510*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fc6000fffe03f */ /*0520*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fe20003f05270 */ /*0530*/ IMAD.IADD R0, R3, 0x1, R0 ; /* 0x0000000103007824 */ /* 0x001fd800078e0200 */ /*0540*/ @P0 BRA 0x4f0 ; /* 0xffffffa000000947 */ /* 0x000fea000383ffff */ /*0550*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0560*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff027624 */ /* 0x000fe400078e00ff */ /*0570*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff037624 */ /* 0x000fca00078e00ff */ /*0580*/ RED.E.ADD.STRONG.GPU [R2.64], R0 ; /* 0x000000000200798e */ /* 0x000fe2000c10e186 */ /*0590*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*05a0*/ BRA 0x5a0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*05b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0600*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0610*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0620*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0630*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0640*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0650*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0660*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0670*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
/****************************************************** * CUDA Sum Reduction * By: Sairam Krishnan * Date: May 6, 2014 * Compile command: nvcc -arch=sm_20 reduction.cu ******************************************************/ #include <cuda.h> #include <stdio.h> #define N 10 #define NTHRDS 4 #define NBLKS (((N) + (NTHRDS-1)) / (NTHRDS)) __global__ void sumReduction(int *input, int *output) { int index = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0, i; __shared__ int temp[NTHRDS]; //Load the values into shared memory. temp[threadIdx.x] = input[index]; //Wait for all threads in the current block to finish loading values. __syncthreads(); //Offload the reduction work for this block to thread 0. if (threadIdx.x != 0) return; for (i = 0; i<blockDim.x; i++) { if (index+i >= N) break; sum += temp[i]; } //Atomic add to prevent inteference from threads outside this block atomicAdd(output, sum); } int main() { int input[N], output, i; int *devInput, *devOutput; for (i = 0; i<N; i++) input[i] = i+1; cudaMalloc(&devInput, N*sizeof(int)); cudaMalloc(&devOutput, sizeof(int)); cudaMemcpy(devInput, input, N*sizeof(int), cudaMemcpyHostToDevice); cudaMemset(devOutput, 0, sizeof(int)); sumReduction <<<NBLKS, NTHRDS>>>(devInput, devOutput); cudaMemcpy(&output, devOutput, sizeof(int), cudaMemcpyDeviceToHost); printf("%d\n", output); cudaFree(devOutput); cudaFree(devInput); return 0; }
.file "tmpxft_0012e436_00000000-6_reduction.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z34__device_stub__Z12sumReductionPiS_PiS_ .type _Z34__device_stub__Z12sumReductionPiS_PiS_, @function _Z34__device_stub__Z12sumReductionPiS_PiS_: .LFB2082: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movq %rsi, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 104(%rsp), %rax subq %fs:40, %rax jne .L8 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z12sumReductionPiS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z34__device_stub__Z12sumReductionPiS_PiS_, .-_Z34__device_stub__Z12sumReductionPiS_PiS_ .globl _Z12sumReductionPiS_ .type _Z12sumReductionPiS_, @function _Z12sumReductionPiS_: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z34__device_stub__Z12sumReductionPiS_PiS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z12sumReductionPiS_, .-_Z12sumReductionPiS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax movl $1, %eax .L12: movl %eax, 44(%rsp,%rax,4) addq $1, %rax cmpq $11, %rax jne .L12 leaq 8(%rsp), %rdi movl $40, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT leaq 48(%rsp), %rsi movl $1, %ecx movl $40, %edx movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $4, %edx movl $0, %esi movq 16(%rsp), %rdi call cudaMemset@PLT movl $4, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $3, 24(%rsp) movl $1, 28(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L17 .L13: leaq 36(%rsp), %rdi movl $2, %ecx movl $4, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT movl 36(%rsp), %edx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 88(%rsp), %rax subq %fs:40, %rax jne .L18 movl $0, %eax addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L17: .cfi_restore_state movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z34__device_stub__Z12sumReductionPiS_PiS_ jmp .L13 .L18: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC1: .string "_Z12sumReductionPiS_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC1(%rip), %rdx movq %rdx, %rcx leaq _Z12sumReductionPiS_(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
/****************************************************** * CUDA Sum Reduction * By: Sairam Krishnan * Date: May 6, 2014 * Compile command: nvcc -arch=sm_20 reduction.cu ******************************************************/ #include <cuda.h> #include <stdio.h> #define N 10 #define NTHRDS 4 #define NBLKS (((N) + (NTHRDS-1)) / (NTHRDS)) __global__ void sumReduction(int *input, int *output) { int index = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0, i; __shared__ int temp[NTHRDS]; //Load the values into shared memory. temp[threadIdx.x] = input[index]; //Wait for all threads in the current block to finish loading values. __syncthreads(); //Offload the reduction work for this block to thread 0. if (threadIdx.x != 0) return; for (i = 0; i<blockDim.x; i++) { if (index+i >= N) break; sum += temp[i]; } //Atomic add to prevent inteference from threads outside this block atomicAdd(output, sum); } int main() { int input[N], output, i; int *devInput, *devOutput; for (i = 0; i<N; i++) input[i] = i+1; cudaMalloc(&devInput, N*sizeof(int)); cudaMalloc(&devOutput, sizeof(int)); cudaMemcpy(devInput, input, N*sizeof(int), cudaMemcpyHostToDevice); cudaMemset(devOutput, 0, sizeof(int)); sumReduction <<<NBLKS, NTHRDS>>>(devInput, devOutput); cudaMemcpy(&output, devOutput, sizeof(int), cudaMemcpyDeviceToHost); printf("%d\n", output); cudaFree(devOutput); cudaFree(devInput); return 0; }
/****************************************************** * CUDA Sum Reduction * By: Sairam Krishnan * Date: May 6, 2014 * Compile command: nvcc -arch=sm_20 reduction.cu ******************************************************/ #include <hip/hip_runtime.h> #include <stdio.h> #define N 10 #define NTHRDS 4 #define NBLKS (((N) + (NTHRDS-1)) / (NTHRDS)) __global__ void sumReduction(int *input, int *output) { int index = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0, i; __shared__ int temp[NTHRDS]; //Load the values into shared memory. temp[threadIdx.x] = input[index]; //Wait for all threads in the current block to finish loading values. __syncthreads(); //Offload the reduction work for this block to thread 0. if (threadIdx.x != 0) return; for (i = 0; i<blockDim.x; i++) { if (index+i >= N) break; sum += temp[i]; } //Atomic add to prevent inteference from threads outside this block atomicAdd(output, sum); } int main() { int input[N], output, i; int *devInput, *devOutput; for (i = 0; i<N; i++) input[i] = i+1; hipMalloc(&devInput, N*sizeof(int)); hipMalloc(&devOutput, sizeof(int)); hipMemcpy(devInput, input, N*sizeof(int), hipMemcpyHostToDevice); hipMemset(devOutput, 0, sizeof(int)); sumReduction <<<NBLKS, NTHRDS>>>(devInput, devOutput); hipMemcpy(&output, devOutput, sizeof(int), hipMemcpyDeviceToHost); printf("%d\n", output); hipFree(devOutput); hipFree(devInput); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/****************************************************** * CUDA Sum Reduction * By: Sairam Krishnan * Date: May 6, 2014 * Compile command: nvcc -arch=sm_20 reduction.cu ******************************************************/ #include <hip/hip_runtime.h> #include <stdio.h> #define N 10 #define NTHRDS 4 #define NBLKS (((N) + (NTHRDS-1)) / (NTHRDS)) __global__ void sumReduction(int *input, int *output) { int index = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0, i; __shared__ int temp[NTHRDS]; //Load the values into shared memory. temp[threadIdx.x] = input[index]; //Wait for all threads in the current block to finish loading values. __syncthreads(); //Offload the reduction work for this block to thread 0. if (threadIdx.x != 0) return; for (i = 0; i<blockDim.x; i++) { if (index+i >= N) break; sum += temp[i]; } //Atomic add to prevent inteference from threads outside this block atomicAdd(output, sum); } int main() { int input[N], output, i; int *devInput, *devOutput; for (i = 0; i<N; i++) input[i] = i+1; hipMalloc(&devInput, N*sizeof(int)); hipMalloc(&devOutput, sizeof(int)); hipMemcpy(devInput, input, N*sizeof(int), hipMemcpyHostToDevice); hipMemset(devOutput, 0, sizeof(int)); sumReduction <<<NBLKS, NTHRDS>>>(devInput, devOutput); hipMemcpy(&output, devOutput, sizeof(int), hipMemcpyDeviceToHost); printf("%d\n", output); hipFree(devOutput); hipFree(devInput); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z12sumReductionPiS_ .globl _Z12sumReductionPiS_ .p2align 8 .type _Z12sumReductionPiS_,@function _Z12sumReductionPiS_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x1c s_load_b64 s[4:5], s[0:1], 0x0 s_mov_b32 s3, exec_lo s_waitcnt lgkmcnt(0) s_and_b32 s2, s2, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1] v_ashrrev_i32_e32 v2, 31, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 2, v[1:2] v_add_co_u32 v2, vcc_lo, s4, v2 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo global_load_b32 v2, v[2:3], off v_lshlrev_b32_e32 v3, 2, v0 s_waitcnt vmcnt(0) ds_store_b32 v3, v2 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv v_cmpx_eq_u32_e32 0, v0 s_cbranch_execz .LBB0_9 v_cmp_gt_i32_e32 vcc_lo, 10, v1 s_cmp_lg_u32 s2, 0 v_mov_b32_e32 v0, 0 s_cselect_b32 s3, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s4, s3, vcc_lo s_and_saveexec_b32 s3, s4 s_cbranch_execz .LBB0_5 v_mov_b32_e32 v0, 0 s_mov_b32 s4, 1 s_mov_b32 s6, 0 s_mov_b32 s5, 0 .LBB0_3: v_dual_mov_b32 v2, s6 :: v_dual_add_nc_u32 v3, s4, v1 s_cmp_ge_u32 s4, s2 s_cselect_b32 s7, -1, 0 ds_load_b32 v2, v2 v_cmp_lt_i32_e32 vcc_lo, 9, v3 s_add_i32 s4, s4, 1 s_add_i32 s6, s6, 4 s_or_b32 s7, s7, vcc_lo s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s7, exec_lo, s7 s_or_b32 s5, s7, s5 s_waitcnt lgkmcnt(0) v_add_nc_u32_e32 v0, v2, v0 s_and_not1_b32 exec_lo, exec_lo, s5 s_cbranch_execnz .LBB0_3 s_or_b32 exec_lo, exec_lo, s5 .LBB0_5: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_or_b32 exec_lo, exec_lo, s3 s_mov_b32 s3, exec_lo s_mov_b32 s2, 0 .LBB0_6: s_ctz_i32_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_readlane_b32 s5, v0, s4 s_lshl_b32 s4, 1, s4 s_and_not1_b32 s3, s3, s4 s_delay_alu instid0(VALU_DEP_1) s_add_i32 s2, s2, s5 s_cmp_lg_u32 s3, 0 s_cbranch_scc1 .LBB0_6 v_mbcnt_lo_u32_b32 v0, exec_lo, 0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v0 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB0_9 s_load_b64 s[0:1], s[0:1], 0x8 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 s_waitcnt lgkmcnt(0) global_atomic_add_u32 v0, v1, s[0:1] .LBB0_9: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z12sumReductionPiS_ .amdhsa_group_segment_fixed_size 16 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 272 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 4 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z12sumReductionPiS_, .Lfunc_end0-_Z12sumReductionPiS_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: hidden_block_count_x - .offset: 20 .size: 4 .value_kind: hidden_block_count_y - .offset: 24 .size: 4 .value_kind: hidden_block_count_z - .offset: 28 .size: 2 .value_kind: hidden_group_size_x - .offset: 30 .size: 2 .value_kind: hidden_group_size_y - .offset: 32 .size: 2 .value_kind: hidden_group_size_z - .offset: 34 .size: 2 .value_kind: hidden_remainder_x - .offset: 36 .size: 2 .value_kind: hidden_remainder_y - .offset: 38 .size: 2 .value_kind: hidden_remainder_z - .offset: 56 .size: 8 .value_kind: hidden_global_offset_x - .offset: 64 .size: 8 .value_kind: hidden_global_offset_y - .offset: 72 .size: 8 .value_kind: hidden_global_offset_z - .offset: 80 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 16 .kernarg_segment_align: 8 .kernarg_segment_size: 272 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z12sumReductionPiS_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z12sumReductionPiS_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 4 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
/****************************************************** * CUDA Sum Reduction * By: Sairam Krishnan * Date: May 6, 2014 * Compile command: nvcc -arch=sm_20 reduction.cu ******************************************************/ #include <hip/hip_runtime.h> #include <stdio.h> #define N 10 #define NTHRDS 4 #define NBLKS (((N) + (NTHRDS-1)) / (NTHRDS)) __global__ void sumReduction(int *input, int *output) { int index = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0, i; __shared__ int temp[NTHRDS]; //Load the values into shared memory. temp[threadIdx.x] = input[index]; //Wait for all threads in the current block to finish loading values. __syncthreads(); //Offload the reduction work for this block to thread 0. if (threadIdx.x != 0) return; for (i = 0; i<blockDim.x; i++) { if (index+i >= N) break; sum += temp[i]; } //Atomic add to prevent inteference from threads outside this block atomicAdd(output, sum); } int main() { int input[N], output, i; int *devInput, *devOutput; for (i = 0; i<N; i++) input[i] = i+1; hipMalloc(&devInput, N*sizeof(int)); hipMalloc(&devOutput, sizeof(int)); hipMemcpy(devInput, input, N*sizeof(int), hipMemcpyHostToDevice); hipMemset(devOutput, 0, sizeof(int)); sumReduction <<<NBLKS, NTHRDS>>>(devInput, devOutput); hipMemcpy(&output, devOutput, sizeof(int), hipMemcpyDeviceToHost); printf("%d\n", output); hipFree(devOutput); hipFree(devInput); return 0; }
.text .file "reduction.hip" .globl _Z27__device_stub__sumReductionPiS_ # -- Begin function _Z27__device_stub__sumReductionPiS_ .p2align 4, 0x90 .type _Z27__device_stub__sumReductionPiS_,@function _Z27__device_stub__sumReductionPiS_: # @_Z27__device_stub__sumReductionPiS_ .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movq %rsi, 48(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 48(%rsp), %rax movq %rax, 72(%rsp) leaq 32(%rsp), %rdi leaq 16(%rsp), %rsi leaq 8(%rsp), %rdx movq %rsp, %rcx callq __hipPopCallConfiguration movq 32(%rsp), %rsi movl 40(%rsp), %edx movq 16(%rsp), %rcx movl 24(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z12sumReductionPiS_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z27__device_stub__sumReductionPiS_, .Lfunc_end0-_Z27__device_stub__sumReductionPiS_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: subq $136, %rsp .cfi_def_cfa_offset 144 xorl %eax, %eax .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 leaq 1(%rax), %rcx movl %ecx, 96(%rsp,%rax,4) movq %rcx, %rax cmpq $10, %rcx jne .LBB1_1 # %bb.2: leaq 8(%rsp), %rdi movl $40, %esi callq hipMalloc movq %rsp, %rdi movl $4, %esi callq hipMalloc movq 8(%rsp), %rdi leaq 96(%rsp), %rsi movl $40, %edx movl $1, %ecx callq hipMemcpy movq (%rsp), %rdi movl $4, %edx xorl %esi, %esi callq hipMemset movabsq $4294967299, %rdi # imm = 0x100000003 leaq 1(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_4 # %bb.3: movq 8(%rsp), %rax movq (%rsp), %rcx movq %rax, 88(%rsp) movq %rcx, 80(%rsp) leaq 88(%rsp), %rax movq %rax, 16(%rsp) leaq 80(%rsp), %rax movq %rax, 24(%rsp) leaq 64(%rsp), %rdi leaq 48(%rsp), %rsi leaq 40(%rsp), %rdx leaq 32(%rsp), %rcx callq __hipPopCallConfiguration movq 64(%rsp), %rsi movl 72(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z12sumReductionPiS_, %edi pushq 32(%rsp) .cfi_adjust_cfa_offset 8 pushq 48(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_4: movq (%rsp), %rsi leaq 16(%rsp), %rdi movl $4, %edx movl $2, %ecx callq hipMemcpy movl 16(%rsp), %esi movl $.L.str, %edi xorl %eax, %eax callq printf movq (%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree xorl %eax, %eax addq $136, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z12sumReductionPiS_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type _Z12sumReductionPiS_,@object # @_Z12sumReductionPiS_ .section .rodata,"a",@progbits .globl _Z12sumReductionPiS_ .p2align 3, 0x0 _Z12sumReductionPiS_: .quad _Z27__device_stub__sumReductionPiS_ .size _Z12sumReductionPiS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d\n" .size .L.str, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z12sumReductionPiS_" .size .L__unnamed_1, 21 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z27__device_stub__sumReductionPiS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z12sumReductionPiS_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z12sumReductionPiS_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R4, SR_CTAID.X ; /* 0x0000000000047919 */ /* 0x000e220000002500 */ /*0020*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R5, SR_TID.X ; /* 0x0000000000057919 */ /* 0x000e240000002100 */ /*0050*/ IMAD R0, R4, c[0x0][0x0], R5 ; /* 0x0000000004007a24 */ /* 0x001fc800078e0205 */ /*0060*/ IMAD.WIDE R2, R0, R3, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fcc00078e0203 */ /*0070*/ LDG.E R2, [R2.64] ; /* 0x0000000602027981 */ /* 0x000ea2000c1e1900 */ /*0080*/ ISETP.NE.AND P0, PT, R5, RZ, PT ; /* 0x000000ff0500720c */ /* 0x000fc60003f05270 */ /*0090*/ STS [R5.X4], R2 ; /* 0x0000000205007388 */ /* 0x0041e80000004800 */ /*00a0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*00b0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00c0*/ ISETP.GT.AND P0, PT, R0, 0x9, PT ; /* 0x000000090000780c */ /* 0x001fe20003f04270 */ /*00d0*/ BSSY B0, 0x560 ; /* 0x0000048000007945 */ /* 0x000fe20003800000 */ /*00e0*/ IMAD.MOV.U32 R0, RZ, RZ, RZ ; /* 0x000000ffff007224 */ /* 0x000fc400078e00ff */ /*00f0*/ ISETP.EQ.OR P0, PT, RZ, c[0x0][0x0], P0 ; /* 0x00000000ff007a0c */ /* 0x000fda0000702670 */ /*0100*/ @P0 BRA 0x550 ; /* 0x0000044000000947 */ /* 0x000fea0003800000 */ /*0110*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff037624 */ /* 0x000fe200078e00ff */ /*0120*/ ULDC UR4, c[0x0][0x0] ; /* 0x0000000000047ab9 */ /* 0x000fe40000000800 */ /*0130*/ UIADD3 UR4, -UR4, URZ, URZ ; /* 0x0000003f04047290 */ /* 0x000fe2000fffe13f */ /*0140*/ IMAD R0, R4, R3, -0xa ; /* 0xfffffff604007424 */ /* 0x000fca00078e0203 */ /*0150*/ IMNMX.U32 R3, R0, UR4, !PT ; /* 0x0000000400037c17 */ /* 0x000fe2000f800000 */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ IMAD.MOV.U32 R0, RZ, RZ, RZ ; /* 0x000000ffff007224 */ /* 0x000fe400078e00ff */ /*0180*/ ISETP.GT.U32.AND P0, PT, R3, -0x4, PT ; /* 0xfffffffc0300780c */ /* 0x000fe20003f04070 */ /*0190*/ IMAD.MOV R2, RZ, RZ, -R3 ; /* 0x000000ffff027224 */ /* 0x000fca00078e0a03 */ /*01a0*/ LOP3.LUT R2, R2, 0x3, RZ, 0xc0, !PT ; /* 0x0000000302027812 */ /* 0x000fce00078ec0ff */ /*01b0*/ @P0 BRA 0x4c0 ; /* 0x0000030000000947 */ /* 0x000fea0003800000 */ /*01c0*/ IADD3 R3, RZ, -R3, -R2 ; /* 0x80000003ff037210 */ /* 0x000fe20007ffe802 */ /*01d0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe40008000000 */ /*01e0*/ UMOV UR5, URZ ; /* 0x0000003f00057c82 */ /* 0x000fe20008000000 */ /*01f0*/ ISETP.GT.AND P0, PT, R3, RZ, PT ; /* 0x000000ff0300720c */ /* 0x000fda0003f04270 */ /*0200*/ @!P0 BRA 0x440 ; /* 0x0000023000008947 */ /* 0x000fea0003800000 */ /*0210*/ ISETP.GT.AND P1, PT, R3, 0xc, PT ; /* 0x0000000c0300780c */ /* 0x000fe40003f24270 */ /*0220*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0230*/ @!P1 BRA 0x360 ; /* 0x0000012000009947 */ /* 0x000fea0003800000 */ /*0240*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0250*/ LDS.128 R4, [UR5] ; /* 0x00000005ff047984 */ /* 0x000e220008000c00 */ /*0260*/ IADD3 R3, R3, -0x10, RZ ; /* 0xfffffff003037810 */ /* 0x000fe20007ffe0ff */ /*0270*/ UIADD3 UR4, UR4, 0x10, URZ ; /* 0x0000001004047890 */ /* 0x000fe4000fffe03f */ /*0280*/ LDS.128 R8, [UR5+0x10] ; /* 0x00001005ff087984 */ /* 0x000e620008000c00 */ /*0290*/ ISETP.GT.AND P1, PT, R3, 0xc, PT ; /* 0x0000000c0300780c */ /* 0x000fc60003f24270 */ /*02a0*/ LDS.128 R12, [UR5+0x20] ; /* 0x00002005ff0c7984 */ /* 0x000ea80008000c00 */ /*02b0*/ LDS.128 R16, [UR5+0x30] ; /* 0x00003005ff107984 */ /* 0x000ee20008000c00 */ /*02c0*/ UIADD3 UR5, UR5, 0x40, URZ ; /* 0x0000004005057890 */ /* 0x000fe2000fffe03f */ /*02d0*/ IADD3 R4, R5, R4, R0 ; /* 0x0000000405047210 */ /* 0x001fc80007ffe000 */ /*02e0*/ IADD3 R4, R7, R6, R4 ; /* 0x0000000607047210 */ /* 0x000fc80007ffe004 */ /*02f0*/ IADD3 R4, R9, R8, R4 ; /* 0x0000000809047210 */ /* 0x002fc80007ffe004 */ /*0300*/ IADD3 R4, R11, R10, R4 ; /* 0x0000000a0b047210 */ /* 0x000fc80007ffe004 */ /*0310*/ IADD3 R4, R13, R12, R4 ; /* 0x0000000c0d047210 */ /* 0x004fc80007ffe004 */ /*0320*/ IADD3 R4, R15, R14, R4 ; /* 0x0000000e0f047210 */ /* 0x000fc80007ffe004 */ /*0330*/ IADD3 R4, R17, R16, R4 ; /* 0x0000001011047210 */ /* 0x008fc80007ffe004 */ /*0340*/ IADD3 R0, R19, R18, R4 ; /* 0x0000001213007210 */ /* 0x000fe20007ffe004 */ /*0350*/ @P1 BRA 0x250 ; /* 0xfffffef000001947 */ /* 0x000fea000383ffff */ /*0360*/ ISETP.GT.AND P1, PT, R3, 0x4, PT ; /* 0x000000040300780c */ /* 0x000fda0003f24270 */ /*0370*/ @!P1 BRA 0x420 ; /* 0x000000a000009947 */ /* 0x000fea0003800000 */ /*0380*/ LDS.128 R8, [UR5] ; /* 0x00000005ff087984 */ /* 0x000e220008000c00 */ /*0390*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe20003f0e170 */ /*03a0*/ UIADD3 UR4, UR4, 0x8, URZ ; /* 0x0000000804047890 */ /* 0x000fe2000fffe03f */ /*03b0*/ IADD3 R3, R3, -0x8, RZ ; /* 0xfffffff803037810 */ /* 0x000fe20007ffe0ff */ /*03c0*/ LDS.128 R4, [UR5+0x10] ; /* 0x00001005ff047984 */ /* 0x000e620008000c00 */ /*03d0*/ UIADD3 UR5, UR5, 0x20, URZ ; /* 0x0000002005057890 */ /* 0x000fe2000fffe03f */ /*03e0*/ IADD3 R8, R9, R8, R0 ; /* 0x0000000809087210 */ /* 0x001fc80007ffe000 */ /*03f0*/ IADD3 R8, R11, R10, R8 ; /* 0x0000000a0b087210 */ /* 0x000fc80007ffe008 */ /*0400*/ IADD3 R4, R5, R4, R8 ; /* 0x0000000405047210 */ /* 0x002fc80007ffe008 */ /*0410*/ IADD3 R0, R7, R6, R4 ; /* 0x0000000607007210 */ /* 0x000fe40007ffe004 */ /*0420*/ ISETP.NE.OR P0, PT, R3, RZ, P0 ; /* 0x000000ff0300720c */ /* 0x000fda0000705670 */ /*0430*/ @!P0 BRA 0x4c0 ; /* 0x0000008000008947 */ /* 0x000fea0003800000 */ /*0440*/ LDS.128 R4, [UR5] ; /* 0x00000005ff047984 */ /* 0x000e220008000c00 */ /*0450*/ IADD3 R3, R3, -0x4, RZ ; /* 0xfffffffc03037810 */ /* 0x000fe20007ffe0ff */ /*0460*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*0470*/ UIADD3 UR5, UR5, 0x10, URZ ; /* 0x0000001005057890 */ /* 0x000fe2000fffe03f */ /*0480*/ ISETP.NE.AND P0, PT, R3, RZ, PT ; /* 0x000000ff0300720c */ /* 0x000fe40003f05270 */ /*0490*/ IADD3 R0, R5, R4, R0 ; /* 0x0000000405007210 */ /* 0x001fc80007ffe000 */ /*04a0*/ IADD3 R0, R7, R6, R0 ; /* 0x0000000607007210 */ /* 0x000fce0007ffe000 */ /*04b0*/ @P0 BRA 0x440 ; /* 0xffffff8000000947 */ /* 0x000fea000383ffff */ /*04c0*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fda0003f05270 */ /*04d0*/ @!P0 BRA 0x550 ; /* 0x0000007000008947 */ /* 0x000fea0003800000 */ /*04e0*/ USHF.L.U32 UR4, UR4, 0x2, URZ ; /* 0x0000000204047899 */ /* 0x000fd2000800063f */ /*04f0*/ LDS R3, [UR4] ; /* 0x00000004ff037984 */ /* 0x000e220008000800 */ /*0500*/ IADD3 R2, R2, -0x1, RZ ; /* 0xffffffff02027810 */ /* 0x000fe20007ffe0ff */ /*0510*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fc6000fffe03f */ /*0520*/ ISETP.NE.AND P0, PT, R2, RZ, PT ; /* 0x000000ff0200720c */ /* 0x000fe20003f05270 */ /*0530*/ IMAD.IADD R0, R3, 0x1, R0 ; /* 0x0000000103007824 */ /* 0x001fd800078e0200 */ /*0540*/ @P0 BRA 0x4f0 ; /* 0xffffffa000000947 */ /* 0x000fea000383ffff */ /*0550*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0560*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff027624 */ /* 0x000fe400078e00ff */ /*0570*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff037624 */ /* 0x000fca00078e00ff */ /*0580*/ RED.E.ADD.STRONG.GPU [R2.64], R0 ; /* 0x000000000200798e */ /* 0x000fe2000c10e186 */ /*0590*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*05a0*/ BRA 0x5a0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*05b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0600*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0610*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0620*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0630*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0640*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0650*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0660*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0670*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z12sumReductionPiS_ .globl _Z12sumReductionPiS_ .p2align 8 .type _Z12sumReductionPiS_,@function _Z12sumReductionPiS_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x1c s_load_b64 s[4:5], s[0:1], 0x0 s_mov_b32 s3, exec_lo s_waitcnt lgkmcnt(0) s_and_b32 s2, s2, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1] v_ashrrev_i32_e32 v2, 31, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 2, v[1:2] v_add_co_u32 v2, vcc_lo, s4, v2 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo global_load_b32 v2, v[2:3], off v_lshlrev_b32_e32 v3, 2, v0 s_waitcnt vmcnt(0) ds_store_b32 v3, v2 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv v_cmpx_eq_u32_e32 0, v0 s_cbranch_execz .LBB0_9 v_cmp_gt_i32_e32 vcc_lo, 10, v1 s_cmp_lg_u32 s2, 0 v_mov_b32_e32 v0, 0 s_cselect_b32 s3, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s4, s3, vcc_lo s_and_saveexec_b32 s3, s4 s_cbranch_execz .LBB0_5 v_mov_b32_e32 v0, 0 s_mov_b32 s4, 1 s_mov_b32 s6, 0 s_mov_b32 s5, 0 .LBB0_3: v_dual_mov_b32 v2, s6 :: v_dual_add_nc_u32 v3, s4, v1 s_cmp_ge_u32 s4, s2 s_cselect_b32 s7, -1, 0 ds_load_b32 v2, v2 v_cmp_lt_i32_e32 vcc_lo, 9, v3 s_add_i32 s4, s4, 1 s_add_i32 s6, s6, 4 s_or_b32 s7, s7, vcc_lo s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s7, exec_lo, s7 s_or_b32 s5, s7, s5 s_waitcnt lgkmcnt(0) v_add_nc_u32_e32 v0, v2, v0 s_and_not1_b32 exec_lo, exec_lo, s5 s_cbranch_execnz .LBB0_3 s_or_b32 exec_lo, exec_lo, s5 .LBB0_5: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_or_b32 exec_lo, exec_lo, s3 s_mov_b32 s3, exec_lo s_mov_b32 s2, 0 .LBB0_6: s_ctz_i32_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_readlane_b32 s5, v0, s4 s_lshl_b32 s4, 1, s4 s_and_not1_b32 s3, s3, s4 s_delay_alu instid0(VALU_DEP_1) s_add_i32 s2, s2, s5 s_cmp_lg_u32 s3, 0 s_cbranch_scc1 .LBB0_6 v_mbcnt_lo_u32_b32 v0, exec_lo, 0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v0 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB0_9 s_load_b64 s[0:1], s[0:1], 0x8 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 s_waitcnt lgkmcnt(0) global_atomic_add_u32 v0, v1, s[0:1] .LBB0_9: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z12sumReductionPiS_ .amdhsa_group_segment_fixed_size 16 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 272 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 4 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z12sumReductionPiS_, .Lfunc_end0-_Z12sumReductionPiS_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: hidden_block_count_x - .offset: 20 .size: 4 .value_kind: hidden_block_count_y - .offset: 24 .size: 4 .value_kind: hidden_block_count_z - .offset: 28 .size: 2 .value_kind: hidden_group_size_x - .offset: 30 .size: 2 .value_kind: hidden_group_size_y - .offset: 32 .size: 2 .value_kind: hidden_group_size_z - .offset: 34 .size: 2 .value_kind: hidden_remainder_x - .offset: 36 .size: 2 .value_kind: hidden_remainder_y - .offset: 38 .size: 2 .value_kind: hidden_remainder_z - .offset: 56 .size: 8 .value_kind: hidden_global_offset_x - .offset: 64 .size: 8 .value_kind: hidden_global_offset_y - .offset: 72 .size: 8 .value_kind: hidden_global_offset_z - .offset: 80 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 16 .kernarg_segment_align: 8 .kernarg_segment_size: 272 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z12sumReductionPiS_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z12sumReductionPiS_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 4 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_0012e436_00000000-6_reduction.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z34__device_stub__Z12sumReductionPiS_PiS_ .type _Z34__device_stub__Z12sumReductionPiS_PiS_, @function _Z34__device_stub__Z12sumReductionPiS_PiS_: .LFB2082: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movq %rsi, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 104(%rsp), %rax subq %fs:40, %rax jne .L8 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z12sumReductionPiS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z34__device_stub__Z12sumReductionPiS_PiS_, .-_Z34__device_stub__Z12sumReductionPiS_PiS_ .globl _Z12sumReductionPiS_ .type _Z12sumReductionPiS_, @function _Z12sumReductionPiS_: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z34__device_stub__Z12sumReductionPiS_PiS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z12sumReductionPiS_, .-_Z12sumReductionPiS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax movl $1, %eax .L12: movl %eax, 44(%rsp,%rax,4) addq $1, %rax cmpq $11, %rax jne .L12 leaq 8(%rsp), %rdi movl $40, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT leaq 48(%rsp), %rsi movl $1, %ecx movl $40, %edx movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $4, %edx movl $0, %esi movq 16(%rsp), %rdi call cudaMemset@PLT movl $4, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $3, 24(%rsp) movl $1, 28(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L17 .L13: leaq 36(%rsp), %rdi movl $2, %ecx movl $4, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT movl 36(%rsp), %edx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 88(%rsp), %rax subq %fs:40, %rax jne .L18 movl $0, %eax addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L17: .cfi_restore_state movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z34__device_stub__Z12sumReductionPiS_PiS_ jmp .L13 .L18: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC1: .string "_Z12sumReductionPiS_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC1(%rip), %rdx movq %rdx, %rcx leaq _Z12sumReductionPiS_(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "reduction.hip" .globl _Z27__device_stub__sumReductionPiS_ # -- Begin function _Z27__device_stub__sumReductionPiS_ .p2align 4, 0x90 .type _Z27__device_stub__sumReductionPiS_,@function _Z27__device_stub__sumReductionPiS_: # @_Z27__device_stub__sumReductionPiS_ .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movq %rsi, 48(%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 48(%rsp), %rax movq %rax, 72(%rsp) leaq 32(%rsp), %rdi leaq 16(%rsp), %rsi leaq 8(%rsp), %rdx movq %rsp, %rcx callq __hipPopCallConfiguration movq 32(%rsp), %rsi movl 40(%rsp), %edx movq 16(%rsp), %rcx movl 24(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z12sumReductionPiS_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z27__device_stub__sumReductionPiS_, .Lfunc_end0-_Z27__device_stub__sumReductionPiS_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: subq $136, %rsp .cfi_def_cfa_offset 144 xorl %eax, %eax .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 leaq 1(%rax), %rcx movl %ecx, 96(%rsp,%rax,4) movq %rcx, %rax cmpq $10, %rcx jne .LBB1_1 # %bb.2: leaq 8(%rsp), %rdi movl $40, %esi callq hipMalloc movq %rsp, %rdi movl $4, %esi callq hipMalloc movq 8(%rsp), %rdi leaq 96(%rsp), %rsi movl $40, %edx movl $1, %ecx callq hipMemcpy movq (%rsp), %rdi movl $4, %edx xorl %esi, %esi callq hipMemset movabsq $4294967299, %rdi # imm = 0x100000003 leaq 1(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_4 # %bb.3: movq 8(%rsp), %rax movq (%rsp), %rcx movq %rax, 88(%rsp) movq %rcx, 80(%rsp) leaq 88(%rsp), %rax movq %rax, 16(%rsp) leaq 80(%rsp), %rax movq %rax, 24(%rsp) leaq 64(%rsp), %rdi leaq 48(%rsp), %rsi leaq 40(%rsp), %rdx leaq 32(%rsp), %rcx callq __hipPopCallConfiguration movq 64(%rsp), %rsi movl 72(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z12sumReductionPiS_, %edi pushq 32(%rsp) .cfi_adjust_cfa_offset 8 pushq 48(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_4: movq (%rsp), %rsi leaq 16(%rsp), %rdi movl $4, %edx movl $2, %ecx callq hipMemcpy movl 16(%rsp), %esi movl $.L.str, %edi xorl %eax, %eax callq printf movq (%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree xorl %eax, %eax addq $136, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z12sumReductionPiS_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type _Z12sumReductionPiS_,@object # @_Z12sumReductionPiS_ .section .rodata,"a",@progbits .globl _Z12sumReductionPiS_ .p2align 3, 0x0 _Z12sumReductionPiS_: .quad _Z27__device_stub__sumReductionPiS_ .size _Z12sumReductionPiS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d\n" .size .L.str, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z12sumReductionPiS_" .size .L__unnamed_1, 21 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z27__device_stub__sumReductionPiS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z12sumReductionPiS_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <stdint.h> #include <cuda.h> #include <cuda_runtime.h> #define PAGESIZE 32 #define PHYSICAL_MEM_SIZE 32768 #define STORAGE_SIZE 131072 #define DATAFILE "./data.bin" #define OUTFILE "./snapshot.bin" typedef unsigned char uchar; typedef uint32_t u32; int load_bFile(char* filename, uchar* input, int ssz) { int sz=0; FILE *myfile; myfile = fopen(filename,"rb"); while(1==fread(input+sz*sizeof(uchar),sizeof(uchar),1,myfile)) { sz++; } fclose(myfile); return sz; } void write_bFile(char* out , uchar* results , int input_size) { FILE *myfile; int i; myfile = fopen(out,"wb"); for(i = 0 ; i < input_size ; i++) { fputc(results[i],myfile); } fclose(myfile); } __device__ __managed__ int PAGE_ENTRIES = 0; __device__ __managed__ int PAGEFAULT = 0; __device__ __managed__ uchar storage[STORAGE_SIZE]; __device__ __managed__ uchar results[STORAGE_SIZE]; __device__ __managed__ uchar input[STORAGE_SIZE]; __device__ __managed__ int pt_entries = PHYSICAL_MEM_SIZE/PAGESIZE; extern __shared__ u32 pt[]; __device__ void init_pageTable(int pt_entries) { int i; for( i = 0; i < pt_entries ; i++) { pt[i]=5555; //i is frame number, pt[i] is which page in this frame pt[i+pt_entries]='i'; // valid bit pt[i+pt_entries*2]=0; //LRU counter } } __device__ void swap_block(uchar *phy, uchar *log, int are,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = are * PAGESIZE ; i < PAGESIZE ; k++ , i++) { phy[k]=log[frame*PAGESIZE+i]; log[frame*PAGESIZE+i]='n'; } } __device__ void swap_out(uchar *phy, uchar *log, int victim,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = victim * PAGESIZE ; i < PAGESIZE ; k++ , i++) { log[frame*PAGESIZE+i]=phy[k]; phy[k]='n'; } } __device__ u32 paging(uchar *buffer, u32 frame_num, u32 offset) { int flag = 0; int ad = 0; int i; for(i=0 ; i < pt_entries ; i++) { if(pt[i]==frame_num) //Needy page is in physical memory { flag=1; ad=i; break; } else if(pt[i+pt_entries]=='i') //This page is free for swapping in the page we need. { PAGEFAULT++; flag=2; ad=i; break; } } if(flag==1) { pt[ad+2*pt_entries]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else if(flag==2) { pt[ad+pt_entries]='v'; //swap in the page we need (in storage) and update page table pt[ad]=frame_num; swap_block(buffer,storage,ad,frame_num); pt[ad+pt_entries*2]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else { int min=pt[pt_entries-1+pt_entries*2]; //set the last LRU counter as a start point int victim=0; for(i=pt_entries-1;i>=0;i--) //Finding the LRU page from bottom to up according to LRU counter value. { if(pt[i+2*pt_entries]<=min) { min=pt[i+2*pt_entries]; victim=i; } } swap_out(buffer,storage,victim,pt[victim]); pt[victim+pt_entries]='i'; //set bit to invalid ad=paging(buffer,frame_num,offset); } return ad; } __device__ uchar Gread(uchar *buffer, u32 addr) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); return buffer[addr]; } __device__ void Gwrite(uchar *buffer, u32 addr, uchar value) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); buffer[addr] = value; } __device__ void snapshot(uchar *results, uchar* buffer, int offset, int input_size) { for(int i = 0 ; i < input_size ; i++) results[i] = Gread(buffer, i+offset); } __global__ void mykernel(int input_size) { __shared__ uchar data[PHYSICAL_MEM_SIZE]; init_pageTable(pt_entries); //####Gwrite/Gread code section start#### for(int i = 0; i < input_size ; i++) Gwrite(data, i , input[i]); for(int i = input_size -1 ; i >= input_size - 10 ; i--) int value = Gread(data,i); snapshot(results, data,0, input_size); //####Gwrite/Gread code section end#### printf("pagefault times = %d\n", PAGEFAULT); } int main() { int input_size = load_bFile(DATAFILE, input, STORAGE_SIZE); cudaSetDevice(2); mykernel<<<1, 1, 16384>>>(input_size); cudaDeviceSynchronize(); cudaDeviceReset(); write_bFile(OUTFILE, results, input_size); return 0; }
.file "tmpxft_0011e06d_00000000-6_main.cudafe1.cpp" .text #APP #NO_APP .type _ZL20__nv_init_managed_rtv, @function _ZL20__nv_init_managed_rtv: .LFB1: .cfi_startproc movzbl _ZL22__nv_inited_managed_rt(%rip), %eax testb %al, %al je .L7 movb %al, _ZL22__nv_inited_managed_rt(%rip) ret .L7: subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL32__nv_fatbinhandle_for_managed_rt(%rip), %rdi call __cudaInitModule@PLT movb %al, _ZL22__nv_inited_managed_rt(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE1: .size _ZL20__nv_init_managed_rtv, .-_ZL20__nv_init_managed_rtv .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2069: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2069: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "rb" .text .globl _Z10load_bFilePcPhi .type _Z10load_bFilePcPhi, @function _Z10load_bFilePcPhi: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $8, %rsp .cfi_def_cfa_offset 48 movq %rsi, %r12 leaq .LC0(%rip), %rsi call fopen@PLT movq %rax, %rbp movl $0, %ebx .L11: leaq (%r12,%rbx), %rdi movq %rbp, %r8 movl $1, %ecx movl $1, %edx movq $-1, %rsi call __fread_chk@PLT movq %rbx, %r13 addq $1, %rbx cmpq $1, %rax je .L11 movq %rbp, %rdi call fclose@PLT movl %r13d, %eax addq $8, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2057: .size _Z10load_bFilePcPhi, .-_Z10load_bFilePcPhi .section .rodata.str1.1 .LC1: .string "wb" .text .globl _Z11write_bFilePcPhi .type _Z11write_bFilePcPhi, @function _Z11write_bFilePcPhi: .LFB2058: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $8, %rsp .cfi_def_cfa_offset 48 movq %rsi, %rbp movl %edx, %r13d leaq .LC1(%rip), %rsi call fopen@PLT movq %rax, %r12 testl %r13d, %r13d jle .L15 movq %rbp, %rbx movslq %r13d, %r13 addq %r13, %rbp .L16: movzbl (%rbx), %edi movq %r12, %rsi call fputc@PLT addq $1, %rbx cmpq %rbp, %rbx jne .L16 .L15: movq %r12, %rdi call fclose@PLT addq $8, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z11write_bFilePcPhi, .-_Z11write_bFilePcPhi .globl _Z14init_pageTablei .type _Z14init_pageTablei, @function _Z14init_pageTablei: .LFB2059: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2059: .size _Z14init_pageTablei, .-_Z14init_pageTablei .globl _Z10swap_blockPhS_ii .type _Z10swap_blockPhS_ii, @function _Z10swap_blockPhS_ii: .LFB2060: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2060: .size _Z10swap_blockPhS_ii, .-_Z10swap_blockPhS_ii .globl _Z8swap_outPhS_ii .type _Z8swap_outPhS_ii, @function _Z8swap_outPhS_ii: .LFB2061: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2061: .size _Z8swap_outPhS_ii, .-_Z8swap_outPhS_ii .globl _Z6pagingPhjj .type _Z6pagingPhjj, @function _Z6pagingPhjj: .LFB2062: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2062: .size _Z6pagingPhjj, .-_Z6pagingPhjj .globl _Z5GreadPhj .type _Z5GreadPhj, @function _Z5GreadPhj: .LFB2063: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2063: .size _Z5GreadPhj, .-_Z5GreadPhj .globl _Z6GwritePhjh .type _Z6GwritePhjh, @function _Z6GwritePhjh: .LFB2064: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2064: .size _Z6GwritePhjh, .-_Z6GwritePhjh .globl _Z8snapshotPhS_ii .type _Z8snapshotPhS_ii, @function _Z8snapshotPhS_ii: .LFB2065: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2065: .size _Z8snapshotPhS_ii, .-_Z8snapshotPhS_ii .globl _Z26__device_stub__Z8mykernelii .type _Z26__device_stub__Z8mykernelii, @function _Z26__device_stub__Z8mykernelii: .LFB2091: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movl %edi, 12(%rsp) movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax leaq 12(%rsp), %rax movq %rax, 80(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L37 .L33: movq 88(%rsp), %rax subq %fs:40, %rax jne .L38 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L37: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 120 pushq 24(%rsp) .cfi_def_cfa_offset 128 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z8mykerneli(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L33 .L38: call __stack_chk_fail@PLT .cfi_endproc .LFE2091: .size _Z26__device_stub__Z8mykernelii, .-_Z26__device_stub__Z8mykernelii .globl _Z8mykerneli .type _Z8mykerneli, @function _Z8mykerneli: .LFB2092: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z26__device_stub__Z8mykernelii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2092: .size _Z8mykerneli, .-_Z8mykerneli .section .rodata.str1.1 .LC2: .string "./data.bin" .LC3: .string "./snapshot.bin" .text .globl main .type main, @function main: .LFB2066: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $32, %rsp .cfi_def_cfa_offset 48 cmpb $0, _ZL22__nv_inited_managed_rt(%rip) je .L46 .L42: movl $131072, %edx movq _ZL5input(%rip), %rsi leaq .LC2(%rip), %rdi call _Z10load_bFilePcPhi movl %eax, %ebx movl $2, %edi call cudaSetDevice@PLT movl $1, 20(%rsp) movl $1, 24(%rsp) movl $1, 8(%rsp) movl $1, 12(%rsp) movl $0, %r9d movl $16384, %r8d movq 20(%rsp), %rdx movl $1, %ecx movq 8(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L47 .L43: call cudaDeviceSynchronize@PLT call cudaDeviceReset@PLT cmpb $0, _ZL22__nv_inited_managed_rt(%rip) je .L48 .L44: movl %ebx, %edx movq _ZL7results(%rip), %rsi leaq .LC3(%rip), %rdi call _Z11write_bFilePcPhi movl $0, %eax addq $32, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L46: .cfi_restore_state call _ZL20__nv_init_managed_rtv jmp .L42 .L47: movl %ebx, %edi call _Z26__device_stub__Z8mykernelii jmp .L43 .L48: call _ZL20__nv_init_managed_rtv jmp .L44 .cfi_endproc .LFE2066: .size main, .-main .section .rodata.str1.1 .LC4: .string "_Z8mykerneli" .LC5: .string "PAGE_ENTRIES" .LC6: .string "PAGEFAULT" .LC7: .string "storage" .LC8: .string "results" .LC9: .string "input" .LC10: .string "pt_entries" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2094: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) movq %rax, _ZL32__nv_fatbinhandle_for_managed_rt(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC4(%rip), %rdx movq %rdx, %rcx leaq _Z8mykerneli(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC5(%rip), %rdx movq %rdx, %rcx leaq _ZL12PAGE_ENTRIES(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC6(%rip), %rdx movq %rdx, %rcx leaq _ZL9PAGEFAULT(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $131072, %r9d movl $0, %r8d leaq .LC7(%rip), %rdx movq %rdx, %rcx leaq _ZL7storage(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $131072, %r9d movl $0, %r8d leaq .LC8(%rip), %rdx movq %rdx, %rcx leaq _ZL7results(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $131072, %r9d movl $0, %r8d leaq .LC9(%rip), %rdx movq %rdx, %rcx leaq _ZL5input(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC10(%rip), %rdx movq %rdx, %rcx leaq _ZL10pt_entries(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2094: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section __nv_managed_data__,"aw" .align 8 .type _ZL10pt_entries, @object .size _ZL10pt_entries, 8 _ZL10pt_entries: .zero 8 .align 8 .type _ZL5input, @object .size _ZL5input, 8 _ZL5input: .zero 8 .align 8 .type _ZL7results, @object .size _ZL7results, 8 _ZL7results: .zero 8 .align 8 .type _ZL7storage, @object .size _ZL7storage, 8 _ZL7storage: .zero 8 .align 8 .type _ZL9PAGEFAULT, @object .size _ZL9PAGEFAULT, 8 _ZL9PAGEFAULT: .zero 8 .align 8 .type _ZL12PAGE_ENTRIES, @object .size _ZL12PAGE_ENTRIES, 8 _ZL12PAGE_ENTRIES: .zero 8 .local _ZL32__nv_fatbinhandle_for_managed_rt .comm _ZL32__nv_fatbinhandle_for_managed_rt,8,8 .local _ZL22__nv_inited_managed_rt .comm _ZL22__nv_inited_managed_rt,1,1 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <stdint.h> #include <cuda.h> #include <cuda_runtime.h> #define PAGESIZE 32 #define PHYSICAL_MEM_SIZE 32768 #define STORAGE_SIZE 131072 #define DATAFILE "./data.bin" #define OUTFILE "./snapshot.bin" typedef unsigned char uchar; typedef uint32_t u32; int load_bFile(char* filename, uchar* input, int ssz) { int sz=0; FILE *myfile; myfile = fopen(filename,"rb"); while(1==fread(input+sz*sizeof(uchar),sizeof(uchar),1,myfile)) { sz++; } fclose(myfile); return sz; } void write_bFile(char* out , uchar* results , int input_size) { FILE *myfile; int i; myfile = fopen(out,"wb"); for(i = 0 ; i < input_size ; i++) { fputc(results[i],myfile); } fclose(myfile); } __device__ __managed__ int PAGE_ENTRIES = 0; __device__ __managed__ int PAGEFAULT = 0; __device__ __managed__ uchar storage[STORAGE_SIZE]; __device__ __managed__ uchar results[STORAGE_SIZE]; __device__ __managed__ uchar input[STORAGE_SIZE]; __device__ __managed__ int pt_entries = PHYSICAL_MEM_SIZE/PAGESIZE; extern __shared__ u32 pt[]; __device__ void init_pageTable(int pt_entries) { int i; for( i = 0; i < pt_entries ; i++) { pt[i]=5555; //i is frame number, pt[i] is which page in this frame pt[i+pt_entries]='i'; // valid bit pt[i+pt_entries*2]=0; //LRU counter } } __device__ void swap_block(uchar *phy, uchar *log, int are,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = are * PAGESIZE ; i < PAGESIZE ; k++ , i++) { phy[k]=log[frame*PAGESIZE+i]; log[frame*PAGESIZE+i]='n'; } } __device__ void swap_out(uchar *phy, uchar *log, int victim,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = victim * PAGESIZE ; i < PAGESIZE ; k++ , i++) { log[frame*PAGESIZE+i]=phy[k]; phy[k]='n'; } } __device__ u32 paging(uchar *buffer, u32 frame_num, u32 offset) { int flag = 0; int ad = 0; int i; for(i=0 ; i < pt_entries ; i++) { if(pt[i]==frame_num) //Needy page is in physical memory { flag=1; ad=i; break; } else if(pt[i+pt_entries]=='i') //This page is free for swapping in the page we need. { PAGEFAULT++; flag=2; ad=i; break; } } if(flag==1) { pt[ad+2*pt_entries]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else if(flag==2) { pt[ad+pt_entries]='v'; //swap in the page we need (in storage) and update page table pt[ad]=frame_num; swap_block(buffer,storage,ad,frame_num); pt[ad+pt_entries*2]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else { int min=pt[pt_entries-1+pt_entries*2]; //set the last LRU counter as a start point int victim=0; for(i=pt_entries-1;i>=0;i--) //Finding the LRU page from bottom to up according to LRU counter value. { if(pt[i+2*pt_entries]<=min) { min=pt[i+2*pt_entries]; victim=i; } } swap_out(buffer,storage,victim,pt[victim]); pt[victim+pt_entries]='i'; //set bit to invalid ad=paging(buffer,frame_num,offset); } return ad; } __device__ uchar Gread(uchar *buffer, u32 addr) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); return buffer[addr]; } __device__ void Gwrite(uchar *buffer, u32 addr, uchar value) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); buffer[addr] = value; } __device__ void snapshot(uchar *results, uchar* buffer, int offset, int input_size) { for(int i = 0 ; i < input_size ; i++) results[i] = Gread(buffer, i+offset); } __global__ void mykernel(int input_size) { __shared__ uchar data[PHYSICAL_MEM_SIZE]; init_pageTable(pt_entries); //####Gwrite/Gread code section start#### for(int i = 0; i < input_size ; i++) Gwrite(data, i , input[i]); for(int i = input_size -1 ; i >= input_size - 10 ; i--) int value = Gread(data,i); snapshot(results, data,0, input_size); //####Gwrite/Gread code section end#### printf("pagefault times = %d\n", PAGEFAULT); } int main() { int input_size = load_bFile(DATAFILE, input, STORAGE_SIZE); cudaSetDevice(2); mykernel<<<1, 1, 16384>>>(input_size); cudaDeviceSynchronize(); cudaDeviceReset(); write_bFile(OUTFILE, results, input_size); return 0; }
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <stdint.h> #include <hip/hip_runtime.h> #define PAGESIZE 32 #define PHYSICAL_MEM_SIZE 32768 #define STORAGE_SIZE 131072 #define DATAFILE "./data.bin" #define OUTFILE "./snapshot.bin" typedef unsigned char uchar; typedef uint32_t u32; int load_bFile(char* filename, uchar* input, int ssz) { int sz=0; FILE *myfile; myfile = fopen(filename,"rb"); while(1==fread(input+sz*sizeof(uchar),sizeof(uchar),1,myfile)) { sz++; } fclose(myfile); return sz; } void write_bFile(char* out , uchar* results , int input_size) { FILE *myfile; int i; myfile = fopen(out,"wb"); for(i = 0 ; i < input_size ; i++) { fputc(results[i],myfile); } fclose(myfile); } __device__ __managed__ int PAGE_ENTRIES = 0; __device__ __managed__ int PAGEFAULT = 0; __device__ __managed__ uchar storage[STORAGE_SIZE]; __device__ __managed__ uchar results[STORAGE_SIZE]; __device__ __managed__ uchar input[STORAGE_SIZE]; __device__ __managed__ int pt_entries = PHYSICAL_MEM_SIZE/PAGESIZE; extern __shared__ u32 pt[]; __device__ void init_pageTable(int pt_entries) { int i; for( i = 0; i < pt_entries ; i++) { pt[i]=5555; //i is frame number, pt[i] is which page in this frame pt[i+pt_entries]='i'; // valid bit pt[i+pt_entries*2]=0; //LRU counter } } __device__ void swap_block(uchar *phy, uchar *log, int are,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = are * PAGESIZE ; i < PAGESIZE ; k++ , i++) { phy[k]=log[frame*PAGESIZE+i]; log[frame*PAGESIZE+i]='n'; } } __device__ void swap_out(uchar *phy, uchar *log, int victim,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = victim * PAGESIZE ; i < PAGESIZE ; k++ , i++) { log[frame*PAGESIZE+i]=phy[k]; phy[k]='n'; } } __device__ u32 paging(uchar *buffer, u32 frame_num, u32 offset) { int flag = 0; int ad = 0; int i; for(i=0 ; i < pt_entries ; i++) { if(pt[i]==frame_num) //Needy page is in physical memory { flag=1; ad=i; break; } else if(pt[i+pt_entries]=='i') //This page is free for swapping in the page we need. { PAGEFAULT++; flag=2; ad=i; break; } } if(flag==1) { pt[ad+2*pt_entries]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else if(flag==2) { pt[ad+pt_entries]='v'; //swap in the page we need (in storage) and update page table pt[ad]=frame_num; swap_block(buffer,storage,ad,frame_num); pt[ad+pt_entries*2]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else { int min=pt[pt_entries-1+pt_entries*2]; //set the last LRU counter as a start point int victim=0; for(i=pt_entries-1;i>=0;i--) //Finding the LRU page from bottom to up according to LRU counter value. { if(pt[i+2*pt_entries]<=min) { min=pt[i+2*pt_entries]; victim=i; } } swap_out(buffer,storage,victim,pt[victim]); pt[victim+pt_entries]='i'; //set bit to invalid ad=paging(buffer,frame_num,offset); } return ad; } __device__ uchar Gread(uchar *buffer, u32 addr) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); return buffer[addr]; } __device__ void Gwrite(uchar *buffer, u32 addr, uchar value) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); buffer[addr] = value; } __device__ void snapshot(uchar *results, uchar* buffer, int offset, int input_size) { for(int i = 0 ; i < input_size ; i++) results[i] = Gread(buffer, i+offset); } __global__ void mykernel(int input_size) { __shared__ uchar data[PHYSICAL_MEM_SIZE]; init_pageTable(pt_entries); //####Gwrite/Gread code section start#### for(int i = 0; i < input_size ; i++) Gwrite(data, i , input[i]); for(int i = input_size -1 ; i >= input_size - 10 ; i--) int value = Gread(data,i); snapshot(results, data,0, input_size); //####Gwrite/Gread code section end#### printf("pagefault times = %d\n", PAGEFAULT); } int main() { int input_size = load_bFile(DATAFILE, input, STORAGE_SIZE); hipSetDevice(2); mykernel<<<1, 1, 16384>>>(input_size); hipDeviceSynchronize(); hipDeviceReset(); write_bFile(OUTFILE, results, input_size); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <stdint.h> #include <hip/hip_runtime.h> #define PAGESIZE 32 #define PHYSICAL_MEM_SIZE 32768 #define STORAGE_SIZE 131072 #define DATAFILE "./data.bin" #define OUTFILE "./snapshot.bin" typedef unsigned char uchar; typedef uint32_t u32; int load_bFile(char* filename, uchar* input, int ssz) { int sz=0; FILE *myfile; myfile = fopen(filename,"rb"); while(1==fread(input+sz*sizeof(uchar),sizeof(uchar),1,myfile)) { sz++; } fclose(myfile); return sz; } void write_bFile(char* out , uchar* results , int input_size) { FILE *myfile; int i; myfile = fopen(out,"wb"); for(i = 0 ; i < input_size ; i++) { fputc(results[i],myfile); } fclose(myfile); } __device__ __managed__ int PAGE_ENTRIES = 0; __device__ __managed__ int PAGEFAULT = 0; __device__ __managed__ uchar storage[STORAGE_SIZE]; __device__ __managed__ uchar results[STORAGE_SIZE]; __device__ __managed__ uchar input[STORAGE_SIZE]; __device__ __managed__ int pt_entries = PHYSICAL_MEM_SIZE/PAGESIZE; extern __shared__ u32 pt[]; __device__ void init_pageTable(int pt_entries) { int i; for( i = 0; i < pt_entries ; i++) { pt[i]=5555; //i is frame number, pt[i] is which page in this frame pt[i+pt_entries]='i'; // valid bit pt[i+pt_entries*2]=0; //LRU counter } } __device__ void swap_block(uchar *phy, uchar *log, int are,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = are * PAGESIZE ; i < PAGESIZE ; k++ , i++) { phy[k]=log[frame*PAGESIZE+i]; log[frame*PAGESIZE+i]='n'; } } __device__ void swap_out(uchar *phy, uchar *log, int victim,int frame) //swap needy page in storage and swap the victim back when pagefault occurs. { int i,k; for(i = 0,k = victim * PAGESIZE ; i < PAGESIZE ; k++ , i++) { log[frame*PAGESIZE+i]=phy[k]; phy[k]='n'; } } __device__ u32 paging(uchar *buffer, u32 frame_num, u32 offset) { int flag = 0; int ad = 0; int i; for(i=0 ; i < pt_entries ; i++) { if(pt[i]==frame_num) //Needy page is in physical memory { flag=1; ad=i; break; } else if(pt[i+pt_entries]=='i') //This page is free for swapping in the page we need. { PAGEFAULT++; flag=2; ad=i; break; } } if(flag==1) { pt[ad+2*pt_entries]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else if(flag==2) { pt[ad+pt_entries]='v'; //swap in the page we need (in storage) and update page table pt[ad]=frame_num; swap_block(buffer,storage,ad,frame_num); pt[ad+pt_entries*2]++; //LRU counter +1, return the address in physical memory. ad=(ad*PAGESIZE)+offset; } else { int min=pt[pt_entries-1+pt_entries*2]; //set the last LRU counter as a start point int victim=0; for(i=pt_entries-1;i>=0;i--) //Finding the LRU page from bottom to up according to LRU counter value. { if(pt[i+2*pt_entries]<=min) { min=pt[i+2*pt_entries]; victim=i; } } swap_out(buffer,storage,victim,pt[victim]); pt[victim+pt_entries]='i'; //set bit to invalid ad=paging(buffer,frame_num,offset); } return ad; } __device__ uchar Gread(uchar *buffer, u32 addr) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); return buffer[addr]; } __device__ void Gwrite(uchar *buffer, u32 addr, uchar value) { u32 frame_num = addr/PAGESIZE; u32 offset = addr%PAGESIZE; addr = paging(buffer, frame_num, offset); buffer[addr] = value; } __device__ void snapshot(uchar *results, uchar* buffer, int offset, int input_size) { for(int i = 0 ; i < input_size ; i++) results[i] = Gread(buffer, i+offset); } __global__ void mykernel(int input_size) { __shared__ uchar data[PHYSICAL_MEM_SIZE]; init_pageTable(pt_entries); //####Gwrite/Gread code section start#### for(int i = 0; i < input_size ; i++) Gwrite(data, i , input[i]); for(int i = input_size -1 ; i >= input_size - 10 ; i--) int value = Gread(data,i); snapshot(results, data,0, input_size); //####Gwrite/Gread code section end#### printf("pagefault times = %d\n", PAGEFAULT); } int main() { int input_size = load_bFile(DATAFILE, input, STORAGE_SIZE); hipSetDevice(2); mykernel<<<1, 1, 16384>>>(input_size); hipDeviceSynchronize(); hipDeviceReset(); write_bFile(OUTFILE, results, input_size); return 0; }
.text .file "main.hip" .globl _Z10load_bFilePcPhi # -- Begin function _Z10load_bFilePcPhi .p2align 4, 0x90 .type _Z10load_bFilePcPhi,@function _Z10load_bFilePcPhi: # @_Z10load_bFilePcPhi .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %rbp, -16 movq %rsi, %rbx movl $.L.str, %esi callq fopen movq %rax, %r14 movl $-1, %ebp .p2align 4, 0x90 .LBB0_1: # =>This Inner Loop Header: Depth=1 movl $1, %esi movl $1, %edx movq %rbx, %rdi movq %r14, %rcx callq fread incl %ebp incq %rbx cmpq $1, %rax je .LBB0_1 # %bb.2: movq %r14, %rdi callq fclose movl %ebp, %eax popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z10load_bFilePcPhi, .Lfunc_end0-_Z10load_bFilePcPhi .cfi_endproc # -- End function .globl _Z11write_bFilePcPhi # -- Begin function _Z11write_bFilePcPhi .p2align 4, 0x90 .type _Z11write_bFilePcPhi,@function _Z11write_bFilePcPhi: # @_Z11write_bFilePcPhi .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r12 .cfi_def_cfa_offset 40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset %rbx, -48 .cfi_offset %r12, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %edx, %ebp movq %rsi, %rbx movl $.L.str.1, %esi callq fopen movq %rax, %r14 testl %ebp, %ebp jle .LBB1_3 # %bb.1: # %.lr.ph.preheader movl %ebp, %r15d xorl %r12d, %r12d .p2align 4, 0x90 .LBB1_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 movzbl (%rbx,%r12), %edi movq %r14, %rsi callq fputc incq %r12 cmpq %r12, %r15 jne .LBB1_2 .LBB1_3: # %._crit_edge movq %r14, %rdi popq %rbx .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 jmp fclose # TAILCALL .Lfunc_end1: .size _Z11write_bFilePcPhi, .Lfunc_end1-_Z11write_bFilePcPhi .cfi_endproc # -- End function .globl _Z23__device_stub__mykerneli # -- Begin function _Z23__device_stub__mykerneli .p2align 4, 0x90 .type _Z23__device_stub__mykerneli,@function _Z23__device_stub__mykerneli: # @_Z23__device_stub__mykerneli .cfi_startproc # %bb.0: subq $72, %rsp .cfi_def_cfa_offset 80 movl %edi, 12(%rsp) leaq 12(%rsp), %rax movq %rax, 16(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z8mykerneli, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $88, %rsp .cfi_adjust_cfa_offset -88 retq .Lfunc_end2: .size _Z23__device_stub__mykerneli, .Lfunc_end2-_Z23__device_stub__mykerneli .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r12 .cfi_def_cfa_offset 40 pushq %rbx .cfi_def_cfa_offset 48 subq $80, %rsp .cfi_def_cfa_offset 128 .cfi_offset %rbx, -48 .cfi_offset %r12, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq input(%rip), %rbx movl $.L.str.2, %edi movl $.L.str, %esi callq fopen movq %rax, %r14 movl $-1, %ebp .p2align 4, 0x90 .LBB3_1: # =>This Inner Loop Header: Depth=1 movl $1, %esi movl $1, %edx movq %rbx, %rdi movq %r14, %rcx callq fread incl %ebp incq %rbx cmpq $1, %rax je .LBB3_1 # %bb.2: # %_Z10load_bFilePcPhi.exit movq %r14, %rdi callq fclose movl $2, %edi callq hipSetDevice movabsq $4294967297, %rdi # imm = 0x100000001 movl $16384, %r8d # imm = 0x4000 movl $1, %esi movq %rdi, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_4 # %bb.3: movl %ebp, 12(%rsp) leaq 12(%rsp), %rax movq %rax, 16(%rsp) leaq 64(%rsp), %rdi leaq 48(%rsp), %rsi leaq 40(%rsp), %rdx leaq 32(%rsp), %rcx callq __hipPopCallConfiguration movq 64(%rsp), %rsi movl 72(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z8mykerneli, %edi pushq 32(%rsp) .cfi_adjust_cfa_offset 8 pushq 48(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB3_4: callq hipDeviceSynchronize callq hipDeviceReset movq results(%rip), %r14 movl $.L.str.3, %edi movl $.L.str.1, %esi callq fopen movq %rax, %rbx testl %ebp, %ebp jle .LBB3_7 # %bb.5: # %.lr.ph.preheader.i movl %ebp, %r15d xorl %r12d, %r12d .p2align 4, 0x90 .LBB3_6: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 movzbl (%r14,%r12), %edi movq %rbx, %rsi callq fputc incq %r12 cmpq %r12, %r15 jne .LBB3_6 .LBB3_7: # %_Z11write_bFilePcPhi.exit movq %rbx, %rdi callq fclose xorl %eax, %eax addq $80, %rsp .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size main, .Lfunc_end3-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB4_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB4_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z8mykerneli, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $PAGE_ENTRIES, %esi movl $PAGE_ENTRIES.managed, %edx movl $.L__unnamed_2, %ecx movl $4, %r8d movq %rbx, %rdi movl $4, %r9d callq __hipRegisterManagedVar movl $PAGEFAULT, %esi movl $PAGEFAULT.managed, %edx movl $.L__unnamed_3, %ecx movl $4, %r8d movq %rbx, %rdi movl $4, %r9d callq __hipRegisterManagedVar movl $storage, %esi movl $storage.managed, %edx movl $.L__unnamed_4, %ecx movl $131072, %r8d # imm = 0x20000 movq %rbx, %rdi movl $16, %r9d callq __hipRegisterManagedVar movl $results, %esi movl $results.managed, %edx movl $.L__unnamed_5, %ecx movl $131072, %r8d # imm = 0x20000 movq %rbx, %rdi movl $16, %r9d callq __hipRegisterManagedVar movl $input, %esi movl $input.managed, %edx movl $.L__unnamed_6, %ecx movl $131072, %r8d # imm = 0x20000 movq %rbx, %rdi movl $16, %r9d callq __hipRegisterManagedVar movl $pt_entries, %esi movl $pt_entries.managed, %edx movl $.L__unnamed_7, %ecx movl $4, %r8d movq %rbx, %rdi movl $4, %r9d callq __hipRegisterManagedVar movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end4: .size __hip_module_ctor, .Lfunc_end4-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB5_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB5_2: retq .Lfunc_end5: .size __hip_module_dtor, .Lfunc_end5-__hip_module_dtor .cfi_endproc # -- End function .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "rb" .size .L.str, 3 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "wb" .size .L.str.1, 3 .type PAGE_ENTRIES.managed,@object # @PAGE_ENTRIES.managed .local PAGE_ENTRIES.managed .comm PAGE_ENTRIES.managed,4,4 .type PAGEFAULT.managed,@object # @PAGEFAULT.managed .local PAGEFAULT.managed .comm PAGEFAULT.managed,4,4 .type storage.managed,@object # @storage.managed .local storage.managed .comm storage.managed,131072,16 .type results.managed,@object # @results.managed .local results.managed .comm results.managed,131072,16 .type input.managed,@object # @input.managed .local input.managed .comm input.managed,131072,16 .type pt_entries.managed,@object # @pt_entries.managed .data .p2align 2, 0x0 pt_entries.managed: .long 1024 # 0x400 .size pt_entries.managed, 4 .type _Z8mykerneli,@object # @_Z8mykerneli .section .rodata,"a",@progbits .globl _Z8mykerneli .p2align 3, 0x0 _Z8mykerneli: .quad _Z23__device_stub__mykerneli .size _Z8mykerneli, 8 .type .L.str.2,@object # @.str.2 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.2: .asciz "./data.bin" .size .L.str.2, 11 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "./snapshot.bin" .size .L.str.3, 15 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z8mykerneli" .size .L__unnamed_1, 13 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "PAGE_ENTRIES" .size .L__unnamed_2, 13 .type PAGE_ENTRIES,@object # @PAGE_ENTRIES .local PAGE_ENTRIES .comm PAGE_ENTRIES,8,8 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "PAGEFAULT" .size .L__unnamed_3, 10 .type PAGEFAULT,@object # @PAGEFAULT .local PAGEFAULT .comm PAGEFAULT,8,8 .type .L__unnamed_4,@object # @3 .L__unnamed_4: .asciz "storage" .size .L__unnamed_4, 8 .type storage,@object # @storage .local storage .comm storage,8,8 .type .L__unnamed_5,@object # @4 .L__unnamed_5: .asciz "results" .size .L__unnamed_5, 8 .type results,@object # @results .local results .comm results,8,8 .type .L__unnamed_6,@object # @5 .L__unnamed_6: .asciz "input" .size .L__unnamed_6, 6 .type input,@object # @input .local input .comm input,8,8 .type .L__unnamed_7,@object # @6 .L__unnamed_7: .asciz "pt_entries" .size .L__unnamed_7, 11 .type pt_entries,@object # @pt_entries .local pt_entries .comm pt_entries,8,8 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z23__device_stub__mykerneli .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym PAGE_ENTRIES.managed .addrsig_sym PAGEFAULT.managed .addrsig_sym storage.managed .addrsig_sym results.managed .addrsig_sym input.managed .addrsig_sym pt_entries.managed .addrsig_sym _Z8mykerneli .addrsig_sym PAGE_ENTRIES .addrsig_sym PAGEFAULT .addrsig_sym storage .addrsig_sym results .addrsig_sym input .addrsig_sym pt_entries .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_0011e06d_00000000-6_main.cudafe1.cpp" .text #APP #NO_APP .type _ZL20__nv_init_managed_rtv, @function _ZL20__nv_init_managed_rtv: .LFB1: .cfi_startproc movzbl _ZL22__nv_inited_managed_rt(%rip), %eax testb %al, %al je .L7 movb %al, _ZL22__nv_inited_managed_rt(%rip) ret .L7: subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL32__nv_fatbinhandle_for_managed_rt(%rip), %rdi call __cudaInitModule@PLT movb %al, _ZL22__nv_inited_managed_rt(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE1: .size _ZL20__nv_init_managed_rtv, .-_ZL20__nv_init_managed_rtv .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2069: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2069: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "rb" .text .globl _Z10load_bFilePcPhi .type _Z10load_bFilePcPhi, @function _Z10load_bFilePcPhi: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $8, %rsp .cfi_def_cfa_offset 48 movq %rsi, %r12 leaq .LC0(%rip), %rsi call fopen@PLT movq %rax, %rbp movl $0, %ebx .L11: leaq (%r12,%rbx), %rdi movq %rbp, %r8 movl $1, %ecx movl $1, %edx movq $-1, %rsi call __fread_chk@PLT movq %rbx, %r13 addq $1, %rbx cmpq $1, %rax je .L11 movq %rbp, %rdi call fclose@PLT movl %r13d, %eax addq $8, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2057: .size _Z10load_bFilePcPhi, .-_Z10load_bFilePcPhi .section .rodata.str1.1 .LC1: .string "wb" .text .globl _Z11write_bFilePcPhi .type _Z11write_bFilePcPhi, @function _Z11write_bFilePcPhi: .LFB2058: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $8, %rsp .cfi_def_cfa_offset 48 movq %rsi, %rbp movl %edx, %r13d leaq .LC1(%rip), %rsi call fopen@PLT movq %rax, %r12 testl %r13d, %r13d jle .L15 movq %rbp, %rbx movslq %r13d, %r13 addq %r13, %rbp .L16: movzbl (%rbx), %edi movq %r12, %rsi call fputc@PLT addq $1, %rbx cmpq %rbp, %rbx jne .L16 .L15: movq %r12, %rdi call fclose@PLT addq $8, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z11write_bFilePcPhi, .-_Z11write_bFilePcPhi .globl _Z14init_pageTablei .type _Z14init_pageTablei, @function _Z14init_pageTablei: .LFB2059: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2059: .size _Z14init_pageTablei, .-_Z14init_pageTablei .globl _Z10swap_blockPhS_ii .type _Z10swap_blockPhS_ii, @function _Z10swap_blockPhS_ii: .LFB2060: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2060: .size _Z10swap_blockPhS_ii, .-_Z10swap_blockPhS_ii .globl _Z8swap_outPhS_ii .type _Z8swap_outPhS_ii, @function _Z8swap_outPhS_ii: .LFB2061: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2061: .size _Z8swap_outPhS_ii, .-_Z8swap_outPhS_ii .globl _Z6pagingPhjj .type _Z6pagingPhjj, @function _Z6pagingPhjj: .LFB2062: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2062: .size _Z6pagingPhjj, .-_Z6pagingPhjj .globl _Z5GreadPhj .type _Z5GreadPhj, @function _Z5GreadPhj: .LFB2063: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2063: .size _Z5GreadPhj, .-_Z5GreadPhj .globl _Z6GwritePhjh .type _Z6GwritePhjh, @function _Z6GwritePhjh: .LFB2064: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2064: .size _Z6GwritePhjh, .-_Z6GwritePhjh .globl _Z8snapshotPhS_ii .type _Z8snapshotPhS_ii, @function _Z8snapshotPhS_ii: .LFB2065: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2065: .size _Z8snapshotPhS_ii, .-_Z8snapshotPhS_ii .globl _Z26__device_stub__Z8mykernelii .type _Z26__device_stub__Z8mykernelii, @function _Z26__device_stub__Z8mykernelii: .LFB2091: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movl %edi, 12(%rsp) movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax leaq 12(%rsp), %rax movq %rax, 80(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L37 .L33: movq 88(%rsp), %rax subq %fs:40, %rax jne .L38 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L37: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 120 pushq 24(%rsp) .cfi_def_cfa_offset 128 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z8mykerneli(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L33 .L38: call __stack_chk_fail@PLT .cfi_endproc .LFE2091: .size _Z26__device_stub__Z8mykernelii, .-_Z26__device_stub__Z8mykernelii .globl _Z8mykerneli .type _Z8mykerneli, @function _Z8mykerneli: .LFB2092: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z26__device_stub__Z8mykernelii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2092: .size _Z8mykerneli, .-_Z8mykerneli .section .rodata.str1.1 .LC2: .string "./data.bin" .LC3: .string "./snapshot.bin" .text .globl main .type main, @function main: .LFB2066: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $32, %rsp .cfi_def_cfa_offset 48 cmpb $0, _ZL22__nv_inited_managed_rt(%rip) je .L46 .L42: movl $131072, %edx movq _ZL5input(%rip), %rsi leaq .LC2(%rip), %rdi call _Z10load_bFilePcPhi movl %eax, %ebx movl $2, %edi call cudaSetDevice@PLT movl $1, 20(%rsp) movl $1, 24(%rsp) movl $1, 8(%rsp) movl $1, 12(%rsp) movl $0, %r9d movl $16384, %r8d movq 20(%rsp), %rdx movl $1, %ecx movq 8(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L47 .L43: call cudaDeviceSynchronize@PLT call cudaDeviceReset@PLT cmpb $0, _ZL22__nv_inited_managed_rt(%rip) je .L48 .L44: movl %ebx, %edx movq _ZL7results(%rip), %rsi leaq .LC3(%rip), %rdi call _Z11write_bFilePcPhi movl $0, %eax addq $32, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L46: .cfi_restore_state call _ZL20__nv_init_managed_rtv jmp .L42 .L47: movl %ebx, %edi call _Z26__device_stub__Z8mykernelii jmp .L43 .L48: call _ZL20__nv_init_managed_rtv jmp .L44 .cfi_endproc .LFE2066: .size main, .-main .section .rodata.str1.1 .LC4: .string "_Z8mykerneli" .LC5: .string "PAGE_ENTRIES" .LC6: .string "PAGEFAULT" .LC7: .string "storage" .LC8: .string "results" .LC9: .string "input" .LC10: .string "pt_entries" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2094: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) movq %rax, _ZL32__nv_fatbinhandle_for_managed_rt(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC4(%rip), %rdx movq %rdx, %rcx leaq _Z8mykerneli(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC5(%rip), %rdx movq %rdx, %rcx leaq _ZL12PAGE_ENTRIES(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC6(%rip), %rdx movq %rdx, %rcx leaq _ZL9PAGEFAULT(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $131072, %r9d movl $0, %r8d leaq .LC7(%rip), %rdx movq %rdx, %rcx leaq _ZL7storage(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $131072, %r9d movl $0, %r8d leaq .LC8(%rip), %rdx movq %rdx, %rcx leaq _ZL7results(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $131072, %r9d movl $0, %r8d leaq .LC9(%rip), %rdx movq %rdx, %rcx leaq _ZL5input(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC10(%rip), %rdx movq %rdx, %rcx leaq _ZL10pt_entries(%rip), %rsi movq %rbx, %rdi call __cudaRegisterManagedVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2094: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section __nv_managed_data__,"aw" .align 8 .type _ZL10pt_entries, @object .size _ZL10pt_entries, 8 _ZL10pt_entries: .zero 8 .align 8 .type _ZL5input, @object .size _ZL5input, 8 _ZL5input: .zero 8 .align 8 .type _ZL7results, @object .size _ZL7results, 8 _ZL7results: .zero 8 .align 8 .type _ZL7storage, @object .size _ZL7storage, 8 _ZL7storage: .zero 8 .align 8 .type _ZL9PAGEFAULT, @object .size _ZL9PAGEFAULT, 8 _ZL9PAGEFAULT: .zero 8 .align 8 .type _ZL12PAGE_ENTRIES, @object .size _ZL12PAGE_ENTRIES, 8 _ZL12PAGE_ENTRIES: .zero 8 .local _ZL32__nv_fatbinhandle_for_managed_rt .comm _ZL32__nv_fatbinhandle_for_managed_rt,8,8 .local _ZL22__nv_inited_managed_rt .comm _ZL22__nv_inited_managed_rt,1,1 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "main.hip" .globl _Z10load_bFilePcPhi # -- Begin function _Z10load_bFilePcPhi .p2align 4, 0x90 .type _Z10load_bFilePcPhi,@function _Z10load_bFilePcPhi: # @_Z10load_bFilePcPhi .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %rbp, -16 movq %rsi, %rbx movl $.L.str, %esi callq fopen movq %rax, %r14 movl $-1, %ebp .p2align 4, 0x90 .LBB0_1: # =>This Inner Loop Header: Depth=1 movl $1, %esi movl $1, %edx movq %rbx, %rdi movq %r14, %rcx callq fread incl %ebp incq %rbx cmpq $1, %rax je .LBB0_1 # %bb.2: movq %r14, %rdi callq fclose movl %ebp, %eax popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z10load_bFilePcPhi, .Lfunc_end0-_Z10load_bFilePcPhi .cfi_endproc # -- End function .globl _Z11write_bFilePcPhi # -- Begin function _Z11write_bFilePcPhi .p2align 4, 0x90 .type _Z11write_bFilePcPhi,@function _Z11write_bFilePcPhi: # @_Z11write_bFilePcPhi .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r12 .cfi_def_cfa_offset 40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset %rbx, -48 .cfi_offset %r12, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %edx, %ebp movq %rsi, %rbx movl $.L.str.1, %esi callq fopen movq %rax, %r14 testl %ebp, %ebp jle .LBB1_3 # %bb.1: # %.lr.ph.preheader movl %ebp, %r15d xorl %r12d, %r12d .p2align 4, 0x90 .LBB1_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 movzbl (%rbx,%r12), %edi movq %r14, %rsi callq fputc incq %r12 cmpq %r12, %r15 jne .LBB1_2 .LBB1_3: # %._crit_edge movq %r14, %rdi popq %rbx .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 jmp fclose # TAILCALL .Lfunc_end1: .size _Z11write_bFilePcPhi, .Lfunc_end1-_Z11write_bFilePcPhi .cfi_endproc # -- End function .globl _Z23__device_stub__mykerneli # -- Begin function _Z23__device_stub__mykerneli .p2align 4, 0x90 .type _Z23__device_stub__mykerneli,@function _Z23__device_stub__mykerneli: # @_Z23__device_stub__mykerneli .cfi_startproc # %bb.0: subq $72, %rsp .cfi_def_cfa_offset 80 movl %edi, 12(%rsp) leaq 12(%rsp), %rax movq %rax, 16(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z8mykerneli, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $88, %rsp .cfi_adjust_cfa_offset -88 retq .Lfunc_end2: .size _Z23__device_stub__mykerneli, .Lfunc_end2-_Z23__device_stub__mykerneli .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r12 .cfi_def_cfa_offset 40 pushq %rbx .cfi_def_cfa_offset 48 subq $80, %rsp .cfi_def_cfa_offset 128 .cfi_offset %rbx, -48 .cfi_offset %r12, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq input(%rip), %rbx movl $.L.str.2, %edi movl $.L.str, %esi callq fopen movq %rax, %r14 movl $-1, %ebp .p2align 4, 0x90 .LBB3_1: # =>This Inner Loop Header: Depth=1 movl $1, %esi movl $1, %edx movq %rbx, %rdi movq %r14, %rcx callq fread incl %ebp incq %rbx cmpq $1, %rax je .LBB3_1 # %bb.2: # %_Z10load_bFilePcPhi.exit movq %r14, %rdi callq fclose movl $2, %edi callq hipSetDevice movabsq $4294967297, %rdi # imm = 0x100000001 movl $16384, %r8d # imm = 0x4000 movl $1, %esi movq %rdi, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_4 # %bb.3: movl %ebp, 12(%rsp) leaq 12(%rsp), %rax movq %rax, 16(%rsp) leaq 64(%rsp), %rdi leaq 48(%rsp), %rsi leaq 40(%rsp), %rdx leaq 32(%rsp), %rcx callq __hipPopCallConfiguration movq 64(%rsp), %rsi movl 72(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z8mykerneli, %edi pushq 32(%rsp) .cfi_adjust_cfa_offset 8 pushq 48(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB3_4: callq hipDeviceSynchronize callq hipDeviceReset movq results(%rip), %r14 movl $.L.str.3, %edi movl $.L.str.1, %esi callq fopen movq %rax, %rbx testl %ebp, %ebp jle .LBB3_7 # %bb.5: # %.lr.ph.preheader.i movl %ebp, %r15d xorl %r12d, %r12d .p2align 4, 0x90 .LBB3_6: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 movzbl (%r14,%r12), %edi movq %rbx, %rsi callq fputc incq %r12 cmpq %r12, %r15 jne .LBB3_6 .LBB3_7: # %_Z11write_bFilePcPhi.exit movq %rbx, %rdi callq fclose xorl %eax, %eax addq $80, %rsp .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size main, .Lfunc_end3-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB4_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB4_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z8mykerneli, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $PAGE_ENTRIES, %esi movl $PAGE_ENTRIES.managed, %edx movl $.L__unnamed_2, %ecx movl $4, %r8d movq %rbx, %rdi movl $4, %r9d callq __hipRegisterManagedVar movl $PAGEFAULT, %esi movl $PAGEFAULT.managed, %edx movl $.L__unnamed_3, %ecx movl $4, %r8d movq %rbx, %rdi movl $4, %r9d callq __hipRegisterManagedVar movl $storage, %esi movl $storage.managed, %edx movl $.L__unnamed_4, %ecx movl $131072, %r8d # imm = 0x20000 movq %rbx, %rdi movl $16, %r9d callq __hipRegisterManagedVar movl $results, %esi movl $results.managed, %edx movl $.L__unnamed_5, %ecx movl $131072, %r8d # imm = 0x20000 movq %rbx, %rdi movl $16, %r9d callq __hipRegisterManagedVar movl $input, %esi movl $input.managed, %edx movl $.L__unnamed_6, %ecx movl $131072, %r8d # imm = 0x20000 movq %rbx, %rdi movl $16, %r9d callq __hipRegisterManagedVar movl $pt_entries, %esi movl $pt_entries.managed, %edx movl $.L__unnamed_7, %ecx movl $4, %r8d movq %rbx, %rdi movl $4, %r9d callq __hipRegisterManagedVar movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end4: .size __hip_module_ctor, .Lfunc_end4-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB5_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB5_2: retq .Lfunc_end5: .size __hip_module_dtor, .Lfunc_end5-__hip_module_dtor .cfi_endproc # -- End function .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "rb" .size .L.str, 3 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "wb" .size .L.str.1, 3 .type PAGE_ENTRIES.managed,@object # @PAGE_ENTRIES.managed .local PAGE_ENTRIES.managed .comm PAGE_ENTRIES.managed,4,4 .type PAGEFAULT.managed,@object # @PAGEFAULT.managed .local PAGEFAULT.managed .comm PAGEFAULT.managed,4,4 .type storage.managed,@object # @storage.managed .local storage.managed .comm storage.managed,131072,16 .type results.managed,@object # @results.managed .local results.managed .comm results.managed,131072,16 .type input.managed,@object # @input.managed .local input.managed .comm input.managed,131072,16 .type pt_entries.managed,@object # @pt_entries.managed .data .p2align 2, 0x0 pt_entries.managed: .long 1024 # 0x400 .size pt_entries.managed, 4 .type _Z8mykerneli,@object # @_Z8mykerneli .section .rodata,"a",@progbits .globl _Z8mykerneli .p2align 3, 0x0 _Z8mykerneli: .quad _Z23__device_stub__mykerneli .size _Z8mykerneli, 8 .type .L.str.2,@object # @.str.2 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.2: .asciz "./data.bin" .size .L.str.2, 11 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "./snapshot.bin" .size .L.str.3, 15 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z8mykerneli" .size .L__unnamed_1, 13 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "PAGE_ENTRIES" .size .L__unnamed_2, 13 .type PAGE_ENTRIES,@object # @PAGE_ENTRIES .local PAGE_ENTRIES .comm PAGE_ENTRIES,8,8 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "PAGEFAULT" .size .L__unnamed_3, 10 .type PAGEFAULT,@object # @PAGEFAULT .local PAGEFAULT .comm PAGEFAULT,8,8 .type .L__unnamed_4,@object # @3 .L__unnamed_4: .asciz "storage" .size .L__unnamed_4, 8 .type storage,@object # @storage .local storage .comm storage,8,8 .type .L__unnamed_5,@object # @4 .L__unnamed_5: .asciz "results" .size .L__unnamed_5, 8 .type results,@object # @results .local results .comm results,8,8 .type .L__unnamed_6,@object # @5 .L__unnamed_6: .asciz "input" .size .L__unnamed_6, 6 .type input,@object # @input .local input .comm input,8,8 .type .L__unnamed_7,@object # @6 .L__unnamed_7: .asciz "pt_entries" .size .L__unnamed_7, 11 .type pt_entries,@object # @pt_entries .local pt_entries .comm pt_entries,8,8 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z23__device_stub__mykerneli .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym PAGE_ENTRIES.managed .addrsig_sym PAGEFAULT.managed .addrsig_sym storage.managed .addrsig_sym results.managed .addrsig_sym input.managed .addrsig_sym pt_entries.managed .addrsig_sym _Z8mykerneli .addrsig_sym PAGE_ENTRIES .addrsig_sym PAGEFAULT .addrsig_sym storage .addrsig_sym results .addrsig_sym input .addrsig_sym pt_entries .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <time.h> #include <stdio.h> #include <stdlib.h> //unsigned int radius; #define radius 16 #define FILTER_LENGTH (2 * radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 6 #define tileRH 1 #define tileRW 512 #define tileCH 16 #define tileCW 16 typedef float numid; __constant__ numid d_Filter[FILTER_LENGTH]; __global__ void tiledConvRowGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileRH] [tileRW + 2 * radius]; if(tx-radius<0){ //Near Left Bounds ShMemory[ty][tx] = d_Src[(row+radius) * newImageW + col]; } ShMemory[ty][tx+radius] = d_Src[(row+radius) * newImageW + col + radius]; //Center if(tx >= (tileRW - radius)){ ShMemory[ty] [tx + 2 * radius] = d_Src[(row+radius) * newImageW + col + 2 * radius]; //Near Right Bounds } __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[ty][tx+k+radius] * d_Filter[radius - k]; } d_Dst[(row+radius) * newImageW + col+radius] = sum; } __global__ void tiledConvColGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileCH + 2 * radius][ tileCW]; if(ty-radius<0){ //Upper Bounds ShMemory[ty] [tx] = d_Src[row * newImageW + col + radius]; } ShMemory[ty + radius][ tx ] = d_Src[(row + radius) * newImageW + col + radius ]; //Center ShMemory[ty + 2 * radius ][ tx ] = d_Src[(row + 2* radius) * newImageW + col + radius ]; //Lower Bounds __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[(ty + k + radius)][tx] * d_Filter[radius - k]; } d_Dst[ (row + radius) * newImageW + col + radius] = sum; } //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { cudaSetDevice(0); numid *h_Filter, *h_Input, *h_PadInput, *h_Buffer, *h_OutputCPU, *d_Input, *d_Buffer, *d_OutputGPU, *result; struct timespec tv1, tv2; cudaEvent_t start; cudaEvent_t stop; cudaEventCreate(&start); cudaEventCreate(&stop); int imageW; int imageH; unsigned int i,j; if(argc<2){ printf("Please specify the image size as execution arguments\n"); return 0; } imageW=atoi(argv[1]); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. // printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); // scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (numid *)malloc(FILTER_LENGTH * sizeof(numid)); h_Input = (numid *)malloc(imageW * imageH * sizeof(numid)); h_PadInput = (numid *)malloc((imageW+radius*2 )*(2*radius+ imageH) * sizeof(numid)) ; h_Buffer = (numid *)malloc(imageW * imageH * sizeof(numid)); h_OutputCPU = (numid *)malloc(imageW * imageH * sizeof(numid)); result = (numid *)malloc((imageW+2*radius) * (imageH+2*radius) * sizeof(numid)); cudaMalloc(&d_Input,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMalloc(&d_Buffer,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMemset(d_Buffer,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMalloc(&d_OutputGPU,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); if(d_Filter==NULL || d_Input==NULL || d_Buffer==NULL || d_OutputGPU==NULL){ printf("Cuda Malloc Failed\n"); return 0; } cudaMemset(d_OutputGPU,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); // to 'h_Filter' apotelei to filtro me to opoio ginetai to convolution kai // arxikopoieitai tuxaia. To 'h_Input' einai h eikona panw sthn opoia ginetai // to convolution kai arxikopoieitai kai auth tuxaia. srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (numid)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (numid)rand() / ((numid)RAND_MAX / 255) + (numid)rand() / (numid)RAND_MAX; } // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); clock_gettime(CLOCK_MONOTONIC_RAW, &tv1); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, radius); // convolution kata sthles clock_gettime(CLOCK_MONOTONIC_RAW, &tv2); printf ("CPU time = %10g seconds\n", (double) (tv2.tv_nsec - tv1.tv_nsec) / 1000000000.0 + (double) (tv2.tv_sec - tv1.tv_sec)); dim3 dimGridR(imageW/tileRW,imageH/tileRH); dim3 dimBlockR(tileRW,tileRH); dim3 dimGridC(imageW/tileCW,imageH/tileCH); dim3 dimBlockC(tileCW,tileCH); for(i=0;i<(imageW+2*radius)*(imageW+2*radius);i++){ h_PadInput[i]=0; } for(i=0;i<imageW;i++){ for(j=0;j<imageW;j++){ h_PadInput[(i+radius)*(2*radius+imageW)+j+radius]=h_Input[i*imageW+j]; } } printf("GPU computation... \n"); cudaMemcpyToSymbol(d_Filter, h_Filter,FILTER_LENGTH*sizeof(numid)); cudaMemcpy(d_Input,h_PadInput,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),cudaMemcpyHostToDevice); cudaEventRecord(start,0); tiledConvRowGPU <<< dimGridR, dimBlockR >>>(d_Buffer, d_Input, imageW, imageH); cudaThreadSynchronize(); cudaError_t error=cudaGetLastError(); if(error!=cudaSuccess){ printf("Cuda Error:%s\n",cudaGetErrorString(error)); cudaDeviceReset(); return 0; } tiledConvColGPU <<< dimGridC, dimBlockC >>>(d_OutputGPU, d_Buffer , imageW, imageH); cudaThreadSynchronize(); error=cudaGetLastError(); if(error!=cudaSuccess){ printf("Cuda Error:%s\n",cudaGetErrorString(error)); cudaDeviceReset(); return 0; } cudaEventRecord(stop,0); cudaMemcpy(result,d_OutputGPU,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),cudaMemcpyDeviceToHost); float elapsed; cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed,start,stop); printf("GPU time :%f ms.\n",elapsed); // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i=0;i<imageW;i++){ for(j=0;j<imageH;j++){ numid diff= h_OutputCPU[i*imageW+j]-result[(i+radius)*(imageW+2*radius)+j+radius]; if(ABS(diff)>accuracy){ printf("sfalma akriveias %f",ABS(diff)); } } } // free all the allocated memory free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); cudaFree(d_OutputGPU); cudaFree(d_Buffer); cudaFree(d_Input); cudaFree(d_Filter); cudaDeviceReset(); return 0; }
code for sm_80 Function : _Z15tiledConvColGPUPfS_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R11, SR_TID.Y ; /* 0x00000000000b7919 */ /* 0x000e220000002200 */ /*0020*/ MOV R4, c[0x0][0x170] ; /* 0x00005c0000047a02 */ /* 0x000fe20000000f00 */ /*0030*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fe200000001ff */ /*0040*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0050*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e620000002600 */ /*0060*/ IADD3 R4, R4, 0x20, RZ ; /* 0x0000002004047810 */ /* 0x000fc60007ffe0ff */ /*0070*/ S2R R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000ea80000002500 */ /*0080*/ S2R R10, SR_TID.X ; /* 0x00000000000a7919 */ /* 0x000ea20000002100 */ /*0090*/ ISETP.GE.AND P0, PT, R11, 0x10, PT ; /* 0x000000100b00780c */ /* 0x001fe20003f06270 */ /*00a0*/ IMAD R2, R2, c[0x0][0x4], R11 ; /* 0x0000010002027a24 */ /* 0x002fca00078e020b */ /*00b0*/ IADD3 R3, R2, 0x10, RZ ; /* 0x0000001002037810 */ /* 0x000fe20007ffe0ff */ /*00c0*/ IMAD R5, R5, c[0x0][0x0], R10 ; /* 0x0000000005057a24 */ /* 0x004fc800078e020a */ /*00d0*/ IMAD R3, R4, R3, R5.reuse ; /* 0x0000000304037224 */ /* 0x100fe400078e0205 */ /*00e0*/ @!P0 IMAD R5, R2, R4, R5 ; /* 0x0000000402058224 */ /* 0x000fe400078e0205 */ /*00f0*/ IMAD.WIDE R6, R3, R0, c[0x0][0x168] ; /* 0x00005a0003067625 */ /* 0x000fe200078e0200 */ /*0100*/ LEA R9, R4, R3, 0x4 ; /* 0x0000000304097211 */ /* 0x000fc600078e20ff */ /*0110*/ @!P0 IMAD.WIDE R4, R5, R0.reuse, c[0x0][0x168] ; /* 0x00005a0005048625 */ /* 0x080fe400078e0200 */ /*0120*/ LDG.E R7, [R6.64+0x40] ; /* 0x0000400406077981 */ /* 0x000ea4000c1e1900 */ /*0130*/ IMAD.WIDE R8, R9, R0, c[0x0][0x168] ; /* 0x00005a0009087625 */ /* 0x000fe400078e0200 */ /*0140*/ @!P0 LDG.E R5, [R4.64+0x40] ; /* 0x0000400404058981 */ /* 0x000ee8000c1e1900 */ /*0150*/ LDG.E R9, [R8.64+0x40] ; /* 0x0000400408097981 */ /* 0x000f22000c1e1900 */ /*0160*/ LEA R2, R11, R10, 0x4 ; /* 0x0000000a0b027211 */ /* 0x000fca00078e20ff */ /*0170*/ STS [R2.X4+0x400], R7 ; /* 0x0004000702007388 */ /* 0x004fe80000004800 */ /*0180*/ @!P0 STS [R2.X4], R5 ; /* 0x0000000502008388 */ /* 0x008fe80000004800 */ /*0190*/ STS [R2.X4+0x800], R9 ; /* 0x0008000902007388 */ /* 0x010fe80000004800 */ /*01a0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*01b0*/ LDS R10, [R2.X4] ; /* 0x00000000020a7984 */ /* 0x000e280000004800 */ /*01c0*/ LDS R11, [R2.X4+0x40] ; /* 0x00004000020b7984 */ /* 0x000e680000004800 */ /*01d0*/ LDS R13, [R2.X4+0x80] ; /* 0x00008000020d7984 */ /* 0x000ea80000004800 */ /*01e0*/ LDS R15, [R2.X4+0xc0] ; /* 0x0000c000020f7984 */ /* 0x000ee80000004800 */ /*01f0*/ LDS R17, [R2.X4+0x100] ; /* 0x0001000002117984 */ /* 0x000f280000004800 */ /*0200*/ LDS R19, [R2.X4+0x140] ; /* 0x0001400002137984 */ /* 0x000f680000004800 */ /*0210*/ LDS R12, [R2.X4+0x180] ; /* 0x00018000020c7984 */ /* 0x000f680000004800 */ /*0220*/ LDS R21, [R2.X4+0x1c0] ; /* 0x0001c00002157984 */ /* 0x000f680000004800 */ /*0230*/ LDS R14, [R2.X4+0x200] ; /* 0x00020000020e7984 */ /* 0x000f680000004800 */ /*0240*/ LDS R4, [R2.X4+0x240] ; /* 0x0002400002047984 */ /* 0x000f620000004800 */ /*0250*/ FFMA R10, R10, c[0x3][0x80], RZ ; /* 0x00c020000a0a7a23 */ /* 0x001fc600000000ff */ /*0260*/ LDS R5, [R2.X4+0x280] ; /* 0x0002800002057984 */ /* 0x000e220000004800 */ /*0270*/ FFMA R10, R11, c[0x3][0x7c], R10 ; /* 0x00c01f000b0a7a23 */ /* 0x002fc6000000000a */ /*0280*/ LDS R6, [R2.X4+0x2c0] ; /* 0x0002c00002067984 */ /* 0x000e620000004800 */ /*0290*/ FFMA R10, R13, c[0x3][0x78], R10 ; /* 0x00c01e000d0a7a23 */ /* 0x004fc6000000000a */ /*02a0*/ LDS R7, [R2.X4+0x300] ; /* 0x0003000002077984 */ /* 0x000ea20000004800 */ /*02b0*/ FFMA R10, R15, c[0x3][0x74], R10 ; /* 0x00c01d000f0a7a23 */ /* 0x008fc6000000000a */ /*02c0*/ LDS R8, [R2.X4+0x340] ; /* 0x0003400002087984 */ /* 0x000ee20000004800 */ /*02d0*/ FFMA R10, R17, c[0x3][0x70], R10 ; /* 0x00c01c00110a7a23 */ /* 0x010fc6000000000a */ /*02e0*/ LDS R9, [R2.X4+0x380] ; /* 0x0003800002097984 */ /* 0x000f220000004800 */ /*02f0*/ FFMA R19, R19, c[0x3][0x6c], R10 ; /* 0x00c01b0013137a23 */ /* 0x020fc6000000000a */ /*0300*/ LDS R11, [R2.X4+0x400] ; /* 0x00040000020b7984 */ /* 0x000fe80000004800 */ /*0310*/ LDS R10, [R2.X4+0x3c0] ; /* 0x0003c000020a7984 */ /* 0x000f620000004800 */ /*0320*/ FFMA R12, R12, c[0x3][0x68], R19 ; /* 0x00c01a000c0c7a23 */ /* 0x000fc60000000013 */ /*0330*/ LDS R13, [R2.X4+0x480] ; /* 0x00048000020d7984 */ /* 0x000fe20000004800 */ /*0340*/ FFMA R21, R21, c[0x3][0x64], R12 ; /* 0x00c0190015157a23 */ /* 0x000fc6000000000c */ /*0350*/ LDS R12, [R2.X4+0x440] ; /* 0x00044000020c7984 */ /* 0x000f620000004800 */ /*0360*/ FFMA R21, R14, c[0x3][0x60], R21 ; /* 0x00c018000e157a23 */ /* 0x000fc60000000015 */ /*0370*/ LDS R16, [R2.X4+0x6c0] ; /* 0x0006c00002107984 */ /* 0x000fe20000004800 */ /*0380*/ FFMA R14, R4, c[0x3][0x5c], R21 ; /* 0x00c01700040e7a23 */ /* 0x000fc60000000015 */ /*0390*/ LDS R4, [R2.X4+0x4c0] ; /* 0x0004c00002047984 */ /* 0x000f620000004800 */ /*03a0*/ FFMA R15, R5, c[0x3][0x58], R14 ; /* 0x00c01600050f7a23 */ /* 0x001fc6000000000e */ /*03b0*/ LDS R5, [R2.X4+0x500] ; /* 0x0005000002057984 */ /* 0x000e220000004800 */ /*03c0*/ FFMA R14, R6, c[0x3][0x54], R15 ; /* 0x00c01500060e7a23 */ /* 0x002fc6000000000f */ /*03d0*/ LDS R6, [R2.X4+0x540] ; /* 0x0005400002067984 */ /* 0x000e620000004800 */ /*03e0*/ FFMA R15, R7, c[0x3][0x50], R14 ; /* 0x00c01400070f7a23 */ /* 0x004fc6000000000e */ /*03f0*/ LDS R7, [R2.X4+0x580] ; /* 0x0005800002077984 */ /* 0x000ea20000004800 */ /*0400*/ FFMA R14, R8, c[0x3][0x4c], R15 ; /* 0x00c01300080e7a23 */ /* 0x008fc6000000000f */ /*0410*/ LDS R8, [R2.X4+0x5c0] ; /* 0x0005c00002087984 */ /* 0x000ee20000004800 */ /*0420*/ FFMA R15, R9, c[0x3][0x48], R14 ; /* 0x00c01200090f7a23 */ /* 0x010fc6000000000e */ /*0430*/ LDS R9, [R2.X4+0x600] ; /* 0x0006000002097984 */ /* 0x000f220000004800 */ /*0440*/ FFMA R14, R10, c[0x3][0x44], R15 ; /* 0x00c011000a0e7a23 */ /* 0x020fc6000000000f */ /*0450*/ LDS R18, [R2.X4+0x740] ; /* 0x0007400002127984 */ /* 0x000fe80000004800 */ /*0460*/ LDS R10, [R2.X4+0x640] ; /* 0x00064000020a7984 */ /* 0x000f620000004800 */ /*0470*/ FFMA R11, R11, c[0x3][0x40], R14 ; /* 0x00c010000b0b7a23 */ /* 0x000fc6000000000e */ /*0480*/ LDS R14, [R2.X4+0x680] ; /* 0x00068000020e7984 */ /* 0x000f620000004800 */ /*0490*/ FFMA R12, R12, c[0x3][0x3c], R11 ; /* 0x00c00f000c0c7a23 */ /* 0x000fc6000000000b */ /*04a0*/ LDS R11, [R2.X4+0x800] ; /* 0x00080000020b7984 */ /* 0x000fe20000004800 */ /*04b0*/ FFMA R13, R13, c[0x3][0x38], R12 ; /* 0x00c00e000d0d7a23 */ /* 0x000fc6000000000c */ /*04c0*/ LDS R12, [R2.X4+0x700] ; /* 0x00070000020c7984 */ /* 0x000f620000004800 */ /*04d0*/ FFMA R4, R4, c[0x3][0x34], R13 ; /* 0x00c00d0004047a23 */ /* 0x000fc8000000000d */ /*04e0*/ FFMA R5, R5, c[0x3][0x30], R4 ; /* 0x00c00c0005057a23 */ /* 0x001fe40000000004 */ /*04f0*/ LDS R4, [R2.X4+0x780] ; /* 0x0007800002047984 */ /* 0x000e240000004800 */ /*0500*/ FFMA R6, R6, c[0x3][0x2c], R5 ; /* 0x00c00b0006067a23 */ /* 0x002fe40000000005 */ /*0510*/ LDS R5, [R2.X4+0x7c0] ; /* 0x0007c00002057984 */ /* 0x000e640000004800 */ /*0520*/ FFMA R7, R7, c[0x3][0x28], R6 ; /* 0x00c00a0007077a23 */ /* 0x004fc80000000006 */ /*0530*/ FFMA R8, R8, c[0x3][0x24], R7 ; /* 0x00c0090008087a23 */ /* 0x008fc80000000007 */ /*0540*/ FFMA R9, R9, c[0x3][0x20], R8 ; /* 0x00c0080009097a23 */ /* 0x010fc80000000008 */ /*0550*/ FFMA R9, R10, c[0x3][0x1c], R9 ; /* 0x00c007000a097a23 */ /* 0x020fc80000000009 */ /*0560*/ FFMA R9, R14, c[0x3][0x18], R9 ; /* 0x00c006000e097a23 */ /* 0x000fc80000000009 */ /*0570*/ FFMA R9, R16, c[0x3][0x14], R9 ; /* 0x00c0050010097a23 */ /* 0x000fc80000000009 */ /*0580*/ FFMA R9, R12, c[0x3][0x10], R9 ; /* 0x00c004000c097a23 */ /* 0x000fc80000000009 */ /*0590*/ FFMA R9, R18, c[0x3][0xc], R9 ; /* 0x00c0030012097a23 */ /* 0x000fc80000000009 */ /*05a0*/ FFMA R4, R4, c[0x3][0x8], R9 ; /* 0x00c0020004047a23 */ /* 0x001fc80000000009 */ /*05b0*/ FFMA R6, R5, c[0x3][0x4], R4 ; /* 0x00c0010005067a23 */ /* 0x002fe40000000004 */ /*05c0*/ IMAD.WIDE R4, R3, R0, c[0x0][0x160] ; /* 0x0000580003047625 */ /* 0x000fc800078e0200 */ /*05d0*/ FFMA R11, R11, c[0x3][0x0], R6 ; /* 0x00c000000b0b7a23 */ /* 0x000fca0000000006 */ /*05e0*/ STG.E [R4.64+0x40], R11 ; /* 0x0000400b04007986 */ /* 0x000fe2000c101904 */ /*05f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0600*/ BRA 0x600; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0610*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0620*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0630*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0640*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0650*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0660*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0670*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0680*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0690*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z15tiledConvRowGPUPfS_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ ULDC UR4, c[0x0][0x170] ; /* 0x00005c0000047ab9 */ /* 0x000fe40000000800 */ /*0030*/ UIADD3 UR4, UR4, 0x20, URZ ; /* 0x0000002004047890 */ /* 0x000fe2000fffe03f */ /*0040*/ S2R R13, SR_TID.Y ; /* 0x00000000000d7919 */ /* 0x000e280000002200 */ /*0050*/ S2R R6, SR_TID.X ; /* 0x0000000000067919 */ /* 0x000e680000002100 */ /*0060*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000ea20000002500 */ /*0070*/ IMAD R0, R0, c[0x0][0x4], R13 ; /* 0x0000010000007a24 */ /* 0x001fe200078e020d */ /*0080*/ ISETP.GT.AND P0, PT, R6, 0xf, PT ; /* 0x0000000f0600780c */ /* 0x002fc80003f04270 */ /*0090*/ IADD3 R2, R0, 0x10, RZ ; /* 0x0000001000027810 */ /* 0x000fe20007ffe0ff */ /*00a0*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fe200000001ff */ /*00b0*/ IMAD R3, R3, c[0x0][0x0], R6 ; /* 0x0000000003037a24 */ /* 0x004fe200078e0206 */ /*00c0*/ ISETP.GT.AND P1, PT, R6, 0x1ef, PT ; /* 0x000001ef0600780c */ /* 0x000fc60003f24270 */ /*00d0*/ IMAD R3, R2, UR4, R3 ; /* 0x0000000402037c24 */ /* 0x000fe2000f8e0203 */ /*00e0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc80000000a00 */ /*00f0*/ IMAD.WIDE R4, R3, R0, c[0x0][0x168] ; /* 0x00005a0003047625 */ /* 0x000fca00078e0200 */ /*0100*/ @!P0 LDG.E R7, [R4.64] ; /* 0x0000000404078981 */ /* 0x000ea8000c1e1900 */ /*0110*/ LDG.E R9, [R4.64+0x40] ; /* 0x0000400404097981 */ /* 0x000ee8000c1e1900 */ /*0120*/ @P1 LDG.E R11, [R4.64+0x80] ; /* 0x00008004040b1981 */ /* 0x000f22000c1e1900 */ /*0130*/ IMAD R2, R13, 0x220, R6 ; /* 0x000002200d027824 */ /* 0x000fe200078e0206 */ /*0140*/ IADD3 R3, R3, 0x10, RZ ; /* 0x0000001003037810 */ /* 0x000fc80007ffe0ff */ /*0150*/ @!P0 STS [R2.X4], R7 ; /* 0x0000000702008388 */ /* 0x004fe80000004800 */ /*0160*/ STS [R2.X4+0x40], R9 ; /* 0x0000400902007388 */ /* 0x008fe80000004800 */ /*0170*/ @P1 STS [R2.X4+0x80], R11 ; /* 0x0000800b02001388 */ /* 0x010fe80000004800 */ /*0180*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0190*/ LDS R6, [R2.X4] ; /* 0x0000000002067984 */ /* 0x000e280000004800 */ /*01a0*/ LDS R13, [R2.X4+0x4] ; /* 0x00000400020d7984 */ /* 0x000e680000004800 */ /*01b0*/ LDS R8, [R2.X4+0x8] ; /* 0x0000080002087984 */ /* 0x000ea80000004800 */ /*01c0*/ LDS R15, [R2.X4+0xc] ; /* 0x00000c00020f7984 */ /* 0x000ee80000004800 */ /*01d0*/ LDS R10, [R2.X4+0x10] ; /* 0x00001000020a7984 */ /* 0x000f280000004800 */ /*01e0*/ LDS R17, [R2.X4+0x14] ; /* 0x0000140002117984 */ /* 0x000f680000004800 */ /*01f0*/ LDS R12, [R2.X4+0x18] ; /* 0x00001800020c7984 */ /* 0x000f680000004800 */ /*0200*/ LDS R19, [R2.X4+0x1c] ; /* 0x00001c0002137984 */ /* 0x000f680000004800 */ /*0210*/ LDS R14, [R2.X4+0x20] ; /* 0x00002000020e7984 */ /* 0x000f680000004800 */ /*0220*/ LDS R4, [R2.X4+0x24] ; /* 0x0000240002047984 */ /* 0x000f620000004800 */ /*0230*/ FFMA R6, R6, c[0x3][0x80], RZ ; /* 0x00c0200006067a23 */ /* 0x001fc600000000ff */ /*0240*/ LDS R5, [R2.X4+0x28] ; /* 0x0000280002057984 */ /* 0x000e220000004800 */ /*0250*/ FFMA R13, R13, c[0x3][0x7c], R6 ; /* 0x00c01f000d0d7a23 */ /* 0x002fc60000000006 */ /*0260*/ LDS R7, [R2.X4+0x30] ; /* 0x0000300002077984 */ /* 0x000fe20000004800 */ /*0270*/ FFMA R8, R8, c[0x3][0x78], R13 ; /* 0x00c01e0008087a23 */ /* 0x004fc6000000000d */ /*0280*/ LDS R6, [R2.X4+0x2c] ; /* 0x00002c0002067984 */ /* 0x000e620000004800 */ /*0290*/ FFMA R15, R15, c[0x3][0x74], R8 ; /* 0x00c01d000f0f7a23 */ /* 0x008fc60000000008 */ /*02a0*/ LDS R9, [R2.X4+0x38] ; /* 0x0000380002097984 */ /* 0x000fe20000004800 */ /*02b0*/ FFMA R10, R10, c[0x3][0x70], R15 ; /* 0x00c01c000a0a7a23 */ /* 0x010fc6000000000f */ /*02c0*/ LDS R8, [R2.X4+0x34] ; /* 0x0000340002087984 */ /* 0x000ea20000004800 */ /*02d0*/ FFMA R17, R17, c[0x3][0x6c], R10 ; /* 0x00c01b0011117a23 */ /* 0x020fc6000000000a */ /*02e0*/ LDS R11, [R2.X4+0x40] ; /* 0x00004000020b7984 */ /* 0x000fe20000004800 */ /*02f0*/ FFMA R12, R12, c[0x3][0x68], R17 ; /* 0x00c01a000c0c7a23 */ /* 0x000fc60000000011 */ /*0300*/ LDS R10, [R2.X4+0x3c] ; /* 0x00003c00020a7984 */ /* 0x000ee20000004800 */ /*0310*/ FFMA R19, R19, c[0x3][0x64], R12 ; /* 0x00c0190013137a23 */ /* 0x000fc6000000000c */ /*0320*/ LDS R13, [R2.X4+0x48] ; /* 0x00004800020d7984 */ /* 0x000fe20000004800 */ /*0330*/ FFMA R19, R14, c[0x3][0x60], R19 ; /* 0x00c018000e137a23 */ /* 0x000fc60000000013 */ /*0340*/ LDS R12, [R2.X4+0x44] ; /* 0x00004400020c7984 */ /* 0x000f220000004800 */ /*0350*/ FFMA R14, R4, c[0x3][0x5c], R19 ; /* 0x00c01700040e7a23 */ /* 0x000fc60000000013 */ /*0360*/ LDS R16, [R2.X4+0x6c] ; /* 0x00006c0002107984 */ /* 0x000fe80000004800 */ /*0370*/ LDS R4, [R2.X4+0x4c] ; /* 0x00004c0002047984 */ /* 0x000f620000004800 */ /*0380*/ FFMA R15, R5, c[0x3][0x58], R14 ; /* 0x00c01600050f7a23 */ /* 0x001fc6000000000e */ /*0390*/ LDS R5, [R2.X4+0x50] ; /* 0x0000500002057984 */ /* 0x000e220000004800 */ /*03a0*/ FFMA R14, R6, c[0x3][0x54], R15 ; /* 0x00c01500060e7a23 */ /* 0x002fc6000000000f */ /*03b0*/ LDS R18, [R2.X4+0x74] ; /* 0x0000740002127984 */ /* 0x000fe20000004800 */ /*03c0*/ FFMA R15, R7, c[0x3][0x50], R14 ; /* 0x00c01400070f7a23 */ /* 0x000fc6000000000e */ /*03d0*/ LDS R6, [R2.X4+0x54] ; /* 0x0000540002067984 */ /* 0x000e620000004800 */ /*03e0*/ FFMA R14, R8, c[0x3][0x4c], R15 ; /* 0x00c01300080e7a23 */ /* 0x004fc6000000000f */ /*03f0*/ LDS R7, [R2.X4+0x58] ; /* 0x0000580002077984 */ /* 0x000ea20000004800 */ /*0400*/ FFMA R15, R9, c[0x3][0x48], R14 ; /* 0x00c01200090f7a23 */ /* 0x000fc6000000000e */ /*0410*/ LDS R8, [R2.X4+0x5c] ; /* 0x00005c0002087984 */ /* 0x000ea20000004800 */ /*0420*/ FFMA R14, R10, c[0x3][0x44], R15 ; /* 0x00c011000a0e7a23 */ /* 0x008fc6000000000f */ /*0430*/ LDS R9, [R2.X4+0x60] ; /* 0x0000600002097984 */ /* 0x000ee20000004800 */ /*0440*/ FFMA R11, R11, c[0x3][0x40], R14 ; /* 0x00c010000b0b7a23 */ /* 0x000fc6000000000e */ /*0450*/ LDS R10, [R2.X4+0x64] ; /* 0x00006400020a7984 */ /* 0x000ee20000004800 */ /*0460*/ FFMA R12, R12, c[0x3][0x3c], R11 ; /* 0x00c00f000c0c7a23 */ /* 0x010fc6000000000b */ /*0470*/ LDS R14, [R2.X4+0x68] ; /* 0x00006800020e7984 */ /* 0x000f220000004800 */ /*0480*/ FFMA R13, R13, c[0x3][0x38], R12 ; /* 0x00c00e000d0d7a23 */ /* 0x000fc6000000000c */ /*0490*/ LDS R11, [R2.X4+0x80] ; /* 0x00008000020b7984 */ /* 0x000fe20000004800 */ /*04a0*/ FFMA R4, R4, c[0x3][0x34], R13 ; /* 0x00c00d0004047a23 */ /* 0x020fc6000000000d */ /*04b0*/ LDS R12, [R2.X4+0x70] ; /* 0x00007000020c7984 */ /* 0x000f620000004800 */ /*04c0*/ FFMA R5, R5, c[0x3][0x30], R4 ; /* 0x00c00c0005057a23 */ /* 0x001fc60000000004 */ /*04d0*/ LDS R4, [R2.X4+0x78] ; /* 0x0000780002047984 */ /* 0x000e220000004800 */ /*04e0*/ FFMA R6, R6, c[0x3][0x2c], R5 ; /* 0x00c00b0006067a23 */ /* 0x002fc60000000005 */ /*04f0*/ LDS R5, [R2.X4+0x7c] ; /* 0x00007c0002057984 */ /* 0x0002220000004800 */ /*0500*/ FFMA R7, R7, c[0x3][0x28], R6 ; /* 0x00c00a0007077a23 */ /* 0x004fc80000000006 */ /*0510*/ FFMA R8, R8, c[0x3][0x24], R7 ; /* 0x00c0090008087a23 */ /* 0x000fe40000000007 */ /*0520*/ IMAD.WIDE R2, R3, R0, c[0x0][0x160] ; /* 0x0000580003027625 */ /* 0x002fc800078e0200 */ /*0530*/ FFMA R9, R9, c[0x3][0x20], R8 ; /* 0x00c0080009097a23 */ /* 0x008fc80000000008 */ /*0540*/ FFMA R9, R10, c[0x3][0x1c], R9 ; /* 0x00c007000a097a23 */ /* 0x000fc80000000009 */ /*0550*/ FFMA R9, R14, c[0x3][0x18], R9 ; /* 0x00c006000e097a23 */ /* 0x010fc80000000009 */ /*0560*/ FFMA R9, R16, c[0x3][0x14], R9 ; /* 0x00c0050010097a23 */ /* 0x000fc80000000009 */ /*0570*/ FFMA R9, R12, c[0x3][0x10], R9 ; /* 0x00c004000c097a23 */ /* 0x020fc80000000009 */ /*0580*/ FFMA R9, R18, c[0x3][0xc], R9 ; /* 0x00c0030012097a23 */ /* 0x000fc80000000009 */ /*0590*/ FFMA R4, R4, c[0x3][0x8], R9 ; /* 0x00c0020004047a23 */ /* 0x001fc80000000009 */ /*05a0*/ FFMA R4, R5, c[0x3][0x4], R4 ; /* 0x00c0010005047a23 */ /* 0x000fc80000000004 */ /*05b0*/ FFMA R11, R11, c[0x3][0x0], R4 ; /* 0x00c000000b0b7a23 */ /* 0x000fca0000000004 */ /*05c0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x000fe2000c101904 */ /*05d0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*05e0*/ BRA 0x5e0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*05f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0600*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0610*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0620*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0630*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0640*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0650*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0660*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0670*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <time.h> #include <stdio.h> #include <stdlib.h> //unsigned int radius; #define radius 16 #define FILTER_LENGTH (2 * radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 6 #define tileRH 1 #define tileRW 512 #define tileCH 16 #define tileCW 16 typedef float numid; __constant__ numid d_Filter[FILTER_LENGTH]; __global__ void tiledConvRowGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileRH] [tileRW + 2 * radius]; if(tx-radius<0){ //Near Left Bounds ShMemory[ty][tx] = d_Src[(row+radius) * newImageW + col]; } ShMemory[ty][tx+radius] = d_Src[(row+radius) * newImageW + col + radius]; //Center if(tx >= (tileRW - radius)){ ShMemory[ty] [tx + 2 * radius] = d_Src[(row+radius) * newImageW + col + 2 * radius]; //Near Right Bounds } __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[ty][tx+k+radius] * d_Filter[radius - k]; } d_Dst[(row+radius) * newImageW + col+radius] = sum; } __global__ void tiledConvColGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileCH + 2 * radius][ tileCW]; if(ty-radius<0){ //Upper Bounds ShMemory[ty] [tx] = d_Src[row * newImageW + col + radius]; } ShMemory[ty + radius][ tx ] = d_Src[(row + radius) * newImageW + col + radius ]; //Center ShMemory[ty + 2 * radius ][ tx ] = d_Src[(row + 2* radius) * newImageW + col + radius ]; //Lower Bounds __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[(ty + k + radius)][tx] * d_Filter[radius - k]; } d_Dst[ (row + radius) * newImageW + col + radius] = sum; } //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { cudaSetDevice(0); numid *h_Filter, *h_Input, *h_PadInput, *h_Buffer, *h_OutputCPU, *d_Input, *d_Buffer, *d_OutputGPU, *result; struct timespec tv1, tv2; cudaEvent_t start; cudaEvent_t stop; cudaEventCreate(&start); cudaEventCreate(&stop); int imageW; int imageH; unsigned int i,j; if(argc<2){ printf("Please specify the image size as execution arguments\n"); return 0; } imageW=atoi(argv[1]); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. // printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); // scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (numid *)malloc(FILTER_LENGTH * sizeof(numid)); h_Input = (numid *)malloc(imageW * imageH * sizeof(numid)); h_PadInput = (numid *)malloc((imageW+radius*2 )*(2*radius+ imageH) * sizeof(numid)) ; h_Buffer = (numid *)malloc(imageW * imageH * sizeof(numid)); h_OutputCPU = (numid *)malloc(imageW * imageH * sizeof(numid)); result = (numid *)malloc((imageW+2*radius) * (imageH+2*radius) * sizeof(numid)); cudaMalloc(&d_Input,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMalloc(&d_Buffer,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMemset(d_Buffer,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMalloc(&d_OutputGPU,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); if(d_Filter==NULL || d_Input==NULL || d_Buffer==NULL || d_OutputGPU==NULL){ printf("Cuda Malloc Failed\n"); return 0; } cudaMemset(d_OutputGPU,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); // to 'h_Filter' apotelei to filtro me to opoio ginetai to convolution kai // arxikopoieitai tuxaia. To 'h_Input' einai h eikona panw sthn opoia ginetai // to convolution kai arxikopoieitai kai auth tuxaia. srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (numid)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (numid)rand() / ((numid)RAND_MAX / 255) + (numid)rand() / (numid)RAND_MAX; } // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); clock_gettime(CLOCK_MONOTONIC_RAW, &tv1); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, radius); // convolution kata sthles clock_gettime(CLOCK_MONOTONIC_RAW, &tv2); printf ("CPU time = %10g seconds\n", (double) (tv2.tv_nsec - tv1.tv_nsec) / 1000000000.0 + (double) (tv2.tv_sec - tv1.tv_sec)); dim3 dimGridR(imageW/tileRW,imageH/tileRH); dim3 dimBlockR(tileRW,tileRH); dim3 dimGridC(imageW/tileCW,imageH/tileCH); dim3 dimBlockC(tileCW,tileCH); for(i=0;i<(imageW+2*radius)*(imageW+2*radius);i++){ h_PadInput[i]=0; } for(i=0;i<imageW;i++){ for(j=0;j<imageW;j++){ h_PadInput[(i+radius)*(2*radius+imageW)+j+radius]=h_Input[i*imageW+j]; } } printf("GPU computation... \n"); cudaMemcpyToSymbol(d_Filter, h_Filter,FILTER_LENGTH*sizeof(numid)); cudaMemcpy(d_Input,h_PadInput,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),cudaMemcpyHostToDevice); cudaEventRecord(start,0); tiledConvRowGPU <<< dimGridR, dimBlockR >>>(d_Buffer, d_Input, imageW, imageH); cudaThreadSynchronize(); cudaError_t error=cudaGetLastError(); if(error!=cudaSuccess){ printf("Cuda Error:%s\n",cudaGetErrorString(error)); cudaDeviceReset(); return 0; } tiledConvColGPU <<< dimGridC, dimBlockC >>>(d_OutputGPU, d_Buffer , imageW, imageH); cudaThreadSynchronize(); error=cudaGetLastError(); if(error!=cudaSuccess){ printf("Cuda Error:%s\n",cudaGetErrorString(error)); cudaDeviceReset(); return 0; } cudaEventRecord(stop,0); cudaMemcpy(result,d_OutputGPU,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),cudaMemcpyDeviceToHost); float elapsed; cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed,start,stop); printf("GPU time :%f ms.\n",elapsed); // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i=0;i<imageW;i++){ for(j=0;j<imageH;j++){ numid diff= h_OutputCPU[i*imageW+j]-result[(i+radius)*(imageW+2*radius)+j+radius]; if(ABS(diff)>accuracy){ printf("sfalma akriveias %f",ABS(diff)); } } } // free all the allocated memory free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); cudaFree(d_OutputGPU); cudaFree(d_Buffer); cudaFree(d_Input); cudaFree(d_Filter); cudaDeviceReset(); return 0; }
.file "tmpxft_000e865c_00000000-6_quest32.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2062: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2062: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z17convolutionRowCPUPfS_S_iii .type _Z17convolutionRowCPUPfS_S_iii, @function _Z17convolutionRowCPUPfS_S_iii: .LFB2057: .cfi_startproc endbr64 testl %r8d, %r8d jle .L15 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 movq %rdi, %rax movq %rsi, %r11 movq %rdx, %rbx movl %ecx, %r10d movl %r9d, %ebp movl %r9d, %edx negl %edx leal (%r9,%r9), %r15d negl %r15d movl $0, %ecx movl %edx, %r13d movl %r8d, -4(%rsp) movl %ecx, %edi movq %rax, %rcx jmp .L5 .L18: leal (%r9,%rax), %r12d movslq %r12d, %r12 movl %r8d, %edx subl %eax, %edx movslq %edx, %rdx movss (%r11,%r12,4), %xmm1 mulss (%rbx,%rdx,4), %xmm1 addss %xmm1, %xmm0 .L7: movss %xmm0, (%r14) addl $1, %eax cmpl %esi, %eax je .L6 .L8: testl %eax, %eax js .L7 cmpl %eax, %r10d jg .L18 jmp .L7 .L6: addl $1, %esi addl $1, %r8d movl -16(%rsp), %eax cmpl %eax, %esi je .L19 .L9: cmpl %r13d, %ebp jl .L6 leal (%rdi,%rsi), %eax cltq leaq (%rcx,%rax,4), %r14 leal (%r8,%r15), %eax pxor %xmm0, %xmm0 jmp .L8 .L19: movl -12(%rsp), %edi movl -8(%rsp), %edx .L11: addl $1, %edi addl %r10d, %edx cmpl %edi, -4(%rsp) je .L3 .L5: testl %r10d, %r10d jle .L11 leal (%rdx,%rbp), %r9d leal 1(%rbp), %esi leal (%rsi,%r10), %r12d movl %ebp, %r8d leal -1(%rdx), %r14d movl %edi, -12(%rsp) movl %r12d, -16(%rsp) movl %edx, -8(%rsp) movl %r14d, %edi jmp .L9 .L3: popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .L15: .cfi_restore 3 .cfi_restore 6 .cfi_restore 12 .cfi_restore 13 .cfi_restore 14 .cfi_restore 15 ret .cfi_endproc .LFE2057: .size _Z17convolutionRowCPUPfS_S_iii, .-_Z17convolutionRowCPUPfS_S_iii .globl _Z20convolutionColumnCPUPfS_S_iii .type _Z20convolutionColumnCPUPfS_S_iii, @function _Z20convolutionColumnCPUPfS_S_iii: .LFB2058: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 movq %rdi, -16(%rsp) testl %r8d, %r8d jle .L20 movq %rsi, %rbp movq %rdx, %r12 movl %ecx, %r10d movl %r8d, %r11d movl %r9d, %esi movl %r9d, %ebx leal 1(%r9), %r8d movl %r9d, %eax negl %eax movl %eax, -20(%rsp) movl %ecx, %eax imull %r9d, %eax negl %eax movl %eax, %edx leal (%r11,%r8), %ecx movl %r10d, %r13d movl %r9d, %r15d negl %r15d movl %ecx, -4(%rsp) jmp .L22 .L35: movl %ebx, %r9d subl %eax, %r9d movslq %r9d, %r9 movslq %edx, %rcx movss (%r12,%r9,4), %xmm1 mulss 0(%rbp,%rcx,4), %xmm1 addss %xmm1, %xmm0 .L24: movss %xmm0, (%r14) addl $1, %eax addl %r10d, %edx cmpl %r8d, %eax je .L34 .L25: testl %eax, %eax js .L24 cmpl %eax, %r11d jg .L35 jmp .L24 .L34: movl -24(%rsp), %r9d .L23: addl $1, %r9d cmpl %r13d, %r9d je .L36 .L26: cmpl %r15d, %esi jl .L23 movslq %r9d, %rax movq -16(%rsp), %rdx leaq (%rdx,%rax,4), %r14 leal (%rdi,%r9), %edx movl -20(%rsp), %eax pxor %xmm0, %xmm0 movl %r9d, -24(%rsp) jmp .L25 .L36: movl -8(%rsp), %edx .L28: addl %r10d, %r13d addl $1, %r8d addl $1, %ebx addl $1, -20(%rsp) addl %r10d, %edx movl -4(%rsp), %eax cmpl %eax, %r8d je .L20 .L22: movl %r13d, %r9d subl %r10d, %r9d movl %r10d, %r14d subl %r13d, %r14d addl %edx, %r14d testl %r10d, %r10d jle .L28 movl %edx, -8(%rsp) movl %r14d, %edi jmp .L26 .L20: popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z20convolutionColumnCPUPfS_S_iii, .-_Z20convolutionColumnCPUPfS_S_iii .globl _Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii .type _Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii, @function _Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii: .LFB2084: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movl %edx, 12(%rsp) movl %ecx, 8(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 12(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L41 .L37: movq 136(%rsp), %rax subq %fs:40, %rax jne .L42 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L41: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z15tiledConvRowGPUPfS_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L37 .L42: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii, .-_Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii .globl _Z15tiledConvRowGPUPfS_ii .type _Z15tiledConvRowGPUPfS_ii, @function _Z15tiledConvRowGPUPfS_ii: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z15tiledConvRowGPUPfS_ii, .-_Z15tiledConvRowGPUPfS_ii .globl _Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii .type _Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii, @function _Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii: .LFB2086: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movl %edx, 12(%rsp) movl %ecx, 8(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 12(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L49 .L45: movq 136(%rsp), %rax subq %fs:40, %rax jne .L50 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L49: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z15tiledConvColGPUPfS_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L45 .L50: call __stack_chk_fail@PLT .cfi_endproc .LFE2086: .size _Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii, .-_Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii .globl _Z15tiledConvColGPUPfS_ii .type _Z15tiledConvColGPUPfS_ii, @function _Z15tiledConvColGPUPfS_ii: .LFB2087: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2087: .size _Z15tiledConvColGPUPfS_ii, .-_Z15tiledConvColGPUPfS_ii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC1: .string "Please specify the image size as execution arguments\n" .align 8 .LC2: .string "Image Width x Height = %i x %i\n\n" .align 8 .LC3: .string "Allocating and initializing host arrays...\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC4: .string "Cuda Malloc Failed\n" .LC7: .string "CPU computation...\n" .LC9: .string "CPU time = %10g seconds\n" .LC10: .string "GPU computation... \n" .LC11: .string "Cuda Error:%s\n" .LC12: .string "GPU time :%f ms.\n" .LC15: .string "sfalma akriveias %f" .text .globl main .type main, @function main: .LFB2059: .cfi_startproc endbr64 pushq %r15 .cfi_def_cfa_offset 16 .cfi_offset 15, -16 pushq %r14 .cfi_def_cfa_offset 24 .cfi_offset 14, -24 pushq %r13 .cfi_def_cfa_offset 32 .cfi_offset 13, -32 pushq %r12 .cfi_def_cfa_offset 40 .cfi_offset 12, -40 pushq %rbp .cfi_def_cfa_offset 48 .cfi_offset 6, -48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset 3, -56 subq $216, %rsp .cfi_def_cfa_offset 272 movl %edi, %ebx movq %rsi, %rbp movq %fs:40, %rax movq %rax, 200(%rsp) xorl %eax, %eax movl $0, %edi call cudaSetDevice@PLT leaq 96(%rsp), %rdi call cudaEventCreate@PLT leaq 104(%rsp), %rdi call cudaEventCreate@PLT cmpl $1, %ebx jle .L88 movq 8(%rbp), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movq %rax, %r14 movq %rax, 32(%rsp) movl %eax, %ecx movl %eax, 12(%rsp) movl %eax, %edx leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $132, %edi call malloc@PLT movq %rax, 16(%rsp) movl %r14d, %r15d imull %r14d, %r15d movslq %r15d, %rbx salq $2, %rbx movq %rbx, %rdi call malloc@PLT movq %rax, %rbp movl %r14d, %eax addl $32, %eax movl %eax, 48(%rsp) imull %eax, %eax movl %eax, 52(%rsp) cltq leaq 0(,%rax,4), %r13 movq %r13, 24(%rsp) movq %r13, %rdi call malloc@PLT movq %rax, %r12 movq %rbx, %rdi call malloc@PLT movq %rax, 40(%rsp) movq %rbx, %rdi call malloc@PLT movq %rax, %r14 movq %r13, %rdi call malloc@PLT movq %rax, 56(%rsp) leaq 72(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 80(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movq %r13, %rdx movl $0, %esi movq 80(%rsp), %rdi call cudaMemset@PLT leaq 88(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT cmpq $0, 72(%rsp) je .L56 cmpq $0, 80(%rsp) je .L56 movq 88(%rsp), %rdi testq %rdi, %rdi je .L56 movq 24(%rsp), %rdx movl $0, %esi call cudaMemset@PLT movl $200, %edi call srand@PLT movq 16(%rsp), %rax movq %rax, %rbx leaq 132(%rax), %r13 .L58: call rand@PLT cltd shrl $28, %edx addl %edx, %eax andl $15, %eax subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 movss %xmm0, (%rbx) addq $4, %rbx cmpq %r13, %rbx jne .L58 testl %r15d, %r15d je .L59 movq %rbp, %rbx leal -1(%r15), %eax leaq 4(%rbp,%rax,4), %r13 .L60: call rand@PLT pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 divss .LC5(%rip), %xmm0 movss %xmm0, 8(%rsp) call rand@PLT pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss .LC6(%rip), %xmm0 addss 8(%rsp), %xmm0 movss %xmm0, (%rbx) addq $4, %rbx cmpq %r13, %rbx jne .L60 .L59: leaq .LC7(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 160(%rsp), %rsi movl $4, %edi call clock_gettime@PLT movl $16, %r9d movq 32(%rsp), %rbx movl %ebx, %r8d movl 12(%rsp), %r13d movl %r13d, %ecx movq 16(%rsp), %rdx movq %rbp, %rsi movq 40(%rsp), %r15 movq %r15, %rdi call _Z17convolutionRowCPUPfS_S_iii movl $16, %r9d movl %ebx, %r8d movl %r13d, %ecx movq 16(%rsp), %rdx movq %r15, %rsi movq %r14, %rdi call _Z20convolutionColumnCPUPfS_S_iii leaq 176(%rsp), %rsi movl $4, %edi call clock_gettime@PLT movq 184(%rsp), %rax subq 168(%rsp), %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 divsd .LC8(%rip), %xmm0 movq 176(%rsp), %rax subq 160(%rsp), %rax pxor %xmm1, %xmm1 cvtsi2sdq %rax, %xmm1 addsd %xmm1, %xmm0 leaq .LC9(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl %ebx, %r15d movl $512, %ecx movl %r13d, 12(%rsp) movl %r13d, %eax cltd idivl %ecx movl %eax, 112(%rsp) movl %ebx, 116(%rsp) movl $1, 120(%rsp) movl $512, 124(%rsp) movl $1, 128(%rsp) movl $1, 132(%rsp) movl $16, %ecx movl %r13d, %eax cltd idivl %ecx movl %eax, 136(%rsp) movl %eax, 140(%rsp) movl $1, 144(%rsp) movl $16, 148(%rsp) movl $16, 152(%rsp) movl $1, 156(%rsp) movl 52(%rsp), %ecx testl %ecx, %ecx je .L61 movq %r12, %rax leal -1(%rcx), %edx leaq 4(%r12,%rdx,4), %rdx .L62: movl $0x00000000, (%rax) addq $4, %rax cmpq %rdx, %rax jne .L62 .L61: movq 32(%rsp), %rax testl %eax, %eax je .L63 movl $32, %r10d movl 48(%rsp), %r9d sall $4, %r9d movl %eax, %esi movl $0, %r8d movl $0, %ecx .L64: movl %r8d, %eax leal 16(%r9), %r11d .L65: leal (%r11,%rax), %edx movl %eax, %edi movss 0(%rbp,%rdi,4), %xmm0 movss %xmm0, (%r12,%rdx,4) addl $1, %eax cmpl %esi, %eax jne .L65 addl $1, %ecx addl %r15d, %r8d addl %r10d, %r9d addl %r15d, %esi cmpl %ecx, %r15d jne .L64 .L63: leaq .LC10(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %r8d movl $0, %ecx movl $132, %edx movq 16(%rsp), %rsi leaq _ZL8d_Filter(%rip), %rdi call cudaMemcpyToSymbol@PLT movl $1, %ecx movq 24(%rsp), %rdx movq %r12, %rsi movq 72(%rsp), %rdi call cudaMemcpy@PLT movl $0, %esi movq 96(%rsp), %rdi call cudaEventRecord@PLT movl 132(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 124(%rsp), %rdx movq 112(%rsp), %rdi movl 120(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L89 .L66: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT testl %eax, %eax jne .L90 movl 156(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 148(%rsp), %rdx movq 136(%rsp), %rdi movl 144(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L91 .L68: call cudaThreadSynchronize@PLT call cudaGetLastError@PLT movl %eax, %r13d testl %eax, %eax jne .L92 movl $0, %esi movq 104(%rsp), %rdi call cudaEventRecord@PLT movl $2, %ecx movq 24(%rsp), %rdx movq 88(%rsp), %rsi movq 56(%rsp), %rbx movq %rbx, %rdi call cudaMemcpy@PLT movq 104(%rsp), %rdi call cudaEventSynchronize@PLT leaq 68(%rsp), %rdi movq 104(%rsp), %rdx movq 96(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 68(%rsp), %xmm0 leaq .LC12(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 32(%rsp), %rax testl %eax, %eax je .L70 movl 48(%rsp), %edx sall $4, %edx movl %eax, %r12d movq %rbp, 24(%rsp) movl %r15d, %ebp movq %rbx, %r15 movl %r13d, %esi jmp .L71 .L88: leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L55 .L56: leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT .L55: movq 200(%rsp), %rax subq %fs:40, %rax jne .L93 movl $0, %eax addq $216, %rsp .cfi_remember_state .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .L89: .cfi_restore_state movl 12(%rsp), %ecx movl %ecx, %edx movq 72(%rsp), %rsi movq 80(%rsp), %rdi call _Z39__device_stub__Z15tiledConvRowGPUPfS_iiPfS_ii jmp .L66 .L90: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L55 .L91: movl 12(%rsp), %ecx movl %ecx, %edx movq 80(%rsp), %rsi movq 88(%rsp), %rdi call _Z39__device_stub__Z15tiledConvColGPUPfS_iiPfS_ii jmp .L68 .L92: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L55 .L72: comiss .LC14(%rip), %xmm0 ja .L94 .L74: addl $1, %ebx cmpl %ebx, %r12d je .L95 .L76: movl %ebx, %edx leal 0(%r13,%rbx), %eax movss (%r14,%rdx,4), %xmm0 subss (%r15,%rax,4), %xmm0 pxor %xmm2, %xmm2 comiss %xmm0, %xmm2 jbe .L72 xorps .LC13(%rip), %xmm0 jmp .L72 .L94: cvtss2sd %xmm0, %xmm0 leaq .LC15(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT jmp .L74 .L95: movl 12(%rsp), %edx movl %ebp, %esi movl 8(%rsp), %ebp addl $1, %esi addl %ebp, %r12d addl $32, %edx cmpl %esi, %ebp je .L86 .L71: movl %r12d, %ebx subl %ebp, %ebx leal 16(%rdx), %r13d movl %ebp, 8(%rsp) movl %edx, 12(%rsp) movl %esi, %ebp jmp .L76 .L86: movq 24(%rsp), %rbp .L70: movq %r14, %rdi call free@PLT movq 40(%rsp), %rdi call free@PLT movq %rbp, %rdi call free@PLT movq 16(%rsp), %rdi call free@PLT movq 88(%rsp), %rdi call cudaFree@PLT movq 80(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT leaq _ZL8d_Filter(%rip), %rdi call cudaFree@PLT call cudaDeviceReset@PLT jmp .L55 .L93: call __stack_chk_fail@PLT .cfi_endproc .LFE2059: .size main, .-main .section .rodata.str1.1 .LC16: .string "_Z15tiledConvColGPUPfS_ii" .LC17: .string "_Z15tiledConvRowGPUPfS_ii" .LC18: .string "d_Filter" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2089: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC16(%rip), %rdx movq %rdx, %rcx leaq _Z15tiledConvColGPUPfS_ii(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC17(%rip), %rdx movq %rdx, %rcx leaq _Z15tiledConvRowGPUPfS_ii(%rip), %rsi movq %rbx, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $1 .cfi_def_cfa_offset 32 movl $132, %r9d movl $0, %r8d leaq .LC18(%rip), %rdx movq %rdx, %rcx leaq _ZL8d_Filter(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2089: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .local _ZL8d_Filter .comm _ZL8d_Filter,132,32 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC5: .long 1258324097 .align 4 .LC6: .long 805306368 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC8: .long 0 .long 1104006501 .section .rodata.cst16,"aM",@progbits,16 .align 16 .LC13: .long -2147483648 .long 0 .long 0 .long 0 .section .rodata.cst4 .align 4 .LC14: .long 1086324736 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <time.h> #include <stdio.h> #include <stdlib.h> //unsigned int radius; #define radius 16 #define FILTER_LENGTH (2 * radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 6 #define tileRH 1 #define tileRW 512 #define tileCH 16 #define tileCW 16 typedef float numid; __constant__ numid d_Filter[FILTER_LENGTH]; __global__ void tiledConvRowGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileRH] [tileRW + 2 * radius]; if(tx-radius<0){ //Near Left Bounds ShMemory[ty][tx] = d_Src[(row+radius) * newImageW + col]; } ShMemory[ty][tx+radius] = d_Src[(row+radius) * newImageW + col + radius]; //Center if(tx >= (tileRW - radius)){ ShMemory[ty] [tx + 2 * radius] = d_Src[(row+radius) * newImageW + col + 2 * radius]; //Near Right Bounds } __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[ty][tx+k+radius] * d_Filter[radius - k]; } d_Dst[(row+radius) * newImageW + col+radius] = sum; } __global__ void tiledConvColGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileCH + 2 * radius][ tileCW]; if(ty-radius<0){ //Upper Bounds ShMemory[ty] [tx] = d_Src[row * newImageW + col + radius]; } ShMemory[ty + radius][ tx ] = d_Src[(row + radius) * newImageW + col + radius ]; //Center ShMemory[ty + 2 * radius ][ tx ] = d_Src[(row + 2* radius) * newImageW + col + radius ]; //Lower Bounds __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[(ty + k + radius)][tx] * d_Filter[radius - k]; } d_Dst[ (row + radius) * newImageW + col + radius] = sum; } //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { cudaSetDevice(0); numid *h_Filter, *h_Input, *h_PadInput, *h_Buffer, *h_OutputCPU, *d_Input, *d_Buffer, *d_OutputGPU, *result; struct timespec tv1, tv2; cudaEvent_t start; cudaEvent_t stop; cudaEventCreate(&start); cudaEventCreate(&stop); int imageW; int imageH; unsigned int i,j; if(argc<2){ printf("Please specify the image size as execution arguments\n"); return 0; } imageW=atoi(argv[1]); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. // printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); // scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (numid *)malloc(FILTER_LENGTH * sizeof(numid)); h_Input = (numid *)malloc(imageW * imageH * sizeof(numid)); h_PadInput = (numid *)malloc((imageW+radius*2 )*(2*radius+ imageH) * sizeof(numid)) ; h_Buffer = (numid *)malloc(imageW * imageH * sizeof(numid)); h_OutputCPU = (numid *)malloc(imageW * imageH * sizeof(numid)); result = (numid *)malloc((imageW+2*radius) * (imageH+2*radius) * sizeof(numid)); cudaMalloc(&d_Input,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMalloc(&d_Buffer,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMemset(d_Buffer,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); cudaMalloc(&d_OutputGPU,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); if(d_Filter==NULL || d_Input==NULL || d_Buffer==NULL || d_OutputGPU==NULL){ printf("Cuda Malloc Failed\n"); return 0; } cudaMemset(d_OutputGPU,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); // to 'h_Filter' apotelei to filtro me to opoio ginetai to convolution kai // arxikopoieitai tuxaia. To 'h_Input' einai h eikona panw sthn opoia ginetai // to convolution kai arxikopoieitai kai auth tuxaia. srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (numid)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (numid)rand() / ((numid)RAND_MAX / 255) + (numid)rand() / (numid)RAND_MAX; } // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); clock_gettime(CLOCK_MONOTONIC_RAW, &tv1); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, radius); // convolution kata sthles clock_gettime(CLOCK_MONOTONIC_RAW, &tv2); printf ("CPU time = %10g seconds\n", (double) (tv2.tv_nsec - tv1.tv_nsec) / 1000000000.0 + (double) (tv2.tv_sec - tv1.tv_sec)); dim3 dimGridR(imageW/tileRW,imageH/tileRH); dim3 dimBlockR(tileRW,tileRH); dim3 dimGridC(imageW/tileCW,imageH/tileCH); dim3 dimBlockC(tileCW,tileCH); for(i=0;i<(imageW+2*radius)*(imageW+2*radius);i++){ h_PadInput[i]=0; } for(i=0;i<imageW;i++){ for(j=0;j<imageW;j++){ h_PadInput[(i+radius)*(2*radius+imageW)+j+radius]=h_Input[i*imageW+j]; } } printf("GPU computation... \n"); cudaMemcpyToSymbol(d_Filter, h_Filter,FILTER_LENGTH*sizeof(numid)); cudaMemcpy(d_Input,h_PadInput,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),cudaMemcpyHostToDevice); cudaEventRecord(start,0); tiledConvRowGPU <<< dimGridR, dimBlockR >>>(d_Buffer, d_Input, imageW, imageH); cudaThreadSynchronize(); cudaError_t error=cudaGetLastError(); if(error!=cudaSuccess){ printf("Cuda Error:%s\n",cudaGetErrorString(error)); cudaDeviceReset(); return 0; } tiledConvColGPU <<< dimGridC, dimBlockC >>>(d_OutputGPU, d_Buffer , imageW, imageH); cudaThreadSynchronize(); error=cudaGetLastError(); if(error!=cudaSuccess){ printf("Cuda Error:%s\n",cudaGetErrorString(error)); cudaDeviceReset(); return 0; } cudaEventRecord(stop,0); cudaMemcpy(result,d_OutputGPU,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),cudaMemcpyDeviceToHost); float elapsed; cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed,start,stop); printf("GPU time :%f ms.\n",elapsed); // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i=0;i<imageW;i++){ for(j=0;j<imageH;j++){ numid diff= h_OutputCPU[i*imageW+j]-result[(i+radius)*(imageW+2*radius)+j+radius]; if(ABS(diff)>accuracy){ printf("sfalma akriveias %f",ABS(diff)); } } } // free all the allocated memory free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); cudaFree(d_OutputGPU); cudaFree(d_Buffer); cudaFree(d_Input); cudaFree(d_Filter); cudaDeviceReset(); return 0; }
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <hip/hip_runtime.h> #include <time.h> #include <stdio.h> #include <stdlib.h> //unsigned int radius; #define radius 16 #define FILTER_LENGTH (2 * radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 6 #define tileRH 1 #define tileRW 512 #define tileCH 16 #define tileCW 16 typedef float numid; __constant__ numid d_Filter[FILTER_LENGTH]; __global__ void tiledConvRowGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileRH] [tileRW + 2 * radius]; if(tx-radius<0){ //Near Left Bounds ShMemory[ty][tx] = d_Src[(row+radius) * newImageW + col]; } ShMemory[ty][tx+radius] = d_Src[(row+radius) * newImageW + col + radius]; //Center if(tx >= (tileRW - radius)){ ShMemory[ty] [tx + 2 * radius] = d_Src[(row+radius) * newImageW + col + 2 * radius]; //Near Right Bounds } __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[ty][tx+k+radius] * d_Filter[radius - k]; } d_Dst[(row+radius) * newImageW + col+radius] = sum; } __global__ void tiledConvColGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileCH + 2 * radius][ tileCW]; if(ty-radius<0){ //Upper Bounds ShMemory[ty] [tx] = d_Src[row * newImageW + col + radius]; } ShMemory[ty + radius][ tx ] = d_Src[(row + radius) * newImageW + col + radius ]; //Center ShMemory[ty + 2 * radius ][ tx ] = d_Src[(row + 2* radius) * newImageW + col + radius ]; //Lower Bounds __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[(ty + k + radius)][tx] * d_Filter[radius - k]; } d_Dst[ (row + radius) * newImageW + col + radius] = sum; } //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { hipSetDevice(0); numid *h_Filter, *h_Input, *h_PadInput, *h_Buffer, *h_OutputCPU, *d_Input, *d_Buffer, *d_OutputGPU, *result; struct timespec tv1, tv2; hipEvent_t start; hipEvent_t stop; hipEventCreate(&start); hipEventCreate(&stop); int imageW; int imageH; unsigned int i,j; if(argc<2){ printf("Please specify the image size as execution arguments\n"); return 0; } imageW=atoi(argv[1]); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. // printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); // scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (numid *)malloc(FILTER_LENGTH * sizeof(numid)); h_Input = (numid *)malloc(imageW * imageH * sizeof(numid)); h_PadInput = (numid *)malloc((imageW+radius*2 )*(2*radius+ imageH) * sizeof(numid)) ; h_Buffer = (numid *)malloc(imageW * imageH * sizeof(numid)); h_OutputCPU = (numid *)malloc(imageW * imageH * sizeof(numid)); result = (numid *)malloc((imageW+2*radius) * (imageH+2*radius) * sizeof(numid)); hipMalloc(&d_Input,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMalloc(&d_Buffer,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMemset(d_Buffer,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMalloc(&d_OutputGPU,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); if(d_Filter==NULL || d_Input==NULL || d_Buffer==NULL || d_OutputGPU==NULL){ printf("Cuda Malloc Failed\n"); return 0; } hipMemset(d_OutputGPU,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); // to 'h_Filter' apotelei to filtro me to opoio ginetai to convolution kai // arxikopoieitai tuxaia. To 'h_Input' einai h eikona panw sthn opoia ginetai // to convolution kai arxikopoieitai kai auth tuxaia. srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (numid)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (numid)rand() / ((numid)RAND_MAX / 255) + (numid)rand() / (numid)RAND_MAX; } // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); clock_gettime(CLOCK_MONOTONIC_RAW, &tv1); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, radius); // convolution kata sthles clock_gettime(CLOCK_MONOTONIC_RAW, &tv2); printf ("CPU time = %10g seconds\n", (double) (tv2.tv_nsec - tv1.tv_nsec) / 1000000000.0 + (double) (tv2.tv_sec - tv1.tv_sec)); dim3 dimGridR(imageW/tileRW,imageH/tileRH); dim3 dimBlockR(tileRW,tileRH); dim3 dimGridC(imageW/tileCW,imageH/tileCH); dim3 dimBlockC(tileCW,tileCH); for(i=0;i<(imageW+2*radius)*(imageW+2*radius);i++){ h_PadInput[i]=0; } for(i=0;i<imageW;i++){ for(j=0;j<imageW;j++){ h_PadInput[(i+radius)*(2*radius+imageW)+j+radius]=h_Input[i*imageW+j]; } } printf("GPU computation... \n"); hipMemcpyToSymbol(HIP_SYMBOL(d_Filter), h_Filter,FILTER_LENGTH*sizeof(numid)); hipMemcpy(d_Input,h_PadInput,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),hipMemcpyHostToDevice); hipEventRecord(start,0); tiledConvRowGPU <<< dimGridR, dimBlockR >>>(d_Buffer, d_Input, imageW, imageH); hipDeviceSynchronize(); hipError_t error=hipGetLastError(); if(error!=hipSuccess){ printf("Cuda Error:%s\n",hipGetErrorString(error)); hipDeviceReset(); return 0; } tiledConvColGPU <<< dimGridC, dimBlockC >>>(d_OutputGPU, d_Buffer , imageW, imageH); hipDeviceSynchronize(); error=hipGetLastError(); if(error!=hipSuccess){ printf("Cuda Error:%s\n",hipGetErrorString(error)); hipDeviceReset(); return 0; } hipEventRecord(stop,0); hipMemcpy(result,d_OutputGPU,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),hipMemcpyDeviceToHost); float elapsed; hipEventSynchronize(stop); hipEventElapsedTime(&elapsed,start,stop); printf("GPU time :%f ms.\n",elapsed); // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i=0;i<imageW;i++){ for(j=0;j<imageH;j++){ numid diff= h_OutputCPU[i*imageW+j]-result[(i+radius)*(imageW+2*radius)+j+radius]; if(ABS(diff)>accuracy){ printf("sfalma akriveias %f",ABS(diff)); } } } // free all the allocated memory free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); hipFree(d_OutputGPU); hipFree(d_Buffer); hipFree(d_Input); hipFree(d_Filter); hipDeviceReset(); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <hip/hip_runtime.h> #include <time.h> #include <stdio.h> #include <stdlib.h> //unsigned int radius; #define radius 16 #define FILTER_LENGTH (2 * radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 6 #define tileRH 1 #define tileRW 512 #define tileCH 16 #define tileCW 16 typedef float numid; __constant__ numid d_Filter[FILTER_LENGTH]; __global__ void tiledConvRowGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileRH] [tileRW + 2 * radius]; if(tx-radius<0){ //Near Left Bounds ShMemory[ty][tx] = d_Src[(row+radius) * newImageW + col]; } ShMemory[ty][tx+radius] = d_Src[(row+radius) * newImageW + col + radius]; //Center if(tx >= (tileRW - radius)){ ShMemory[ty] [tx + 2 * radius] = d_Src[(row+radius) * newImageW + col + 2 * radius]; //Near Right Bounds } __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[ty][tx+k+radius] * d_Filter[radius - k]; } d_Dst[(row+radius) * newImageW + col+radius] = sum; } __global__ void tiledConvColGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileCH + 2 * radius][ tileCW]; if(ty-radius<0){ //Upper Bounds ShMemory[ty] [tx] = d_Src[row * newImageW + col + radius]; } ShMemory[ty + radius][ tx ] = d_Src[(row + radius) * newImageW + col + radius ]; //Center ShMemory[ty + 2 * radius ][ tx ] = d_Src[(row + 2* radius) * newImageW + col + radius ]; //Lower Bounds __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[(ty + k + radius)][tx] * d_Filter[radius - k]; } d_Dst[ (row + radius) * newImageW + col + radius] = sum; } //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { hipSetDevice(0); numid *h_Filter, *h_Input, *h_PadInput, *h_Buffer, *h_OutputCPU, *d_Input, *d_Buffer, *d_OutputGPU, *result; struct timespec tv1, tv2; hipEvent_t start; hipEvent_t stop; hipEventCreate(&start); hipEventCreate(&stop); int imageW; int imageH; unsigned int i,j; if(argc<2){ printf("Please specify the image size as execution arguments\n"); return 0; } imageW=atoi(argv[1]); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. // printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); // scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (numid *)malloc(FILTER_LENGTH * sizeof(numid)); h_Input = (numid *)malloc(imageW * imageH * sizeof(numid)); h_PadInput = (numid *)malloc((imageW+radius*2 )*(2*radius+ imageH) * sizeof(numid)) ; h_Buffer = (numid *)malloc(imageW * imageH * sizeof(numid)); h_OutputCPU = (numid *)malloc(imageW * imageH * sizeof(numid)); result = (numid *)malloc((imageW+2*radius) * (imageH+2*radius) * sizeof(numid)); hipMalloc(&d_Input,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMalloc(&d_Buffer,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMemset(d_Buffer,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMalloc(&d_OutputGPU,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); if(d_Filter==NULL || d_Input==NULL || d_Buffer==NULL || d_OutputGPU==NULL){ printf("Cuda Malloc Failed\n"); return 0; } hipMemset(d_OutputGPU,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); // to 'h_Filter' apotelei to filtro me to opoio ginetai to convolution kai // arxikopoieitai tuxaia. To 'h_Input' einai h eikona panw sthn opoia ginetai // to convolution kai arxikopoieitai kai auth tuxaia. srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (numid)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (numid)rand() / ((numid)RAND_MAX / 255) + (numid)rand() / (numid)RAND_MAX; } // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); clock_gettime(CLOCK_MONOTONIC_RAW, &tv1); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, radius); // convolution kata sthles clock_gettime(CLOCK_MONOTONIC_RAW, &tv2); printf ("CPU time = %10g seconds\n", (double) (tv2.tv_nsec - tv1.tv_nsec) / 1000000000.0 + (double) (tv2.tv_sec - tv1.tv_sec)); dim3 dimGridR(imageW/tileRW,imageH/tileRH); dim3 dimBlockR(tileRW,tileRH); dim3 dimGridC(imageW/tileCW,imageH/tileCH); dim3 dimBlockC(tileCW,tileCH); for(i=0;i<(imageW+2*radius)*(imageW+2*radius);i++){ h_PadInput[i]=0; } for(i=0;i<imageW;i++){ for(j=0;j<imageW;j++){ h_PadInput[(i+radius)*(2*radius+imageW)+j+radius]=h_Input[i*imageW+j]; } } printf("GPU computation... \n"); hipMemcpyToSymbol(HIP_SYMBOL(d_Filter), h_Filter,FILTER_LENGTH*sizeof(numid)); hipMemcpy(d_Input,h_PadInput,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),hipMemcpyHostToDevice); hipEventRecord(start,0); tiledConvRowGPU <<< dimGridR, dimBlockR >>>(d_Buffer, d_Input, imageW, imageH); hipDeviceSynchronize(); hipError_t error=hipGetLastError(); if(error!=hipSuccess){ printf("Cuda Error:%s\n",hipGetErrorString(error)); hipDeviceReset(); return 0; } tiledConvColGPU <<< dimGridC, dimBlockC >>>(d_OutputGPU, d_Buffer , imageW, imageH); hipDeviceSynchronize(); error=hipGetLastError(); if(error!=hipSuccess){ printf("Cuda Error:%s\n",hipGetErrorString(error)); hipDeviceReset(); return 0; } hipEventRecord(stop,0); hipMemcpy(result,d_OutputGPU,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),hipMemcpyDeviceToHost); float elapsed; hipEventSynchronize(stop); hipEventElapsedTime(&elapsed,start,stop); printf("GPU time :%f ms.\n",elapsed); // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i=0;i<imageW;i++){ for(j=0;j<imageH;j++){ numid diff= h_OutputCPU[i*imageW+j]-result[(i+radius)*(imageW+2*radius)+j+radius]; if(ABS(diff)>accuracy){ printf("sfalma akriveias %f",ABS(diff)); } } } // free all the allocated memory free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); hipFree(d_OutputGPU); hipFree(d_Buffer); hipFree(d_Input); hipFree(d_Filter); hipDeviceReset(); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15tiledConvRowGPUPfS_ii .globl _Z15tiledConvRowGPUPfS_ii .p2align 8 .type _Z15tiledConvRowGPUPfS_ii,@function _Z15tiledConvRowGPUPfS_ii: s_clause 0x2 s_load_b32 s4, s[0:1], 0x24 s_load_b32 s5, s[0:1], 0x10 s_load_b64 s[2:3], s[0:1], 0x8 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s6, s4, 16 s_and_b32 s4, s4, 0xffff v_mad_u64_u32 v[2:3], null, s15, s6, v[1:2] v_mad_u64_u32 v[3:4], null, s14, s4, v[0:1] s_add_i32 s4, s5, 32 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 16, v0 s_cbranch_execz .LBB0_2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v6, 16, v2 v_mad_u64_u32 v[4:5], null, v6, s4, v[3:4] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v5, 31, v4 v_lshlrev_b64 v[4:5], 2, v[4:5] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v4, vcc_lo, s2, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off v_lshlrev_b32_e32 v5, 2, v0 s_delay_alu instid0(VALU_DEP_1) v_mad_u32_u24 v5, v1, 0x880, v5 s_waitcnt vmcnt(0) ds_store_b32 v5, v4 .LBB0_2: s_or_b32 exec_lo, exec_lo, s5 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v2, 16, v2 v_mad_u64_u32 v[4:5], null, v2, s4, v[3:4] s_mov_b32 s4, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v2, 16, v4 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[5:6], 2, v[2:3] v_add_co_u32 v5, vcc_lo, s2, v5 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo global_load_b32 v5, v[5:6], off v_mul_u32_u24_e32 v6, 0x880, v1 v_lshl_add_u32 v6, v0, 2, v6 s_waitcnt vmcnt(0) ds_store_b32 v6, v5 offset:64 v_cmpx_lt_u32_e32 0x1ef, v0 s_cbranch_execz .LBB0_4 v_ashrrev_i32_e32 v5, 31, v4 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[4:5], 2, v[4:5] v_add_co_u32 v4, vcc_lo, s2, v4 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off offset:128 s_waitcnt vmcnt(0) ds_store_b32 v6, v4 offset:128 .LBB0_4: s_or_b32 exec_lo, exec_lo, s4 v_lshlrev_b32_e32 v0, 2, v0 s_mov_b32 s4, 0 s_getpc_b64 s[2:3] s_add_u32 s2, s2, d_Filter@rel32@lo+132 s_addc_u32 s3, s3, d_Filter@rel32@hi+140 s_waitcnt lgkmcnt(0) s_barrier v_mad_u32_u24 v1, v1, 0x880, v0 v_mov_b32_e32 v0, 0 buffer_gl0_inv .LBB0_5: v_add_nc_u32_e32 v4, s4, v1 s_load_b32 s5, s[2:3], 0x0 s_add_i32 s4, s4, 4 s_add_u32 s2, s2, -4 s_addc_u32 s3, s3, -1 ds_load_b32 v4, v4 s_cmpk_lg_i32 s4, 0x84 s_waitcnt lgkmcnt(0) v_fmac_f32_e32 v0, s5, v4 s_cbranch_scc1 .LBB0_5 s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b64 v[1:2], 2, v[2:3] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v1, vcc_lo, s0, v1 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo global_store_b32 v[1:2], v0, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15tiledConvRowGPUPfS_ii .amdhsa_group_segment_fixed_size 2176 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 7 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z15tiledConvRowGPUPfS_ii, .Lfunc_end0-_Z15tiledConvRowGPUPfS_ii .section .AMDGPU.csdata,"",@progbits .text .protected _Z15tiledConvColGPUPfS_ii .globl _Z15tiledConvColGPUPfS_ii .p2align 8 .type _Z15tiledConvColGPUPfS_ii,@function _Z15tiledConvColGPUPfS_ii: s_clause 0x2 s_load_b32 s4, s[0:1], 0x24 s_load_b32 s5, s[0:1], 0x10 s_load_b64 s[2:3], s[0:1], 0x8 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s6, s4, 16 s_and_b32 s4, s4, 0xffff v_mad_u64_u32 v[2:3], null, s15, s6, v[1:2] v_mad_u64_u32 v[3:4], null, s14, s4, v[0:1] s_add_i32 s4, s5, 32 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 16, v1 s_cbranch_execz .LBB1_2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[4:5], null, v2, s4, v[3:4] v_ashrrev_i32_e32 v5, 31, v4 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[4:5], 2, v[4:5] v_add_co_u32 v4, vcc_lo, s2, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off offset:64 v_lshlrev_b32_e32 v5, 2, v0 v_lshl_add_u32 v5, v1, 6, v5 s_waitcnt vmcnt(0) ds_store_b32 v5, v4 .LBB1_2: s_or_b32 exec_lo, exec_lo, s5 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v4, 16, v2 v_add_nc_u32_e32 v6, 32, v2 v_lshlrev_b32_e32 v0, 2, v0 v_mul_lo_u32 v4, v4, s4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_lshl_add_u32 v1, v1, 6, v0 v_mov_b32_e32 v0, 0 v_add3_u32 v2, v3, v4, 16 v_mad_u64_u32 v[4:5], null, v6, s4, v[3:4] s_mov_b32 s4, 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v3, 31, v2 v_ashrrev_i32_e32 v5, 31, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[6:7], 2, v[2:3] v_lshlrev_b64 v[4:5], 2, v[4:5] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v6, vcc_lo, s2, v6 v_add_co_ci_u32_e32 v7, vcc_lo, s3, v7, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v4, vcc_lo, s2, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo s_getpc_b64 s[2:3] s_add_u32 s2, s2, d_Filter@rel32@lo+132 s_addc_u32 s3, s3, d_Filter@rel32@hi+140 s_clause 0x1 global_load_b32 v6, v[6:7], off global_load_b32 v4, v[4:5], off offset:64 s_waitcnt vmcnt(0) ds_store_2addr_stride64_b32 v1, v6, v4 offset0:4 offset1:8 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB1_3: v_add_nc_u32_e32 v4, s4, v1 s_load_b32 s5, s[2:3], 0x0 s_add_i32 s4, s4, 64 s_add_u32 s2, s2, -4 s_addc_u32 s3, s3, -1 ds_load_b32 v4, v4 s_cmpk_lg_i32 s4, 0x840 s_waitcnt lgkmcnt(0) v_fmac_f32_e32 v0, s5, v4 s_cbranch_scc1 .LBB1_3 s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b64 v[1:2], 2, v[2:3] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v1, vcc_lo, s0, v1 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo global_store_b32 v[1:2], v0, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15tiledConvColGPUPfS_ii .amdhsa_group_segment_fixed_size 3072 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z15tiledConvColGPUPfS_ii, .Lfunc_end1-_Z15tiledConvColGPUPfS_ii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .protected d_Filter .type d_Filter,@object .section .bss,"aw",@nobits .globl d_Filter .p2align 4, 0x0 d_Filter: .zero 132 .size d_Filter, 132 .type __hip_cuid_,@object .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym d_Filter .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: by_value - .offset: 20 .size: 4 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 2176 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15tiledConvRowGPUPfS_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15tiledConvRowGPUPfS_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 7 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: by_value - .offset: 20 .size: 4 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 3072 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15tiledConvColGPUPfS_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15tiledConvColGPUPfS_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <hip/hip_runtime.h> #include <time.h> #include <stdio.h> #include <stdlib.h> //unsigned int radius; #define radius 16 #define FILTER_LENGTH (2 * radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 6 #define tileRH 1 #define tileRW 512 #define tileCH 16 #define tileCW 16 typedef float numid; __constant__ numid d_Filter[FILTER_LENGTH]; __global__ void tiledConvRowGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileRH] [tileRW + 2 * radius]; if(tx-radius<0){ //Near Left Bounds ShMemory[ty][tx] = d_Src[(row+radius) * newImageW + col]; } ShMemory[ty][tx+radius] = d_Src[(row+radius) * newImageW + col + radius]; //Center if(tx >= (tileRW - radius)){ ShMemory[ty] [tx + 2 * radius] = d_Src[(row+radius) * newImageW + col + 2 * radius]; //Near Right Bounds } __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[ty][tx+k+radius] * d_Filter[radius - k]; } d_Dst[(row+radius) * newImageW + col+radius] = sum; } __global__ void tiledConvColGPU(numid *d_Dst, numid *d_Src, int imageW, int imageH){ int k; numid sum = 0; int tx=threadIdx.x; int ty=threadIdx.y; int bx=blockIdx.x; int by=blockIdx.y; int row = blockDim.y*by + ty ; int col = blockDim.x*bx + tx; int newImageW = imageW + radius * 2; __shared__ numid ShMemory[tileCH + 2 * radius][ tileCW]; if(ty-radius<0){ //Upper Bounds ShMemory[ty] [tx] = d_Src[row * newImageW + col + radius]; } ShMemory[ty + radius][ tx ] = d_Src[(row + radius) * newImageW + col + radius ]; //Center ShMemory[ty + 2 * radius ][ tx ] = d_Src[(row + 2* radius) * newImageW + col + radius ]; //Lower Bounds __syncthreads(); for (k = -radius; k <= radius; k++) { sum += ShMemory[(ty + k + radius)][tx] * d_Filter[radius - k]; } d_Dst[ (row + radius) * newImageW + col + radius] = sum; } //////////////////////////////////////////////////////////////////////////////// // Reference row convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionRowCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < imageW) { sum += h_Src[y * imageW + d] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Reference column convolution filter //////////////////////////////////////////////////////////////////////////////// void convolutionColumnCPU(numid *h_Dst, numid *h_Src, numid *h_Filter, int imageW, int imageH, int filterR) { int x, y, k; for (y = 0; y < imageH; y++) { for (x = 0; x < imageW; x++) { numid sum = 0; for (k = -filterR; k <= filterR; k++) { int d = y + k; if (d >= 0 && d < imageH) { sum += h_Src[d * imageW + x] * h_Filter[filterR - k]; } h_Dst[y * imageW + x] = sum; } } } } //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { hipSetDevice(0); numid *h_Filter, *h_Input, *h_PadInput, *h_Buffer, *h_OutputCPU, *d_Input, *d_Buffer, *d_OutputGPU, *result; struct timespec tv1, tv2; hipEvent_t start; hipEvent_t stop; hipEventCreate(&start); hipEventCreate(&stop); int imageW; int imageH; unsigned int i,j; if(argc<2){ printf("Please specify the image size as execution arguments\n"); return 0; } imageW=atoi(argv[1]); // Ta imageW, imageH ta dinei o xrhsths kai thewroume oti einai isa, // dhladh imageW = imageH = N, opou to N to dinei o xrhsths. // Gia aplothta thewroume tetragwnikes eikones. // printf("Enter image size. Should be a power of two and greater than %d : ", FILTER_LENGTH); // scanf("%d", &imageW); imageH = imageW; printf("Image Width x Height = %i x %i\n\n", imageW, imageH); printf("Allocating and initializing host arrays...\n"); // Tha htan kalh idea na elegxete kai to apotelesma twn malloc... h_Filter = (numid *)malloc(FILTER_LENGTH * sizeof(numid)); h_Input = (numid *)malloc(imageW * imageH * sizeof(numid)); h_PadInput = (numid *)malloc((imageW+radius*2 )*(2*radius+ imageH) * sizeof(numid)) ; h_Buffer = (numid *)malloc(imageW * imageH * sizeof(numid)); h_OutputCPU = (numid *)malloc(imageW * imageH * sizeof(numid)); result = (numid *)malloc((imageW+2*radius) * (imageH+2*radius) * sizeof(numid)); hipMalloc(&d_Input,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMalloc(&d_Buffer,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMemset(d_Buffer,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); hipMalloc(&d_OutputGPU,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); if(d_Filter==NULL || d_Input==NULL || d_Buffer==NULL || d_OutputGPU==NULL){ printf("Cuda Malloc Failed\n"); return 0; } hipMemset(d_OutputGPU,0,(imageW+2*radius)*(imageH+2*radius)*sizeof(numid)); // to 'h_Filter' apotelei to filtro me to opoio ginetai to convolution kai // arxikopoieitai tuxaia. To 'h_Input' einai h eikona panw sthn opoia ginetai // to convolution kai arxikopoieitai kai auth tuxaia. srand(200); for (i = 0; i < FILTER_LENGTH; i++) { h_Filter[i] = (numid)(rand() % 16); } for (i = 0; i < imageW * imageH; i++) { h_Input[i] = (numid)rand() / ((numid)RAND_MAX / 255) + (numid)rand() / (numid)RAND_MAX; } // To parakatw einai to kommati pou ekteleitai sthn CPU kai me vash auto prepei na ginei h sugrish me thn GPU. printf("CPU computation...\n"); clock_gettime(CLOCK_MONOTONIC_RAW, &tv1); convolutionRowCPU(h_Buffer, h_Input, h_Filter, imageW, imageH, radius); // convolution kata grammes convolutionColumnCPU(h_OutputCPU, h_Buffer, h_Filter, imageW, imageH, radius); // convolution kata sthles clock_gettime(CLOCK_MONOTONIC_RAW, &tv2); printf ("CPU time = %10g seconds\n", (double) (tv2.tv_nsec - tv1.tv_nsec) / 1000000000.0 + (double) (tv2.tv_sec - tv1.tv_sec)); dim3 dimGridR(imageW/tileRW,imageH/tileRH); dim3 dimBlockR(tileRW,tileRH); dim3 dimGridC(imageW/tileCW,imageH/tileCH); dim3 dimBlockC(tileCW,tileCH); for(i=0;i<(imageW+2*radius)*(imageW+2*radius);i++){ h_PadInput[i]=0; } for(i=0;i<imageW;i++){ for(j=0;j<imageW;j++){ h_PadInput[(i+radius)*(2*radius+imageW)+j+radius]=h_Input[i*imageW+j]; } } printf("GPU computation... \n"); hipMemcpyToSymbol(HIP_SYMBOL(d_Filter), h_Filter,FILTER_LENGTH*sizeof(numid)); hipMemcpy(d_Input,h_PadInput,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),hipMemcpyHostToDevice); hipEventRecord(start,0); tiledConvRowGPU <<< dimGridR, dimBlockR >>>(d_Buffer, d_Input, imageW, imageH); hipDeviceSynchronize(); hipError_t error=hipGetLastError(); if(error!=hipSuccess){ printf("Cuda Error:%s\n",hipGetErrorString(error)); hipDeviceReset(); return 0; } tiledConvColGPU <<< dimGridC, dimBlockC >>>(d_OutputGPU, d_Buffer , imageW, imageH); hipDeviceSynchronize(); error=hipGetLastError(); if(error!=hipSuccess){ printf("Cuda Error:%s\n",hipGetErrorString(error)); hipDeviceReset(); return 0; } hipEventRecord(stop,0); hipMemcpy(result,d_OutputGPU,(imageH+2*radius)*(imageW+2*radius)*sizeof(numid),hipMemcpyDeviceToHost); float elapsed; hipEventSynchronize(stop); hipEventElapsedTime(&elapsed,start,stop); printf("GPU time :%f ms.\n",elapsed); // Kanete h sugrish anamesa se GPU kai CPU kai an estw kai kapoio apotelesma xeperna thn akriveia // pou exoume orisei, tote exoume sfalma kai mporoume endexomenws na termatisoume to programma mas for(i=0;i<imageW;i++){ for(j=0;j<imageH;j++){ numid diff= h_OutputCPU[i*imageW+j]-result[(i+radius)*(imageW+2*radius)+j+radius]; if(ABS(diff)>accuracy){ printf("sfalma akriveias %f",ABS(diff)); } } } // free all the allocated memory free(h_OutputCPU); free(h_Buffer); free(h_Input); free(h_Filter); hipFree(d_OutputGPU); hipFree(d_Buffer); hipFree(d_Input); hipFree(d_Filter); hipDeviceReset(); return 0; }
.text .file "quest32.hip" .globl _Z30__device_stub__tiledConvRowGPUPfS_ii # -- Begin function _Z30__device_stub__tiledConvRowGPUPfS_ii .p2align 4, 0x90 .type _Z30__device_stub__tiledConvRowGPUPfS_ii,@function _Z30__device_stub__tiledConvRowGPUPfS_ii: # @_Z30__device_stub__tiledConvRowGPUPfS_ii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movl %edx, 12(%rsp) movl %ecx, 8(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 12(%rsp), %rax movq %rax, 96(%rsp) leaq 8(%rsp), %rax movq %rax, 104(%rsp) leaq 48(%rsp), %rdi leaq 32(%rsp), %rsi leaq 24(%rsp), %rdx leaq 16(%rsp), %rcx callq __hipPopCallConfiguration movq 48(%rsp), %rsi movl 56(%rsp), %edx movq 32(%rsp), %rcx movl 40(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z15tiledConvRowGPUPfS_ii, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end0: .size _Z30__device_stub__tiledConvRowGPUPfS_ii, .Lfunc_end0-_Z30__device_stub__tiledConvRowGPUPfS_ii .cfi_endproc # -- End function .globl _Z30__device_stub__tiledConvColGPUPfS_ii # -- Begin function _Z30__device_stub__tiledConvColGPUPfS_ii .p2align 4, 0x90 .type _Z30__device_stub__tiledConvColGPUPfS_ii,@function _Z30__device_stub__tiledConvColGPUPfS_ii: # @_Z30__device_stub__tiledConvColGPUPfS_ii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movl %edx, 12(%rsp) movl %ecx, 8(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 12(%rsp), %rax movq %rax, 96(%rsp) leaq 8(%rsp), %rax movq %rax, 104(%rsp) leaq 48(%rsp), %rdi leaq 32(%rsp), %rsi leaq 24(%rsp), %rdx leaq 16(%rsp), %rcx callq __hipPopCallConfiguration movq 48(%rsp), %rsi movl 56(%rsp), %edx movq 32(%rsp), %rcx movl 40(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z15tiledConvColGPUPfS_ii, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end1: .size _Z30__device_stub__tiledConvColGPUPfS_ii, .Lfunc_end1-_Z30__device_stub__tiledConvColGPUPfS_ii .cfi_endproc # -- End function .globl _Z17convolutionRowCPUPfS_S_iii # -- Begin function _Z17convolutionRowCPUPfS_S_iii .p2align 4, 0x90 .type _Z17convolutionRowCPUPfS_S_iii,@function _Z17convolutionRowCPUPfS_S_iii: # @_Z17convolutionRowCPUPfS_S_iii .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq %rdi, -16(%rsp) # 8-byte Spill testl %r8d, %r8d jle .LBB2_11 # %bb.1: # %.preheader.lr.ph movq %rdx, %rax movl %r9d, %edx negl %edx movq %rdx, -24(%rsp) # 8-byte Spill movslq %edx, %rdx movslq %r9d, %r10 movslq %ecx, %r14 movl %r8d, %edi movq %rdi, -8(%rsp) # 8-byte Spill movl %r14d, %ebx leaq (,%r10,4), %rdi leaq (,%rdx,4), %r11 subq %r11, %rdi addq %rdi, %rax leaq (%rsi,%rdx,4), %rsi movq %r14, -32(%rsp) # 8-byte Spill leaq (,%r14,4), %r14 addl %r10d, %r10d orq $1, %r10 xorl %r15d, %r15d jmp .LBB2_2 .p2align 4, 0x90 .LBB2_10: # %._crit_edge38 # in Loop: Header=BB2_2 Depth=1 incq %r15 addq %r14, %rsi cmpq -8(%rsp), %r15 # 8-byte Folded Reload je .LBB2_11 .LBB2_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_4 Depth 2 # Child Loop BB2_6 Depth 3 testl %ecx, %ecx jle .LBB2_10 # %bb.3: # %.lr.ph37 # in Loop: Header=BB2_2 Depth=1 movq %r15, %rdx imulq -32(%rsp), %rdx # 8-byte Folded Reload movq -16(%rsp), %rdi # 8-byte Reload leaq (%rdi,%rdx,4), %r12 movq -24(%rsp), %r13 # 8-byte Reload movq %rsi, %rbp xorl %r11d, %r11d jmp .LBB2_4 .p2align 4, 0x90 .LBB2_9: # %._crit_edge # in Loop: Header=BB2_4 Depth=2 incq %r11 addq $4, %rbp incq %r13 cmpq %rbx, %r11 je .LBB2_10 .LBB2_4: # Parent Loop BB2_2 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB2_6 Depth 3 testl %r9d, %r9d js .LBB2_9 # %bb.5: # %.lr.ph # in Loop: Header=BB2_4 Depth=2 xorps %xmm0, %xmm0 xorl %edi, %edi movq %rax, %rdx jmp .LBB2_6 .p2align 4, 0x90 .LBB2_8: # in Loop: Header=BB2_6 Depth=3 movss %xmm0, (%r12,%r11,4) addq $-4, %rdx incq %rdi cmpl %edi, %r10d je .LBB2_9 .LBB2_6: # Parent Loop BB2_2 Depth=1 # Parent Loop BB2_4 Depth=2 # => This Inner Loop Header: Depth=3 leal (%rdi,%r13), %r8d cmpl %ecx, %r8d jae .LBB2_8 # %bb.7: # in Loop: Header=BB2_6 Depth=3 movss (%rbp,%rdi,4), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%rdx), %xmm1 addss %xmm1, %xmm0 jmp .LBB2_8 .LBB2_11: # %._crit_edge40 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size _Z17convolutionRowCPUPfS_S_iii, .Lfunc_end2-_Z17convolutionRowCPUPfS_S_iii .cfi_endproc # -- End function .globl _Z20convolutionColumnCPUPfS_S_iii # -- Begin function _Z20convolutionColumnCPUPfS_S_iii .p2align 4, 0x90 .type _Z20convolutionColumnCPUPfS_S_iii,@function _Z20convolutionColumnCPUPfS_S_iii: # @_Z20convolutionColumnCPUPfS_S_iii .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movl %ecx, -36(%rsp) # 4-byte Spill movq %rdi, -16(%rsp) # 8-byte Spill testl %r8d, %r8d jle .LBB3_11 # %bb.1: # %.preheader.lr.ph movq %rdx, %r11 movl %r9d, %ecx negl %ecx movslq %ecx, %rax movslq -36(%rsp), %r14 # 4-byte Folded Reload movslq %r9d, %rdx movl %r8d, %edi movq %rdi, -8(%rsp) # 8-byte Spill movl %r14d, %ebx leaq (,%rdx,4), %rdi leaq (,%rax,4), %r10 subq %r10, %rdi addq %rdi, %r11 imulq %r14, %rax leaq (%rsi,%rax,4), %rax movq %rax, -32(%rsp) # 8-byte Spill movq %r14, -24(%rsp) # 8-byte Spill leaq (,%r14,4), %r14 leal 1(,%rdx,2), %edi xorl %r15d, %r15d jmp .LBB3_2 .p2align 4, 0x90 .LBB3_10: # %._crit_edge39 # in Loop: Header=BB3_2 Depth=1 incq %r15 incl %ecx addq %r14, -32(%rsp) # 8-byte Folded Spill cmpq -8(%rsp), %r15 # 8-byte Folded Reload je .LBB3_11 .LBB3_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB3_4 Depth 2 # Child Loop BB3_6 Depth 3 cmpl $0, -36(%rsp) # 4-byte Folded Reload jle .LBB3_10 # %bb.3: # %.lr.ph38 # in Loop: Header=BB3_2 Depth=1 movq %r15, %rax imulq -24(%rsp), %rax # 8-byte Folded Reload movq -16(%rsp), %rdx # 8-byte Reload leaq (%rdx,%rax,4), %r12 movq -32(%rsp), %rsi # 8-byte Reload xorl %r10d, %r10d jmp .LBB3_4 .p2align 4, 0x90 .LBB3_9: # %._crit_edge # in Loop: Header=BB3_4 Depth=2 incq %r10 addq $4, %rsi cmpq %rbx, %r10 je .LBB3_10 .LBB3_4: # Parent Loop BB3_2 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB3_6 Depth 3 testl %r9d, %r9d js .LBB3_9 # %bb.5: # %.lr.ph # in Loop: Header=BB3_4 Depth=2 xorps %xmm0, %xmm0 movl %edi, %ebp movq %rsi, %r13 movl %ecx, %eax movq %r11, %rdx jmp .LBB3_6 .p2align 4, 0x90 .LBB3_8: # in Loop: Header=BB3_6 Depth=3 movss %xmm0, (%r12,%r10,4) addq $-4, %rdx incl %eax addq %r14, %r13 decl %ebp je .LBB3_9 .LBB3_6: # Parent Loop BB3_2 Depth=1 # Parent Loop BB3_4 Depth=2 # => This Inner Loop Header: Depth=3 cmpl %r8d, %eax jae .LBB3_8 # %bb.7: # in Loop: Header=BB3_6 Depth=3 movss (%r13), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%rdx), %xmm1 addss %xmm1, %xmm0 jmp .LBB3_8 .LBB3_11: # %._crit_edge41 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size _Z20convolutionColumnCPUPfS_S_iii, .Lfunc_end3-_Z20convolutionColumnCPUPfS_S_iii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI4_0: .long 0x4b008081 # float 8421505 .LCPI4_1: .long 0x30000000 # float 4.65661287E-10 .LCPI4_4: .long 0x40c00000 # float 6 .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 .LCPI4_2: .quad 0x41cdcd6500000000 # double 1.0E+9 .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 .LCPI4_3: .long 0x80000000 # float -0 .long 0x80000000 # float -0 .long 0x80000000 # float -0 .long 0x80000000 # float -0 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $248, %rsp .cfi_def_cfa_offset 304 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq %rsi, %rbx movl %edi, %ebp xorl %edi, %edi callq hipSetDevice leaq 200(%rsp), %rdi callq hipEventCreate leaq 88(%rsp), %rdi callq hipEventCreate cmpl $1, %ebp jg .LBB4_2 # %bb.1: movl $.Lstr.4, %edi callq puts@PLT jmp .LBB4_52 .LBB4_2: movq 8(%rbx), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol movq %rax, 32(%rsp) # 8-byte Spill movl %eax, %ebx movl $.L.str.1, %edi movl %eax, %esi movl %eax, %edx xorl %eax, %eax callq printf movl $.Lstr, %edi callq puts@PLT movl $132, %edi callq malloc movq %rax, %r14 movl %ebx, %eax imull %eax, %eax movq %rax, (%rsp) # 8-byte Spill leaq (,%rax,4), %r13 movq %r13, %rdi callq malloc movq %rax, %r15 leal 32(%rbx), %eax movl %eax, 52(%rsp) # 4-byte Spill # kill: def $eax killed $eax def $rax imull %eax, %eax movq %rax, 208(%rsp) # 8-byte Spill leaq (,%rax,4), %rbp movq %rbp, %rdi callq malloc movq %rax, %r12 movq %r13, %rdi callq malloc movq %rax, 72(%rsp) # 8-byte Spill movq %r13, %rdi callq malloc movq %rax, 80(%rsp) # 8-byte Spill movq %rbp, %rdi callq malloc movq %rax, 192(%rsp) # 8-byte Spill leaq 64(%rsp), %rdi movq %rbp, %rsi callq hipMalloc leaq 40(%rsp), %rdi movq %rbp, %rsi callq hipMalloc movq 40(%rsp), %rdi xorl %esi, %esi movq %rbp, %rdx callq hipMemset leaq 56(%rsp), %rdi movq %rbp, 24(%rsp) # 8-byte Spill movq %rbp, %rsi callq hipMalloc cmpq $0, 64(%rsp) je .LBB4_5 # %bb.3: cmpq $0, 40(%rsp) je .LBB4_5 # %bb.4: movq 56(%rsp), %rdi testq %rdi, %rdi je .LBB4_5 # %bb.38: movq 32(%rsp), %rax # 8-byte Reload movq %rax, 16(%rsp) # 8-byte Spill xorl %r13d, %r13d xorl %esi, %esi movq 24(%rsp), %rdx # 8-byte Reload callq hipMemset movl $200, %edi callq srand .p2align 4, 0x90 .LBB4_39: # =>This Inner Loop Header: Depth=1 callq rand # kill: def $eax killed $eax def $rax leal 15(%rax), %ecx testl %eax, %eax cmovnsl %eax, %ecx andl $-16, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%r14,%r13,4) incq %r13 cmpq $33, %r13 jne .LBB4_39 # %bb.6: # %.preheader165 testl %ebx, %ebx movq (%rsp), %rbp # 8-byte Reload je .LBB4_9 # %bb.7: # %.lr.ph.preheader cmpl $1, %ebp adcl $0, %ebp xorl %r13d, %r13d .p2align 4, 0x90 .LBB4_8: # %.lr.ph # =>This Inner Loop Header: Depth=1 callq rand xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 divss .LCPI4_0(%rip), %xmm0 movss %xmm0, (%rsp) # 4-byte Spill callq rand xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 mulss .LCPI4_1(%rip), %xmm0 addss (%rsp), %xmm0 # 4-byte Folded Reload movss %xmm0, (%r15,%r13,4) incq %r13 cmpq %r13, %rbp jne .LBB4_8 .LBB4_9: # %._crit_edge movl $.Lstr.1, %edi callq puts@PLT leaq 232(%rsp), %rsi movl $4, %edi callq clock_gettime testl %ebx, %ebx jle .LBB4_27 # %bb.10: # %.preheader.lr.ph.i movl 16(%rsp), %eax # 4-byte Reload movq %r14, %rcx subq $-128, %rcx leaq (,%rax,4), %rdx xorl %esi, %esi movq %r15, %rdi jmp .LBB4_11 .p2align 4, 0x90 .LBB4_17: # %._crit_edge38.i # in Loop: Header=BB4_11 Depth=1 incq %rsi addq %rdx, %rdi cmpq %rax, %rsi je .LBB4_18 .LBB4_11: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB4_12 Depth 2 # Child Loop BB4_13 Depth 3 movq %rsi, %r8 imulq %rax, %r8 movq 72(%rsp), %r9 # 8-byte Reload leaq (%r9,%r8,4), %r8 movq %rdi, %r9 xorl %r10d, %r10d jmp .LBB4_12 .p2align 4, 0x90 .LBB4_16: # %._crit_edge.i # in Loop: Header=BB4_12 Depth=2 movss %xmm0, (%r8,%r10,4) incq %r10 addq $4, %r9 cmpq %rax, %r10 je .LBB4_17 .LBB4_12: # Parent Loop BB4_11 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB4_13 Depth 3 xorps %xmm0, %xmm0 movq $-16, %r11 movq %rcx, %r13 jmp .LBB4_13 .p2align 4, 0x90 .LBB4_15: # in Loop: Header=BB4_13 Depth=3 incq %r11 addq $-4, %r13 cmpq $17, %r11 je .LBB4_16 .LBB4_13: # Parent Loop BB4_11 Depth=1 # Parent Loop BB4_12 Depth=2 # => This Inner Loop Header: Depth=3 leal (%r10,%r11), %ebp cmpl %ebx, %ebp jae .LBB4_15 # %bb.14: # in Loop: Header=BB4_13 Depth=3 movss (%r9,%r11,4), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%r13), %xmm1 addss %xmm1, %xmm0 jmp .LBB4_15 .LBB4_5: movl $.Lstr.3, %edi callq puts@PLT jmp .LBB4_52 .LBB4_18: # %_Z17convolutionRowCPUPfS_S_iii.exit testl %ebx, %ebx jle .LBB4_27 # %bb.19: # %.preheader.lr.ph.i141 movl 16(%rsp), %eax # 4-byte Reload movq %rax, %rdx shlq $6, %rdx movq 72(%rsp), %rcx # 8-byte Reload subq %rdx, %rcx leaq (,%rax,4), %rdx movl $-16, %esi xorl %edi, %edi jmp .LBB4_20 .p2align 4, 0x90 .LBB4_26: # %._crit_edge39.i # in Loop: Header=BB4_20 Depth=1 incq %rdi addq %rdx, %rcx incl %esi cmpq %rax, %rdi je .LBB4_27 .LBB4_20: # %.preheader.i142 # =>This Loop Header: Depth=1 # Child Loop BB4_21 Depth 2 # Child Loop BB4_22 Depth 3 movq %rdi, %r8 imulq %rax, %r8 movq 80(%rsp), %r9 # 8-byte Reload leaq (%r9,%r8,4), %r8 movq %rcx, %r9 xorl %r10d, %r10d jmp .LBB4_21 .p2align 4, 0x90 .LBB4_25: # %._crit_edge.i150 # in Loop: Header=BB4_21 Depth=2 movss %xmm0, (%r8,%r10,4) incq %r10 addq $4, %r9 cmpq %rax, %r10 je .LBB4_26 .LBB4_21: # Parent Loop BB4_20 Depth=1 # => This Loop Header: Depth=2 # Child Loop BB4_22 Depth 3 xorps %xmm0, %xmm0 movl $32, %r11d movl %esi, %ebp movq %r9, %r13 jmp .LBB4_22 .p2align 4, 0x90 .LBB4_24: # in Loop: Header=BB4_22 Depth=3 addq %rdx, %r13 incl %ebp addq $-1, %r11 jae .LBB4_25 .LBB4_22: # Parent Loop BB4_20 Depth=1 # Parent Loop BB4_21 Depth=2 # => This Inner Loop Header: Depth=3 cmpl %ebx, %ebp jae .LBB4_24 # %bb.23: # in Loop: Header=BB4_22 Depth=3 movss (%r13), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss (%r14,%r11,4), %xmm1 addss %xmm1, %xmm0 jmp .LBB4_24 .LBB4_27: # %_Z20convolutionColumnCPUPfS_S_iii.exit leaq 216(%rsp), %rsi movl $4, %edi callq clock_gettime movq 216(%rsp), %rax movq 224(%rsp), %rcx subq 240(%rsp), %rcx xorps %xmm1, %xmm1 cvtsi2sd %rcx, %xmm1 divsd .LCPI4_2(%rip), %xmm1 subq 232(%rsp), %rax xorps %xmm0, %xmm0 cvtsi2sd %rax, %xmm0 addsd %xmm1, %xmm0 movl $.L.str.5, %edi movb $1, %al callq printf leal 511(%rbx), %r13d leal 15(%rbx), %eax testl %ebx, %ebx cmovnsl %ebx, %r13d cmovnsl %ebx, %eax movq %rax, (%rsp) # 8-byte Spill sarl $9, %r13d shlq $32, 32(%rsp) # 8-byte Folded Spill movl 52(%rsp), %ebp # 4-byte Reload testl %ebp, %ebp je .LBB4_29 # %bb.28: # %.lr.ph175.preheader movq 208(%rsp), %rdx # 8-byte Reload cmpl $1, %edx adcl $0, %edx shlq $2, %rdx movq %r12, %rdi xorl %esi, %esi callq memset@PLT .LBB4_29: # %.preheader164 movq 32(%rsp), %rax # 8-byte Reload orq %r13, %rax movq %rax, %r13 testl %ebx, %ebx je .LBB4_34 # %bb.30: # %.preheader163.preheader movl 16(%rsp), %eax # 4-byte Reload movl %ebx, %ecx shll $4, %ecx addl $528, %ecx # imm = 0x210 xorl %edx, %edx xorl %esi, %esi .p2align 4, 0x90 .LBB4_31: # %.preheader163 # =>This Loop Header: Depth=1 # Child Loop BB4_32 Depth 2 movq %rax, %rdi movl %ecx, %r8d movl %edx, %r9d .p2align 4, 0x90 .LBB4_32: # Parent Loop BB4_31 Depth=1 # => This Inner Loop Header: Depth=2 movl %r9d, %r10d movss (%r15,%r10,4), %xmm0 # xmm0 = mem[0],zero,zero,zero movl %r8d, %r10d movss %xmm0, (%r12,%r10,4) incl %r9d incl %r8d decq %rdi jne .LBB4_32 # %bb.33: # in Loop: Header=BB4_31 Depth=1 incl %esi addl %ebx, %edx addl %ebp, %ecx cmpl %ebx, %esi jne .LBB4_31 .LBB4_34: # %._crit_edge178 movl $.Lstr.2, %edi callq puts@PLT movl $d_Filter, %edi movl $132, %edx movq %r14, %rsi xorl %ecx, %ecx movl $1, %r8d callq hipMemcpyToSymbol movq 64(%rsp), %rdi movq %r12, %rsi movq 24(%rsp), %rdx # 8-byte Reload movl $1, %ecx callq hipMemcpy movq 200(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movabsq $4294967297, %rdx # imm = 0x100000001 addq $511, %rdx # imm = 0x1FF movq %r13, %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_36 # %bb.35: movq 40(%rsp), %rax movq 64(%rsp), %rcx movq %rax, 152(%rsp) movq %rcx, 144(%rsp) movl %ebx, 12(%rsp) movl %ebx, 8(%rsp) leaq 152(%rsp), %rax movq %rax, 160(%rsp) leaq 144(%rsp), %rax movq %rax, 168(%rsp) leaq 12(%rsp), %rax movq %rax, 176(%rsp) leaq 8(%rsp), %rax movq %rax, 184(%rsp) leaq 128(%rsp), %rdi leaq 112(%rsp), %rsi leaq 104(%rsp), %rdx leaq 96(%rsp), %rcx callq __hipPopCallConfiguration movq 128(%rsp), %rsi movl 136(%rsp), %edx movq 112(%rsp), %rcx movl 120(%rsp), %r8d leaq 160(%rsp), %r9 movl $_Z15tiledConvRowGPUPfS_ii, %edi pushq 96(%rsp) .cfi_adjust_cfa_offset 8 pushq 112(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB4_36: callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB4_37 # %bb.40: movq (%rsp), %rax # 8-byte Reload sarl $4, %eax movq %rax, %rdi shlq $32, %rdi orq %rax, %rdi movabsq $68719476752, %rdx # imm = 0x1000000010 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_42 # %bb.41: movq 56(%rsp), %rax movq 40(%rsp), %rcx movq %rax, 152(%rsp) movq %rcx, 144(%rsp) movl %ebx, 12(%rsp) movl %ebx, 8(%rsp) leaq 152(%rsp), %rax movq %rax, 160(%rsp) leaq 144(%rsp), %rax movq %rax, 168(%rsp) leaq 12(%rsp), %rax movq %rax, 176(%rsp) leaq 8(%rsp), %rax movq %rax, 184(%rsp) leaq 128(%rsp), %rdi leaq 112(%rsp), %rsi leaq 104(%rsp), %rdx leaq 96(%rsp), %rcx callq __hipPopCallConfiguration movq 128(%rsp), %rsi movl 136(%rsp), %edx movq 112(%rsp), %rcx movl 120(%rsp), %r8d leaq 160(%rsp), %r9 movl $_Z15tiledConvColGPUPfS_ii, %edi pushq 96(%rsp) .cfi_adjust_cfa_offset 8 pushq 112(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB4_42: callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax je .LBB4_43 .LBB4_37: movl %eax, %edi callq hipGetErrorString movl $.L.str.7, %edi movq %rax, %rsi xorl %eax, %eax callq printf .LBB4_51: callq hipDeviceReset .LBB4_52: xorl %eax, %eax addq $248, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB4_43: .cfi_def_cfa_offset 304 movq 88(%rsp), %rdi xorl %r13d, %r13d xorl %esi, %esi callq hipEventRecord movq 56(%rsp), %rsi movq 192(%rsp), %rdi # 8-byte Reload movq 24(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy movq 88(%rsp), %rdi callq hipEventSynchronize movq 200(%rsp), %rsi movq 88(%rsp), %rdx leaq 160(%rsp), %rdi callq hipEventElapsedTime movss 160(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.8, %edi movb $1, %al callq printf testl %ebx, %ebx je .LBB4_50 # %bb.44: # %.preheader.preheader movl 16(%rsp), %eax # 4-byte Reload movq %rax, 16(%rsp) # 8-byte Spill movl %ebx, %ebp shll $4, %ebp addl $528, %ebp # imm = 0x210 movaps .LCPI4_3(%rip), %xmm2 # xmm2 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0] movss .LCPI4_4(%rip), %xmm3 # xmm3 = mem[0],zero,zero,zero xorl %eax, %eax jmp .LBB4_45 .p2align 4, 0x90 .LBB4_49: # in Loop: Header=BB4_45 Depth=1 movl 24(%rsp), %eax # 4-byte Reload incl %eax movq (%rsp), %r13 # 8-byte Reload addl %ebx, %r13d movl 32(%rsp), %ebp # 4-byte Reload addl 52(%rsp), %ebp # 4-byte Folded Reload cmpl %ebx, %eax je .LBB4_50 .LBB4_45: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB4_46 Depth 2 movl %eax, 24(%rsp) # 4-byte Spill movq 16(%rsp), %r12 # 8-byte Reload movl %ebp, 32(%rsp) # 4-byte Spill movq %r13, (%rsp) # 8-byte Spill # kill: def $r13d killed $r13d killed $r13 jmp .LBB4_46 .p2align 4, 0x90 .LBB4_48: # in Loop: Header=BB4_46 Depth=2 incl %r13d incl %ebp decq %r12 je .LBB4_49 .LBB4_46: # Parent Loop BB4_45 Depth=1 # => This Inner Loop Header: Depth=2 movl %r13d, %eax movq 80(%rsp), %rcx # 8-byte Reload movss (%rcx,%rax,4), %xmm1 # xmm1 = mem[0],zero,zero,zero movl %ebp, %eax movq 192(%rsp), %rcx # 8-byte Reload subss (%rcx,%rax,4), %xmm1 movaps %xmm1, %xmm0 xorps %xmm2, %xmm0 maxss %xmm1, %xmm0 ucomiss %xmm3, %xmm0 jbe .LBB4_48 # %bb.47: # in Loop: Header=BB4_46 Depth=2 cvtss2sd %xmm0, %xmm0 movl $.L.str.9, %edi movb $1, %al callq printf movss .LCPI4_4(%rip), %xmm3 # xmm3 = mem[0],zero,zero,zero movaps .LCPI4_3(%rip), %xmm2 # xmm2 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0] jmp .LBB4_48 .LBB4_50: # %._crit_edge181 movq 80(%rsp), %rdi # 8-byte Reload callq free movq 72(%rsp), %rdi # 8-byte Reload callq free movq %r15, %rdi callq free movq %r14, %rdi callq free movq 56(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 64(%rsp), %rdi callq hipFree movl $d_Filter, %edi callq hipFree jmp .LBB4_51 .Lfunc_end4: .size main, .Lfunc_end4-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB5_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB5_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z15tiledConvRowGPUPfS_ii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z15tiledConvColGPUPfS_ii, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $0, 8(%rsp) movl $1, (%rsp) movl $d_Filter, %esi movl $.L__unnamed_3, %edx movl $.L__unnamed_3, %ecx movl $132, %r9d movq %rbx, %rdi xorl %r8d, %r8d callq __hipRegisterVar movl $__hip_module_dtor, %edi addq $32, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end5: .size __hip_module_ctor, .Lfunc_end5-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB6_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB6_2: retq .Lfunc_end6: .size __hip_module_dtor, .Lfunc_end6-__hip_module_dtor .cfi_endproc # -- End function .type d_Filter,@object # @d_Filter .local d_Filter .comm d_Filter,132,16 .type _Z15tiledConvRowGPUPfS_ii,@object # @_Z15tiledConvRowGPUPfS_ii .section .rodata,"a",@progbits .globl _Z15tiledConvRowGPUPfS_ii .p2align 3, 0x0 _Z15tiledConvRowGPUPfS_ii: .quad _Z30__device_stub__tiledConvRowGPUPfS_ii .size _Z15tiledConvRowGPUPfS_ii, 8 .type _Z15tiledConvColGPUPfS_ii,@object # @_Z15tiledConvColGPUPfS_ii .globl _Z15tiledConvColGPUPfS_ii .p2align 3, 0x0 _Z15tiledConvColGPUPfS_ii: .quad _Z30__device_stub__tiledConvColGPUPfS_ii .size _Z15tiledConvColGPUPfS_ii, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "Image Width x Height = %i x %i\n\n" .size .L.str.1, 33 .type .L.str.5,@object # @.str.5 .L.str.5: .asciz "CPU time = %10g seconds\n" .size .L.str.5, 25 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "Cuda Error:%s\n" .size .L.str.7, 15 .type .L.str.8,@object # @.str.8 .L.str.8: .asciz "GPU time :%f ms.\n" .size .L.str.8, 18 .type .L.str.9,@object # @.str.9 .L.str.9: .asciz "sfalma akriveias %f" .size .L.str.9, 20 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z15tiledConvRowGPUPfS_ii" .size .L__unnamed_1, 26 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z15tiledConvColGPUPfS_ii" .size .L__unnamed_2, 26 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "d_Filter" .size .L__unnamed_3, 9 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Allocating and initializing host arrays..." .size .Lstr, 43 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "CPU computation..." .size .Lstr.1, 19 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "GPU computation... " .size .Lstr.2, 20 .type .Lstr.3,@object # @str.3 .Lstr.3: .asciz "Cuda Malloc Failed" .size .Lstr.3, 19 .type .Lstr.4,@object # @str.4 .Lstr.4: .asciz "Please specify the image size as execution arguments" .size .Lstr.4, 53 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z30__device_stub__tiledConvRowGPUPfS_ii .addrsig_sym _Z30__device_stub__tiledConvColGPUPfS_ii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym d_Filter .addrsig_sym _Z15tiledConvRowGPUPfS_ii .addrsig_sym _Z15tiledConvColGPUPfS_ii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z15tiledConvColGPUPfS_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R11, SR_TID.Y ; /* 0x00000000000b7919 */ /* 0x000e220000002200 */ /*0020*/ MOV R4, c[0x0][0x170] ; /* 0x00005c0000047a02 */ /* 0x000fe20000000f00 */ /*0030*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fe200000001ff */ /*0040*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0050*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e620000002600 */ /*0060*/ IADD3 R4, R4, 0x20, RZ ; /* 0x0000002004047810 */ /* 0x000fc60007ffe0ff */ /*0070*/ S2R R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000ea80000002500 */ /*0080*/ S2R R10, SR_TID.X ; /* 0x00000000000a7919 */ /* 0x000ea20000002100 */ /*0090*/ ISETP.GE.AND P0, PT, R11, 0x10, PT ; /* 0x000000100b00780c */ /* 0x001fe20003f06270 */ /*00a0*/ IMAD R2, R2, c[0x0][0x4], R11 ; /* 0x0000010002027a24 */ /* 0x002fca00078e020b */ /*00b0*/ IADD3 R3, R2, 0x10, RZ ; /* 0x0000001002037810 */ /* 0x000fe20007ffe0ff */ /*00c0*/ IMAD R5, R5, c[0x0][0x0], R10 ; /* 0x0000000005057a24 */ /* 0x004fc800078e020a */ /*00d0*/ IMAD R3, R4, R3, R5.reuse ; /* 0x0000000304037224 */ /* 0x100fe400078e0205 */ /*00e0*/ @!P0 IMAD R5, R2, R4, R5 ; /* 0x0000000402058224 */ /* 0x000fe400078e0205 */ /*00f0*/ IMAD.WIDE R6, R3, R0, c[0x0][0x168] ; /* 0x00005a0003067625 */ /* 0x000fe200078e0200 */ /*0100*/ LEA R9, R4, R3, 0x4 ; /* 0x0000000304097211 */ /* 0x000fc600078e20ff */ /*0110*/ @!P0 IMAD.WIDE R4, R5, R0.reuse, c[0x0][0x168] ; /* 0x00005a0005048625 */ /* 0x080fe400078e0200 */ /*0120*/ LDG.E R7, [R6.64+0x40] ; /* 0x0000400406077981 */ /* 0x000ea4000c1e1900 */ /*0130*/ IMAD.WIDE R8, R9, R0, c[0x0][0x168] ; /* 0x00005a0009087625 */ /* 0x000fe400078e0200 */ /*0140*/ @!P0 LDG.E R5, [R4.64+0x40] ; /* 0x0000400404058981 */ /* 0x000ee8000c1e1900 */ /*0150*/ LDG.E R9, [R8.64+0x40] ; /* 0x0000400408097981 */ /* 0x000f22000c1e1900 */ /*0160*/ LEA R2, R11, R10, 0x4 ; /* 0x0000000a0b027211 */ /* 0x000fca00078e20ff */ /*0170*/ STS [R2.X4+0x400], R7 ; /* 0x0004000702007388 */ /* 0x004fe80000004800 */ /*0180*/ @!P0 STS [R2.X4], R5 ; /* 0x0000000502008388 */ /* 0x008fe80000004800 */ /*0190*/ STS [R2.X4+0x800], R9 ; /* 0x0008000902007388 */ /* 0x010fe80000004800 */ /*01a0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*01b0*/ LDS R10, [R2.X4] ; /* 0x00000000020a7984 */ /* 0x000e280000004800 */ /*01c0*/ LDS R11, [R2.X4+0x40] ; /* 0x00004000020b7984 */ /* 0x000e680000004800 */ /*01d0*/ LDS R13, [R2.X4+0x80] ; /* 0x00008000020d7984 */ /* 0x000ea80000004800 */ /*01e0*/ LDS R15, [R2.X4+0xc0] ; /* 0x0000c000020f7984 */ /* 0x000ee80000004800 */ /*01f0*/ LDS R17, [R2.X4+0x100] ; /* 0x0001000002117984 */ /* 0x000f280000004800 */ /*0200*/ LDS R19, [R2.X4+0x140] ; /* 0x0001400002137984 */ /* 0x000f680000004800 */ /*0210*/ LDS R12, [R2.X4+0x180] ; /* 0x00018000020c7984 */ /* 0x000f680000004800 */ /*0220*/ LDS R21, [R2.X4+0x1c0] ; /* 0x0001c00002157984 */ /* 0x000f680000004800 */ /*0230*/ LDS R14, [R2.X4+0x200] ; /* 0x00020000020e7984 */ /* 0x000f680000004800 */ /*0240*/ LDS R4, [R2.X4+0x240] ; /* 0x0002400002047984 */ /* 0x000f620000004800 */ /*0250*/ FFMA R10, R10, c[0x3][0x80], RZ ; /* 0x00c020000a0a7a23 */ /* 0x001fc600000000ff */ /*0260*/ LDS R5, [R2.X4+0x280] ; /* 0x0002800002057984 */ /* 0x000e220000004800 */ /*0270*/ FFMA R10, R11, c[0x3][0x7c], R10 ; /* 0x00c01f000b0a7a23 */ /* 0x002fc6000000000a */ /*0280*/ LDS R6, [R2.X4+0x2c0] ; /* 0x0002c00002067984 */ /* 0x000e620000004800 */ /*0290*/ FFMA R10, R13, c[0x3][0x78], R10 ; /* 0x00c01e000d0a7a23 */ /* 0x004fc6000000000a */ /*02a0*/ LDS R7, [R2.X4+0x300] ; /* 0x0003000002077984 */ /* 0x000ea20000004800 */ /*02b0*/ FFMA R10, R15, c[0x3][0x74], R10 ; /* 0x00c01d000f0a7a23 */ /* 0x008fc6000000000a */ /*02c0*/ LDS R8, [R2.X4+0x340] ; /* 0x0003400002087984 */ /* 0x000ee20000004800 */ /*02d0*/ FFMA R10, R17, c[0x3][0x70], R10 ; /* 0x00c01c00110a7a23 */ /* 0x010fc6000000000a */ /*02e0*/ LDS R9, [R2.X4+0x380] ; /* 0x0003800002097984 */ /* 0x000f220000004800 */ /*02f0*/ FFMA R19, R19, c[0x3][0x6c], R10 ; /* 0x00c01b0013137a23 */ /* 0x020fc6000000000a */ /*0300*/ LDS R11, [R2.X4+0x400] ; /* 0x00040000020b7984 */ /* 0x000fe80000004800 */ /*0310*/ LDS R10, [R2.X4+0x3c0] ; /* 0x0003c000020a7984 */ /* 0x000f620000004800 */ /*0320*/ FFMA R12, R12, c[0x3][0x68], R19 ; /* 0x00c01a000c0c7a23 */ /* 0x000fc60000000013 */ /*0330*/ LDS R13, [R2.X4+0x480] ; /* 0x00048000020d7984 */ /* 0x000fe20000004800 */ /*0340*/ FFMA R21, R21, c[0x3][0x64], R12 ; /* 0x00c0190015157a23 */ /* 0x000fc6000000000c */ /*0350*/ LDS R12, [R2.X4+0x440] ; /* 0x00044000020c7984 */ /* 0x000f620000004800 */ /*0360*/ FFMA R21, R14, c[0x3][0x60], R21 ; /* 0x00c018000e157a23 */ /* 0x000fc60000000015 */ /*0370*/ LDS R16, [R2.X4+0x6c0] ; /* 0x0006c00002107984 */ /* 0x000fe20000004800 */ /*0380*/ FFMA R14, R4, c[0x3][0x5c], R21 ; /* 0x00c01700040e7a23 */ /* 0x000fc60000000015 */ /*0390*/ LDS R4, [R2.X4+0x4c0] ; /* 0x0004c00002047984 */ /* 0x000f620000004800 */ /*03a0*/ FFMA R15, R5, c[0x3][0x58], R14 ; /* 0x00c01600050f7a23 */ /* 0x001fc6000000000e */ /*03b0*/ LDS R5, [R2.X4+0x500] ; /* 0x0005000002057984 */ /* 0x000e220000004800 */ /*03c0*/ FFMA R14, R6, c[0x3][0x54], R15 ; /* 0x00c01500060e7a23 */ /* 0x002fc6000000000f */ /*03d0*/ LDS R6, [R2.X4+0x540] ; /* 0x0005400002067984 */ /* 0x000e620000004800 */ /*03e0*/ FFMA R15, R7, c[0x3][0x50], R14 ; /* 0x00c01400070f7a23 */ /* 0x004fc6000000000e */ /*03f0*/ LDS R7, [R2.X4+0x580] ; /* 0x0005800002077984 */ /* 0x000ea20000004800 */ /*0400*/ FFMA R14, R8, c[0x3][0x4c], R15 ; /* 0x00c01300080e7a23 */ /* 0x008fc6000000000f */ /*0410*/ LDS R8, [R2.X4+0x5c0] ; /* 0x0005c00002087984 */ /* 0x000ee20000004800 */ /*0420*/ FFMA R15, R9, c[0x3][0x48], R14 ; /* 0x00c01200090f7a23 */ /* 0x010fc6000000000e */ /*0430*/ LDS R9, [R2.X4+0x600] ; /* 0x0006000002097984 */ /* 0x000f220000004800 */ /*0440*/ FFMA R14, R10, c[0x3][0x44], R15 ; /* 0x00c011000a0e7a23 */ /* 0x020fc6000000000f */ /*0450*/ LDS R18, [R2.X4+0x740] ; /* 0x0007400002127984 */ /* 0x000fe80000004800 */ /*0460*/ LDS R10, [R2.X4+0x640] ; /* 0x00064000020a7984 */ /* 0x000f620000004800 */ /*0470*/ FFMA R11, R11, c[0x3][0x40], R14 ; /* 0x00c010000b0b7a23 */ /* 0x000fc6000000000e */ /*0480*/ LDS R14, [R2.X4+0x680] ; /* 0x00068000020e7984 */ /* 0x000f620000004800 */ /*0490*/ FFMA R12, R12, c[0x3][0x3c], R11 ; /* 0x00c00f000c0c7a23 */ /* 0x000fc6000000000b */ /*04a0*/ LDS R11, [R2.X4+0x800] ; /* 0x00080000020b7984 */ /* 0x000fe20000004800 */ /*04b0*/ FFMA R13, R13, c[0x3][0x38], R12 ; /* 0x00c00e000d0d7a23 */ /* 0x000fc6000000000c */ /*04c0*/ LDS R12, [R2.X4+0x700] ; /* 0x00070000020c7984 */ /* 0x000f620000004800 */ /*04d0*/ FFMA R4, R4, c[0x3][0x34], R13 ; /* 0x00c00d0004047a23 */ /* 0x000fc8000000000d */ /*04e0*/ FFMA R5, R5, c[0x3][0x30], R4 ; /* 0x00c00c0005057a23 */ /* 0x001fe40000000004 */ /*04f0*/ LDS R4, [R2.X4+0x780] ; /* 0x0007800002047984 */ /* 0x000e240000004800 */ /*0500*/ FFMA R6, R6, c[0x3][0x2c], R5 ; /* 0x00c00b0006067a23 */ /* 0x002fe40000000005 */ /*0510*/ LDS R5, [R2.X4+0x7c0] ; /* 0x0007c00002057984 */ /* 0x000e640000004800 */ /*0520*/ FFMA R7, R7, c[0x3][0x28], R6 ; /* 0x00c00a0007077a23 */ /* 0x004fc80000000006 */ /*0530*/ FFMA R8, R8, c[0x3][0x24], R7 ; /* 0x00c0090008087a23 */ /* 0x008fc80000000007 */ /*0540*/ FFMA R9, R9, c[0x3][0x20], R8 ; /* 0x00c0080009097a23 */ /* 0x010fc80000000008 */ /*0550*/ FFMA R9, R10, c[0x3][0x1c], R9 ; /* 0x00c007000a097a23 */ /* 0x020fc80000000009 */ /*0560*/ FFMA R9, R14, c[0x3][0x18], R9 ; /* 0x00c006000e097a23 */ /* 0x000fc80000000009 */ /*0570*/ FFMA R9, R16, c[0x3][0x14], R9 ; /* 0x00c0050010097a23 */ /* 0x000fc80000000009 */ /*0580*/ FFMA R9, R12, c[0x3][0x10], R9 ; /* 0x00c004000c097a23 */ /* 0x000fc80000000009 */ /*0590*/ FFMA R9, R18, c[0x3][0xc], R9 ; /* 0x00c0030012097a23 */ /* 0x000fc80000000009 */ /*05a0*/ FFMA R4, R4, c[0x3][0x8], R9 ; /* 0x00c0020004047a23 */ /* 0x001fc80000000009 */ /*05b0*/ FFMA R6, R5, c[0x3][0x4], R4 ; /* 0x00c0010005067a23 */ /* 0x002fe40000000004 */ /*05c0*/ IMAD.WIDE R4, R3, R0, c[0x0][0x160] ; /* 0x0000580003047625 */ /* 0x000fc800078e0200 */ /*05d0*/ FFMA R11, R11, c[0x3][0x0], R6 ; /* 0x00c000000b0b7a23 */ /* 0x000fca0000000006 */ /*05e0*/ STG.E [R4.64+0x40], R11 ; /* 0x0000400b04007986 */ /* 0x000fe2000c101904 */ /*05f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0600*/ BRA 0x600; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0610*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0620*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0630*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0640*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0650*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0660*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0670*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0680*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0690*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*06f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z15tiledConvRowGPUPfS_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ ULDC UR4, c[0x0][0x170] ; /* 0x00005c0000047ab9 */ /* 0x000fe40000000800 */ /*0030*/ UIADD3 UR4, UR4, 0x20, URZ ; /* 0x0000002004047890 */ /* 0x000fe2000fffe03f */ /*0040*/ S2R R13, SR_TID.Y ; /* 0x00000000000d7919 */ /* 0x000e280000002200 */ /*0050*/ S2R R6, SR_TID.X ; /* 0x0000000000067919 */ /* 0x000e680000002100 */ /*0060*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000ea20000002500 */ /*0070*/ IMAD R0, R0, c[0x0][0x4], R13 ; /* 0x0000010000007a24 */ /* 0x001fe200078e020d */ /*0080*/ ISETP.GT.AND P0, PT, R6, 0xf, PT ; /* 0x0000000f0600780c */ /* 0x002fc80003f04270 */ /*0090*/ IADD3 R2, R0, 0x10, RZ ; /* 0x0000001000027810 */ /* 0x000fe20007ffe0ff */ /*00a0*/ HFMA2.MMA R0, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff007435 */ /* 0x000fe200000001ff */ /*00b0*/ IMAD R3, R3, c[0x0][0x0], R6 ; /* 0x0000000003037a24 */ /* 0x004fe200078e0206 */ /*00c0*/ ISETP.GT.AND P1, PT, R6, 0x1ef, PT ; /* 0x000001ef0600780c */ /* 0x000fc60003f24270 */ /*00d0*/ IMAD R3, R2, UR4, R3 ; /* 0x0000000402037c24 */ /* 0x000fe2000f8e0203 */ /*00e0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc80000000a00 */ /*00f0*/ IMAD.WIDE R4, R3, R0, c[0x0][0x168] ; /* 0x00005a0003047625 */ /* 0x000fca00078e0200 */ /*0100*/ @!P0 LDG.E R7, [R4.64] ; /* 0x0000000404078981 */ /* 0x000ea8000c1e1900 */ /*0110*/ LDG.E R9, [R4.64+0x40] ; /* 0x0000400404097981 */ /* 0x000ee8000c1e1900 */ /*0120*/ @P1 LDG.E R11, [R4.64+0x80] ; /* 0x00008004040b1981 */ /* 0x000f22000c1e1900 */ /*0130*/ IMAD R2, R13, 0x220, R6 ; /* 0x000002200d027824 */ /* 0x000fe200078e0206 */ /*0140*/ IADD3 R3, R3, 0x10, RZ ; /* 0x0000001003037810 */ /* 0x000fc80007ffe0ff */ /*0150*/ @!P0 STS [R2.X4], R7 ; /* 0x0000000702008388 */ /* 0x004fe80000004800 */ /*0160*/ STS [R2.X4+0x40], R9 ; /* 0x0000400902007388 */ /* 0x008fe80000004800 */ /*0170*/ @P1 STS [R2.X4+0x80], R11 ; /* 0x0000800b02001388 */ /* 0x010fe80000004800 */ /*0180*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0190*/ LDS R6, [R2.X4] ; /* 0x0000000002067984 */ /* 0x000e280000004800 */ /*01a0*/ LDS R13, [R2.X4+0x4] ; /* 0x00000400020d7984 */ /* 0x000e680000004800 */ /*01b0*/ LDS R8, [R2.X4+0x8] ; /* 0x0000080002087984 */ /* 0x000ea80000004800 */ /*01c0*/ LDS R15, [R2.X4+0xc] ; /* 0x00000c00020f7984 */ /* 0x000ee80000004800 */ /*01d0*/ LDS R10, [R2.X4+0x10] ; /* 0x00001000020a7984 */ /* 0x000f280000004800 */ /*01e0*/ LDS R17, [R2.X4+0x14] ; /* 0x0000140002117984 */ /* 0x000f680000004800 */ /*01f0*/ LDS R12, [R2.X4+0x18] ; /* 0x00001800020c7984 */ /* 0x000f680000004800 */ /*0200*/ LDS R19, [R2.X4+0x1c] ; /* 0x00001c0002137984 */ /* 0x000f680000004800 */ /*0210*/ LDS R14, [R2.X4+0x20] ; /* 0x00002000020e7984 */ /* 0x000f680000004800 */ /*0220*/ LDS R4, [R2.X4+0x24] ; /* 0x0000240002047984 */ /* 0x000f620000004800 */ /*0230*/ FFMA R6, R6, c[0x3][0x80], RZ ; /* 0x00c0200006067a23 */ /* 0x001fc600000000ff */ /*0240*/ LDS R5, [R2.X4+0x28] ; /* 0x0000280002057984 */ /* 0x000e220000004800 */ /*0250*/ FFMA R13, R13, c[0x3][0x7c], R6 ; /* 0x00c01f000d0d7a23 */ /* 0x002fc60000000006 */ /*0260*/ LDS R7, [R2.X4+0x30] ; /* 0x0000300002077984 */ /* 0x000fe20000004800 */ /*0270*/ FFMA R8, R8, c[0x3][0x78], R13 ; /* 0x00c01e0008087a23 */ /* 0x004fc6000000000d */ /*0280*/ LDS R6, [R2.X4+0x2c] ; /* 0x00002c0002067984 */ /* 0x000e620000004800 */ /*0290*/ FFMA R15, R15, c[0x3][0x74], R8 ; /* 0x00c01d000f0f7a23 */ /* 0x008fc60000000008 */ /*02a0*/ LDS R9, [R2.X4+0x38] ; /* 0x0000380002097984 */ /* 0x000fe20000004800 */ /*02b0*/ FFMA R10, R10, c[0x3][0x70], R15 ; /* 0x00c01c000a0a7a23 */ /* 0x010fc6000000000f */ /*02c0*/ LDS R8, [R2.X4+0x34] ; /* 0x0000340002087984 */ /* 0x000ea20000004800 */ /*02d0*/ FFMA R17, R17, c[0x3][0x6c], R10 ; /* 0x00c01b0011117a23 */ /* 0x020fc6000000000a */ /*02e0*/ LDS R11, [R2.X4+0x40] ; /* 0x00004000020b7984 */ /* 0x000fe20000004800 */ /*02f0*/ FFMA R12, R12, c[0x3][0x68], R17 ; /* 0x00c01a000c0c7a23 */ /* 0x000fc60000000011 */ /*0300*/ LDS R10, [R2.X4+0x3c] ; /* 0x00003c00020a7984 */ /* 0x000ee20000004800 */ /*0310*/ FFMA R19, R19, c[0x3][0x64], R12 ; /* 0x00c0190013137a23 */ /* 0x000fc6000000000c */ /*0320*/ LDS R13, [R2.X4+0x48] ; /* 0x00004800020d7984 */ /* 0x000fe20000004800 */ /*0330*/ FFMA R19, R14, c[0x3][0x60], R19 ; /* 0x00c018000e137a23 */ /* 0x000fc60000000013 */ /*0340*/ LDS R12, [R2.X4+0x44] ; /* 0x00004400020c7984 */ /* 0x000f220000004800 */ /*0350*/ FFMA R14, R4, c[0x3][0x5c], R19 ; /* 0x00c01700040e7a23 */ /* 0x000fc60000000013 */ /*0360*/ LDS R16, [R2.X4+0x6c] ; /* 0x00006c0002107984 */ /* 0x000fe80000004800 */ /*0370*/ LDS R4, [R2.X4+0x4c] ; /* 0x00004c0002047984 */ /* 0x000f620000004800 */ /*0380*/ FFMA R15, R5, c[0x3][0x58], R14 ; /* 0x00c01600050f7a23 */ /* 0x001fc6000000000e */ /*0390*/ LDS R5, [R2.X4+0x50] ; /* 0x0000500002057984 */ /* 0x000e220000004800 */ /*03a0*/ FFMA R14, R6, c[0x3][0x54], R15 ; /* 0x00c01500060e7a23 */ /* 0x002fc6000000000f */ /*03b0*/ LDS R18, [R2.X4+0x74] ; /* 0x0000740002127984 */ /* 0x000fe20000004800 */ /*03c0*/ FFMA R15, R7, c[0x3][0x50], R14 ; /* 0x00c01400070f7a23 */ /* 0x000fc6000000000e */ /*03d0*/ LDS R6, [R2.X4+0x54] ; /* 0x0000540002067984 */ /* 0x000e620000004800 */ /*03e0*/ FFMA R14, R8, c[0x3][0x4c], R15 ; /* 0x00c01300080e7a23 */ /* 0x004fc6000000000f */ /*03f0*/ LDS R7, [R2.X4+0x58] ; /* 0x0000580002077984 */ /* 0x000ea20000004800 */ /*0400*/ FFMA R15, R9, c[0x3][0x48], R14 ; /* 0x00c01200090f7a23 */ /* 0x000fc6000000000e */ /*0410*/ LDS R8, [R2.X4+0x5c] ; /* 0x00005c0002087984 */ /* 0x000ea20000004800 */ /*0420*/ FFMA R14, R10, c[0x3][0x44], R15 ; /* 0x00c011000a0e7a23 */ /* 0x008fc6000000000f */ /*0430*/ LDS R9, [R2.X4+0x60] ; /* 0x0000600002097984 */ /* 0x000ee20000004800 */ /*0440*/ FFMA R11, R11, c[0x3][0x40], R14 ; /* 0x00c010000b0b7a23 */ /* 0x000fc6000000000e */ /*0450*/ LDS R10, [R2.X4+0x64] ; /* 0x00006400020a7984 */ /* 0x000ee20000004800 */ /*0460*/ FFMA R12, R12, c[0x3][0x3c], R11 ; /* 0x00c00f000c0c7a23 */ /* 0x010fc6000000000b */ /*0470*/ LDS R14, [R2.X4+0x68] ; /* 0x00006800020e7984 */ /* 0x000f220000004800 */ /*0480*/ FFMA R13, R13, c[0x3][0x38], R12 ; /* 0x00c00e000d0d7a23 */ /* 0x000fc6000000000c */ /*0490*/ LDS R11, [R2.X4+0x80] ; /* 0x00008000020b7984 */ /* 0x000fe20000004800 */ /*04a0*/ FFMA R4, R4, c[0x3][0x34], R13 ; /* 0x00c00d0004047a23 */ /* 0x020fc6000000000d */ /*04b0*/ LDS R12, [R2.X4+0x70] ; /* 0x00007000020c7984 */ /* 0x000f620000004800 */ /*04c0*/ FFMA R5, R5, c[0x3][0x30], R4 ; /* 0x00c00c0005057a23 */ /* 0x001fc60000000004 */ /*04d0*/ LDS R4, [R2.X4+0x78] ; /* 0x0000780002047984 */ /* 0x000e220000004800 */ /*04e0*/ FFMA R6, R6, c[0x3][0x2c], R5 ; /* 0x00c00b0006067a23 */ /* 0x002fc60000000005 */ /*04f0*/ LDS R5, [R2.X4+0x7c] ; /* 0x00007c0002057984 */ /* 0x0002220000004800 */ /*0500*/ FFMA R7, R7, c[0x3][0x28], R6 ; /* 0x00c00a0007077a23 */ /* 0x004fc80000000006 */ /*0510*/ FFMA R8, R8, c[0x3][0x24], R7 ; /* 0x00c0090008087a23 */ /* 0x000fe40000000007 */ /*0520*/ IMAD.WIDE R2, R3, R0, c[0x0][0x160] ; /* 0x0000580003027625 */ /* 0x002fc800078e0200 */ /*0530*/ FFMA R9, R9, c[0x3][0x20], R8 ; /* 0x00c0080009097a23 */ /* 0x008fc80000000008 */ /*0540*/ FFMA R9, R10, c[0x3][0x1c], R9 ; /* 0x00c007000a097a23 */ /* 0x000fc80000000009 */ /*0550*/ FFMA R9, R14, c[0x3][0x18], R9 ; /* 0x00c006000e097a23 */ /* 0x010fc80000000009 */ /*0560*/ FFMA R9, R16, c[0x3][0x14], R9 ; /* 0x00c0050010097a23 */ /* 0x000fc80000000009 */ /*0570*/ FFMA R9, R12, c[0x3][0x10], R9 ; /* 0x00c004000c097a23 */ /* 0x020fc80000000009 */ /*0580*/ FFMA R9, R18, c[0x3][0xc], R9 ; /* 0x00c0030012097a23 */ /* 0x000fc80000000009 */ /*0590*/ FFMA R4, R4, c[0x3][0x8], R9 ; /* 0x00c0020004047a23 */ /* 0x001fc80000000009 */ /*05a0*/ FFMA R4, R5, c[0x3][0x4], R4 ; /* 0x00c0010005047a23 */ /* 0x000fc80000000004 */ /*05b0*/ FFMA R11, R11, c[0x3][0x0], R4 ; /* 0x00c000000b0b7a23 */ /* 0x000fca0000000004 */ /*05c0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x000fe2000c101904 */ /*05d0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*05e0*/ BRA 0x5e0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*05f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0600*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0610*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0620*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0630*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0640*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0650*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0660*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0670*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15tiledConvRowGPUPfS_ii .globl _Z15tiledConvRowGPUPfS_ii .p2align 8 .type _Z15tiledConvRowGPUPfS_ii,@function _Z15tiledConvRowGPUPfS_ii: s_clause 0x2 s_load_b32 s4, s[0:1], 0x24 s_load_b32 s5, s[0:1], 0x10 s_load_b64 s[2:3], s[0:1], 0x8 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s6, s4, 16 s_and_b32 s4, s4, 0xffff v_mad_u64_u32 v[2:3], null, s15, s6, v[1:2] v_mad_u64_u32 v[3:4], null, s14, s4, v[0:1] s_add_i32 s4, s5, 32 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 16, v0 s_cbranch_execz .LBB0_2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v6, 16, v2 v_mad_u64_u32 v[4:5], null, v6, s4, v[3:4] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v5, 31, v4 v_lshlrev_b64 v[4:5], 2, v[4:5] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v4, vcc_lo, s2, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off v_lshlrev_b32_e32 v5, 2, v0 s_delay_alu instid0(VALU_DEP_1) v_mad_u32_u24 v5, v1, 0x880, v5 s_waitcnt vmcnt(0) ds_store_b32 v5, v4 .LBB0_2: s_or_b32 exec_lo, exec_lo, s5 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v2, 16, v2 v_mad_u64_u32 v[4:5], null, v2, s4, v[3:4] s_mov_b32 s4, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v2, 16, v4 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[5:6], 2, v[2:3] v_add_co_u32 v5, vcc_lo, s2, v5 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v6, vcc_lo, s3, v6, vcc_lo global_load_b32 v5, v[5:6], off v_mul_u32_u24_e32 v6, 0x880, v1 v_lshl_add_u32 v6, v0, 2, v6 s_waitcnt vmcnt(0) ds_store_b32 v6, v5 offset:64 v_cmpx_lt_u32_e32 0x1ef, v0 s_cbranch_execz .LBB0_4 v_ashrrev_i32_e32 v5, 31, v4 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[4:5], 2, v[4:5] v_add_co_u32 v4, vcc_lo, s2, v4 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off offset:128 s_waitcnt vmcnt(0) ds_store_b32 v6, v4 offset:128 .LBB0_4: s_or_b32 exec_lo, exec_lo, s4 v_lshlrev_b32_e32 v0, 2, v0 s_mov_b32 s4, 0 s_getpc_b64 s[2:3] s_add_u32 s2, s2, d_Filter@rel32@lo+132 s_addc_u32 s3, s3, d_Filter@rel32@hi+140 s_waitcnt lgkmcnt(0) s_barrier v_mad_u32_u24 v1, v1, 0x880, v0 v_mov_b32_e32 v0, 0 buffer_gl0_inv .LBB0_5: v_add_nc_u32_e32 v4, s4, v1 s_load_b32 s5, s[2:3], 0x0 s_add_i32 s4, s4, 4 s_add_u32 s2, s2, -4 s_addc_u32 s3, s3, -1 ds_load_b32 v4, v4 s_cmpk_lg_i32 s4, 0x84 s_waitcnt lgkmcnt(0) v_fmac_f32_e32 v0, s5, v4 s_cbranch_scc1 .LBB0_5 s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b64 v[1:2], 2, v[2:3] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v1, vcc_lo, s0, v1 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo global_store_b32 v[1:2], v0, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15tiledConvRowGPUPfS_ii .amdhsa_group_segment_fixed_size 2176 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 7 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z15tiledConvRowGPUPfS_ii, .Lfunc_end0-_Z15tiledConvRowGPUPfS_ii .section .AMDGPU.csdata,"",@progbits .text .protected _Z15tiledConvColGPUPfS_ii .globl _Z15tiledConvColGPUPfS_ii .p2align 8 .type _Z15tiledConvColGPUPfS_ii,@function _Z15tiledConvColGPUPfS_ii: s_clause 0x2 s_load_b32 s4, s[0:1], 0x24 s_load_b32 s5, s[0:1], 0x10 s_load_b64 s[2:3], s[0:1], 0x8 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s6, s4, 16 s_and_b32 s4, s4, 0xffff v_mad_u64_u32 v[2:3], null, s15, s6, v[1:2] v_mad_u64_u32 v[3:4], null, s14, s4, v[0:1] s_add_i32 s4, s5, 32 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 16, v1 s_cbranch_execz .LBB1_2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[4:5], null, v2, s4, v[3:4] v_ashrrev_i32_e32 v5, 31, v4 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[4:5], 2, v[4:5] v_add_co_u32 v4, vcc_lo, s2, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo global_load_b32 v4, v[4:5], off offset:64 v_lshlrev_b32_e32 v5, 2, v0 v_lshl_add_u32 v5, v1, 6, v5 s_waitcnt vmcnt(0) ds_store_b32 v5, v4 .LBB1_2: s_or_b32 exec_lo, exec_lo, s5 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v4, 16, v2 v_add_nc_u32_e32 v6, 32, v2 v_lshlrev_b32_e32 v0, 2, v0 v_mul_lo_u32 v4, v4, s4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_lshl_add_u32 v1, v1, 6, v0 v_mov_b32_e32 v0, 0 v_add3_u32 v2, v3, v4, 16 v_mad_u64_u32 v[4:5], null, v6, s4, v[3:4] s_mov_b32 s4, 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v3, 31, v2 v_ashrrev_i32_e32 v5, 31, v4 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[6:7], 2, v[2:3] v_lshlrev_b64 v[4:5], 2, v[4:5] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v6, vcc_lo, s2, v6 v_add_co_ci_u32_e32 v7, vcc_lo, s3, v7, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v4, vcc_lo, s2, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo s_getpc_b64 s[2:3] s_add_u32 s2, s2, d_Filter@rel32@lo+132 s_addc_u32 s3, s3, d_Filter@rel32@hi+140 s_clause 0x1 global_load_b32 v6, v[6:7], off global_load_b32 v4, v[4:5], off offset:64 s_waitcnt vmcnt(0) ds_store_2addr_stride64_b32 v1, v6, v4 offset0:4 offset1:8 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB1_3: v_add_nc_u32_e32 v4, s4, v1 s_load_b32 s5, s[2:3], 0x0 s_add_i32 s4, s4, 64 s_add_u32 s2, s2, -4 s_addc_u32 s3, s3, -1 ds_load_b32 v4, v4 s_cmpk_lg_i32 s4, 0x840 s_waitcnt lgkmcnt(0) v_fmac_f32_e32 v0, s5, v4 s_cbranch_scc1 .LBB1_3 s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b64 v[1:2], 2, v[2:3] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v1, vcc_lo, s0, v1 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo global_store_b32 v[1:2], v0, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15tiledConvColGPUPfS_ii .amdhsa_group_segment_fixed_size 3072 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z15tiledConvColGPUPfS_ii, .Lfunc_end1-_Z15tiledConvColGPUPfS_ii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .protected d_Filter .type d_Filter,@object .section .bss,"aw",@nobits .globl d_Filter .p2align 4, 0x0 d_Filter: .zero 132 .size d_Filter, 132 .type __hip_cuid_,@object .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym d_Filter .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: by_value - .offset: 20 .size: 4 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 2176 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15tiledConvRowGPUPfS_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15tiledConvRowGPUPfS_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 7 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: by_value - .offset: 20 .size: 4 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 3072 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15tiledConvColGPUPfS_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15tiledConvColGPUPfS_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <chrono> int main() { std::vector<double> stocks; while (std::cin){ double stock_day; std::cin >> stock_day; stocks.push_back(stock_day); } auto start = std::chrono::steady_clock::now(); thrust::device_vector<double> dev(stocks); auto end = std::chrono::steady_clock::now(); std::chrono::duration<double> time_seconds = end-start; std::cout << "time: " << time_seconds.count() << "s\n"; }
code for sm_80 Function : _ZN3cub17CUB_200700_800_NS11EmptyKernelIvEEvv .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0020*/ BRA 0x20; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0030*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0040*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0050*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0060*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0070*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0080*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0090*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <chrono> int main() { std::vector<double> stocks; while (std::cin){ double stock_day; std::cin >> stock_day; stocks.push_back(stock_day); } auto start = std::chrono::steady_clock::now(); thrust::device_vector<double> dev(stocks); auto end = std::chrono::steady_clock::now(); std::chrono::duration<double> time_seconds = end-start; std::cout << "time: " << time_seconds.count() << "s\n"; }
#include <hip/hip_runtime.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <chrono> int main() { std::vector<double> stocks; while (std::cin){ double stock_day; std::cin >> stock_day; stocks.push_back(stock_day); } auto start = std::chrono::steady_clock::now(); thrust::device_vector<double> dev(stocks); auto end = std::chrono::steady_clock::now(); std::chrono::duration<double> time_seconds = end-start; std::cout << "time: " << time_seconds.count() << "s\n"; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <chrono> int main() { std::vector<double> stocks; while (std::cin){ double stock_day; std::cin >> stock_day; stocks.push_back(stock_day); } auto start = std::chrono::steady_clock::now(); thrust::device_vector<double> dev(stocks); auto end = std::chrono::steady_clock::now(); std::chrono::duration<double> time_seconds = end-start; std::cout << "time: " << time_seconds.count() << "s\n"; }
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _ZN3cub17CUB_200700_800_NS11EmptyKernelIvEEvv .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0020*/ BRA 0x20; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0030*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0040*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0050*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0060*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0070*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0080*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0090*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include <stdlib.h> #include <stdio.h> int main(void){ int num_elements = 16; int num_bytes = num_elements*sizeof(int); int *device_array = 0; int *host_array = 0; host_array = (int *)malloc(num_bytes); cudaMalloc((void**)&device_array, num_bytes); cudaMemset(device_array, 0, num_bytes); cudaMemcpy(host_array, device_array, num_bytes, cudaMemcpyDeviceToHost); int i; for(i = 0; i<num_elements; i++) printf("%d\n", host_array[i]); free(host_array); cudaFree(device_array); return 0; }
code for sm_80
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <stdlib.h> #include <stdio.h> int main(void){ int num_elements = 16; int num_bytes = num_elements*sizeof(int); int *device_array = 0; int *host_array = 0; host_array = (int *)malloc(num_bytes); cudaMalloc((void**)&device_array, num_bytes); cudaMemset(device_array, 0, num_bytes); cudaMemcpy(host_array, device_array, num_bytes, cudaMemcpyDeviceToHost); int i; for(i = 0; i<num_elements; i++) printf("%d\n", host_array[i]); free(host_array); cudaFree(device_array); return 0; }
.file "tmpxft_00003664_00000000-6_memory_model.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $24, %rsp .cfi_def_cfa_offset 64 movq %fs:40, %rax movq %rax, 8(%rsp) xorl %eax, %eax movq $0, (%rsp) movl $64, %edi call malloc@PLT movq %rax, %r13 movq %rsp, %rdi movl $64, %esi call cudaMalloc@PLT movl $64, %edx movl $0, %esi movq (%rsp), %rdi call cudaMemset@PLT movl $2, %ecx movl $64, %edx movq (%rsp), %rsi movq %r13, %rdi call cudaMemcpy@PLT movq %r13, %rbx leaq 64(%r13), %r12 leaq .LC0(%rip), %rbp .L4: movl (%rbx), %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT addq $4, %rbx cmpq %r12, %rbx jne .L4 movq %r13, %rdi call free@PLT movq (%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rax subq %fs:40, %rax jne .L8 movl $0, %eax addq $24, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L8: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <stdlib.h> #include <stdio.h> int main(void){ int num_elements = 16; int num_bytes = num_elements*sizeof(int); int *device_array = 0; int *host_array = 0; host_array = (int *)malloc(num_bytes); cudaMalloc((void**)&device_array, num_bytes); cudaMemset(device_array, 0, num_bytes); cudaMemcpy(host_array, device_array, num_bytes, cudaMemcpyDeviceToHost); int i; for(i = 0; i<num_elements; i++) printf("%d\n", host_array[i]); free(host_array); cudaFree(device_array); return 0; }
#include <hip/hip_runtime.h> #include <stdlib.h> #include <stdio.h> int main(void){ int num_elements = 16; int num_bytes = num_elements*sizeof(int); int *device_array = 0; int *host_array = 0; host_array = (int *)malloc(num_bytes); hipMalloc((void**)&device_array, num_bytes); hipMemset(device_array, 0, num_bytes); hipMemcpy(host_array, device_array, num_bytes, hipMemcpyDeviceToHost); int i; for(i = 0; i<num_elements; i++) printf("%d\n", host_array[i]); free(host_array); hipFree(device_array); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <stdlib.h> #include <stdio.h> int main(void){ int num_elements = 16; int num_bytes = num_elements*sizeof(int); int *device_array = 0; int *host_array = 0; host_array = (int *)malloc(num_bytes); hipMalloc((void**)&device_array, num_bytes); hipMemset(device_array, 0, num_bytes); hipMemcpy(host_array, device_array, num_bytes, hipMemcpyDeviceToHost); int i; for(i = 0; i<num_elements; i++) printf("%d\n", host_array[i]); free(host_array); hipFree(device_array); return 0; }
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include <stdlib.h> #include <stdio.h> int main(void){ int num_elements = 16; int num_bytes = num_elements*sizeof(int); int *device_array = 0; int *host_array = 0; host_array = (int *)malloc(num_bytes); hipMalloc((void**)&device_array, num_bytes); hipMemset(device_array, 0, num_bytes); hipMemcpy(host_array, device_array, num_bytes, hipMemcpyDeviceToHost); int i; for(i = 0; i<num_elements; i++) printf("%d\n", host_array[i]); free(host_array); hipFree(device_array); return 0; }
.text .file "memory_model.hip" .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r14 .cfi_def_cfa_offset 16 pushq %rbx .cfi_def_cfa_offset 24 pushq %rax .cfi_def_cfa_offset 32 .cfi_offset %rbx, -24 .cfi_offset %r14, -16 movq $0, (%rsp) movl $64, %edi callq malloc movq %rax, %rbx movq %rsp, %rdi movl $64, %esi callq hipMalloc movq (%rsp), %rdi movl $64, %edx xorl %esi, %esi callq hipMemset movq (%rsp), %rsi movl $64, %edx movq %rbx, %rdi movl $2, %ecx callq hipMemcpy xorl %r14d, %r14d .p2align 4, 0x90 .LBB0_1: # =>This Inner Loop Header: Depth=1 movl (%rbx,%r14,4), %esi movl $.L.str, %edi xorl %eax, %eax callq printf incq %r14 cmpq $16, %r14 jne .LBB0_1 # %bb.2: movq %rbx, %rdi callq free movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size main, .Lfunc_end0-main .cfi_endproc # -- End function .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d\n" .size .L.str, 4 .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00003664_00000000-6_memory_model.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $24, %rsp .cfi_def_cfa_offset 64 movq %fs:40, %rax movq %rax, 8(%rsp) xorl %eax, %eax movq $0, (%rsp) movl $64, %edi call malloc@PLT movq %rax, %r13 movq %rsp, %rdi movl $64, %esi call cudaMalloc@PLT movl $64, %edx movl $0, %esi movq (%rsp), %rdi call cudaMemset@PLT movl $2, %ecx movl $64, %edx movq (%rsp), %rsi movq %r13, %rdi call cudaMemcpy@PLT movq %r13, %rbx leaq 64(%r13), %r12 leaq .LC0(%rip), %rbp .L4: movl (%rbx), %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT addq $4, %rbx cmpq %r12, %rbx jne .L4 movq %r13, %rdi call free@PLT movq (%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rax subq %fs:40, %rax jne .L8 movl $0, %eax addq $24, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L8: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "memory_model.hip" .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r14 .cfi_def_cfa_offset 16 pushq %rbx .cfi_def_cfa_offset 24 pushq %rax .cfi_def_cfa_offset 32 .cfi_offset %rbx, -24 .cfi_offset %r14, -16 movq $0, (%rsp) movl $64, %edi callq malloc movq %rax, %rbx movq %rsp, %rdi movl $64, %esi callq hipMalloc movq (%rsp), %rdi movl $64, %edx xorl %esi, %esi callq hipMemset movq (%rsp), %rsi movl $64, %edx movq %rbx, %rdi movl $2, %ecx callq hipMemcpy xorl %r14d, %r14d .p2align 4, 0x90 .LBB0_1: # =>This Inner Loop Header: Depth=1 movl (%rbx,%r14,4), %esi movl $.L.str, %edi xorl %eax, %eax callq printf incq %r14 cmpq $16, %r14 jne .LBB0_1 # %bb.2: movq %rbx, %rdi callq free movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size main, .Lfunc_end0-main .cfi_endproc # -- End function .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d\n" .size .L.str, 4 .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include<thrust/sort.h> #include<stdio.h> #include<cuda.h> #include<thrust/device_ptr.h> int main() { const int N = 6; int keys_h[N] = { 1, 2, 1, 2, 4, 1}; int values_h[N] = {10,20,300,400,600,200}; int *keys_d,*values_d; size_t size = N * sizeof(int); cudaMalloc((void **) &keys_d, size); cudaMalloc((void **) &values_d, size); cudaMemcpy(keys_d, keys_h, size, cudaMemcpyHostToDevice); cudaMemcpy(values_d, values_h, size, cudaMemcpyHostToDevice); thrust::sort_by_key(keys_h, keys_h + N, values_h); cudaMemcpy(keys_d, keys_h, size, cudaMemcpyDeviceToHost); cudaMemcpy(values_d, values_h, size, cudaMemcpyDeviceToHost); for(int i=0; i<N; i++)printf("%d %d \n",keys_h[i],values_h[i]); cudaFree(keys_d); cudaFree(values_d); return 0; }
code for sm_80 Function : _ZN3cub17CUB_200700_800_NS11EmptyKernelIvEEvv .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0020*/ BRA 0x20; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0030*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0040*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0050*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0060*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0070*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0080*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0090*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include<thrust/sort.h> #include<stdio.h> #include<cuda.h> #include<thrust/device_ptr.h> int main() { const int N = 6; int keys_h[N] = { 1, 2, 1, 2, 4, 1}; int values_h[N] = {10,20,300,400,600,200}; int *keys_d,*values_d; size_t size = N * sizeof(int); cudaMalloc((void **) &keys_d, size); cudaMalloc((void **) &values_d, size); cudaMemcpy(keys_d, keys_h, size, cudaMemcpyHostToDevice); cudaMemcpy(values_d, values_h, size, cudaMemcpyHostToDevice); thrust::sort_by_key(keys_h, keys_h + N, values_h); cudaMemcpy(keys_d, keys_h, size, cudaMemcpyDeviceToHost); cudaMemcpy(values_d, values_h, size, cudaMemcpyDeviceToHost); for(int i=0; i<N; i++)printf("%d %d \n",keys_h[i],values_h[i]); cudaFree(keys_d); cudaFree(values_d); return 0; }
#include<thrust/sort.h> #include<stdio.h> #include<hip/hip_runtime.h> #include<thrust/device_ptr.h> int main() { const int N = 6; int keys_h[N] = { 1, 2, 1, 2, 4, 1}; int values_h[N] = {10,20,300,400,600,200}; int *keys_d,*values_d; size_t size = N * sizeof(int); hipMalloc((void **) &keys_d, size); hipMalloc((void **) &values_d, size); hipMemcpy(keys_d, keys_h, size, hipMemcpyHostToDevice); hipMemcpy(values_d, values_h, size, hipMemcpyHostToDevice); thrust::sort_by_key(keys_h, keys_h + N, values_h); hipMemcpy(keys_d, keys_h, size, hipMemcpyDeviceToHost); hipMemcpy(values_d, values_h, size, hipMemcpyDeviceToHost); for(int i=0; i<N; i++)printf("%d %d \n",keys_h[i],values_h[i]); hipFree(keys_d); hipFree(values_d); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include<thrust/sort.h> #include<stdio.h> #include<hip/hip_runtime.h> #include<thrust/device_ptr.h> int main() { const int N = 6; int keys_h[N] = { 1, 2, 1, 2, 4, 1}; int values_h[N] = {10,20,300,400,600,200}; int *keys_d,*values_d; size_t size = N * sizeof(int); hipMalloc((void **) &keys_d, size); hipMalloc((void **) &values_d, size); hipMemcpy(keys_d, keys_h, size, hipMemcpyHostToDevice); hipMemcpy(values_d, values_h, size, hipMemcpyHostToDevice); thrust::sort_by_key(keys_h, keys_h + N, values_h); hipMemcpy(keys_d, keys_h, size, hipMemcpyDeviceToHost); hipMemcpy(values_d, values_h, size, hipMemcpyDeviceToHost); for(int i=0; i<N; i++)printf("%d %d \n",keys_h[i],values_h[i]); hipFree(keys_d); hipFree(values_d); return 0; }
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _ZN3cub17CUB_200700_800_NS11EmptyKernelIvEEvv .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0020*/ BRA 0x20; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0030*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0040*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0050*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0060*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0070*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0080*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0090*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*00f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include <sys/time.h> #include <cuda.h> #include <stdio.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "Error: %s in %s at line %d\n", cudaGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; return (double) tv.tv_usec/1000000 + tv.tv_sec ; } // host side matrix addition void h_addmat(float *A, float *B, float *C, int nx, int ny){ for (int i =0;i<nx;i++){ for(int j=0;j<ny;j++){ C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; } } return; } // device-side matrix addition __global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){ int ix = threadIdx.x + blockIdx.x*(blockDim.x) ; int iy = threadIdx.y + blockIdx.y*(blockDim.y) ; //printf("In add\n"); if( (ix<nx/2) && (iy<ny/2) ){ int idx = (iy*nx/2 + ix)*4; C[idx] = A[idx] + B[idx] ; C[idx+1] = A[idx+1] + B[idx+1] ; C[idx+2] = A[idx+2] + B[idx+2] ; C[idx+3] = A[idx+3] + B[idx+3] ; //printf("Thread %d %d\n",ix,iy); } } void initData(float *M, int x, int y, int flag ){ if(flag) { //printf("A\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)(i+j)/3.0; } } } else { //printf("B\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)3.14*(i+j) ; } } } } int main( int argc, char *argv[] ) { if (argc!=3){ printf("Error: Invalid number of arguments.\n"); exit(1); } int nx = atoi( argv[1] ) ; // should check validity int ny = atoi( argv[2] ) ; // should check validity if(nx <=0 || ny <=0){ printf("Error: Dimension lessThanOrEqualto Zero.\n"); exit(1); } if(ny>nx) { nx=nx^ny; ny=nx^ny; nx=nx^ny; } int noElems = (nx)*(ny) ; int bytes = noElems * sizeof(float) ; // GPU and CPU memory Allocations float *d_A, *d_B, *d_C ; HANDLE_ERROR(cudaMalloc( (float **) &d_A, bytes )) ; HANDLE_ERROR(cudaMalloc( (float **) &d_B, bytes )) ; HANDLE_ERROR(cudaMalloc( (float **) &d_C, bytes )) ; float *h_hC = (float *) malloc( bytes ) ; // host result float *h_Ap, *h_Bp, *h_dCp; HANDLE_ERROR(cudaMallocHost( (float **) &h_Ap, bytes )) ; HANDLE_ERROR(cudaMallocHost( (float **) &h_Bp, bytes )) ; HANDLE_ERROR(cudaMallocHost( (float **) &h_dCp, bytes )) ; // init matrices with random data initData(h_Ap,nx,ny,1); initData(h_Bp,nx,ny,0); double timeStampA = getTimeStamp() ; //transfer data to dev HANDLE_ERROR (cudaMemcpy( d_A, h_Ap, bytes, cudaMemcpyHostToDevice )) ; HANDLE_ERROR (cudaMemcpy( d_B, h_Bp, bytes, cudaMemcpyHostToDevice )) ; double timeStampB = getTimeStamp() ; // invoke Kernel dim3 block( 1024, 1) ; // you will want to configure this dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; //printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes); f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ; cudaError_t err = cudaGetLastError(); if (err != cudaSuccess) printf("Error: %s\n", cudaGetErrorString(err)); HANDLE_ERROR(cudaDeviceSynchronize()) ; double timeStampC = getTimeStamp() ; //copy data back HANDLE_ERROR(cudaMemcpy(h_dCp, d_C, bytes, cudaMemcpyDeviceToHost)); double timeStampD = getTimeStamp() ; // free GPU resources cudaFree( d_A ) ; cudaFree( d_B ) ; cudaFree( d_C ) ; // CPU Matrix add h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ; // Check results int flag = 0; for(int i=0;i<(nx);i++){ for(int j=0;j<(ny);j++){ if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j]) flag++; } } if (flag == 0){ printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC)); } else printf("host result is not the same as the device result!"); //free other resourses cudaFreeHost(h_Ap); cudaFreeHost(h_Bp); cudaFreeHost(h_dCp); free(h_hC); cudaDeviceReset() ; }
code for sm_80 Function : _Z8f_addmatPfS_S_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e220000002600 */ /*0020*/ ULDC.64 UR10, c[0x0][0x178] ; /* 0x00005e00000a7ab9 */ /* 0x000fe40000000a00 */ /*0030*/ UMOV UR8, 0x2 ; /* 0x0000000200087882 */ /* 0x000fe20000000000 */ /*0040*/ S2R R5, SR_TID.Y ; /* 0x0000000000057919 */ /* 0x000e220000002200 */ /*0050*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe40008000000 */ /*0060*/ UMOV UR5, UR11 ; /* 0x0000000b00057c82 */ /* 0x000fe20008000000 */ /*0070*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e620000002500 */ /*0080*/ UIMAD.WIDE.U32 UR6, UR8, UR11, UR4 ; /* 0x0000000b080672a5 */ /* 0x000fc6000f8e0004 */ /*0090*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e620000002100 */ /*00a0*/ UMOV UR5, UR10 ; /* 0x0000000a00057c82 */ /* 0x000fe40008000000 */ /*00b0*/ UIMAD.WIDE.U32 UR4, UR8, UR10, UR4 ; /* 0x0000000a080472a5 */ /* 0x000fe4000f8e0004 */ /*00c0*/ USHF.R.S32.HI UR7, URZ, 0x1, UR7 ; /* 0x000000013f077899 */ /* 0x000fe40008011407 */ /*00d0*/ USHF.R.S32.HI UR5, URZ, 0x1, UR5 ; /* 0x000000013f057899 */ /* 0x000fe20008011405 */ /*00e0*/ IMAD R2, R2, c[0x0][0x4], R5 ; /* 0x0000010002027a24 */ /* 0x001fca00078e0205 */ /*00f0*/ ISETP.GE.AND P0, PT, R2, UR7, PT ; /* 0x0000000702007c0c */ /* 0x000fe2000bf06270 */ /*0100*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x002fca00078e0203 */ /*0110*/ ISETP.GE.OR P0, PT, R0, UR5, P0 ; /* 0x0000000500007c0c */ /* 0x000fda0008706670 */ /*0120*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0130*/ IMAD R2, R2, c[0x0][0x178], RZ ; /* 0x00005e0002027a24 */ /* 0x000fe200078e02ff */ /*0140*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc80000000a00 */ /*0150*/ LEA.HI R3, R2, R2, RZ, 0x1 ; /* 0x0000000202037211 */ /* 0x000fe200078f08ff */ /*0160*/ HFMA2.MMA R2, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff027435 */ /* 0x000fc600000001ff */ /*0170*/ LEA.HI R3, R3, R0, RZ, 0x1f ; /* 0x0000000003037211 */ /* 0x000fc800078ff8ff */ /*0180*/ SHF.L.U32 R3, R3, 0x2, RZ ; /* 0x0000000203037819 */ /* 0x000fca00000006ff */ /*0190*/ IMAD.WIDE R4, R3, R2, c[0x0][0x160] ; /* 0x0000580003047625 */ /* 0x000fc800078e0202 */ /*01a0*/ IMAD.WIDE R6, R3.reuse, R2.reuse, c[0x0][0x168] ; /* 0x00005a0003067625 */ /* 0x0c0fe200078e0202 */ /*01b0*/ LDG.E R9, [R4.64] ; /* 0x0000000404097981 */ /* 0x000ea8000c1e1900 */ /*01c0*/ LDG.E R0, [R6.64] ; /* 0x0000000406007981 */ /* 0x000ea2000c1e1900 */ /*01d0*/ IMAD.WIDE R2, R3, R2, c[0x0][0x170] ; /* 0x00005c0003027625 */ /* 0x000fc800078e0202 */ /*01e0*/ FADD R9, R0, R9 ; /* 0x0000000900097221 */ /* 0x004fca0000000000 */ /*01f0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x000fe8000c101904 */ /*0200*/ LDG.E R0, [R6.64+0x4] ; /* 0x0000040406007981 */ /* 0x000ea8000c1e1900 */ /*0210*/ LDG.E R11, [R4.64+0x4] ; /* 0x00000404040b7981 */ /* 0x000ea4000c1e1900 */ /*0220*/ FADD R11, R0, R11 ; /* 0x0000000b000b7221 */ /* 0x004fca0000000000 */ /*0230*/ STG.E [R2.64+0x4], R11 ; /* 0x0000040b02007986 */ /* 0x000fe8000c101904 */ /*0240*/ LDG.E R0, [R6.64+0x8] ; /* 0x0000080406007981 */ /* 0x000ea8000c1e1900 */ /*0250*/ LDG.E R13, [R4.64+0x8] ; /* 0x00000804040d7981 */ /* 0x000ea4000c1e1900 */ /*0260*/ FADD R13, R0, R13 ; /* 0x0000000d000d7221 */ /* 0x004fca0000000000 */ /*0270*/ STG.E [R2.64+0x8], R13 ; /* 0x0000080d02007986 */ /* 0x000fe8000c101904 */ /*0280*/ LDG.E R0, [R6.64+0xc] ; /* 0x00000c0406007981 */ /* 0x000ea8000c1e1900 */ /*0290*/ LDG.E R15, [R4.64+0xc] ; /* 0x00000c04040f7981 */ /* 0x000ea4000c1e1900 */ /*02a0*/ FADD R15, R0, R15 ; /* 0x0000000f000f7221 */ /* 0x004fca0000000000 */ /*02b0*/ STG.E [R2.64+0xc], R15 ; /* 0x00000c0f02007986 */ /* 0x000fe2000c101904 */ /*02c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*02d0*/ BRA 0x2d0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*02e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0300*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0310*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0320*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0330*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0340*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0350*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0360*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0370*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <sys/time.h> #include <cuda.h> #include <stdio.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "Error: %s in %s at line %d\n", cudaGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; return (double) tv.tv_usec/1000000 + tv.tv_sec ; } // host side matrix addition void h_addmat(float *A, float *B, float *C, int nx, int ny){ for (int i =0;i<nx;i++){ for(int j=0;j<ny;j++){ C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; } } return; } // device-side matrix addition __global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){ int ix = threadIdx.x + blockIdx.x*(blockDim.x) ; int iy = threadIdx.y + blockIdx.y*(blockDim.y) ; //printf("In add\n"); if( (ix<nx/2) && (iy<ny/2) ){ int idx = (iy*nx/2 + ix)*4; C[idx] = A[idx] + B[idx] ; C[idx+1] = A[idx+1] + B[idx+1] ; C[idx+2] = A[idx+2] + B[idx+2] ; C[idx+3] = A[idx+3] + B[idx+3] ; //printf("Thread %d %d\n",ix,iy); } } void initData(float *M, int x, int y, int flag ){ if(flag) { //printf("A\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)(i+j)/3.0; } } } else { //printf("B\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)3.14*(i+j) ; } } } } int main( int argc, char *argv[] ) { if (argc!=3){ printf("Error: Invalid number of arguments.\n"); exit(1); } int nx = atoi( argv[1] ) ; // should check validity int ny = atoi( argv[2] ) ; // should check validity if(nx <=0 || ny <=0){ printf("Error: Dimension lessThanOrEqualto Zero.\n"); exit(1); } if(ny>nx) { nx=nx^ny; ny=nx^ny; nx=nx^ny; } int noElems = (nx)*(ny) ; int bytes = noElems * sizeof(float) ; // GPU and CPU memory Allocations float *d_A, *d_B, *d_C ; HANDLE_ERROR(cudaMalloc( (float **) &d_A, bytes )) ; HANDLE_ERROR(cudaMalloc( (float **) &d_B, bytes )) ; HANDLE_ERROR(cudaMalloc( (float **) &d_C, bytes )) ; float *h_hC = (float *) malloc( bytes ) ; // host result float *h_Ap, *h_Bp, *h_dCp; HANDLE_ERROR(cudaMallocHost( (float **) &h_Ap, bytes )) ; HANDLE_ERROR(cudaMallocHost( (float **) &h_Bp, bytes )) ; HANDLE_ERROR(cudaMallocHost( (float **) &h_dCp, bytes )) ; // init matrices with random data initData(h_Ap,nx,ny,1); initData(h_Bp,nx,ny,0); double timeStampA = getTimeStamp() ; //transfer data to dev HANDLE_ERROR (cudaMemcpy( d_A, h_Ap, bytes, cudaMemcpyHostToDevice )) ; HANDLE_ERROR (cudaMemcpy( d_B, h_Bp, bytes, cudaMemcpyHostToDevice )) ; double timeStampB = getTimeStamp() ; // invoke Kernel dim3 block( 1024, 1) ; // you will want to configure this dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; //printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes); f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ; cudaError_t err = cudaGetLastError(); if (err != cudaSuccess) printf("Error: %s\n", cudaGetErrorString(err)); HANDLE_ERROR(cudaDeviceSynchronize()) ; double timeStampC = getTimeStamp() ; //copy data back HANDLE_ERROR(cudaMemcpy(h_dCp, d_C, bytes, cudaMemcpyDeviceToHost)); double timeStampD = getTimeStamp() ; // free GPU resources cudaFree( d_A ) ; cudaFree( d_B ) ; cudaFree( d_C ) ; // CPU Matrix add h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ; // Check results int flag = 0; for(int i=0;i<(nx);i++){ for(int j=0;j<(ny);j++){ if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j]) flag++; } } if (flag == 0){ printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC)); } else printf("host result is not the same as the device result!"); //free other resourses cudaFreeHost(h_Ap); cudaFreeHost(h_Bp); cudaFreeHost(h_dCp); free(h_hC); cudaDeviceReset() ; }
.file "tmpxft_00011dd8_00000000-6_1005678036.cudafe1.cpp" .text #APP .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Error: %s in %s at line %d\n" #NO_APP .text .type _ZL11HandleError9cudaErrorPKci, @function _ZL11HandleError9cudaErrorPKci: .LFB2057: .cfi_startproc testl %edi, %edi jne .L6 ret .L6: pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 subq $8, %rsp .cfi_def_cfa_offset 32 movq %rsi, %rbx movl %edx, %ebp call cudaGetErrorString@PLT movq %rax, %rdx movl %ebp, %r8d movq %rbx, %rcx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .cfi_endproc .LFE2057: .size _ZL11HandleError9cudaErrorPKci, .-_ZL11HandleError9cudaErrorPKci .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2064: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2064: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z12getTimeStampv .type _Z12getTimeStampv, @function _Z12getTimeStampv: .LFB2058: .cfi_startproc endbr64 subq $40, %rsp .cfi_def_cfa_offset 48 movq %fs:40, %rax movq %rax, 24(%rsp) xorl %eax, %eax movq %rsp, %rdi movl $0, %esi call gettimeofday@PLT pxor %xmm0, %xmm0 cvtsi2sdq 8(%rsp), %xmm0 divsd .LC1(%rip), %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq (%rsp), %xmm1 addsd %xmm1, %xmm0 movq 24(%rsp), %rax subq %fs:40, %rax jne .L12 addq $40, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L12: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size _Z12getTimeStampv, .-_Z12getTimeStampv .globl _Z8h_addmatPfS_S_ii .type _Z8h_addmatPfS_S_ii, @function _Z8h_addmatPfS_S_ii: .LFB2059: .cfi_startproc endbr64 testl %ecx, %ecx jle .L21 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movq %rdx, %r9 movl $0, %r11d movl $0, %r10d movslq %r8d, %rbx jmp .L15 .L17: movslq %r11d, %rdx leaq 0(,%rdx,4), %rax addq %rbx, %rdx salq $2, %rdx .L16: movss (%rdi,%rax), %xmm0 addss (%rsi,%rax), %xmm0 movss %xmm0, (%r9,%rax) addq $4, %rax cmpq %rdx, %rax jne .L16 .L18: addl $1, %r10d addl %r8d, %r11d cmpl %r10d, %ecx je .L13 .L15: testl %r8d, %r8d jg .L17 jmp .L18 .L13: popq %rbx .cfi_def_cfa_offset 8 ret .L21: .cfi_restore 3 ret .cfi_endproc .LFE2059: .size _Z8h_addmatPfS_S_ii, .-_Z8h_addmatPfS_S_ii .globl _Z8initDataPfiii .type _Z8initDataPfiii, @function _Z8initDataPfiii: .LFB2060: .cfi_startproc endbr64 movq %rdi, %r8 movl %esi, %r9d movl %edx, %edi testl %ecx, %ecx jne .L25 testl %esi, %esi jle .L24 movl %edx, %esi movl $0, %r10d movss .LC3(%rip), %xmm1 jmp .L27 .L25: testl %esi, %esi jle .L24 movl %edx, %ecx movl $0, %r10d movl $0, %esi movss .LC2(%rip), %xmm1 jmp .L28 .L30: movl %esi, %eax movslq %r10d, %rdx leaq (%r8,%rdx,4), %rdx .L29: pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 divss %xmm1, %xmm0 movss %xmm0, (%rdx) addl $1, %eax addq $4, %rdx cmpl %ecx, %eax jne .L29 .L31: addl $1, %esi addl %edi, %r10d addl $1, %ecx cmpl %esi, %r9d je .L24 .L28: testl %edi, %edi jg .L30 jmp .L31 .L33: movl %ecx, %eax movslq %r10d, %rdx leaq (%r8,%rdx,4), %rdx .L32: pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss %xmm1, %xmm0 movss %xmm0, (%rdx) addl $1, %eax addq $4, %rdx cmpl %esi, %eax jne .L32 .L34: addl $1, %ecx addl %edi, %r10d addl $1, %esi cmpl %ecx, %r9d je .L24 .L27: testl %edi, %edi jg .L33 jmp .L34 .L24: ret .cfi_endproc .LFE2060: .size _Z8initDataPfiii, .-_Z8initDataPfiii .globl _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii .type _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, @function _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii: .LFB2086: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movl %ecx, 4(%rsp) movl %r8d, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 4(%rsp), %rax movq %rax, 120(%rsp) movq %rsp, %rax movq %rax, 128(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L41 .L37: movq 136(%rsp), %rax subq %fs:40, %rax jne .L42 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L41: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z8f_addmatPfS_S_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L37 .L42: call __stack_chk_fail@PLT .cfi_endproc .LFE2086: .size _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, .-_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii .globl _Z8f_addmatPfS_S_ii .type _Z8f_addmatPfS_S_ii, @function _Z8f_addmatPfS_S_ii: .LFB2087: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2087: .size _Z8f_addmatPfS_S_ii, .-_Z8f_addmatPfS_S_ii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "Error: Invalid number of arguments.\n" .align 8 .LC5: .string "Error: Dimension lessThanOrEqualto Zero.\n" .align 8 .LC6: .string "/home/ubuntu/Datasets/stackv2/train-structured/Eavenx/assignment2/master/1005678036.cu" .section .rodata.str1.1 .LC7: .string "Error: %s\n" .LC8: .string "%.6f %.6f %.6f %.6f\n" .section .rodata.str1.8 .align 8 .LC9: .string "host result is not the same as the device result!" .text .globl main .type main, @function main: .LFB2061: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $112, %rsp .cfi_def_cfa_offset 160 movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax cmpl $3, %edi jne .L64 movq %rsi, %rbp movq 8(%rsi), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movq %rax, %rbx movl %eax, %r12d movq 16(%rbp), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movl %eax, %ebp testl %ebx, %ebx jle .L60 testl %eax, %eax jle .L60 cmpl %ebx, %eax cmovle %ebx, %ebp cmovle %eax, %r12d movl %ebp, %r13d imull %r12d, %r13d sall $2, %r13d movslq %r13d, %r13 leaq 32(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl %eax, %edi movl $107, %edx leaq .LC6(%rip), %r14 movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 40(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl %eax, %edi movl $108, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 48(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl %eax, %edi movl $109, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci movq %r13, %rdi call malloc@PLT movq %rax, %rbx leaq 56(%rsp), %rdi movl $0, %edx movq %r13, %rsi call cudaHostAlloc@PLT movl %eax, %edi movl $113, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 64(%rsp), %rdi movl $0, %edx movq %r13, %rsi call cudaHostAlloc@PLT movl %eax, %edi movl $114, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 72(%rsp), %rdi movl $0, %edx movq %r13, %rsi call cudaHostAlloc@PLT movl %eax, %edi movl $115, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci movl $1, %ecx movl %r12d, %edx movl %ebp, %esi movq 56(%rsp), %rdi call _Z8initDataPfiii movl $0, %ecx movl %r12d, %edx movl %ebp, %esi movq 64(%rsp), %rdi call _Z8initDataPfiii call _Z12getTimeStampv movsd %xmm0, (%rsp) movl $1, %ecx movq %r13, %rdx movq 56(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %edi movl $124, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci movl $1, %ecx movq %r13, %rdx movq 64(%rsp), %rsi movq 40(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %edi movl $125, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci call _Z12getTimeStampv movsd %xmm0, 8(%rsp) movl $1, 88(%rsp) leal 1023(%rbp), %eax shrl $10, %eax movl %eax, 92(%rsp) movl %r12d, 96(%rsp) movl $1, 100(%rsp) movl $1024, 80(%rsp) movl $1, 84(%rsp) movl $0, %r9d movl $0, %r8d movq 80(%rsp), %rdx movl $1, %ecx movq 92(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L65 .L50: call cudaGetLastError@PLT testl %eax, %eax jne .L66 .L51: call cudaDeviceSynchronize@PLT movl %eax, %edi movl $139, %edx leaq .LC6(%rip), %r14 movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci call _Z12getTimeStampv movsd %xmm0, 16(%rsp) movl $2, %ecx movq %r13, %rdx movq 48(%rsp), %rsi movq 72(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %edi movl $144, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci call _Z12getTimeStampv movsd %xmm0, 24(%rsp) movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 48(%rsp), %rdi call cudaFree@PLT movl %r12d, %r8d movl %ebp, %ecx movq %rbx, %rdx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z8h_addmatPfS_S_ii movq 72(%rsp), %rdx movslq %r12d, %r8 leaq 0(,%r8,4), %r9 negq %r8 salq $2, %r8 movq %r9, %rcx movl $0, %edi movl $0, %esi jmp .L52 .L64: leaq .LC4(%rip), %rsi movl $2, %edi call __printf_chk@PLT movl $1, %edi call exit@PLT .L60: leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .L65: movl %r12d, %r8d movl %ebp, %ecx movq 48(%rsp), %rdx movq 40(%rsp), %rsi movq 32(%rsp), %rdi call _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii jmp .L50 .L66: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx leaq .LC7(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L51 .L61: addl $1, %esi .L53: addq $4, %rax cmpq %rcx, %rax je .L67 .L55: movss (%rbx,%rax), %xmm0 ucomiss (%rdx,%rax), %xmm0 jp .L61 je .L53 jmp .L61 .L67: addl $1, %edi addq %r9, %rcx cmpl %edi, %ebp je .L56 .L52: leaq (%rcx,%r8), %rax jmp .L55 .L56: testl %esi, %esi jne .L57 movsd 24(%rsp), %xmm4 movapd %xmm4, %xmm0 movsd (%rsp), %xmm5 subsd %xmm5, %xmm0 movapd %xmm4, %xmm3 movsd 16(%rsp), %xmm2 subsd %xmm2, %xmm3 movsd 8(%rsp), %xmm1 subsd %xmm1, %xmm2 subsd %xmm5, %xmm1 leaq .LC8(%rip), %rsi movl $2, %edi movl $4, %eax call __printf_chk@PLT .L58: movq 56(%rsp), %rdi call cudaFreeHost@PLT movq 64(%rsp), %rdi call cudaFreeHost@PLT movq 72(%rsp), %rdi call cudaFreeHost@PLT movq %rbx, %rdi call free@PLT call cudaDeviceReset@PLT movq 104(%rsp), %rax subq %fs:40, %rax jne .L68 movl $0, %eax addq $112, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L57: .cfi_restore_state leaq .LC9(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L58 .L68: call __stack_chk_fail@PLT .cfi_endproc .LFE2061: .size main, .-main .section .rodata.str1.1 .LC10: .string "_Z8f_addmatPfS_S_ii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2089: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC10(%rip), %rdx movq %rdx, %rcx leaq _Z8f_addmatPfS_S_ii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2089: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC1: .long 0 .long 1093567616 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC2: .long 1077936128 .align 4 .LC3: .long 1078523331 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <sys/time.h> #include <cuda.h> #include <stdio.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "Error: %s in %s at line %d\n", cudaGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; return (double) tv.tv_usec/1000000 + tv.tv_sec ; } // host side matrix addition void h_addmat(float *A, float *B, float *C, int nx, int ny){ for (int i =0;i<nx;i++){ for(int j=0;j<ny;j++){ C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; } } return; } // device-side matrix addition __global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){ int ix = threadIdx.x + blockIdx.x*(blockDim.x) ; int iy = threadIdx.y + blockIdx.y*(blockDim.y) ; //printf("In add\n"); if( (ix<nx/2) && (iy<ny/2) ){ int idx = (iy*nx/2 + ix)*4; C[idx] = A[idx] + B[idx] ; C[idx+1] = A[idx+1] + B[idx+1] ; C[idx+2] = A[idx+2] + B[idx+2] ; C[idx+3] = A[idx+3] + B[idx+3] ; //printf("Thread %d %d\n",ix,iy); } } void initData(float *M, int x, int y, int flag ){ if(flag) { //printf("A\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)(i+j)/3.0; } } } else { //printf("B\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)3.14*(i+j) ; } } } } int main( int argc, char *argv[] ) { if (argc!=3){ printf("Error: Invalid number of arguments.\n"); exit(1); } int nx = atoi( argv[1] ) ; // should check validity int ny = atoi( argv[2] ) ; // should check validity if(nx <=0 || ny <=0){ printf("Error: Dimension lessThanOrEqualto Zero.\n"); exit(1); } if(ny>nx) { nx=nx^ny; ny=nx^ny; nx=nx^ny; } int noElems = (nx)*(ny) ; int bytes = noElems * sizeof(float) ; // GPU and CPU memory Allocations float *d_A, *d_B, *d_C ; HANDLE_ERROR(cudaMalloc( (float **) &d_A, bytes )) ; HANDLE_ERROR(cudaMalloc( (float **) &d_B, bytes )) ; HANDLE_ERROR(cudaMalloc( (float **) &d_C, bytes )) ; float *h_hC = (float *) malloc( bytes ) ; // host result float *h_Ap, *h_Bp, *h_dCp; HANDLE_ERROR(cudaMallocHost( (float **) &h_Ap, bytes )) ; HANDLE_ERROR(cudaMallocHost( (float **) &h_Bp, bytes )) ; HANDLE_ERROR(cudaMallocHost( (float **) &h_dCp, bytes )) ; // init matrices with random data initData(h_Ap,nx,ny,1); initData(h_Bp,nx,ny,0); double timeStampA = getTimeStamp() ; //transfer data to dev HANDLE_ERROR (cudaMemcpy( d_A, h_Ap, bytes, cudaMemcpyHostToDevice )) ; HANDLE_ERROR (cudaMemcpy( d_B, h_Bp, bytes, cudaMemcpyHostToDevice )) ; double timeStampB = getTimeStamp() ; // invoke Kernel dim3 block( 1024, 1) ; // you will want to configure this dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; //printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes); f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ; cudaError_t err = cudaGetLastError(); if (err != cudaSuccess) printf("Error: %s\n", cudaGetErrorString(err)); HANDLE_ERROR(cudaDeviceSynchronize()) ; double timeStampC = getTimeStamp() ; //copy data back HANDLE_ERROR(cudaMemcpy(h_dCp, d_C, bytes, cudaMemcpyDeviceToHost)); double timeStampD = getTimeStamp() ; // free GPU resources cudaFree( d_A ) ; cudaFree( d_B ) ; cudaFree( d_C ) ; // CPU Matrix add h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ; // Check results int flag = 0; for(int i=0;i<(nx);i++){ for(int j=0;j<(ny);j++){ if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j]) flag++; } } if (flag == 0){ printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC)); } else printf("host result is not the same as the device result!"); //free other resourses cudaFreeHost(h_Ap); cudaFreeHost(h_Bp); cudaFreeHost(h_dCp); free(h_hC); cudaDeviceReset() ; }
#include <sys/time.h> #include <hip/hip_runtime.h> #include <stdio.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( hipError_t err, const char *file, int line ) { if (err != hipSuccess) { printf( "Error: %s in %s at line %d\n", hipGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; return (double) tv.tv_usec/1000000 + tv.tv_sec ; } // host side matrix addition void h_addmat(float *A, float *B, float *C, int nx, int ny){ for (int i =0;i<nx;i++){ for(int j=0;j<ny;j++){ C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; } } return; } // device-side matrix addition __global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){ int ix = threadIdx.x + blockIdx.x*(blockDim.x) ; int iy = threadIdx.y + blockIdx.y*(blockDim.y) ; //printf("In add\n"); if( (ix<nx/2) && (iy<ny/2) ){ int idx = (iy*nx/2 + ix)*4; C[idx] = A[idx] + B[idx] ; C[idx+1] = A[idx+1] + B[idx+1] ; C[idx+2] = A[idx+2] + B[idx+2] ; C[idx+3] = A[idx+3] + B[idx+3] ; //printf("Thread %d %d\n",ix,iy); } } void initData(float *M, int x, int y, int flag ){ if(flag) { //printf("A\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)(i+j)/3.0; } } } else { //printf("B\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)3.14*(i+j) ; } } } } int main( int argc, char *argv[] ) { if (argc!=3){ printf("Error: Invalid number of arguments.\n"); exit(1); } int nx = atoi( argv[1] ) ; // should check validity int ny = atoi( argv[2] ) ; // should check validity if(nx <=0 || ny <=0){ printf("Error: Dimension lessThanOrEqualto Zero.\n"); exit(1); } if(ny>nx) { nx=nx^ny; ny=nx^ny; nx=nx^ny; } int noElems = (nx)*(ny) ; int bytes = noElems * sizeof(float) ; // GPU and CPU memory Allocations float *d_A, *d_B, *d_C ; HANDLE_ERROR(hipMalloc( (float **) &d_A, bytes )) ; HANDLE_ERROR(hipMalloc( (float **) &d_B, bytes )) ; HANDLE_ERROR(hipMalloc( (float **) &d_C, bytes )) ; float *h_hC = (float *) malloc( bytes ) ; // host result float *h_Ap, *h_Bp, *h_dCp; HANDLE_ERROR(hipHostMalloc( (float **) &h_Ap, bytes , hipHostMallocDefault)) ; HANDLE_ERROR(hipHostMalloc( (float **) &h_Bp, bytes , hipHostMallocDefault)) ; HANDLE_ERROR(hipHostMalloc( (float **) &h_dCp, bytes , hipHostMallocDefault)) ; // init matrices with random data initData(h_Ap,nx,ny,1); initData(h_Bp,nx,ny,0); double timeStampA = getTimeStamp() ; //transfer data to dev HANDLE_ERROR (hipMemcpy( d_A, h_Ap, bytes, hipMemcpyHostToDevice )) ; HANDLE_ERROR (hipMemcpy( d_B, h_Bp, bytes, hipMemcpyHostToDevice )) ; double timeStampB = getTimeStamp() ; // invoke Kernel dim3 block( 1024, 1) ; // you will want to configure this dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; //printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes); f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ; hipError_t err = hipGetLastError(); if (err != hipSuccess) printf("Error: %s\n", hipGetErrorString(err)); HANDLE_ERROR(hipDeviceSynchronize()) ; double timeStampC = getTimeStamp() ; //copy data back HANDLE_ERROR(hipMemcpy(h_dCp, d_C, bytes, hipMemcpyDeviceToHost)); double timeStampD = getTimeStamp() ; // free GPU resources hipFree( d_A ) ; hipFree( d_B ) ; hipFree( d_C ) ; // CPU Matrix add h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ; // Check results int flag = 0; for(int i=0;i<(nx);i++){ for(int j=0;j<(ny);j++){ if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j]) flag++; } } if (flag == 0){ printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC)); } else printf("host result is not the same as the device result!"); //free other resourses hipHostFree(h_Ap); hipHostFree(h_Bp); hipHostFree(h_dCp); free(h_hC); hipDeviceReset() ; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <sys/time.h> #include <hip/hip_runtime.h> #include <stdio.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( hipError_t err, const char *file, int line ) { if (err != hipSuccess) { printf( "Error: %s in %s at line %d\n", hipGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; return (double) tv.tv_usec/1000000 + tv.tv_sec ; } // host side matrix addition void h_addmat(float *A, float *B, float *C, int nx, int ny){ for (int i =0;i<nx;i++){ for(int j=0;j<ny;j++){ C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; } } return; } // device-side matrix addition __global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){ int ix = threadIdx.x + blockIdx.x*(blockDim.x) ; int iy = threadIdx.y + blockIdx.y*(blockDim.y) ; //printf("In add\n"); if( (ix<nx/2) && (iy<ny/2) ){ int idx = (iy*nx/2 + ix)*4; C[idx] = A[idx] + B[idx] ; C[idx+1] = A[idx+1] + B[idx+1] ; C[idx+2] = A[idx+2] + B[idx+2] ; C[idx+3] = A[idx+3] + B[idx+3] ; //printf("Thread %d %d\n",ix,iy); } } void initData(float *M, int x, int y, int flag ){ if(flag) { //printf("A\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)(i+j)/3.0; } } } else { //printf("B\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)3.14*(i+j) ; } } } } int main( int argc, char *argv[] ) { if (argc!=3){ printf("Error: Invalid number of arguments.\n"); exit(1); } int nx = atoi( argv[1] ) ; // should check validity int ny = atoi( argv[2] ) ; // should check validity if(nx <=0 || ny <=0){ printf("Error: Dimension lessThanOrEqualto Zero.\n"); exit(1); } if(ny>nx) { nx=nx^ny; ny=nx^ny; nx=nx^ny; } int noElems = (nx)*(ny) ; int bytes = noElems * sizeof(float) ; // GPU and CPU memory Allocations float *d_A, *d_B, *d_C ; HANDLE_ERROR(hipMalloc( (float **) &d_A, bytes )) ; HANDLE_ERROR(hipMalloc( (float **) &d_B, bytes )) ; HANDLE_ERROR(hipMalloc( (float **) &d_C, bytes )) ; float *h_hC = (float *) malloc( bytes ) ; // host result float *h_Ap, *h_Bp, *h_dCp; HANDLE_ERROR(hipHostMalloc( (float **) &h_Ap, bytes , hipHostMallocDefault)) ; HANDLE_ERROR(hipHostMalloc( (float **) &h_Bp, bytes , hipHostMallocDefault)) ; HANDLE_ERROR(hipHostMalloc( (float **) &h_dCp, bytes , hipHostMallocDefault)) ; // init matrices with random data initData(h_Ap,nx,ny,1); initData(h_Bp,nx,ny,0); double timeStampA = getTimeStamp() ; //transfer data to dev HANDLE_ERROR (hipMemcpy( d_A, h_Ap, bytes, hipMemcpyHostToDevice )) ; HANDLE_ERROR (hipMemcpy( d_B, h_Bp, bytes, hipMemcpyHostToDevice )) ; double timeStampB = getTimeStamp() ; // invoke Kernel dim3 block( 1024, 1) ; // you will want to configure this dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; //printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes); f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ; hipError_t err = hipGetLastError(); if (err != hipSuccess) printf("Error: %s\n", hipGetErrorString(err)); HANDLE_ERROR(hipDeviceSynchronize()) ; double timeStampC = getTimeStamp() ; //copy data back HANDLE_ERROR(hipMemcpy(h_dCp, d_C, bytes, hipMemcpyDeviceToHost)); double timeStampD = getTimeStamp() ; // free GPU resources hipFree( d_A ) ; hipFree( d_B ) ; hipFree( d_C ) ; // CPU Matrix add h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ; // Check results int flag = 0; for(int i=0;i<(nx);i++){ for(int j=0;j<(ny);j++){ if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j]) flag++; } } if (flag == 0){ printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC)); } else printf("host result is not the same as the device result!"); //free other resourses hipHostFree(h_Ap); hipHostFree(h_Bp); hipHostFree(h_dCp); free(h_hC); hipDeviceReset() ; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z8f_addmatPfS_S_ii .globl _Z8f_addmatPfS_S_ii .p2align 8 .type _Z8f_addmatPfS_S_ii,@function _Z8f_addmatPfS_S_ii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b64 s[4:5], s[0:1], 0x18 v_and_b32_e32 v2, 0x3ff, v0 v_bfe_u32 v3, v0, 10, 10 s_waitcnt lgkmcnt(0) s_and_b32 s3, s2, 0xffff s_lshr_b32 s2, s2, 16 s_delay_alu instid0(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, s14, s3, v[2:3] v_mad_u64_u32 v[1:2], null, s15, s2, v[3:4] s_lshr_b32 s2, s4, 31 s_lshr_b32 s3, s5, 31 s_add_i32 s2, s4, s2 s_add_i32 s3, s5, s3 s_ashr_i32 s2, s2, 1 s_ashr_i32 s3, s3, 1 v_cmp_gt_i32_e32 vcc_lo, s2, v0 v_cmp_gt_i32_e64 s2, s3, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s2, vcc_lo, s2 s_and_saveexec_b32 s3, s2 s_cbranch_execz .LBB0_2 v_mul_lo_u32 v1, v1, s4 s_clause 0x1 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshrrev_b32_e32 v2, 31, v1 v_add_nc_u32_e32 v1, v1, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshrrev_b32_e32 v1, 1, v1 v_add_lshl_u32 v0, v1, v0, 2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[1:2], 2, v[0:1] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v3, vcc_lo, s4, v1 v_add_co_ci_u32_e32 v4, vcc_lo, s5, v2, vcc_lo v_add_co_u32 v5, vcc_lo, s6, v1 v_add_co_ci_u32_e32 v6, vcc_lo, s7, v2, vcc_lo v_add_co_u32 v1, vcc_lo, s0, v1 global_load_b32 v7, v[3:4], off global_load_b32 v8, v[5:6], off v_or_b32_e32 v3, 1, v0 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[3:4], 2, v[3:4] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s4, v3 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v4, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v9, v7, v8 v_add_co_u32 v7, vcc_lo, s6, v3 v_add_co_ci_u32_e32 v8, vcc_lo, s7, v4, vcc_lo global_store_b32 v[1:2], v9, off global_load_b32 v9, v[5:6], off global_load_b32 v7, v[7:8], off v_or_b32_e32 v1, 2, v0 v_add_co_u32 v3, vcc_lo, s0, v3 v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v2, 31, v1 v_lshlrev_b64 v[1:2], 2, v[1:2] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s4, v1 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v2, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v9, v9, v7 v_add_co_u32 v7, vcc_lo, s6, v1 v_add_co_ci_u32_e32 v8, vcc_lo, s7, v2, vcc_lo global_store_b32 v[3:4], v9, off global_load_b32 v9, v[5:6], off global_load_b32 v7, v[7:8], off v_or_b32_e32 v3, 3, v0 v_add_co_u32 v0, vcc_lo, s0, v1 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v2, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[3:4], 2, v[3:4] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s4, v3 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v4, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v2, v9, v7 v_add_co_u32 v7, vcc_lo, s6, v3 v_add_co_ci_u32_e32 v8, vcc_lo, s7, v4, vcc_lo global_store_b32 v[0:1], v2, off global_load_b32 v0, v[5:6], off global_load_b32 v1, v[7:8], off s_waitcnt vmcnt(0) v_add_f32_e32 v2, v0, v1 v_add_co_u32 v0, vcc_lo, s0, v3 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v4, vcc_lo global_store_b32 v[0:1], v2, off .LBB0_2: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z8f_addmatPfS_S_ii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 10 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z8f_addmatPfS_S_ii, .Lfunc_end0-_Z8f_addmatPfS_S_ii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: hidden_block_count_x - .offset: 36 .size: 4 .value_kind: hidden_block_count_y - .offset: 40 .size: 4 .value_kind: hidden_block_count_z - .offset: 44 .size: 2 .value_kind: hidden_group_size_x - .offset: 46 .size: 2 .value_kind: hidden_group_size_y - .offset: 48 .size: 2 .value_kind: hidden_group_size_z - .offset: 50 .size: 2 .value_kind: hidden_remainder_x - .offset: 52 .size: 2 .value_kind: hidden_remainder_y - .offset: 54 .size: 2 .value_kind: hidden_remainder_z - .offset: 72 .size: 8 .value_kind: hidden_global_offset_x - .offset: 80 .size: 8 .value_kind: hidden_global_offset_y - .offset: 88 .size: 8 .value_kind: hidden_global_offset_z - .offset: 96 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 288 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z8f_addmatPfS_S_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z8f_addmatPfS_S_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 10 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <sys/time.h> #include <hip/hip_runtime.h> #include <stdio.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( hipError_t err, const char *file, int line ) { if (err != hipSuccess) { printf( "Error: %s in %s at line %d\n", hipGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; return (double) tv.tv_usec/1000000 + tv.tv_sec ; } // host side matrix addition void h_addmat(float *A, float *B, float *C, int nx, int ny){ for (int i =0;i<nx;i++){ for(int j=0;j<ny;j++){ C[i*ny+j] = A[i*ny+j]+B[i*ny+j]; } } return; } // device-side matrix addition __global__ void f_addmat( float *A, float *B, float *C, int nx, int ny ){ int ix = threadIdx.x + blockIdx.x*(blockDim.x) ; int iy = threadIdx.y + blockIdx.y*(blockDim.y) ; //printf("In add\n"); if( (ix<nx/2) && (iy<ny/2) ){ int idx = (iy*nx/2 + ix)*4; C[idx] = A[idx] + B[idx] ; C[idx+1] = A[idx+1] + B[idx+1] ; C[idx+2] = A[idx+2] + B[idx+2] ; C[idx+3] = A[idx+3] + B[idx+3] ; //printf("Thread %d %d\n",ix,iy); } } void initData(float *M, int x, int y, int flag ){ if(flag) { //printf("A\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)(i+j)/3.0; } } } else { //printf("B\n"); for (int i=0;i<x;i++){ for (int j=0;j<y;j++){ M[i*y+j] = (float)3.14*(i+j) ; } } } } int main( int argc, char *argv[] ) { if (argc!=3){ printf("Error: Invalid number of arguments.\n"); exit(1); } int nx = atoi( argv[1] ) ; // should check validity int ny = atoi( argv[2] ) ; // should check validity if(nx <=0 || ny <=0){ printf("Error: Dimension lessThanOrEqualto Zero.\n"); exit(1); } if(ny>nx) { nx=nx^ny; ny=nx^ny; nx=nx^ny; } int noElems = (nx)*(ny) ; int bytes = noElems * sizeof(float) ; // GPU and CPU memory Allocations float *d_A, *d_B, *d_C ; HANDLE_ERROR(hipMalloc( (float **) &d_A, bytes )) ; HANDLE_ERROR(hipMalloc( (float **) &d_B, bytes )) ; HANDLE_ERROR(hipMalloc( (float **) &d_C, bytes )) ; float *h_hC = (float *) malloc( bytes ) ; // host result float *h_Ap, *h_Bp, *h_dCp; HANDLE_ERROR(hipHostMalloc( (float **) &h_Ap, bytes , hipHostMallocDefault)) ; HANDLE_ERROR(hipHostMalloc( (float **) &h_Bp, bytes , hipHostMallocDefault)) ; HANDLE_ERROR(hipHostMalloc( (float **) &h_dCp, bytes , hipHostMallocDefault)) ; // init matrices with random data initData(h_Ap,nx,ny,1); initData(h_Bp,nx,ny,0); double timeStampA = getTimeStamp() ; //transfer data to dev HANDLE_ERROR (hipMemcpy( d_A, h_Ap, bytes, hipMemcpyHostToDevice )) ; HANDLE_ERROR (hipMemcpy( d_B, h_Bp, bytes, hipMemcpyHostToDevice )) ; double timeStampB = getTimeStamp() ; // invoke Kernel dim3 block( 1024, 1) ; // you will want to configure this dim3 grid( (nx+block.x-1)/block.x, (ny+block.y-1)/block.y) ; //printf("reached add %d %d %d %d %lu %d %d \n",(nx+block.x-1)/block.x, (ny+block.y-1)/block.y, nx, ny, sizeof(float), noElems, bytes); f_addmat<<<grid, block>>>( d_A, d_B, d_C, nx, ny ) ; hipError_t err = hipGetLastError(); if (err != hipSuccess) printf("Error: %s\n", hipGetErrorString(err)); HANDLE_ERROR(hipDeviceSynchronize()) ; double timeStampC = getTimeStamp() ; //copy data back HANDLE_ERROR(hipMemcpy(h_dCp, d_C, bytes, hipMemcpyDeviceToHost)); double timeStampD = getTimeStamp() ; // free GPU resources hipFree( d_A ) ; hipFree( d_B ) ; hipFree( d_C ) ; // CPU Matrix add h_addmat( h_Ap, h_Bp, h_hC, nx, ny ) ; // Check results int flag = 0; for(int i=0;i<(nx);i++){ for(int j=0;j<(ny);j++){ if(h_hC[i*(ny)+j] != h_dCp[i*(ny)+j]) flag++; } } if (flag == 0){ printf("%.6f %.6f %.6f %.6f\n",(timeStampD-timeStampA),(timeStampB-timeStampA),(timeStampC-timeStampB),(timeStampD-timeStampC)); } else printf("host result is not the same as the device result!"); //free other resourses hipHostFree(h_Ap); hipHostFree(h_Bp); hipHostFree(h_dCp); free(h_hC); hipDeviceReset() ; }
.text .file "1005678036.hip" .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function _Z12getTimeStampv .LCPI0_0: .quad 0x412e848000000000 # double 1.0E+6 .text .globl _Z12getTimeStampv .p2align 4, 0x90 .type _Z12getTimeStampv,@function _Z12getTimeStampv: # @_Z12getTimeStampv .cfi_startproc # %bb.0: subq $24, %rsp .cfi_def_cfa_offset 32 leaq 8(%rsp), %rdi xorl %esi, %esi callq gettimeofday cvtsi2sdq 16(%rsp), %xmm1 divsd .LCPI0_0(%rip), %xmm1 cvtsi2sdq 8(%rsp), %xmm0 addsd %xmm1, %xmm0 addq $24, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z12getTimeStampv, .Lfunc_end0-_Z12getTimeStampv .cfi_endproc # -- End function .globl _Z8h_addmatPfS_S_ii # -- Begin function _Z8h_addmatPfS_S_ii .p2align 4, 0x90 .type _Z8h_addmatPfS_S_ii,@function _Z8h_addmatPfS_S_ii: # @_Z8h_addmatPfS_S_ii .cfi_startproc # %bb.0: testl %ecx, %ecx jle .LBB1_7 # %bb.1: # %.preheader.lr.ph pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl %ecx, %eax movl %r8d, %ecx xorl %r9d, %r9d xorl %r10d, %r10d jmp .LBB1_2 .p2align 4, 0x90 .LBB1_5: # %._crit_edge # in Loop: Header=BB1_2 Depth=1 incq %r10 addl %r8d, %r9d cmpq %rax, %r10 je .LBB1_6 .LBB1_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 testl %r8d, %r8d jle .LBB1_5 # %bb.3: # %.lr.ph # in Loop: Header=BB1_2 Depth=1 movl %r9d, %r14d leaq (%rdx,%r14,4), %r11 leaq (%rsi,%r14,4), %rbx leaq (%rdi,%r14,4), %r14 xorl %r15d, %r15d .p2align 4, 0x90 .LBB1_4: # Parent Loop BB1_2 Depth=1 # => This Inner Loop Header: Depth=2 movss (%r14,%r15,4), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rbx,%r15,4), %xmm0 movss %xmm0, (%r11,%r15,4) incq %r15 cmpq %r15, %rcx jne .LBB1_4 jmp .LBB1_5 .LBB1_6: popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 .cfi_restore %rbx .cfi_restore %r14 .cfi_restore %r15 .LBB1_7: # %._crit_edge21 retq .Lfunc_end1: .size _Z8h_addmatPfS_S_ii, .Lfunc_end1-_Z8h_addmatPfS_S_ii .cfi_endproc # -- End function .globl _Z23__device_stub__f_addmatPfS_S_ii # -- Begin function _Z23__device_stub__f_addmatPfS_S_ii .p2align 4, 0x90 .type _Z23__device_stub__f_addmatPfS_S_ii,@function _Z23__device_stub__f_addmatPfS_S_ii: # @_Z23__device_stub__f_addmatPfS_S_ii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) movl %ecx, 4(%rsp) movl %r8d, (%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 4(%rsp), %rax movq %rax, 104(%rsp) movq %rsp, %rax movq %rax, 112(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z8f_addmatPfS_S_ii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end2: .size _Z23__device_stub__f_addmatPfS_S_ii, .Lfunc_end2-_Z23__device_stub__f_addmatPfS_S_ii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z8initDataPfiii .LCPI3_0: .long 0x40400000 # float 3 .LCPI3_1: .long 0x4048f5c3 # float 3.1400001 .text .globl _Z8initDataPfiii .p2align 4, 0x90 .type _Z8initDataPfiii,@function _Z8initDataPfiii: # @_Z8initDataPfiii .cfi_startproc # %bb.0: testl %ecx, %ecx je .LBB3_7 # %bb.1: # %.preheader30 testl %esi, %esi jle .LBB3_13 # %bb.2: # %.preheader29.lr.ph movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI3_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB3_3 .p2align 4, 0x90 .LBB3_6: # %._crit_edge # in Loop: Header=BB3_3 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB3_13 .LBB3_3: # %.preheader29 # =>This Loop Header: Depth=1 # Child Loop BB3_5 Depth 2 testl %edx, %edx jle .LBB3_6 # %bb.4: # %.lr.ph # in Loop: Header=BB3_3 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d .p2align 4, 0x90 .LBB3_5: # Parent Loop BB3_3 Depth=1 # => This Inner Loop Header: Depth=2 leal (%r8,%r10), %r11d xorps %xmm1, %xmm1 cvtsi2ss %r11d, %xmm1 divss %xmm0, %xmm1 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx jne .LBB3_5 jmp .LBB3_6 .LBB3_7: # %.preheader28 testl %esi, %esi jle .LBB3_13 # %bb.8: # %.preheader.lr.ph movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI3_1(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB3_9 .p2align 4, 0x90 .LBB3_12: # %._crit_edge36 # in Loop: Header=BB3_9 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB3_13 .LBB3_9: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB3_11 Depth 2 testl %edx, %edx jle .LBB3_12 # %bb.10: # %.lr.ph35 # in Loop: Header=BB3_9 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d .p2align 4, 0x90 .LBB3_11: # Parent Loop BB3_9 Depth=1 # => This Inner Loop Header: Depth=2 leal (%r8,%r10), %r11d xorps %xmm1, %xmm1 cvtsi2ss %r11d, %xmm1 mulss %xmm0, %xmm1 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx jne .LBB3_11 jmp .LBB3_12 .LBB3_13: # %.loopexit retq .Lfunc_end3: .size _Z8initDataPfiii, .Lfunc_end3-_Z8initDataPfiii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI4_0: .long 0x40400000 # float 3 .LCPI4_1: .long 0x4048f5c3 # float 3.1400001 .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 .LCPI4_2: .quad 0x412e848000000000 # double 1.0E+6 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $248, %rsp .cfi_def_cfa_offset 304 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 cmpl $3, %edi jne .LBB4_1 # %bb.3: movq %rsi, %r14 movq 8(%rsi), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol movq %rax, %rbx movq 16(%r14), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol testl %ebx, %ebx jle .LBB4_5 # %bb.4: testl %eax, %eax jle .LBB4_5 # %bb.6: cmpl %ebx, %eax movl %ebx, %ebp cmovll %eax, %ebp movl %ebx, %r15d cmovgl %eax, %r15d imull %eax, %ebx shll $2, %ebx movslq %ebx, %r14 leaq 48(%rsp), %rdi movq %r14, %rsi callq hipMalloc testl %eax, %eax jne .LBB4_7 # %bb.9: # %_ZL11HandleError10hipError_tPKci.exit leaq 40(%rsp), %rdi movq %r14, %rsi callq hipMalloc testl %eax, %eax jne .LBB4_10 # %bb.11: # %_ZL11HandleError10hipError_tPKci.exit82 leaq 32(%rsp), %rdi movq %r14, %rsi callq hipMalloc testl %eax, %eax jne .LBB4_12 # %bb.13: # %_ZL11HandleError10hipError_tPKci.exit84 movq %r14, %rdi callq malloc movq %rax, %rbx leaq 16(%rsp), %rdi movq %r14, %rsi xorl %edx, %edx callq hipHostMalloc testl %eax, %eax jne .LBB4_14 # %bb.15: # %_ZL11HandleError10hipError_tPKci.exit86 leaq 8(%rsp), %rdi movq %r14, %rsi xorl %edx, %edx callq hipHostMalloc testl %eax, %eax jne .LBB4_16 # %bb.17: # %_ZL11HandleError10hipError_tPKci.exit88 leaq 24(%rsp), %rdi movq %r14, %rsi xorl %edx, %edx callq hipHostMalloc testl %eax, %eax jne .LBB4_18 # %bb.19: # %_ZL11HandleError10hipError_tPKci.exit90 movl %r15d, %r12d movl %ebp, %r13d testl %r15d, %r15d jle .LBB4_25 # %bb.20: # %.preheader29.lr.ph.i movq 16(%rsp), %rax xorl %ecx, %ecx movss .LCPI4_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %edx, %edx jmp .LBB4_21 .p2align 4, 0x90 .LBB4_24: # %._crit_edge.i # in Loop: Header=BB4_21 Depth=1 incq %rdx addl %ebp, %ecx cmpq %r12, %rdx je .LBB4_25 .LBB4_21: # %.preheader29.i # =>This Loop Header: Depth=1 # Child Loop BB4_23 Depth 2 testl %ebp, %ebp jle .LBB4_24 # %bb.22: # %.lr.ph.i # in Loop: Header=BB4_21 Depth=1 movl %ecx, %esi leaq (%rax,%rsi,4), %rsi xorl %edi, %edi .p2align 4, 0x90 .LBB4_23: # Parent Loop BB4_21 Depth=1 # => This Inner Loop Header: Depth=2 leal (%rdx,%rdi), %r8d xorps %xmm1, %xmm1 cvtsi2ss %r8d, %xmm1 divss %xmm0, %xmm1 movss %xmm1, (%rsi,%rdi,4) incq %rdi cmpq %rdi, %r13 jne .LBB4_23 jmp .LBB4_24 .LBB4_25: # %_Z8initDataPfiii.exit testl %r15d, %r15d jle .LBB4_31 # %bb.26: # %.preheader.lr.ph.i movq 8(%rsp), %rax xorl %ecx, %ecx movss .LCPI4_1(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %edx, %edx jmp .LBB4_27 .p2align 4, 0x90 .LBB4_30: # %._crit_edge36.i # in Loop: Header=BB4_27 Depth=1 incq %rdx addl %ebp, %ecx cmpq %r12, %rdx je .LBB4_31 .LBB4_27: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB4_29 Depth 2 testl %ebp, %ebp jle .LBB4_30 # %bb.28: # %.lr.ph35.i # in Loop: Header=BB4_27 Depth=1 movl %ecx, %esi leaq (%rax,%rsi,4), %rsi xorl %edi, %edi .p2align 4, 0x90 .LBB4_29: # Parent Loop BB4_27 Depth=1 # => This Inner Loop Header: Depth=2 leal (%rdx,%rdi), %r8d xorps %xmm1, %xmm1 cvtsi2ss %r8d, %xmm1 mulss %xmm0, %xmm1 movss %xmm1, (%rsi,%rdi,4) incq %rdi cmpq %rdi, %r13 jne .LBB4_29 jmp .LBB4_30 .LBB4_31: # %_Z8initDataPfiii.exit91 leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 168(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 160(%rsp) # 8-byte Spill movq 48(%rsp), %rdi movq 16(%rsp), %rsi movq %r14, %rdx movl $1, %ecx callq hipMemcpy testl %eax, %eax jne .LBB4_32 # %bb.33: # %_ZL11HandleError10hipError_tPKci.exit93 movq 40(%rsp), %rdi movq 8(%rsp), %rsi movq %r14, %rdx movl $1, %ecx callq hipMemcpy testl %eax, %eax jne .LBB4_34 # %bb.35: # %_ZL11HandleError10hipError_tPKci.exit95 leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 152(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 144(%rsp) # 8-byte Spill leal 1023(%r15), %eax shrl $10, %eax movq %r13, %rdi shlq $32, %rdi orq %rax, %rdi movabsq $4294968320, %rdx # imm = 0x100000400 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_37 # %bb.36: movq 48(%rsp), %rax movq 40(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 240(%rsp) movq %rcx, 232(%rsp) movq %rdx, 224(%rsp) movl %r15d, 60(%rsp) movl %ebp, 56(%rsp) leaq 240(%rsp), %rax movq %rax, 64(%rsp) leaq 232(%rsp), %rax movq %rax, 72(%rsp) leaq 224(%rsp), %rax movq %rax, 80(%rsp) leaq 60(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 208(%rsp), %rdi leaq 192(%rsp), %rsi leaq 184(%rsp), %rdx leaq 176(%rsp), %rcx callq __hipPopCallConfiguration movq 208(%rsp), %rsi movl 216(%rsp), %edx movq 192(%rsp), %rcx movl 200(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z8f_addmatPfS_S_ii, %edi pushq 176(%rsp) .cfi_adjust_cfa_offset 8 pushq 192(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB4_37: callq hipGetLastError testl %eax, %eax je .LBB4_39 # %bb.38: movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %edi movq %rax, %rsi xorl %eax, %eax callq printf .LBB4_39: callq hipDeviceSynchronize testl %eax, %eax jne .LBB4_40 # %bb.41: # %_ZL11HandleError10hipError_tPKci.exit97 leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 136(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 128(%rsp) # 8-byte Spill movq 24(%rsp), %rdi movq 32(%rsp), %rsi movq %r14, %rdx movl $2, %ecx callq hipMemcpy testl %eax, %eax jne .LBB4_42 # %bb.43: # %_ZL11HandleError10hipError_tPKci.exit99 xorl %r14d, %r14d leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 120(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 112(%rsp) # 8-byte Spill movq 48(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 32(%rsp), %rdi callq hipFree testl %r15d, %r15d jle .LBB4_49 # %bb.44: # %.preheader.lr.ph.i100 movq 16(%rsp), %rax movq 8(%rsp), %rcx xorl %edx, %edx jmp .LBB4_45 .p2align 4, 0x90 .LBB4_48: # %._crit_edge.i102 # in Loop: Header=BB4_45 Depth=1 incq %rdx addl %ebp, %r14d cmpq %r12, %rdx je .LBB4_49 .LBB4_45: # %.preheader.i101 # =>This Loop Header: Depth=1 # Child Loop BB4_47 Depth 2 testl %ebp, %ebp jle .LBB4_48 # %bb.46: # %.lr.ph.i103 # in Loop: Header=BB4_45 Depth=1 movl %r14d, %r8d leaq (%rbx,%r8,4), %rsi leaq (%rcx,%r8,4), %rdi leaq (%rax,%r8,4), %r8 xorl %r9d, %r9d .p2align 4, 0x90 .LBB4_47: # Parent Loop BB4_45 Depth=1 # => This Inner Loop Header: Depth=2 movss (%r8,%r9,4), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rdi,%r9,4), %xmm0 movss %xmm0, (%rsi,%r9,4) incq %r9 cmpq %r9, %r13 jne .LBB4_47 jmp .LBB4_48 .LBB4_49: # %_Z8h_addmatPfS_S_ii.exit testl %r15d, %r15d jle .LBB4_56 # %bb.50: # %.preheader.lr.ph movq 24(%rsp), %rax xorl %ecx, %ecx xorl %esi, %esi xorl %edx, %edx jmp .LBB4_51 .p2align 4, 0x90 .LBB4_54: # %._crit_edge # in Loop: Header=BB4_51 Depth=1 incq %rsi addl %ebp, %ecx cmpq %r12, %rsi je .LBB4_55 .LBB4_51: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB4_53 Depth 2 testl %ebp, %ebp jle .LBB4_54 # %bb.52: # %.lr.ph # in Loop: Header=BB4_51 Depth=1 movl %ecx, %r8d leaq (%rax,%r8,4), %rdi leaq (%rbx,%r8,4), %r8 xorl %r9d, %r9d .p2align 4, 0x90 .LBB4_53: # Parent Loop BB4_51 Depth=1 # => This Inner Loop Header: Depth=2 movss (%rdi,%r9,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cmpneqss (%r8,%r9,4), %xmm0 movd %xmm0, %r10d subl %r10d, %edx incq %r9 cmpq %r9, %r13 jne .LBB4_53 jmp .LBB4_54 .LBB4_55: # %._crit_edge116.loopexit testl %edx, %edx je .LBB4_56 # %bb.57: movl $.L.str.5, %edi xorl %eax, %eax callq printf jmp .LBB4_58 .LBB4_56: # %.critedge movsd 168(%rsp), %xmm4 # 8-byte Reload # xmm4 = mem[0],zero divsd .LCPI4_2(%rip), %xmm4 addsd 160(%rsp), %xmm4 # 8-byte Folded Reload movsd 152(%rsp), %xmm1 # 8-byte Reload # xmm1 = mem[0],zero divsd .LCPI4_2(%rip), %xmm1 addsd 144(%rsp), %xmm1 # 8-byte Folded Reload movsd 136(%rsp), %xmm2 # 8-byte Reload # xmm2 = mem[0],zero divsd .LCPI4_2(%rip), %xmm2 addsd 128(%rsp), %xmm2 # 8-byte Folded Reload movsd 120(%rsp), %xmm3 # 8-byte Reload # xmm3 = mem[0],zero divsd .LCPI4_2(%rip), %xmm3 addsd 112(%rsp), %xmm3 # 8-byte Folded Reload movapd %xmm3, %xmm0 subsd %xmm4, %xmm0 subsd %xmm2, %xmm3 subsd %xmm1, %xmm2 subsd %xmm4, %xmm1 movl $.L.str.4, %edi movb $4, %al callq printf .LBB4_58: movq 16(%rsp), %rdi callq hipHostFree movq 8(%rsp), %rdi callq hipHostFree movq 24(%rsp), %rdi callq hipHostFree movq %rbx, %rdi callq free callq hipDeviceReset xorl %eax, %eax addq $248, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB4_1: .cfi_def_cfa_offset 304 movl $.Lstr.1, %edi jmp .LBB4_2 .LBB4_5: movl $.Lstr, %edi .LBB4_2: callq puts@PLT movl $1, %edi callq exit .LBB4_7: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $107, %ecx jmp .LBB4_8 .LBB4_10: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $108, %ecx jmp .LBB4_8 .LBB4_12: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $109, %ecx jmp .LBB4_8 .LBB4_14: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $113, %ecx jmp .LBB4_8 .LBB4_16: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $114, %ecx jmp .LBB4_8 .LBB4_18: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $115, %ecx jmp .LBB4_8 .LBB4_32: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $124, %ecx jmp .LBB4_8 .LBB4_34: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $125, %ecx jmp .LBB4_8 .LBB4_40: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $139, %ecx jmp .LBB4_8 .LBB4_42: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $144, %ecx .LBB4_8: xorl %eax, %eax callq printf movl $1, %edi callq exit .Lfunc_end4: .size main, .Lfunc_end4-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB5_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB5_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z8f_addmatPfS_S_ii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end5: .size __hip_module_ctor, .Lfunc_end5-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB6_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB6_2: retq .Lfunc_end6: .size __hip_module_dtor, .Lfunc_end6-__hip_module_dtor .cfi_endproc # -- End function .type _Z8f_addmatPfS_S_ii,@object # @_Z8f_addmatPfS_S_ii .section .rodata,"a",@progbits .globl _Z8f_addmatPfS_S_ii .p2align 3, 0x0 _Z8f_addmatPfS_S_ii: .quad _Z23__device_stub__f_addmatPfS_S_ii .size _Z8f_addmatPfS_S_ii, 8 .type .L.str.2,@object # @.str.2 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.2: .asciz "/home/ubuntu/Datasets/stackv2/train-structured-repos-hip/Eavenx/assignment2/master/1005678036.hip" .size .L.str.2, 98 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Error: %s\n" .size .L.str.3, 11 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "%.6f %.6f %.6f %.6f\n" .size .L.str.4, 21 .type .L.str.5,@object # @.str.5 .L.str.5: .asciz "host result is not the same as the device result!" .size .L.str.5, 50 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "Error: %s in %s at line %d\n" .size .L.str.6, 28 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z8f_addmatPfS_S_ii" .size .L__unnamed_1, 20 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Error: Dimension lessThanOrEqualto Zero." .size .Lstr, 41 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Error: Invalid number of arguments." .size .Lstr.1, 36 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z23__device_stub__f_addmatPfS_S_ii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z8f_addmatPfS_S_ii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z8f_addmatPfS_S_ii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e220000002600 */ /*0020*/ ULDC.64 UR10, c[0x0][0x178] ; /* 0x00005e00000a7ab9 */ /* 0x000fe40000000a00 */ /*0030*/ UMOV UR8, 0x2 ; /* 0x0000000200087882 */ /* 0x000fe20000000000 */ /*0040*/ S2R R5, SR_TID.Y ; /* 0x0000000000057919 */ /* 0x000e220000002200 */ /*0050*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe40008000000 */ /*0060*/ UMOV UR5, UR11 ; /* 0x0000000b00057c82 */ /* 0x000fe20008000000 */ /*0070*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e620000002500 */ /*0080*/ UIMAD.WIDE.U32 UR6, UR8, UR11, UR4 ; /* 0x0000000b080672a5 */ /* 0x000fc6000f8e0004 */ /*0090*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e620000002100 */ /*00a0*/ UMOV UR5, UR10 ; /* 0x0000000a00057c82 */ /* 0x000fe40008000000 */ /*00b0*/ UIMAD.WIDE.U32 UR4, UR8, UR10, UR4 ; /* 0x0000000a080472a5 */ /* 0x000fe4000f8e0004 */ /*00c0*/ USHF.R.S32.HI UR7, URZ, 0x1, UR7 ; /* 0x000000013f077899 */ /* 0x000fe40008011407 */ /*00d0*/ USHF.R.S32.HI UR5, URZ, 0x1, UR5 ; /* 0x000000013f057899 */ /* 0x000fe20008011405 */ /*00e0*/ IMAD R2, R2, c[0x0][0x4], R5 ; /* 0x0000010002027a24 */ /* 0x001fca00078e0205 */ /*00f0*/ ISETP.GE.AND P0, PT, R2, UR7, PT ; /* 0x0000000702007c0c */ /* 0x000fe2000bf06270 */ /*0100*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x002fca00078e0203 */ /*0110*/ ISETP.GE.OR P0, PT, R0, UR5, P0 ; /* 0x0000000500007c0c */ /* 0x000fda0008706670 */ /*0120*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0130*/ IMAD R2, R2, c[0x0][0x178], RZ ; /* 0x00005e0002027a24 */ /* 0x000fe200078e02ff */ /*0140*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc80000000a00 */ /*0150*/ LEA.HI R3, R2, R2, RZ, 0x1 ; /* 0x0000000202037211 */ /* 0x000fe200078f08ff */ /*0160*/ HFMA2.MMA R2, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff027435 */ /* 0x000fc600000001ff */ /*0170*/ LEA.HI R3, R3, R0, RZ, 0x1f ; /* 0x0000000003037211 */ /* 0x000fc800078ff8ff */ /*0180*/ SHF.L.U32 R3, R3, 0x2, RZ ; /* 0x0000000203037819 */ /* 0x000fca00000006ff */ /*0190*/ IMAD.WIDE R4, R3, R2, c[0x0][0x160] ; /* 0x0000580003047625 */ /* 0x000fc800078e0202 */ /*01a0*/ IMAD.WIDE R6, R3.reuse, R2.reuse, c[0x0][0x168] ; /* 0x00005a0003067625 */ /* 0x0c0fe200078e0202 */ /*01b0*/ LDG.E R9, [R4.64] ; /* 0x0000000404097981 */ /* 0x000ea8000c1e1900 */ /*01c0*/ LDG.E R0, [R6.64] ; /* 0x0000000406007981 */ /* 0x000ea2000c1e1900 */ /*01d0*/ IMAD.WIDE R2, R3, R2, c[0x0][0x170] ; /* 0x00005c0003027625 */ /* 0x000fc800078e0202 */ /*01e0*/ FADD R9, R0, R9 ; /* 0x0000000900097221 */ /* 0x004fca0000000000 */ /*01f0*/ STG.E [R2.64], R9 ; /* 0x0000000902007986 */ /* 0x000fe8000c101904 */ /*0200*/ LDG.E R0, [R6.64+0x4] ; /* 0x0000040406007981 */ /* 0x000ea8000c1e1900 */ /*0210*/ LDG.E R11, [R4.64+0x4] ; /* 0x00000404040b7981 */ /* 0x000ea4000c1e1900 */ /*0220*/ FADD R11, R0, R11 ; /* 0x0000000b000b7221 */ /* 0x004fca0000000000 */ /*0230*/ STG.E [R2.64+0x4], R11 ; /* 0x0000040b02007986 */ /* 0x000fe8000c101904 */ /*0240*/ LDG.E R0, [R6.64+0x8] ; /* 0x0000080406007981 */ /* 0x000ea8000c1e1900 */ /*0250*/ LDG.E R13, [R4.64+0x8] ; /* 0x00000804040d7981 */ /* 0x000ea4000c1e1900 */ /*0260*/ FADD R13, R0, R13 ; /* 0x0000000d000d7221 */ /* 0x004fca0000000000 */ /*0270*/ STG.E [R2.64+0x8], R13 ; /* 0x0000080d02007986 */ /* 0x000fe8000c101904 */ /*0280*/ LDG.E R0, [R6.64+0xc] ; /* 0x00000c0406007981 */ /* 0x000ea8000c1e1900 */ /*0290*/ LDG.E R15, [R4.64+0xc] ; /* 0x00000c04040f7981 */ /* 0x000ea4000c1e1900 */ /*02a0*/ FADD R15, R0, R15 ; /* 0x0000000f000f7221 */ /* 0x004fca0000000000 */ /*02b0*/ STG.E [R2.64+0xc], R15 ; /* 0x00000c0f02007986 */ /* 0x000fe2000c101904 */ /*02c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*02d0*/ BRA 0x2d0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*02e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*02f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0300*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0310*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0320*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0330*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0340*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0350*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0360*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0370*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z8f_addmatPfS_S_ii .globl _Z8f_addmatPfS_S_ii .p2align 8 .type _Z8f_addmatPfS_S_ii,@function _Z8f_addmatPfS_S_ii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b64 s[4:5], s[0:1], 0x18 v_and_b32_e32 v2, 0x3ff, v0 v_bfe_u32 v3, v0, 10, 10 s_waitcnt lgkmcnt(0) s_and_b32 s3, s2, 0xffff s_lshr_b32 s2, s2, 16 s_delay_alu instid0(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, s14, s3, v[2:3] v_mad_u64_u32 v[1:2], null, s15, s2, v[3:4] s_lshr_b32 s2, s4, 31 s_lshr_b32 s3, s5, 31 s_add_i32 s2, s4, s2 s_add_i32 s3, s5, s3 s_ashr_i32 s2, s2, 1 s_ashr_i32 s3, s3, 1 v_cmp_gt_i32_e32 vcc_lo, s2, v0 v_cmp_gt_i32_e64 s2, s3, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s2, vcc_lo, s2 s_and_saveexec_b32 s3, s2 s_cbranch_execz .LBB0_2 v_mul_lo_u32 v1, v1, s4 s_clause 0x1 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshrrev_b32_e32 v2, 31, v1 v_add_nc_u32_e32 v1, v1, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshrrev_b32_e32 v1, 1, v1 v_add_lshl_u32 v0, v1, v0, 2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[1:2], 2, v[0:1] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v3, vcc_lo, s4, v1 v_add_co_ci_u32_e32 v4, vcc_lo, s5, v2, vcc_lo v_add_co_u32 v5, vcc_lo, s6, v1 v_add_co_ci_u32_e32 v6, vcc_lo, s7, v2, vcc_lo v_add_co_u32 v1, vcc_lo, s0, v1 global_load_b32 v7, v[3:4], off global_load_b32 v8, v[5:6], off v_or_b32_e32 v3, 1, v0 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[3:4], 2, v[3:4] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s4, v3 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v4, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v9, v7, v8 v_add_co_u32 v7, vcc_lo, s6, v3 v_add_co_ci_u32_e32 v8, vcc_lo, s7, v4, vcc_lo global_store_b32 v[1:2], v9, off global_load_b32 v9, v[5:6], off global_load_b32 v7, v[7:8], off v_or_b32_e32 v1, 2, v0 v_add_co_u32 v3, vcc_lo, s0, v3 v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v2, 31, v1 v_lshlrev_b64 v[1:2], 2, v[1:2] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s4, v1 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v2, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v9, v9, v7 v_add_co_u32 v7, vcc_lo, s6, v1 v_add_co_ci_u32_e32 v8, vcc_lo, s7, v2, vcc_lo global_store_b32 v[3:4], v9, off global_load_b32 v9, v[5:6], off global_load_b32 v7, v[7:8], off v_or_b32_e32 v3, 3, v0 v_add_co_u32 v0, vcc_lo, s0, v1 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v2, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[3:4], 2, v[3:4] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v5, vcc_lo, s4, v3 v_add_co_ci_u32_e32 v6, vcc_lo, s5, v4, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v2, v9, v7 v_add_co_u32 v7, vcc_lo, s6, v3 v_add_co_ci_u32_e32 v8, vcc_lo, s7, v4, vcc_lo global_store_b32 v[0:1], v2, off global_load_b32 v0, v[5:6], off global_load_b32 v1, v[7:8], off s_waitcnt vmcnt(0) v_add_f32_e32 v2, v0, v1 v_add_co_u32 v0, vcc_lo, s0, v3 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v4, vcc_lo global_store_b32 v[0:1], v2, off .LBB0_2: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z8f_addmatPfS_S_ii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .amdhsa_user_sgpr_count 14 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 1 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 1 .amdhsa_next_free_vgpr 10 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z8f_addmatPfS_S_ii, .Lfunc_end0-_Z8f_addmatPfS_S_ii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: hidden_block_count_x - .offset: 36 .size: 4 .value_kind: hidden_block_count_y - .offset: 40 .size: 4 .value_kind: hidden_block_count_z - .offset: 44 .size: 2 .value_kind: hidden_group_size_x - .offset: 46 .size: 2 .value_kind: hidden_group_size_y - .offset: 48 .size: 2 .value_kind: hidden_group_size_z - .offset: 50 .size: 2 .value_kind: hidden_remainder_x - .offset: 52 .size: 2 .value_kind: hidden_remainder_y - .offset: 54 .size: 2 .value_kind: hidden_remainder_z - .offset: 72 .size: 8 .value_kind: hidden_global_offset_x - .offset: 80 .size: 8 .value_kind: hidden_global_offset_y - .offset: 88 .size: 8 .value_kind: hidden_global_offset_z - .offset: 96 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 288 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z8f_addmatPfS_S_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z8f_addmatPfS_S_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 10 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00011dd8_00000000-6_1005678036.cudafe1.cpp" .text #APP .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Error: %s in %s at line %d\n" #NO_APP .text .type _ZL11HandleError9cudaErrorPKci, @function _ZL11HandleError9cudaErrorPKci: .LFB2057: .cfi_startproc testl %edi, %edi jne .L6 ret .L6: pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 subq $8, %rsp .cfi_def_cfa_offset 32 movq %rsi, %rbx movl %edx, %ebp call cudaGetErrorString@PLT movq %rax, %rdx movl %ebp, %r8d movq %rbx, %rcx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .cfi_endproc .LFE2057: .size _ZL11HandleError9cudaErrorPKci, .-_ZL11HandleError9cudaErrorPKci .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2064: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2064: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z12getTimeStampv .type _Z12getTimeStampv, @function _Z12getTimeStampv: .LFB2058: .cfi_startproc endbr64 subq $40, %rsp .cfi_def_cfa_offset 48 movq %fs:40, %rax movq %rax, 24(%rsp) xorl %eax, %eax movq %rsp, %rdi movl $0, %esi call gettimeofday@PLT pxor %xmm0, %xmm0 cvtsi2sdq 8(%rsp), %xmm0 divsd .LC1(%rip), %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq (%rsp), %xmm1 addsd %xmm1, %xmm0 movq 24(%rsp), %rax subq %fs:40, %rax jne .L12 addq $40, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L12: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size _Z12getTimeStampv, .-_Z12getTimeStampv .globl _Z8h_addmatPfS_S_ii .type _Z8h_addmatPfS_S_ii, @function _Z8h_addmatPfS_S_ii: .LFB2059: .cfi_startproc endbr64 testl %ecx, %ecx jle .L21 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movq %rdx, %r9 movl $0, %r11d movl $0, %r10d movslq %r8d, %rbx jmp .L15 .L17: movslq %r11d, %rdx leaq 0(,%rdx,4), %rax addq %rbx, %rdx salq $2, %rdx .L16: movss (%rdi,%rax), %xmm0 addss (%rsi,%rax), %xmm0 movss %xmm0, (%r9,%rax) addq $4, %rax cmpq %rdx, %rax jne .L16 .L18: addl $1, %r10d addl %r8d, %r11d cmpl %r10d, %ecx je .L13 .L15: testl %r8d, %r8d jg .L17 jmp .L18 .L13: popq %rbx .cfi_def_cfa_offset 8 ret .L21: .cfi_restore 3 ret .cfi_endproc .LFE2059: .size _Z8h_addmatPfS_S_ii, .-_Z8h_addmatPfS_S_ii .globl _Z8initDataPfiii .type _Z8initDataPfiii, @function _Z8initDataPfiii: .LFB2060: .cfi_startproc endbr64 movq %rdi, %r8 movl %esi, %r9d movl %edx, %edi testl %ecx, %ecx jne .L25 testl %esi, %esi jle .L24 movl %edx, %esi movl $0, %r10d movss .LC3(%rip), %xmm1 jmp .L27 .L25: testl %esi, %esi jle .L24 movl %edx, %ecx movl $0, %r10d movl $0, %esi movss .LC2(%rip), %xmm1 jmp .L28 .L30: movl %esi, %eax movslq %r10d, %rdx leaq (%r8,%rdx,4), %rdx .L29: pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 divss %xmm1, %xmm0 movss %xmm0, (%rdx) addl $1, %eax addq $4, %rdx cmpl %ecx, %eax jne .L29 .L31: addl $1, %esi addl %edi, %r10d addl $1, %ecx cmpl %esi, %r9d je .L24 .L28: testl %edi, %edi jg .L30 jmp .L31 .L33: movl %ecx, %eax movslq %r10d, %rdx leaq (%r8,%rdx,4), %rdx .L32: pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss %xmm1, %xmm0 movss %xmm0, (%rdx) addl $1, %eax addq $4, %rdx cmpl %esi, %eax jne .L32 .L34: addl $1, %ecx addl %edi, %r10d addl $1, %esi cmpl %ecx, %r9d je .L24 .L27: testl %edi, %edi jg .L33 jmp .L34 .L24: ret .cfi_endproc .LFE2060: .size _Z8initDataPfiii, .-_Z8initDataPfiii .globl _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii .type _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, @function _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii: .LFB2086: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movl %ecx, 4(%rsp) movl %r8d, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 4(%rsp), %rax movq %rax, 120(%rsp) movq %rsp, %rax movq %rax, 128(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L41 .L37: movq 136(%rsp), %rax subq %fs:40, %rax jne .L42 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L41: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 168 pushq 40(%rsp) .cfi_def_cfa_offset 176 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z8f_addmatPfS_S_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L37 .L42: call __stack_chk_fail@PLT .cfi_endproc .LFE2086: .size _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii, .-_Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii .globl _Z8f_addmatPfS_S_ii .type _Z8f_addmatPfS_S_ii, @function _Z8f_addmatPfS_S_ii: .LFB2087: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2087: .size _Z8f_addmatPfS_S_ii, .-_Z8f_addmatPfS_S_ii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "Error: Invalid number of arguments.\n" .align 8 .LC5: .string "Error: Dimension lessThanOrEqualto Zero.\n" .align 8 .LC6: .string "/home/ubuntu/Datasets/stackv2/train-structured/Eavenx/assignment2/master/1005678036.cu" .section .rodata.str1.1 .LC7: .string "Error: %s\n" .LC8: .string "%.6f %.6f %.6f %.6f\n" .section .rodata.str1.8 .align 8 .LC9: .string "host result is not the same as the device result!" .text .globl main .type main, @function main: .LFB2061: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $112, %rsp .cfi_def_cfa_offset 160 movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax cmpl $3, %edi jne .L64 movq %rsi, %rbp movq 8(%rsi), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movq %rax, %rbx movl %eax, %r12d movq 16(%rbp), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movl %eax, %ebp testl %ebx, %ebx jle .L60 testl %eax, %eax jle .L60 cmpl %ebx, %eax cmovle %ebx, %ebp cmovle %eax, %r12d movl %ebp, %r13d imull %r12d, %r13d sall $2, %r13d movslq %r13d, %r13 leaq 32(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl %eax, %edi movl $107, %edx leaq .LC6(%rip), %r14 movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 40(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl %eax, %edi movl $108, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 48(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT movl %eax, %edi movl $109, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci movq %r13, %rdi call malloc@PLT movq %rax, %rbx leaq 56(%rsp), %rdi movl $0, %edx movq %r13, %rsi call cudaHostAlloc@PLT movl %eax, %edi movl $113, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 64(%rsp), %rdi movl $0, %edx movq %r13, %rsi call cudaHostAlloc@PLT movl %eax, %edi movl $114, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci leaq 72(%rsp), %rdi movl $0, %edx movq %r13, %rsi call cudaHostAlloc@PLT movl %eax, %edi movl $115, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci movl $1, %ecx movl %r12d, %edx movl %ebp, %esi movq 56(%rsp), %rdi call _Z8initDataPfiii movl $0, %ecx movl %r12d, %edx movl %ebp, %esi movq 64(%rsp), %rdi call _Z8initDataPfiii call _Z12getTimeStampv movsd %xmm0, (%rsp) movl $1, %ecx movq %r13, %rdx movq 56(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %edi movl $124, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci movl $1, %ecx movq %r13, %rdx movq 64(%rsp), %rsi movq 40(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %edi movl $125, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci call _Z12getTimeStampv movsd %xmm0, 8(%rsp) movl $1, 88(%rsp) leal 1023(%rbp), %eax shrl $10, %eax movl %eax, 92(%rsp) movl %r12d, 96(%rsp) movl $1, 100(%rsp) movl $1024, 80(%rsp) movl $1, 84(%rsp) movl $0, %r9d movl $0, %r8d movq 80(%rsp), %rdx movl $1, %ecx movq 92(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L65 .L50: call cudaGetLastError@PLT testl %eax, %eax jne .L66 .L51: call cudaDeviceSynchronize@PLT movl %eax, %edi movl $139, %edx leaq .LC6(%rip), %r14 movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci call _Z12getTimeStampv movsd %xmm0, 16(%rsp) movl $2, %ecx movq %r13, %rdx movq 48(%rsp), %rsi movq 72(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %edi movl $144, %edx movq %r14, %rsi call _ZL11HandleError9cudaErrorPKci call _Z12getTimeStampv movsd %xmm0, 24(%rsp) movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 48(%rsp), %rdi call cudaFree@PLT movl %r12d, %r8d movl %ebp, %ecx movq %rbx, %rdx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z8h_addmatPfS_S_ii movq 72(%rsp), %rdx movslq %r12d, %r8 leaq 0(,%r8,4), %r9 negq %r8 salq $2, %r8 movq %r9, %rcx movl $0, %edi movl $0, %esi jmp .L52 .L64: leaq .LC4(%rip), %rsi movl $2, %edi call __printf_chk@PLT movl $1, %edi call exit@PLT .L60: leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .L65: movl %r12d, %r8d movl %ebp, %ecx movq 48(%rsp), %rdx movq 40(%rsp), %rsi movq 32(%rsp), %rdi call _Z33__device_stub__Z8f_addmatPfS_S_iiPfS_S_ii jmp .L50 .L66: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx leaq .LC7(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L51 .L61: addl $1, %esi .L53: addq $4, %rax cmpq %rcx, %rax je .L67 .L55: movss (%rbx,%rax), %xmm0 ucomiss (%rdx,%rax), %xmm0 jp .L61 je .L53 jmp .L61 .L67: addl $1, %edi addq %r9, %rcx cmpl %edi, %ebp je .L56 .L52: leaq (%rcx,%r8), %rax jmp .L55 .L56: testl %esi, %esi jne .L57 movsd 24(%rsp), %xmm4 movapd %xmm4, %xmm0 movsd (%rsp), %xmm5 subsd %xmm5, %xmm0 movapd %xmm4, %xmm3 movsd 16(%rsp), %xmm2 subsd %xmm2, %xmm3 movsd 8(%rsp), %xmm1 subsd %xmm1, %xmm2 subsd %xmm5, %xmm1 leaq .LC8(%rip), %rsi movl $2, %edi movl $4, %eax call __printf_chk@PLT .L58: movq 56(%rsp), %rdi call cudaFreeHost@PLT movq 64(%rsp), %rdi call cudaFreeHost@PLT movq 72(%rsp), %rdi call cudaFreeHost@PLT movq %rbx, %rdi call free@PLT call cudaDeviceReset@PLT movq 104(%rsp), %rax subq %fs:40, %rax jne .L68 movl $0, %eax addq $112, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L57: .cfi_restore_state leaq .LC9(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L58 .L68: call __stack_chk_fail@PLT .cfi_endproc .LFE2061: .size main, .-main .section .rodata.str1.1 .LC10: .string "_Z8f_addmatPfS_S_ii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2089: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC10(%rip), %rdx movq %rdx, %rcx leaq _Z8f_addmatPfS_S_ii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2089: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC1: .long 0 .long 1093567616 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC2: .long 1077936128 .align 4 .LC3: .long 1078523331 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "1005678036.hip" .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function _Z12getTimeStampv .LCPI0_0: .quad 0x412e848000000000 # double 1.0E+6 .text .globl _Z12getTimeStampv .p2align 4, 0x90 .type _Z12getTimeStampv,@function _Z12getTimeStampv: # @_Z12getTimeStampv .cfi_startproc # %bb.0: subq $24, %rsp .cfi_def_cfa_offset 32 leaq 8(%rsp), %rdi xorl %esi, %esi callq gettimeofday cvtsi2sdq 16(%rsp), %xmm1 divsd .LCPI0_0(%rip), %xmm1 cvtsi2sdq 8(%rsp), %xmm0 addsd %xmm1, %xmm0 addq $24, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z12getTimeStampv, .Lfunc_end0-_Z12getTimeStampv .cfi_endproc # -- End function .globl _Z8h_addmatPfS_S_ii # -- Begin function _Z8h_addmatPfS_S_ii .p2align 4, 0x90 .type _Z8h_addmatPfS_S_ii,@function _Z8h_addmatPfS_S_ii: # @_Z8h_addmatPfS_S_ii .cfi_startproc # %bb.0: testl %ecx, %ecx jle .LBB1_7 # %bb.1: # %.preheader.lr.ph pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl %ecx, %eax movl %r8d, %ecx xorl %r9d, %r9d xorl %r10d, %r10d jmp .LBB1_2 .p2align 4, 0x90 .LBB1_5: # %._crit_edge # in Loop: Header=BB1_2 Depth=1 incq %r10 addl %r8d, %r9d cmpq %rax, %r10 je .LBB1_6 .LBB1_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 testl %r8d, %r8d jle .LBB1_5 # %bb.3: # %.lr.ph # in Loop: Header=BB1_2 Depth=1 movl %r9d, %r14d leaq (%rdx,%r14,4), %r11 leaq (%rsi,%r14,4), %rbx leaq (%rdi,%r14,4), %r14 xorl %r15d, %r15d .p2align 4, 0x90 .LBB1_4: # Parent Loop BB1_2 Depth=1 # => This Inner Loop Header: Depth=2 movss (%r14,%r15,4), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rbx,%r15,4), %xmm0 movss %xmm0, (%r11,%r15,4) incq %r15 cmpq %r15, %rcx jne .LBB1_4 jmp .LBB1_5 .LBB1_6: popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 .cfi_restore %rbx .cfi_restore %r14 .cfi_restore %r15 .LBB1_7: # %._crit_edge21 retq .Lfunc_end1: .size _Z8h_addmatPfS_S_ii, .Lfunc_end1-_Z8h_addmatPfS_S_ii .cfi_endproc # -- End function .globl _Z23__device_stub__f_addmatPfS_S_ii # -- Begin function _Z23__device_stub__f_addmatPfS_S_ii .p2align 4, 0x90 .type _Z23__device_stub__f_addmatPfS_S_ii,@function _Z23__device_stub__f_addmatPfS_S_ii: # @_Z23__device_stub__f_addmatPfS_S_ii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) movl %ecx, 4(%rsp) movl %r8d, (%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 4(%rsp), %rax movq %rax, 104(%rsp) movq %rsp, %rax movq %rax, 112(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z8f_addmatPfS_S_ii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end2: .size _Z23__device_stub__f_addmatPfS_S_ii, .Lfunc_end2-_Z23__device_stub__f_addmatPfS_S_ii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z8initDataPfiii .LCPI3_0: .long 0x40400000 # float 3 .LCPI3_1: .long 0x4048f5c3 # float 3.1400001 .text .globl _Z8initDataPfiii .p2align 4, 0x90 .type _Z8initDataPfiii,@function _Z8initDataPfiii: # @_Z8initDataPfiii .cfi_startproc # %bb.0: testl %ecx, %ecx je .LBB3_7 # %bb.1: # %.preheader30 testl %esi, %esi jle .LBB3_13 # %bb.2: # %.preheader29.lr.ph movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI3_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB3_3 .p2align 4, 0x90 .LBB3_6: # %._crit_edge # in Loop: Header=BB3_3 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB3_13 .LBB3_3: # %.preheader29 # =>This Loop Header: Depth=1 # Child Loop BB3_5 Depth 2 testl %edx, %edx jle .LBB3_6 # %bb.4: # %.lr.ph # in Loop: Header=BB3_3 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d .p2align 4, 0x90 .LBB3_5: # Parent Loop BB3_3 Depth=1 # => This Inner Loop Header: Depth=2 leal (%r8,%r10), %r11d xorps %xmm1, %xmm1 cvtsi2ss %r11d, %xmm1 divss %xmm0, %xmm1 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx jne .LBB3_5 jmp .LBB3_6 .LBB3_7: # %.preheader28 testl %esi, %esi jle .LBB3_13 # %bb.8: # %.preheader.lr.ph movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI3_1(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB3_9 .p2align 4, 0x90 .LBB3_12: # %._crit_edge36 # in Loop: Header=BB3_9 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB3_13 .LBB3_9: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB3_11 Depth 2 testl %edx, %edx jle .LBB3_12 # %bb.10: # %.lr.ph35 # in Loop: Header=BB3_9 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d .p2align 4, 0x90 .LBB3_11: # Parent Loop BB3_9 Depth=1 # => This Inner Loop Header: Depth=2 leal (%r8,%r10), %r11d xorps %xmm1, %xmm1 cvtsi2ss %r11d, %xmm1 mulss %xmm0, %xmm1 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx jne .LBB3_11 jmp .LBB3_12 .LBB3_13: # %.loopexit retq .Lfunc_end3: .size _Z8initDataPfiii, .Lfunc_end3-_Z8initDataPfiii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI4_0: .long 0x40400000 # float 3 .LCPI4_1: .long 0x4048f5c3 # float 3.1400001 .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 .LCPI4_2: .quad 0x412e848000000000 # double 1.0E+6 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $248, %rsp .cfi_def_cfa_offset 304 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 cmpl $3, %edi jne .LBB4_1 # %bb.3: movq %rsi, %r14 movq 8(%rsi), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol movq %rax, %rbx movq 16(%r14), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol testl %ebx, %ebx jle .LBB4_5 # %bb.4: testl %eax, %eax jle .LBB4_5 # %bb.6: cmpl %ebx, %eax movl %ebx, %ebp cmovll %eax, %ebp movl %ebx, %r15d cmovgl %eax, %r15d imull %eax, %ebx shll $2, %ebx movslq %ebx, %r14 leaq 48(%rsp), %rdi movq %r14, %rsi callq hipMalloc testl %eax, %eax jne .LBB4_7 # %bb.9: # %_ZL11HandleError10hipError_tPKci.exit leaq 40(%rsp), %rdi movq %r14, %rsi callq hipMalloc testl %eax, %eax jne .LBB4_10 # %bb.11: # %_ZL11HandleError10hipError_tPKci.exit82 leaq 32(%rsp), %rdi movq %r14, %rsi callq hipMalloc testl %eax, %eax jne .LBB4_12 # %bb.13: # %_ZL11HandleError10hipError_tPKci.exit84 movq %r14, %rdi callq malloc movq %rax, %rbx leaq 16(%rsp), %rdi movq %r14, %rsi xorl %edx, %edx callq hipHostMalloc testl %eax, %eax jne .LBB4_14 # %bb.15: # %_ZL11HandleError10hipError_tPKci.exit86 leaq 8(%rsp), %rdi movq %r14, %rsi xorl %edx, %edx callq hipHostMalloc testl %eax, %eax jne .LBB4_16 # %bb.17: # %_ZL11HandleError10hipError_tPKci.exit88 leaq 24(%rsp), %rdi movq %r14, %rsi xorl %edx, %edx callq hipHostMalloc testl %eax, %eax jne .LBB4_18 # %bb.19: # %_ZL11HandleError10hipError_tPKci.exit90 movl %r15d, %r12d movl %ebp, %r13d testl %r15d, %r15d jle .LBB4_25 # %bb.20: # %.preheader29.lr.ph.i movq 16(%rsp), %rax xorl %ecx, %ecx movss .LCPI4_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %edx, %edx jmp .LBB4_21 .p2align 4, 0x90 .LBB4_24: # %._crit_edge.i # in Loop: Header=BB4_21 Depth=1 incq %rdx addl %ebp, %ecx cmpq %r12, %rdx je .LBB4_25 .LBB4_21: # %.preheader29.i # =>This Loop Header: Depth=1 # Child Loop BB4_23 Depth 2 testl %ebp, %ebp jle .LBB4_24 # %bb.22: # %.lr.ph.i # in Loop: Header=BB4_21 Depth=1 movl %ecx, %esi leaq (%rax,%rsi,4), %rsi xorl %edi, %edi .p2align 4, 0x90 .LBB4_23: # Parent Loop BB4_21 Depth=1 # => This Inner Loop Header: Depth=2 leal (%rdx,%rdi), %r8d xorps %xmm1, %xmm1 cvtsi2ss %r8d, %xmm1 divss %xmm0, %xmm1 movss %xmm1, (%rsi,%rdi,4) incq %rdi cmpq %rdi, %r13 jne .LBB4_23 jmp .LBB4_24 .LBB4_25: # %_Z8initDataPfiii.exit testl %r15d, %r15d jle .LBB4_31 # %bb.26: # %.preheader.lr.ph.i movq 8(%rsp), %rax xorl %ecx, %ecx movss .LCPI4_1(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %edx, %edx jmp .LBB4_27 .p2align 4, 0x90 .LBB4_30: # %._crit_edge36.i # in Loop: Header=BB4_27 Depth=1 incq %rdx addl %ebp, %ecx cmpq %r12, %rdx je .LBB4_31 .LBB4_27: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB4_29 Depth 2 testl %ebp, %ebp jle .LBB4_30 # %bb.28: # %.lr.ph35.i # in Loop: Header=BB4_27 Depth=1 movl %ecx, %esi leaq (%rax,%rsi,4), %rsi xorl %edi, %edi .p2align 4, 0x90 .LBB4_29: # Parent Loop BB4_27 Depth=1 # => This Inner Loop Header: Depth=2 leal (%rdx,%rdi), %r8d xorps %xmm1, %xmm1 cvtsi2ss %r8d, %xmm1 mulss %xmm0, %xmm1 movss %xmm1, (%rsi,%rdi,4) incq %rdi cmpq %rdi, %r13 jne .LBB4_29 jmp .LBB4_30 .LBB4_31: # %_Z8initDataPfiii.exit91 leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 168(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 160(%rsp) # 8-byte Spill movq 48(%rsp), %rdi movq 16(%rsp), %rsi movq %r14, %rdx movl $1, %ecx callq hipMemcpy testl %eax, %eax jne .LBB4_32 # %bb.33: # %_ZL11HandleError10hipError_tPKci.exit93 movq 40(%rsp), %rdi movq 8(%rsp), %rsi movq %r14, %rdx movl $1, %ecx callq hipMemcpy testl %eax, %eax jne .LBB4_34 # %bb.35: # %_ZL11HandleError10hipError_tPKci.exit95 leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 152(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 144(%rsp) # 8-byte Spill leal 1023(%r15), %eax shrl $10, %eax movq %r13, %rdi shlq $32, %rdi orq %rax, %rdi movabsq $4294968320, %rdx # imm = 0x100000400 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_37 # %bb.36: movq 48(%rsp), %rax movq 40(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 240(%rsp) movq %rcx, 232(%rsp) movq %rdx, 224(%rsp) movl %r15d, 60(%rsp) movl %ebp, 56(%rsp) leaq 240(%rsp), %rax movq %rax, 64(%rsp) leaq 232(%rsp), %rax movq %rax, 72(%rsp) leaq 224(%rsp), %rax movq %rax, 80(%rsp) leaq 60(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 208(%rsp), %rdi leaq 192(%rsp), %rsi leaq 184(%rsp), %rdx leaq 176(%rsp), %rcx callq __hipPopCallConfiguration movq 208(%rsp), %rsi movl 216(%rsp), %edx movq 192(%rsp), %rcx movl 200(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z8f_addmatPfS_S_ii, %edi pushq 176(%rsp) .cfi_adjust_cfa_offset 8 pushq 192(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB4_37: callq hipGetLastError testl %eax, %eax je .LBB4_39 # %bb.38: movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %edi movq %rax, %rsi xorl %eax, %eax callq printf .LBB4_39: callq hipDeviceSynchronize testl %eax, %eax jne .LBB4_40 # %bb.41: # %_ZL11HandleError10hipError_tPKci.exit97 leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 136(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 128(%rsp) # 8-byte Spill movq 24(%rsp), %rdi movq 32(%rsp), %rsi movq %r14, %rdx movl $2, %ecx callq hipMemcpy testl %eax, %eax jne .LBB4_42 # %bb.43: # %_ZL11HandleError10hipError_tPKci.exit99 xorl %r14d, %r14d leaq 64(%rsp), %rdi xorl %esi, %esi callq gettimeofday xorps %xmm0, %xmm0 cvtsi2sdq 72(%rsp), %xmm0 movsd %xmm0, 120(%rsp) # 8-byte Spill xorps %xmm0, %xmm0 cvtsi2sdq 64(%rsp), %xmm0 movsd %xmm0, 112(%rsp) # 8-byte Spill movq 48(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 32(%rsp), %rdi callq hipFree testl %r15d, %r15d jle .LBB4_49 # %bb.44: # %.preheader.lr.ph.i100 movq 16(%rsp), %rax movq 8(%rsp), %rcx xorl %edx, %edx jmp .LBB4_45 .p2align 4, 0x90 .LBB4_48: # %._crit_edge.i102 # in Loop: Header=BB4_45 Depth=1 incq %rdx addl %ebp, %r14d cmpq %r12, %rdx je .LBB4_49 .LBB4_45: # %.preheader.i101 # =>This Loop Header: Depth=1 # Child Loop BB4_47 Depth 2 testl %ebp, %ebp jle .LBB4_48 # %bb.46: # %.lr.ph.i103 # in Loop: Header=BB4_45 Depth=1 movl %r14d, %r8d leaq (%rbx,%r8,4), %rsi leaq (%rcx,%r8,4), %rdi leaq (%rax,%r8,4), %r8 xorl %r9d, %r9d .p2align 4, 0x90 .LBB4_47: # Parent Loop BB4_45 Depth=1 # => This Inner Loop Header: Depth=2 movss (%r8,%r9,4), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rdi,%r9,4), %xmm0 movss %xmm0, (%rsi,%r9,4) incq %r9 cmpq %r9, %r13 jne .LBB4_47 jmp .LBB4_48 .LBB4_49: # %_Z8h_addmatPfS_S_ii.exit testl %r15d, %r15d jle .LBB4_56 # %bb.50: # %.preheader.lr.ph movq 24(%rsp), %rax xorl %ecx, %ecx xorl %esi, %esi xorl %edx, %edx jmp .LBB4_51 .p2align 4, 0x90 .LBB4_54: # %._crit_edge # in Loop: Header=BB4_51 Depth=1 incq %rsi addl %ebp, %ecx cmpq %r12, %rsi je .LBB4_55 .LBB4_51: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB4_53 Depth 2 testl %ebp, %ebp jle .LBB4_54 # %bb.52: # %.lr.ph # in Loop: Header=BB4_51 Depth=1 movl %ecx, %r8d leaq (%rax,%r8,4), %rdi leaq (%rbx,%r8,4), %r8 xorl %r9d, %r9d .p2align 4, 0x90 .LBB4_53: # Parent Loop BB4_51 Depth=1 # => This Inner Loop Header: Depth=2 movss (%rdi,%r9,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cmpneqss (%r8,%r9,4), %xmm0 movd %xmm0, %r10d subl %r10d, %edx incq %r9 cmpq %r9, %r13 jne .LBB4_53 jmp .LBB4_54 .LBB4_55: # %._crit_edge116.loopexit testl %edx, %edx je .LBB4_56 # %bb.57: movl $.L.str.5, %edi xorl %eax, %eax callq printf jmp .LBB4_58 .LBB4_56: # %.critedge movsd 168(%rsp), %xmm4 # 8-byte Reload # xmm4 = mem[0],zero divsd .LCPI4_2(%rip), %xmm4 addsd 160(%rsp), %xmm4 # 8-byte Folded Reload movsd 152(%rsp), %xmm1 # 8-byte Reload # xmm1 = mem[0],zero divsd .LCPI4_2(%rip), %xmm1 addsd 144(%rsp), %xmm1 # 8-byte Folded Reload movsd 136(%rsp), %xmm2 # 8-byte Reload # xmm2 = mem[0],zero divsd .LCPI4_2(%rip), %xmm2 addsd 128(%rsp), %xmm2 # 8-byte Folded Reload movsd 120(%rsp), %xmm3 # 8-byte Reload # xmm3 = mem[0],zero divsd .LCPI4_2(%rip), %xmm3 addsd 112(%rsp), %xmm3 # 8-byte Folded Reload movapd %xmm3, %xmm0 subsd %xmm4, %xmm0 subsd %xmm2, %xmm3 subsd %xmm1, %xmm2 subsd %xmm4, %xmm1 movl $.L.str.4, %edi movb $4, %al callq printf .LBB4_58: movq 16(%rsp), %rdi callq hipHostFree movq 8(%rsp), %rdi callq hipHostFree movq 24(%rsp), %rdi callq hipHostFree movq %rbx, %rdi callq free callq hipDeviceReset xorl %eax, %eax addq $248, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %r12 .cfi_def_cfa_offset 40 popq %r13 .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .LBB4_1: .cfi_def_cfa_offset 304 movl $.Lstr.1, %edi jmp .LBB4_2 .LBB4_5: movl $.Lstr, %edi .LBB4_2: callq puts@PLT movl $1, %edi callq exit .LBB4_7: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $107, %ecx jmp .LBB4_8 .LBB4_10: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $108, %ecx jmp .LBB4_8 .LBB4_12: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $109, %ecx jmp .LBB4_8 .LBB4_14: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $113, %ecx jmp .LBB4_8 .LBB4_16: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $114, %ecx jmp .LBB4_8 .LBB4_18: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $115, %ecx jmp .LBB4_8 .LBB4_32: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $124, %ecx jmp .LBB4_8 .LBB4_34: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $125, %ecx jmp .LBB4_8 .LBB4_40: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $139, %ecx jmp .LBB4_8 .LBB4_42: movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %edi movl $.L.str.2, %edx movq %rax, %rsi movl $144, %ecx .LBB4_8: xorl %eax, %eax callq printf movl $1, %edi callq exit .Lfunc_end4: .size main, .Lfunc_end4-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB5_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB5_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z8f_addmatPfS_S_ii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end5: .size __hip_module_ctor, .Lfunc_end5-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB6_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB6_2: retq .Lfunc_end6: .size __hip_module_dtor, .Lfunc_end6-__hip_module_dtor .cfi_endproc # -- End function .type _Z8f_addmatPfS_S_ii,@object # @_Z8f_addmatPfS_S_ii .section .rodata,"a",@progbits .globl _Z8f_addmatPfS_S_ii .p2align 3, 0x0 _Z8f_addmatPfS_S_ii: .quad _Z23__device_stub__f_addmatPfS_S_ii .size _Z8f_addmatPfS_S_ii, 8 .type .L.str.2,@object # @.str.2 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.2: .asciz "/home/ubuntu/Datasets/stackv2/train-structured-repos-hip/Eavenx/assignment2/master/1005678036.hip" .size .L.str.2, 98 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Error: %s\n" .size .L.str.3, 11 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "%.6f %.6f %.6f %.6f\n" .size .L.str.4, 21 .type .L.str.5,@object # @.str.5 .L.str.5: .asciz "host result is not the same as the device result!" .size .L.str.5, 50 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "Error: %s in %s at line %d\n" .size .L.str.6, 28 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z8f_addmatPfS_S_ii" .size .L__unnamed_1, 20 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Error: Dimension lessThanOrEqualto Zero." .size .Lstr, 41 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Error: Invalid number of arguments." .size .Lstr.1, 36 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z23__device_stub__f_addmatPfS_S_ii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z8f_addmatPfS_S_ii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define N (1024 * 64) __global__ void add(int* a, int* b, int* c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } } int main() { int a[N]; int b[N]; int c[N]; int* dev_a; int* dev_b; int* dev_c; // Allocate memory for the GPU arrays cudaMalloc(&dev_a, N * sizeof(int)); cudaMalloc(&dev_b, N * sizeof(int)); cudaMalloc(&dev_c, N * sizeof(int)); // Fill a and b with some "random" numbers for (int i = 0; i < N; i++) { a[i] = i; b[i] = i * i; } // Copy a and b to the gpu cudaMemcpy(dev_a, a, N * sizeof(int), cudaMemcpyHostToDevice); cudaMemcpy(dev_b, b, N * sizeof(int), cudaMemcpyHostToDevice); // Perform the addition add<<<128, 128>>>(dev_a, dev_b, dev_c); // Copy back the result to host cudaMemcpy(c, dev_c, N * sizeof(int), cudaMemcpyDeviceToHost); // Verify calculation bool success = true; for (int i = 0; i < N; i++) { if ((a[i] + b[i]) != c[i]) { printf("Error at index: %d, %d + %d != %d\n", i, a[i], b[i], c[i]); success = false; } } if (success) { printf("Vector addition successful!\n"); } //free memory cudaFree(dev_a); cudaFree(dev_b); cudaFree(dev_c); }
code for sm_80 Function : _Z3addPiS_S_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0203 */ /*0040*/ ISETP.GT.AND P0, PT, R0, 0xffff, PT ; /* 0x0000ffff0000780c */ /* 0x000fda0003f04270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0070*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x001fd400000001ff */ /*0080*/ IMAD.WIDE R2, R0, R7, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fc800078e0207 */ /*0090*/ IMAD.WIDE R4, R0.reuse, R7.reuse, c[0x0][0x168] ; /* 0x00005a0000047625 */ /* 0x0c0fe400078e0207 */ /*00a0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea8000c1e1900 */ /*00b0*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD.WIDE R6, R0, R7, c[0x0][0x170] ; /* 0x00005c0000067625 */ /* 0x000fe200078e0207 */ /*00d0*/ MOV R11, c[0x0][0x0] ; /* 0x00000000000b7a02 */ /* 0x000fca0000000f00 */ /*00e0*/ IMAD R0, R11, c[0x0][0xc], R0 ; /* 0x000003000b007a24 */ /* 0x000fca00078e0200 */ /*00f0*/ ISETP.GE.AND P0, PT, R0, 0x10000, PT ; /* 0x000100000000780c */ /* 0x000fe40003f06270 */ /*0100*/ IADD3 R9, R4, R3, RZ ; /* 0x0000000304097210 */ /* 0x004fca0007ffe0ff */ /*0110*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x0001ec000c101904 */ /*0120*/ @!P0 BRA 0x70 ; /* 0xffffff4000008947 */ /* 0x000fea000383ffff */ /*0130*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0140*/ BRA 0x140; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define N (1024 * 64) __global__ void add(int* a, int* b, int* c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } } int main() { int a[N]; int b[N]; int c[N]; int* dev_a; int* dev_b; int* dev_c; // Allocate memory for the GPU arrays cudaMalloc(&dev_a, N * sizeof(int)); cudaMalloc(&dev_b, N * sizeof(int)); cudaMalloc(&dev_c, N * sizeof(int)); // Fill a and b with some "random" numbers for (int i = 0; i < N; i++) { a[i] = i; b[i] = i * i; } // Copy a and b to the gpu cudaMemcpy(dev_a, a, N * sizeof(int), cudaMemcpyHostToDevice); cudaMemcpy(dev_b, b, N * sizeof(int), cudaMemcpyHostToDevice); // Perform the addition add<<<128, 128>>>(dev_a, dev_b, dev_c); // Copy back the result to host cudaMemcpy(c, dev_c, N * sizeof(int), cudaMemcpyDeviceToHost); // Verify calculation bool success = true; for (int i = 0; i < N; i++) { if ((a[i] + b[i]) != c[i]) { printf("Error at index: %d, %d + %d != %d\n", i, a[i], b[i], c[i]); success = false; } } if (success) { printf("Vector addition successful!\n"); } //free memory cudaFree(dev_a); cudaFree(dev_b); cudaFree(dev_c); }
.file "tmpxft_00018eed_00000000-6_arbitraryLengthVectorAddition.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z26__device_stub__Z3addPiS_S_PiS_S_ .type _Z26__device_stub__Z3addPiS_S_PiS_S_, @function _Z26__device_stub__Z3addPiS_S_PiS_S_: .LFB2082: .cfi_startproc endbr64 subq $136, %rsp .cfi_def_cfa_offset 144 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movq %fs:40, %rax movq %rax, 120(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 120(%rsp), %rax subq %fs:40, %rax jne .L8 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 152 pushq 40(%rsp) .cfi_def_cfa_offset 160 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z3addPiS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z26__device_stub__Z3addPiS_S_PiS_S_, .-_Z26__device_stub__Z3addPiS_S_PiS_S_ .globl _Z3addPiS_S_ .type _Z3addPiS_S_, @function _Z3addPiS_S_: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z26__device_stub__Z3addPiS_S_PiS_S_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z3addPiS_S_, .-_Z3addPiS_S_ .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Error at index: %d, %d + %d != %d\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "Vector addition successful!\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 leaq -786432(%rsp), %r11 .cfi_def_cfa 11, 786456 .LPSRL0: subq $4096, %rsp orq $0, (%rsp) cmpq %r11, %rsp jne .LPSRL0 .cfi_def_cfa_register 7 subq $72, %rsp .cfi_def_cfa_offset 786528 movq %fs:40, %rax movq %rax, 786488(%rsp) xorl %eax, %eax movq %rsp, %rdi movl $262144, %esi call cudaMalloc@PLT leaq 8(%rsp), %rdi movl $262144, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $262144, %esi call cudaMalloc@PLT movl $0, %eax .L12: movl %eax, 48(%rsp,%rax,4) movl %eax, %edx imull %eax, %edx movl %edx, 262192(%rsp,%rax,4) addq $1, %rax cmpq $65536, %rax jne .L12 leaq 48(%rsp), %rsi movl $1, %ecx movl $262144, %edx movq (%rsp), %rdi call cudaMemcpy@PLT leaq 262192(%rsp), %rsi movl $1, %ecx movl $262144, %edx movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $128, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $128, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L21 .L13: leaq 524336(%rsp), %rdi movl $2, %ecx movl $262144, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT movl $0, %ebx movl $1, %edx leaq .LC0(%rip), %rbp jmp .L15 .L21: movq 16(%rsp), %rdx movq 8(%rsp), %rsi movq (%rsp), %rdi call _Z26__device_stub__Z3addPiS_S_PiS_S_ jmp .L13 .L14: addq $1, %rbx cmpq $65536, %rbx je .L22 .L15: movl 48(%rsp,%rbx,4), %ecx movl 262192(%rsp,%rbx,4), %r8d movl 524336(%rsp,%rbx,4), %r9d leal (%rcx,%r8), %eax cmpl %r9d, %eax je .L14 movl %ebx, %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $0, %edx jmp .L14 .L22: testb %dl, %dl jne .L23 .L16: movq (%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 786488(%rsp), %rax subq %fs:40, %rax jne .L24 movl $0, %eax addq $786504, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L23: .cfi_restore_state leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L16 .L24: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC2: .string "_Z3addPiS_S_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC2(%rip), %rdx movq %rdx, %rcx leaq _Z3addPiS_S_(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define N (1024 * 64) __global__ void add(int* a, int* b, int* c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } } int main() { int a[N]; int b[N]; int c[N]; int* dev_a; int* dev_b; int* dev_c; // Allocate memory for the GPU arrays cudaMalloc(&dev_a, N * sizeof(int)); cudaMalloc(&dev_b, N * sizeof(int)); cudaMalloc(&dev_c, N * sizeof(int)); // Fill a and b with some "random" numbers for (int i = 0; i < N; i++) { a[i] = i; b[i] = i * i; } // Copy a and b to the gpu cudaMemcpy(dev_a, a, N * sizeof(int), cudaMemcpyHostToDevice); cudaMemcpy(dev_b, b, N * sizeof(int), cudaMemcpyHostToDevice); // Perform the addition add<<<128, 128>>>(dev_a, dev_b, dev_c); // Copy back the result to host cudaMemcpy(c, dev_c, N * sizeof(int), cudaMemcpyDeviceToHost); // Verify calculation bool success = true; for (int i = 0; i < N; i++) { if ((a[i] + b[i]) != c[i]) { printf("Error at index: %d, %d + %d != %d\n", i, a[i], b[i], c[i]); success = false; } } if (success) { printf("Vector addition successful!\n"); } //free memory cudaFree(dev_a); cudaFree(dev_b); cudaFree(dev_c); }
#include "hip/hip_runtime.h" #include <stdio.h> #define N (1024 * 64) __global__ void add(int* a, int* b, int* c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } } int main() { int a[N]; int b[N]; int c[N]; int* dev_a; int* dev_b; int* dev_c; // Allocate memory for the GPU arrays hipMalloc(&dev_a, N * sizeof(int)); hipMalloc(&dev_b, N * sizeof(int)); hipMalloc(&dev_c, N * sizeof(int)); // Fill a and b with some "random" numbers for (int i = 0; i < N; i++) { a[i] = i; b[i] = i * i; } // Copy a and b to the gpu hipMemcpy(dev_a, a, N * sizeof(int), hipMemcpyHostToDevice); hipMemcpy(dev_b, b, N * sizeof(int), hipMemcpyHostToDevice); // Perform the addition add<<<128, 128>>>(dev_a, dev_b, dev_c); // Copy back the result to host hipMemcpy(c, dev_c, N * sizeof(int), hipMemcpyDeviceToHost); // Verify calculation bool success = true; for (int i = 0; i < N; i++) { if ((a[i] + b[i]) != c[i]) { printf("Error at index: %d, %d + %d != %d\n", i, a[i], b[i], c[i]); success = false; } } if (success) { printf("Vector addition successful!\n"); } //free memory hipFree(dev_a); hipFree(dev_b); hipFree(dev_c); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include "hip/hip_runtime.h" #include <stdio.h> #define N (1024 * 64) __global__ void add(int* a, int* b, int* c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } } int main() { int a[N]; int b[N]; int c[N]; int* dev_a; int* dev_b; int* dev_c; // Allocate memory for the GPU arrays hipMalloc(&dev_a, N * sizeof(int)); hipMalloc(&dev_b, N * sizeof(int)); hipMalloc(&dev_c, N * sizeof(int)); // Fill a and b with some "random" numbers for (int i = 0; i < N; i++) { a[i] = i; b[i] = i * i; } // Copy a and b to the gpu hipMemcpy(dev_a, a, N * sizeof(int), hipMemcpyHostToDevice); hipMemcpy(dev_b, b, N * sizeof(int), hipMemcpyHostToDevice); // Perform the addition add<<<128, 128>>>(dev_a, dev_b, dev_c); // Copy back the result to host hipMemcpy(c, dev_c, N * sizeof(int), hipMemcpyDeviceToHost); // Verify calculation bool success = true; for (int i = 0; i < N; i++) { if ((a[i] + b[i]) != c[i]) { printf("Error at index: %d, %d + %d != %d\n", i, a[i], b[i], c[i]); success = false; } } if (success) { printf("Vector addition successful!\n"); } //free memory hipFree(dev_a); hipFree(dev_b); hipFree(dev_c); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z3addPiS_S_ .globl _Z3addPiS_S_ .p2align 8 .type _Z3addPiS_S_,@function _Z3addPiS_S_: s_load_b32 s4, s[0:1], 0x24 s_add_u32 s2, s0, 24 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s8, s4, 0xffff s_mov_b32 s4, exec_lo v_mad_u64_u32 v[1:2], null, s15, s8, v[0:1] s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e32 0x10000, v1 s_cbranch_execz .LBB0_3 s_load_b32 s9, s[2:3], 0x0 s_clause 0x1 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[2:3], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_mul_i32 s1, s9, s8 s_mov_b32 s8, 0 .p2align 6 .LBB0_2: v_ashrrev_i32_e32 v2, 31, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_lshlrev_b64 v[2:3], 2, v[1:2] v_add_nc_u32_e32 v1, s1, v1 v_add_co_u32 v4, vcc_lo, s4, v2 s_delay_alu instid0(VALU_DEP_3) v_add_co_ci_u32_e32 v5, vcc_lo, s5, v3, vcc_lo v_add_co_u32 v6, vcc_lo, s6, v2 v_add_co_ci_u32_e32 v7, vcc_lo, s7, v3, vcc_lo v_cmp_lt_i32_e32 vcc_lo, 0xffff, v1 global_load_b32 v0, v[4:5], off global_load_b32 v4, v[6:7], off v_add_co_u32 v2, s0, s2, v2 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v3, s0, s3, v3, s0 s_or_b32 s8, vcc_lo, s8 s_waitcnt vmcnt(0) v_add_nc_u32_e32 v0, v4, v0 global_store_b32 v[2:3], v0, off s_and_not1_b32 exec_lo, exec_lo, s8 s_cbranch_execnz .LBB0_2 .LBB0_3: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z3addPiS_S_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z3addPiS_S_, .Lfunc_end0-_Z3addPiS_S_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z3addPiS_S_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z3addPiS_S_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include "hip/hip_runtime.h" #include <stdio.h> #define N (1024 * 64) __global__ void add(int* a, int* b, int* c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } } int main() { int a[N]; int b[N]; int c[N]; int* dev_a; int* dev_b; int* dev_c; // Allocate memory for the GPU arrays hipMalloc(&dev_a, N * sizeof(int)); hipMalloc(&dev_b, N * sizeof(int)); hipMalloc(&dev_c, N * sizeof(int)); // Fill a and b with some "random" numbers for (int i = 0; i < N; i++) { a[i] = i; b[i] = i * i; } // Copy a and b to the gpu hipMemcpy(dev_a, a, N * sizeof(int), hipMemcpyHostToDevice); hipMemcpy(dev_b, b, N * sizeof(int), hipMemcpyHostToDevice); // Perform the addition add<<<128, 128>>>(dev_a, dev_b, dev_c); // Copy back the result to host hipMemcpy(c, dev_c, N * sizeof(int), hipMemcpyDeviceToHost); // Verify calculation bool success = true; for (int i = 0; i < N; i++) { if ((a[i] + b[i]) != c[i]) { printf("Error at index: %d, %d + %d != %d\n", i, a[i], b[i], c[i]); success = false; } } if (success) { printf("Vector addition successful!\n"); } //free memory hipFree(dev_a); hipFree(dev_b); hipFree(dev_c); }
.text .file "arbitraryLengthVectorAddition.hip" .globl _Z18__device_stub__addPiS_S_ # -- Begin function _Z18__device_stub__addPiS_S_ .p2align 4, 0x90 .type _Z18__device_stub__addPiS_S_,@function _Z18__device_stub__addPiS_S_: # @_Z18__device_stub__addPiS_S_ .cfi_startproc # %bb.0: subq $104, %rsp .cfi_def_cfa_offset 112 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z3addPiS_S_, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $120, %rsp .cfi_adjust_cfa_offset -120 retq .Lfunc_end0: .size _Z18__device_stub__addPiS_S_, .Lfunc_end0-_Z18__device_stub__addPiS_S_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %rbx .cfi_def_cfa_offset 24 subq $786536, %rsp # imm = 0xC0068 .cfi_def_cfa_offset 786560 .cfi_offset %rbx, -24 .cfi_offset %rbp, -16 leaq 16(%rsp), %rdi movl $262144, %esi # imm = 0x40000 callq hipMalloc leaq 8(%rsp), %rdi movl $262144, %esi # imm = 0x40000 callq hipMalloc movq %rsp, %rdi movl $262144, %esi # imm = 0x40000 callq hipMalloc xorl %eax, %eax .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 movl %eax, 524384(%rsp,%rax,4) movl %eax, %ecx imull %eax, %ecx movl %ecx, 262240(%rsp,%rax,4) incq %rax cmpq $65536, %rax # imm = 0x10000 jne .LBB1_1 # %bb.2: movq 16(%rsp), %rdi leaq 524384(%rsp), %rsi movl $262144, %edx # imm = 0x40000 movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi leaq 262240(%rsp), %rsi movl $262144, %edx # imm = 0x40000 movl $1, %ecx callq hipMemcpy movabsq $4294967424, %rdi # imm = 0x100000080 movl $1, %esi movq %rdi, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_4 # %bb.3: movq 16(%rsp), %rax movq 8(%rsp), %rcx movq (%rsp), %rdx movq %rax, 88(%rsp) movq %rcx, 80(%rsp) movq %rdx, 72(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z3addPiS_S_, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_4: movq (%rsp), %rsi leaq 96(%rsp), %rdi movl $262144, %edx # imm = 0x40000 movl $2, %ecx callq hipMemcpy movb $1, %bpl xorl %ebx, %ebx jmp .LBB1_5 .p2align 4, 0x90 .LBB1_7: # in Loop: Header=BB1_5 Depth=1 incq %rbx cmpq $65536, %rbx # imm = 0x10000 je .LBB1_8 .LBB1_5: # =>This Inner Loop Header: Depth=1 movl 524384(%rsp,%rbx,4), %edx movl 262240(%rsp,%rbx,4), %ecx leal (%rcx,%rdx), %eax movl 96(%rsp,%rbx,4), %r8d cmpl %r8d, %eax je .LBB1_7 # %bb.6: # in Loop: Header=BB1_5 Depth=1 xorl %ebp, %ebp movl $.L.str, %edi movl %ebx, %esi # kill: def $edx killed $edx killed $rdx # kill: def $ecx killed $ecx killed $rcx xorl %eax, %eax callq printf jmp .LBB1_7 .LBB1_8: testb $1, %bpl je .LBB1_10 # %bb.9: movl $.Lstr, %edi callq puts@PLT .LBB1_10: movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $786536, %rsp # imm = 0xC0068 .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z3addPiS_S_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type _Z3addPiS_S_,@object # @_Z3addPiS_S_ .section .rodata,"a",@progbits .globl _Z3addPiS_S_ .p2align 3, 0x0 _Z3addPiS_S_: .quad _Z18__device_stub__addPiS_S_ .size _Z3addPiS_S_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Error at index: %d, %d + %d != %d\n" .size .L.str, 35 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z3addPiS_S_" .size .L__unnamed_1, 13 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Vector addition successful!" .size .Lstr, 28 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z18__device_stub__addPiS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z3addPiS_S_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z3addPiS_S_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0203 */ /*0040*/ ISETP.GT.AND P0, PT, R0, 0xffff, PT ; /* 0x0000ffff0000780c */ /* 0x000fda0003f04270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0070*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x001fd400000001ff */ /*0080*/ IMAD.WIDE R2, R0, R7, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fc800078e0207 */ /*0090*/ IMAD.WIDE R4, R0.reuse, R7.reuse, c[0x0][0x168] ; /* 0x00005a0000047625 */ /* 0x0c0fe400078e0207 */ /*00a0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea8000c1e1900 */ /*00b0*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD.WIDE R6, R0, R7, c[0x0][0x170] ; /* 0x00005c0000067625 */ /* 0x000fe200078e0207 */ /*00d0*/ MOV R11, c[0x0][0x0] ; /* 0x00000000000b7a02 */ /* 0x000fca0000000f00 */ /*00e0*/ IMAD R0, R11, c[0x0][0xc], R0 ; /* 0x000003000b007a24 */ /* 0x000fca00078e0200 */ /*00f0*/ ISETP.GE.AND P0, PT, R0, 0x10000, PT ; /* 0x000100000000780c */ /* 0x000fe40003f06270 */ /*0100*/ IADD3 R9, R4, R3, RZ ; /* 0x0000000304097210 */ /* 0x004fca0007ffe0ff */ /*0110*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x0001ec000c101904 */ /*0120*/ @!P0 BRA 0x70 ; /* 0xffffff4000008947 */ /* 0x000fea000383ffff */ /*0130*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0140*/ BRA 0x140; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z3addPiS_S_ .globl _Z3addPiS_S_ .p2align 8 .type _Z3addPiS_S_,@function _Z3addPiS_S_: s_load_b32 s4, s[0:1], 0x24 s_add_u32 s2, s0, 24 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s8, s4, 0xffff s_mov_b32 s4, exec_lo v_mad_u64_u32 v[1:2], null, s15, s8, v[0:1] s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e32 0x10000, v1 s_cbranch_execz .LBB0_3 s_load_b32 s9, s[2:3], 0x0 s_clause 0x1 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[2:3], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_mul_i32 s1, s9, s8 s_mov_b32 s8, 0 .p2align 6 .LBB0_2: v_ashrrev_i32_e32 v2, 31, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_lshlrev_b64 v[2:3], 2, v[1:2] v_add_nc_u32_e32 v1, s1, v1 v_add_co_u32 v4, vcc_lo, s4, v2 s_delay_alu instid0(VALU_DEP_3) v_add_co_ci_u32_e32 v5, vcc_lo, s5, v3, vcc_lo v_add_co_u32 v6, vcc_lo, s6, v2 v_add_co_ci_u32_e32 v7, vcc_lo, s7, v3, vcc_lo v_cmp_lt_i32_e32 vcc_lo, 0xffff, v1 global_load_b32 v0, v[4:5], off global_load_b32 v4, v[6:7], off v_add_co_u32 v2, s0, s2, v2 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v3, s0, s3, v3, s0 s_or_b32 s8, vcc_lo, s8 s_waitcnt vmcnt(0) v_add_nc_u32_e32 v0, v4, v0 global_store_b32 v[2:3], v0, off s_and_not1_b32 exec_lo, exec_lo, s8 s_cbranch_execnz .LBB0_2 .LBB0_3: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z3addPiS_S_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 280 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z3addPiS_S_, .Lfunc_end0-_Z3addPiS_S_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z3addPiS_S_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z3addPiS_S_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00018eed_00000000-6_arbitraryLengthVectorAddition.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2060: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2060: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z26__device_stub__Z3addPiS_S_PiS_S_ .type _Z26__device_stub__Z3addPiS_S_PiS_S_, @function _Z26__device_stub__Z3addPiS_S_PiS_S_: .LFB2082: .cfi_startproc endbr64 subq $136, %rsp .cfi_def_cfa_offset 144 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movq %fs:40, %rax movq %rax, 120(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 120(%rsp), %rax subq %fs:40, %rax jne .L8 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 40(%rsp) .cfi_def_cfa_offset 152 pushq 40(%rsp) .cfi_def_cfa_offset 160 leaq 112(%rsp), %r9 movq 76(%rsp), %rcx movl 84(%rsp), %r8d movq 64(%rsp), %rsi movl 72(%rsp), %edx leaq _Z3addPiS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z26__device_stub__Z3addPiS_S_PiS_S_, .-_Z26__device_stub__Z3addPiS_S_PiS_S_ .globl _Z3addPiS_S_ .type _Z3addPiS_S_, @function _Z3addPiS_S_: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z26__device_stub__Z3addPiS_S_PiS_S_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z3addPiS_S_, .-_Z3addPiS_S_ .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Error at index: %d, %d + %d != %d\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "Vector addition successful!\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 leaq -786432(%rsp), %r11 .cfi_def_cfa 11, 786456 .LPSRL0: subq $4096, %rsp orq $0, (%rsp) cmpq %r11, %rsp jne .LPSRL0 .cfi_def_cfa_register 7 subq $72, %rsp .cfi_def_cfa_offset 786528 movq %fs:40, %rax movq %rax, 786488(%rsp) xorl %eax, %eax movq %rsp, %rdi movl $262144, %esi call cudaMalloc@PLT leaq 8(%rsp), %rdi movl $262144, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $262144, %esi call cudaMalloc@PLT movl $0, %eax .L12: movl %eax, 48(%rsp,%rax,4) movl %eax, %edx imull %eax, %edx movl %edx, 262192(%rsp,%rax,4) addq $1, %rax cmpq $65536, %rax jne .L12 leaq 48(%rsp), %rsi movl $1, %ecx movl $262144, %edx movq (%rsp), %rdi call cudaMemcpy@PLT leaq 262192(%rsp), %rsi movl $1, %ecx movl $262144, %edx movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $128, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $128, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L21 .L13: leaq 524336(%rsp), %rdi movl $2, %ecx movl $262144, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT movl $0, %ebx movl $1, %edx leaq .LC0(%rip), %rbp jmp .L15 .L21: movq 16(%rsp), %rdx movq 8(%rsp), %rsi movq (%rsp), %rdi call _Z26__device_stub__Z3addPiS_S_PiS_S_ jmp .L13 .L14: addq $1, %rbx cmpq $65536, %rbx je .L22 .L15: movl 48(%rsp,%rbx,4), %ecx movl 262192(%rsp,%rbx,4), %r8d movl 524336(%rsp,%rbx,4), %r9d leal (%rcx,%r8), %eax cmpl %r9d, %eax je .L14 movl %ebx, %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $0, %edx jmp .L14 .L22: testb %dl, %dl jne .L23 .L16: movq (%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 786488(%rsp), %rax subq %fs:40, %rax jne .L24 movl $0, %eax addq $786504, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L23: .cfi_restore_state leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L16 .L24: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC2: .string "_Z3addPiS_S_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC2(%rip), %rdx movq %rdx, %rcx leaq _Z3addPiS_S_(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "arbitraryLengthVectorAddition.hip" .globl _Z18__device_stub__addPiS_S_ # -- Begin function _Z18__device_stub__addPiS_S_ .p2align 4, 0x90 .type _Z18__device_stub__addPiS_S_,@function _Z18__device_stub__addPiS_S_: # @_Z18__device_stub__addPiS_S_ .cfi_startproc # %bb.0: subq $104, %rsp .cfi_def_cfa_offset 112 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 64(%rsp), %rax movq %rax, 88(%rsp) leaq 56(%rsp), %rax movq %rax, 96(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z3addPiS_S_, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $120, %rsp .cfi_adjust_cfa_offset -120 retq .Lfunc_end0: .size _Z18__device_stub__addPiS_S_, .Lfunc_end0-_Z18__device_stub__addPiS_S_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %rbx .cfi_def_cfa_offset 24 subq $786536, %rsp # imm = 0xC0068 .cfi_def_cfa_offset 786560 .cfi_offset %rbx, -24 .cfi_offset %rbp, -16 leaq 16(%rsp), %rdi movl $262144, %esi # imm = 0x40000 callq hipMalloc leaq 8(%rsp), %rdi movl $262144, %esi # imm = 0x40000 callq hipMalloc movq %rsp, %rdi movl $262144, %esi # imm = 0x40000 callq hipMalloc xorl %eax, %eax .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 movl %eax, 524384(%rsp,%rax,4) movl %eax, %ecx imull %eax, %ecx movl %ecx, 262240(%rsp,%rax,4) incq %rax cmpq $65536, %rax # imm = 0x10000 jne .LBB1_1 # %bb.2: movq 16(%rsp), %rdi leaq 524384(%rsp), %rsi movl $262144, %edx # imm = 0x40000 movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi leaq 262240(%rsp), %rsi movl $262144, %edx # imm = 0x40000 movl $1, %ecx callq hipMemcpy movabsq $4294967424, %rdi # imm = 0x100000080 movl $1, %esi movq %rdi, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_4 # %bb.3: movq 16(%rsp), %rax movq 8(%rsp), %rcx movq (%rsp), %rdx movq %rax, 88(%rsp) movq %rcx, 80(%rsp) movq %rdx, 72(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 56(%rsp), %rdi leaq 40(%rsp), %rsi leaq 32(%rsp), %rdx leaq 24(%rsp), %rcx callq __hipPopCallConfiguration movq 56(%rsp), %rsi movl 64(%rsp), %edx movq 40(%rsp), %rcx movl 48(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z3addPiS_S_, %edi pushq 24(%rsp) .cfi_adjust_cfa_offset 8 pushq 40(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_4: movq (%rsp), %rsi leaq 96(%rsp), %rdi movl $262144, %edx # imm = 0x40000 movl $2, %ecx callq hipMemcpy movb $1, %bpl xorl %ebx, %ebx jmp .LBB1_5 .p2align 4, 0x90 .LBB1_7: # in Loop: Header=BB1_5 Depth=1 incq %rbx cmpq $65536, %rbx # imm = 0x10000 je .LBB1_8 .LBB1_5: # =>This Inner Loop Header: Depth=1 movl 524384(%rsp,%rbx,4), %edx movl 262240(%rsp,%rbx,4), %ecx leal (%rcx,%rdx), %eax movl 96(%rsp,%rbx,4), %r8d cmpl %r8d, %eax je .LBB1_7 # %bb.6: # in Loop: Header=BB1_5 Depth=1 xorl %ebp, %ebp movl $.L.str, %edi movl %ebx, %esi # kill: def $edx killed $edx killed $rdx # kill: def $ecx killed $ecx killed $rcx xorl %eax, %eax callq printf jmp .LBB1_7 .LBB1_8: testb $1, %bpl je .LBB1_10 # %bb.9: movl $.Lstr, %edi callq puts@PLT .LBB1_10: movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $786536, %rsp # imm = 0xC0068 .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z3addPiS_S_, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end2: .size __hip_module_ctor, .Lfunc_end2-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB3_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB3_2: retq .Lfunc_end3: .size __hip_module_dtor, .Lfunc_end3-__hip_module_dtor .cfi_endproc # -- End function .type _Z3addPiS_S_,@object # @_Z3addPiS_S_ .section .rodata,"a",@progbits .globl _Z3addPiS_S_ .p2align 3, 0x0 _Z3addPiS_S_: .quad _Z18__device_stub__addPiS_S_ .size _Z3addPiS_S_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Error at index: %d, %d + %d != %d\n" .size .L.str, 35 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z3addPiS_S_" .size .L__unnamed_1, 13 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Vector addition successful!" .size .Lstr, 28 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z18__device_stub__addPiS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z3addPiS_S_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include "includes.h" __device__ void recover_deleted_rows(short *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } } __global__ void recover_deleted_rows(int *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } }
code for sm_80 Function : _Z20recover_deleted_rowsPiii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0020*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x16c], PT ; /* 0x00005b0000007a0c */ /* 0x001fda0003f06270 */ /*0030*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0040*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0050*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fc800078e00ff */ /*0060*/ IMAD.WIDE R2, R0, R3, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fca00078e0203 */ /*0070*/ LDG.E R5, [R2.64] ; /* 0x0000000402057981 */ /* 0x000ea2000c1e1900 */ /*0080*/ IADD3 R0, R0, c[0x0][0x0], RZ ; /* 0x0000000000007a10 */ /* 0x000fe40007ffe0ff */ /*0090*/ IABS R4, R5 ; /* 0x0000000500047213 */ /* 0x004fe40000000000 */ /*00a0*/ ISETP.NE.AND P0, PT, R5, c[0x0][0x168], PT ; /* 0x00005a0005007a0c */ /* 0x000fc80003f05270 */ /*00b0*/ ISETP.LE.AND P0, PT, R4, c[0x0][0x168], P0 ; /* 0x00005a0004007a0c */ /* 0x000fda0000703270 */ /*00c0*/ @!P0 STG.E [R2.64], RZ ; /* 0x000000ff02008986 */ /* 0x0001e2000c101904 */ /*00d0*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x16c], PT ; /* 0x00005b0000007a0c */ /* 0x000fda0003f06270 */ /*00e0*/ @!P0 BRA 0x50 ; /* 0xffffff6000008947 */ /* 0x001fea000383ffff */ /*00f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0100*/ BRA 0x100; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0110*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0120*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0130*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0140*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __device__ void recover_deleted_rows(short *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } } __global__ void recover_deleted_rows(int *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } }
.file "tmpxft_000cd988_00000000-6_recover_deleted_rows.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2030: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2030: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z20recover_deleted_rowsPsii .type _Z20recover_deleted_rowsPsii, @function _Z20recover_deleted_rowsPsii: .LFB2027: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2027: .size _Z20recover_deleted_rowsPsii, .-_Z20recover_deleted_rowsPsii .globl _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii .type _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii, @function _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii: .LFB2052: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movl %esi, 4(%rsp) movl %edx, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) movq %rsp, %rax movq %rax, 96(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L9 .L5: movq 104(%rsp), %rax subq %fs:40, %rax jne .L10 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L9: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z20recover_deleted_rowsPiii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L5 .L10: call __stack_chk_fail@PLT .cfi_endproc .LFE2052: .size _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii, .-_Z42__device_stub__Z20recover_deleted_rowsPiiiPiii .globl _Z20recover_deleted_rowsPiii .type _Z20recover_deleted_rowsPiii, @function _Z20recover_deleted_rowsPiii: .LFB2053: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2053: .size _Z20recover_deleted_rowsPiii, .-_Z20recover_deleted_rowsPiii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z20recover_deleted_rowsPiii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2055: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z20recover_deleted_rowsPiii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2055: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include "includes.h" __device__ void recover_deleted_rows(short *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } } __global__ void recover_deleted_rows(int *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } }
#include <hip/hip_runtime.h> #include "includes.h" __device__ void recover_deleted_rows(short *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } } __global__ void recover_deleted_rows(int *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include "includes.h" __device__ void recover_deleted_rows(short *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } } __global__ void recover_deleted_rows(int *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z20recover_deleted_rowsPiii .globl _Z20recover_deleted_rowsPiii .p2align 8 .type _Z20recover_deleted_rowsPiii,@function _Z20recover_deleted_rowsPiii: s_load_b32 s4, s[0:1], 0xc s_mov_b32 s2, exec_lo s_waitcnt lgkmcnt(0) v_cmpx_gt_i32_e64 s4, v0 s_cbranch_execz .LBB0_5 s_clause 0x2 s_load_b32 s5, s[0:1], 0x1c s_load_b64 s[2:3], s[0:1], 0x0 s_load_b32 s1, s[0:1], 0x8 v_mov_b32_e32 v3, 0 s_mov_b32 s6, 0 s_waitcnt lgkmcnt(0) s_and_b32 s5, s5, 0xffff s_set_inst_prefetch_distance 0x1 s_branch .LBB0_3 .p2align 6 .LBB0_2: s_or_b32 exec_lo, exec_lo, s0 v_add_nc_u32_e32 v0, s5, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_cmp_le_i32_e32 vcc_lo, s4, v0 s_or_b32 s6, vcc_lo, s6 s_and_not1_b32 exec_lo, exec_lo, s6 s_cbranch_execz .LBB0_5 .LBB0_3: v_ashrrev_i32_e32 v1, 31, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[1:2], 2, v[0:1] v_add_co_u32 v1, vcc_lo, s2, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_2) v_add_co_ci_u32_e32 v2, vcc_lo, s3, v2, vcc_lo global_load_b32 v4, v[1:2], off s_waitcnt vmcnt(0) v_sub_nc_u32_e32 v5, 0, v4 v_cmp_eq_u32_e64 s0, s1, v4 v_max_i32_e32 v5, v4, v5 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3) v_cmp_lt_i32_e32 vcc_lo, s1, v5 s_or_b32 s7, vcc_lo, s0 s_delay_alu instid0(SALU_CYCLE_1) s_and_saveexec_b32 s0, s7 s_cbranch_execz .LBB0_2 global_store_b32 v[1:2], v3, off s_branch .LBB0_2 .LBB0_5: s_set_inst_prefetch_distance 0x2 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z20recover_deleted_rowsPiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 272 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 6 .amdhsa_next_free_sgpr 8 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z20recover_deleted_rowsPiii, .Lfunc_end0-_Z20recover_deleted_rowsPiii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .offset: 8 .size: 4 .value_kind: by_value - .offset: 12 .size: 4 .value_kind: by_value - .offset: 16 .size: 4 .value_kind: hidden_block_count_x - .offset: 20 .size: 4 .value_kind: hidden_block_count_y - .offset: 24 .size: 4 .value_kind: hidden_block_count_z - .offset: 28 .size: 2 .value_kind: hidden_group_size_x - .offset: 30 .size: 2 .value_kind: hidden_group_size_y - .offset: 32 .size: 2 .value_kind: hidden_group_size_z - .offset: 34 .size: 2 .value_kind: hidden_remainder_x - .offset: 36 .size: 2 .value_kind: hidden_remainder_y - .offset: 38 .size: 2 .value_kind: hidden_remainder_z - .offset: 56 .size: 8 .value_kind: hidden_global_offset_x - .offset: 64 .size: 8 .value_kind: hidden_global_offset_y - .offset: 72 .size: 8 .value_kind: hidden_global_offset_z - .offset: 80 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 272 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z20recover_deleted_rowsPiii .private_segment_fixed_size: 0 .sgpr_count: 10 .sgpr_spill_count: 0 .symbol: _Z20recover_deleted_rowsPiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 6 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include "includes.h" __device__ void recover_deleted_rows(short *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } } __global__ void recover_deleted_rows(int *deleted_rows, const int search_depth, const int total_dl_matrix_row_num) { for (int i = threadIdx.x; i < total_dl_matrix_row_num; i = i + blockDim.x) { if (abs(deleted_rows[i]) > search_depth || deleted_rows[i] == search_depth) { deleted_rows[i] = 0; } } }
.text .file "recover_deleted_rows.hip" .globl _Z35__device_stub__recover_deleted_rowsPiii # -- Begin function _Z35__device_stub__recover_deleted_rowsPiii .p2align 4, 0x90 .type _Z35__device_stub__recover_deleted_rowsPiii,@function _Z35__device_stub__recover_deleted_rowsPiii: # @_Z35__device_stub__recover_deleted_rowsPiii .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movl %esi, 4(%rsp) movl %edx, (%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 4(%rsp), %rax movq %rax, 72(%rsp) movq %rsp, %rax movq %rax, 80(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z20recover_deleted_rowsPiii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z35__device_stub__recover_deleted_rowsPiii, .Lfunc_end0-_Z35__device_stub__recover_deleted_rowsPiii .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB1_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB1_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z20recover_deleted_rowsPiii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end1: .size __hip_module_ctor, .Lfunc_end1-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB2_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB2_2: retq .Lfunc_end2: .size __hip_module_dtor, .Lfunc_end2-__hip_module_dtor .cfi_endproc # -- End function .type _Z20recover_deleted_rowsPiii,@object # @_Z20recover_deleted_rowsPiii .section .rodata,"a",@progbits .globl _Z20recover_deleted_rowsPiii .p2align 3, 0x0 _Z20recover_deleted_rowsPiii: .quad _Z35__device_stub__recover_deleted_rowsPiii .size _Z20recover_deleted_rowsPiii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z20recover_deleted_rowsPiii" .size .L__unnamed_1, 29 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z35__device_stub__recover_deleted_rowsPiii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z20recover_deleted_rowsPiii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80 Function : _Z20recover_deleted_rowsPiii .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ IMAD.MOV.U32 R1, RZ, RZ, c[0x0][0x28] ; /* 0x00000a00ff017624 */ /* 0x000fe400078e00ff */ /*0010*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0020*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x16c], PT ; /* 0x00005b0000007a0c */ /* 0x001fda0003f06270 */ /*0030*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0040*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0050*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fc800078e00ff */ /*0060*/ IMAD.WIDE R2, R0, R3, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x000fca00078e0203 */ /*0070*/ LDG.E R5, [R2.64] ; /* 0x0000000402057981 */ /* 0x000ea2000c1e1900 */ /*0080*/ IADD3 R0, R0, c[0x0][0x0], RZ ; /* 0x0000000000007a10 */ /* 0x000fe40007ffe0ff */ /*0090*/ IABS R4, R5 ; /* 0x0000000500047213 */ /* 0x004fe40000000000 */ /*00a0*/ ISETP.NE.AND P0, PT, R5, c[0x0][0x168], PT ; /* 0x00005a0005007a0c */ /* 0x000fc80003f05270 */ /*00b0*/ ISETP.LE.AND P0, PT, R4, c[0x0][0x168], P0 ; /* 0x00005a0004007a0c */ /* 0x000fda0000703270 */ /*00c0*/ @!P0 STG.E [R2.64], RZ ; /* 0x000000ff02008986 */ /* 0x0001e2000c101904 */ /*00d0*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x16c], PT ; /* 0x00005b0000007a0c */ /* 0x000fda0003f06270 */ /*00e0*/ @!P0 BRA 0x50 ; /* 0xffffff6000008947 */ /* 0x001fea000383ffff */ /*00f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0100*/ BRA 0x100; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0110*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0120*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0130*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0140*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z20recover_deleted_rowsPiii .globl _Z20recover_deleted_rowsPiii .p2align 8 .type _Z20recover_deleted_rowsPiii,@function _Z20recover_deleted_rowsPiii: s_load_b32 s4, s[0:1], 0xc s_mov_b32 s2, exec_lo s_waitcnt lgkmcnt(0) v_cmpx_gt_i32_e64 s4, v0 s_cbranch_execz .LBB0_5 s_clause 0x2 s_load_b32 s5, s[0:1], 0x1c s_load_b64 s[2:3], s[0:1], 0x0 s_load_b32 s1, s[0:1], 0x8 v_mov_b32_e32 v3, 0 s_mov_b32 s6, 0 s_waitcnt lgkmcnt(0) s_and_b32 s5, s5, 0xffff s_set_inst_prefetch_distance 0x1 s_branch .LBB0_3 .p2align 6 .LBB0_2: s_or_b32 exec_lo, exec_lo, s0 v_add_nc_u32_e32 v0, s5, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_cmp_le_i32_e32 vcc_lo, s4, v0 s_or_b32 s6, vcc_lo, s6 s_and_not1_b32 exec_lo, exec_lo, s6 s_cbranch_execz .LBB0_5 .LBB0_3: v_ashrrev_i32_e32 v1, 31, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[1:2], 2, v[0:1] v_add_co_u32 v1, vcc_lo, s2, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_2) v_add_co_ci_u32_e32 v2, vcc_lo, s3, v2, vcc_lo global_load_b32 v4, v[1:2], off s_waitcnt vmcnt(0) v_sub_nc_u32_e32 v5, 0, v4 v_cmp_eq_u32_e64 s0, s1, v4 v_max_i32_e32 v5, v4, v5 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3) v_cmp_lt_i32_e32 vcc_lo, s1, v5 s_or_b32 s7, vcc_lo, s0 s_delay_alu instid0(SALU_CYCLE_1) s_and_saveexec_b32 s0, s7 s_cbranch_execz .LBB0_2 global_store_b32 v[1:2], v3, off s_branch .LBB0_2 .LBB0_5: s_set_inst_prefetch_distance 0x2 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z20recover_deleted_rowsPiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 272 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 6 .amdhsa_next_free_sgpr 8 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z20recover_deleted_rowsPiii, .Lfunc_end0-_Z20recover_deleted_rowsPiii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .offset: 8 .size: 4 .value_kind: by_value - .offset: 12 .size: 4 .value_kind: by_value - .offset: 16 .size: 4 .value_kind: hidden_block_count_x - .offset: 20 .size: 4 .value_kind: hidden_block_count_y - .offset: 24 .size: 4 .value_kind: hidden_block_count_z - .offset: 28 .size: 2 .value_kind: hidden_group_size_x - .offset: 30 .size: 2 .value_kind: hidden_group_size_y - .offset: 32 .size: 2 .value_kind: hidden_group_size_z - .offset: 34 .size: 2 .value_kind: hidden_remainder_x - .offset: 36 .size: 2 .value_kind: hidden_remainder_y - .offset: 38 .size: 2 .value_kind: hidden_remainder_z - .offset: 56 .size: 8 .value_kind: hidden_global_offset_x - .offset: 64 .size: 8 .value_kind: hidden_global_offset_y - .offset: 72 .size: 8 .value_kind: hidden_global_offset_z - .offset: 80 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 272 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z20recover_deleted_rowsPiii .private_segment_fixed_size: 0 .sgpr_count: 10 .sgpr_spill_count: 0 .symbol: _Z20recover_deleted_rowsPiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 6 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_000cd988_00000000-6_recover_deleted_rows.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2030: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2030: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z20recover_deleted_rowsPsii .type _Z20recover_deleted_rowsPsii, @function _Z20recover_deleted_rowsPsii: .LFB2027: .cfi_startproc endbr64 pushq %rax .cfi_def_cfa_offset 16 popq %rax .cfi_def_cfa_offset 8 subq $24, %rsp .cfi_def_cfa_offset 32 movl $1, 12(%rsp) movl 12(%rsp), %edi call exit@PLT .cfi_endproc .LFE2027: .size _Z20recover_deleted_rowsPsii, .-_Z20recover_deleted_rowsPsii .globl _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii .type _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii, @function _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii: .LFB2052: .cfi_startproc endbr64 subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 8(%rsp) movl %esi, 4(%rsp) movl %edx, (%rsp) movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax leaq 8(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) movq %rsp, %rax movq %rax, 96(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) leaq 24(%rsp), %rcx leaq 16(%rsp), %rdx leaq 44(%rsp), %rsi leaq 32(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L9 .L5: movq 104(%rsp), %rax subq %fs:40, %rax jne .L10 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L9: .cfi_restore_state pushq 24(%rsp) .cfi_def_cfa_offset 136 pushq 24(%rsp) .cfi_def_cfa_offset 144 leaq 96(%rsp), %r9 movq 60(%rsp), %rcx movl 68(%rsp), %r8d movq 48(%rsp), %rsi movl 56(%rsp), %edx leaq _Z20recover_deleted_rowsPiii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L5 .L10: call __stack_chk_fail@PLT .cfi_endproc .LFE2052: .size _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii, .-_Z42__device_stub__Z20recover_deleted_rowsPiiiPiii .globl _Z20recover_deleted_rowsPiii .type _Z20recover_deleted_rowsPiii, @function _Z20recover_deleted_rowsPiii: .LFB2053: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z42__device_stub__Z20recover_deleted_rowsPiiiPiii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2053: .size _Z20recover_deleted_rowsPiii, .-_Z20recover_deleted_rowsPiii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z20recover_deleted_rowsPiii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2055: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z20recover_deleted_rowsPiii(%rip), %rsi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2055: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "recover_deleted_rows.hip" .globl _Z35__device_stub__recover_deleted_rowsPiii # -- Begin function _Z35__device_stub__recover_deleted_rowsPiii .p2align 4, 0x90 .type _Z35__device_stub__recover_deleted_rowsPiii,@function _Z35__device_stub__recover_deleted_rowsPiii: # @_Z35__device_stub__recover_deleted_rowsPiii .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movq %rdi, 56(%rsp) movl %esi, 4(%rsp) movl %edx, (%rsp) leaq 56(%rsp), %rax movq %rax, 64(%rsp) leaq 4(%rsp), %rax movq %rax, 72(%rsp) movq %rsp, %rax movq %rax, 80(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 64(%rsp), %r9 movl $_Z20recover_deleted_rowsPiii, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $104, %rsp .cfi_adjust_cfa_offset -104 retq .Lfunc_end0: .size _Z35__device_stub__recover_deleted_rowsPiii, .Lfunc_end0-_Z35__device_stub__recover_deleted_rowsPiii .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: subq $40, %rsp .cfi_def_cfa_offset 48 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB1_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB1_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z20recover_deleted_rowsPiii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction movl $__hip_module_dtor, %edi addq $40, %rsp .cfi_def_cfa_offset 8 jmp atexit # TAILCALL .Lfunc_end1: .size __hip_module_ctor, .Lfunc_end1-__hip_module_ctor .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_dtor .type __hip_module_dtor,@function __hip_module_dtor: # @__hip_module_dtor .cfi_startproc # %bb.0: movq __hip_gpubin_handle(%rip), %rdi testq %rdi, %rdi je .LBB2_2 # %bb.1: pushq %rax .cfi_def_cfa_offset 16 callq __hipUnregisterFatBinary movq $0, __hip_gpubin_handle(%rip) addq $8, %rsp .cfi_def_cfa_offset 8 .LBB2_2: retq .Lfunc_end2: .size __hip_module_dtor, .Lfunc_end2-__hip_module_dtor .cfi_endproc # -- End function .type _Z20recover_deleted_rowsPiii,@object # @_Z20recover_deleted_rowsPiii .section .rodata,"a",@progbits .globl _Z20recover_deleted_rowsPiii .p2align 3, 0x0 _Z20recover_deleted_rowsPiii: .quad _Z35__device_stub__recover_deleted_rowsPiii .size _Z20recover_deleted_rowsPiii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z20recover_deleted_rowsPiii" .size .L__unnamed_1, 29 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z35__device_stub__recover_deleted_rowsPiii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z20recover_deleted_rowsPiii .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> void _CheckCudaError(cudaError_t ret, char *file, int line) { if (ret != cudaSuccess) { printf("%s - %s (%s:%d)\n", cudaGetErrorName(ret), cudaGetErrorString(ret), file, line); exit(EXIT_FAILURE); } } #define CheckCudaError(call) _CheckCudaError((call), __FILE__, __LINE__) struct s12 { int a; int b; int c; }; struct s16 { int a; int b; int c; int d; }; struct s20 { int a; int b; int c; int d; int e; }; struct s24 { int a; int b; int c; int d; int e; int f; }; struct s28 { int a; int b; int c; int d; int e; int f; int g; }; struct s32 { int a; int b; int c; int d; int e; int f; int g; int h; }; #define TESTSIZE 1024 template <typename T> __global__ void test_kernel(T* d) { __shared__ T s[TESTSIZE / 2]; // copy first half of data to SMEM if (threadIdx.x < TESTSIZE / 2) s[threadIdx.x] = d[threadIdx.x]; __syncthreads(); // copy SMEM to second half if (threadIdx.x >= TESTSIZE / 2) d[threadIdx.x] = s[threadIdx.x % (TESTSIZE / 2)]; } template <typename T> __global__ void test_kernel_conflict(T* d) { __shared__ T s[TESTSIZE]; if (threadIdx.x < TESTSIZE / 2) s[threadIdx.x * 2] = d[threadIdx.x]; // bank conflict __syncthreads(); if (threadIdx.x >= TESTSIZE / 2) d[threadIdx.x] = s[threadIdx.x * 2 % TESTSIZE]; // bank conflict } template <typename T> void test() { T h[TESTSIZE]; memset(h, 0, sizeof(h)); for (int i = 0; i < TESTSIZE / 2; i++) *(int*)&h[i] = TESTSIZE / 2 - i; T *d; CheckCudaError(cudaMalloc(&d, sizeof(h))); CheckCudaError(cudaMemcpy(d, h, sizeof(h), cudaMemcpyHostToDevice)); test_kernel<<<1, TESTSIZE>>>(d); CheckCudaError(cudaMemcpy(h, d, sizeof(h), cudaMemcpyDeviceToHost)); printf("first element : %d, last element : %d\n", *(int*)&h[0], *(int*)&h[TESTSIZE - 1]); // expected numbers are: TESTSIZE / 2, 1 CheckCudaError(cudaMemcpy(d, h, sizeof(h), cudaMemcpyHostToDevice)); test_kernel_conflict<<<1, TESTSIZE>>>(d); CheckCudaError(cudaMemcpy(h, d, sizeof(h), cudaMemcpyDeviceToHost)); printf("first element : %d, last element : %d\n", *(int*)&h[0], *(int*)&h[TESTSIZE - 1]); // expected numbers are: TESTSIZE / 2, 1 CheckCudaError(cudaFree(d)); } int main() { test<int>(); // 4B per element test<long long int>(); // 8B per element test<struct s12>(); // 12B per element test<struct s16>(); // 16B per element test<struct s20>(); // 20B per element test<struct s24>(); // 24B per element test<struct s28>(); // 28B per element test<struct s32>(); // 32B per element }
#include "hip/hip_runtime.h" #include <stdio.h> #include <stdlib.h> void _CheckCudaError(hipError_t ret, char *file, int line) { if (ret != hipSuccess) { printf("%s - %s (%s:%d)\n", hipGetErrorName(ret), hipGetErrorString(ret), file, line); exit(EXIT_FAILURE); } } #define CheckCudaError(call) _CheckCudaError((call), __FILE__, __LINE__) struct s12 { int a; int b; int c; }; struct s16 { int a; int b; int c; int d; }; struct s20 { int a; int b; int c; int d; int e; }; struct s24 { int a; int b; int c; int d; int e; int f; }; struct s28 { int a; int b; int c; int d; int e; int f; int g; }; struct s32 { int a; int b; int c; int d; int e; int f; int g; int h; }; #define TESTSIZE 1024 template <typename T> __global__ void test_kernel(T* d) { __shared__ T s[TESTSIZE / 2]; // copy first half of data to SMEM if (threadIdx.x < TESTSIZE / 2) s[threadIdx.x] = d[threadIdx.x]; __syncthreads(); // copy SMEM to second half if (threadIdx.x >= TESTSIZE / 2) d[threadIdx.x] = s[threadIdx.x % (TESTSIZE / 2)]; } template <typename T> __global__ void test_kernel_conflict(T* d) { __shared__ T s[TESTSIZE]; if (threadIdx.x < TESTSIZE / 2) s[threadIdx.x * 2] = d[threadIdx.x]; // bank conflict __syncthreads(); if (threadIdx.x >= TESTSIZE / 2) d[threadIdx.x] = s[threadIdx.x * 2 % TESTSIZE]; // bank conflict } template <typename T> void test() { T h[TESTSIZE]; memset(h, 0, sizeof(h)); for (int i = 0; i < TESTSIZE / 2; i++) *(int*)&h[i] = TESTSIZE / 2 - i; T *d; CheckCudaError(hipMalloc(&d, sizeof(h))); CheckCudaError(hipMemcpy(d, h, sizeof(h), hipMemcpyHostToDevice)); test_kernel<<<1, TESTSIZE>>>(d); CheckCudaError(hipMemcpy(h, d, sizeof(h), hipMemcpyDeviceToHost)); printf("first element : %d, last element : %d\n", *(int*)&h[0], *(int*)&h[TESTSIZE - 1]); // expected numbers are: TESTSIZE / 2, 1 CheckCudaError(hipMemcpy(d, h, sizeof(h), hipMemcpyHostToDevice)); test_kernel_conflict<<<1, TESTSIZE>>>(d); CheckCudaError(hipMemcpy(h, d, sizeof(h), hipMemcpyDeviceToHost)); printf("first element : %d, last element : %d\n", *(int*)&h[0], *(int*)&h[TESTSIZE - 1]); // expected numbers are: TESTSIZE / 2, 1 CheckCudaError(hipFree(d)); } int main() { test<int>(); // 4B per element test<long long int>(); // 8B per element test<struct s12>(); // 12B per element test<struct s16>(); // 16B per element test<struct s20>(); // 20B per element test<struct s24>(); // 24B per element test<struct s28>(); // 28B per element test<struct s32>(); // 32B per element }
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
/*! @file gpu_info.cpp *! @brief print gpu info */ #include <stdio.h> #include <cuda.h> #include <stdlib.h> void print_device_props_short() { const size_t kb = 1024; const size_t mb = kb * kb; int devCount; cudaGetDeviceCount(&devCount); printf("Found the following GPUs:\n"); for(int i = 0; i < devCount; ++i) { cudaDeviceProp props; cudaGetDeviceProperties(&props, i); printf(" | %d: %s\n", i, props.name); printf(" | arch version / compute capability: %d.%d\n", props.major, props.minor); printf(" | Global memory: %d MB\n", props.totalGlobalMem / mb); } } void print_device_props_complete() { const int kb = 1024; const int mb = kb * kb; int devCount; cudaGetDeviceCount(&devCount); printf("Found the following GPUs:\n"); for(int i = 0; i < devCount; ++i) { cudaDeviceProp props; cudaGetDeviceProperties(&props, i); printf(" | %d: %s\n", i, props.name); printf(" | arch version / compute capability: %d.%d\n", props.major, props.minor); printf(" | global memory: %d MB\n", props.totalGlobalMem / mb); printf(" | shared memory: %d KB\n", props.sharedMemPerBlock / kb); printf(" | constant memory: %d KB\n", props.totalConstMem / kb); printf(" | 32b-registers per block: %d\n", props.regsPerBlock); printf(" | warp size: %d\n", props.warpSize ); printf(" | max pitch: %d KB\n", props.memPitch / kb ); printf(" | threads per block: %d\n", props.maxThreadsPerBlock ); printf(" | max block dimensions: %d, %d, %d\n", props.maxThreadsDim[0], props.maxThreadsDim[1], props.maxThreadsDim[2] ); printf(" | max grid dimensions: %d, %d, %d\n", props.maxGridSize[0], props.maxGridSize[1], props.maxGridSize[2] ); printf(" | clock rate: %d Hz\n", props.clockRate); } } extern "C" void gpu_print_info_short() { print_device_props_short(); } extern "C" void gpu_print_info_long() { print_device_props_complete(); }
code for sm_80