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_0006584e_00000000-6_hash.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__Z4hashPcS_iPcS_i .type _Z26__device_stub__Z4hashPcS_iPcS_i, @function _Z26__device_stub__Z4hashPcS_iPcS_i: .LFB2082: .cfi_startproc endbr64 subq $136, %rsp .cfi_def_cfa_offset 144 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movl %edx, 12(%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 12(%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 _Z4hashPcS_i(%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__Z4hashPcS_iPcS_i, .-_Z26__device_stub__Z4hashPcS_iPcS_i .globl _Z4hashPcS_i .type _Z4hashPcS_i, @function _Z4hashPcS_i: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z26__device_stub__Z4hashPcS_iPcS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z4hashPcS_i, .-_Z4hashPcS_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Failed to allocate %d bytes for f." .align 8 .LC1: .string "Failed to allocate %d bytes for h." .align 8 .LC2: .string "Failed to cudaMalloc %d bytes for d_f." .align 8 .LC3: .string "Failed to cudaMalloc %d bytes for d_h." .align 8 .LC4: .string "cudaMemcpy (d_f,f) returned error code %d, line(%d)\n" .align 8 .LC5: .string "Failed to create start event (error code %s)!\n" .align 8 .LC6: .string "Failed to create stop event (error code %s)!\n" .align 8 .LC7: .string "Failed to record start event (error code %s)!\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC8: .string "Running...\n" .section .rodata.str1.8 .align 8 .LC9: .string "Failed to record stop event (error code %s)!\n" .align 8 .LC10: .string "Failed to synchronize on the stop event (error code %s)!\n" .align 8 .LC12: .string "Failed to get time elapsed between events (error code %s)!\n" .align 8 .LC13: .string "cudaMemcpy (h,d_h) returned error code %d, line(%d)\n" .section .rodata.str1.1 .LC15: .string "Performance= %.06f sec\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 $64, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $123374234, %esi movl $1, %edi call calloc@PLT testq %rax, %rax je .L34 movq %rax, %rbx movl $61687117, %esi movl $1, %edi call calloc@PLT movq %rax, %rbp testq %rax, %rax je .L35 movq %rsp, %rdi movl $123374234, %esi call cudaMalloc@PLT testl %eax, %eax jne .L36 leaq 8(%rsp), %rdi movl $61687117, %esi call cudaMalloc@PLT testl %eax, %eax jne .L37 movl $0, %edx .L15: movslq %edx, %rax imulq $-1370734243, %rax, %rax shrq $32, %rax addl %edx, %eax sarl $6, %eax movl %edx, %ecx sarl $31, %ecx subl %ecx, %eax imull $94, %eax, %eax movl %edx, %ecx subl %eax, %ecx leal 33(%rcx), %eax movb %al, (%rbx,%rdx) addq $1, %rdx cmpq $123374234, %rdx jne .L15 movl $1, %ecx movq %rbx, %rsi movq (%rsp), %rdi call cudaMemcpy@PLT testl %eax, %eax jne .L38 call cudaDeviceSynchronize@PLT leaq 16(%rsp), %rdi call cudaEventCreate@PLT testl %eax, %eax jne .L39 leaq 24(%rsp), %rdi call cudaEventCreate@PLT testl %eax, %eax jne .L40 movl $0, %esi movq 16(%rsp), %rdi call cudaEventRecord@PLT testl %eax, %eax jne .L41 leaq .LC8(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $50, %r12d jmp .L21 .L34: movl $123374234, %ecx leaq .LC0(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L35: movl $61687117, %ecx leaq .LC1(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L36: movl $123374234, %ecx leaq .LC2(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L37: movl $61687117, %ecx leaq .LC3(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L38: movl $98, %ecx movl %eax, %edx leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .L39: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx leaq .LC5(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L40: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx leaq .LC6(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L41: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx leaq .LC7(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L20: subl $1, %r12d je .L42 .L21: movl $1024, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $60242, 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 jne .L20 movl $61687117, %edx movq 8(%rsp), %rsi movq (%rsp), %rdi call _Z26__device_stub__Z4hashPcS_iPcS_i jmp .L20 .L42: movl $0, %esi movq 24(%rsp), %rdi call cudaEventRecord@PLT testl %eax, %eax jne .L43 movq 24(%rsp), %rdi call cudaEventSynchronize@PLT testl %eax, %eax jne .L44 movl $0x00000000, 44(%rsp) leaq 44(%rsp), %rdi movq 24(%rsp), %rdx movq 16(%rsp), %rsi call cudaEventElapsedTime@PLT testl %eax, %eax jne .L45 movl $2, %ecx movl $61687117, %edx movq 8(%rsp), %rsi movq %rbp, %rdi call cudaMemcpy@PLT testl %eax, %eax jne .L46 movl $0, %eax .L25: movzbl (%rbx,%rax,2), %esi cmpb %sil, 0(%rbp,%rax) jne .L47 addq $1, %rax cmpq $61687117, %rax jne .L25 pxor %xmm0, %xmm0 cvtss2sd 44(%rsp), %xmm0 divsd .LC14(%rip), %xmm0 leaq .LC15(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq %rbx, %rdi call free@PLT movq %rbp, %rdi call free@PLT movq (%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT call cudaDeviceReset@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L48 movl $0, %eax addq $64, %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 .L43: .cfi_restore_state movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx leaq .LC9(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L44: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx leaq .LC10(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L45: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx leaq .LC12(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $1, %edi call exit@PLT .L46: movl $177, %ecx movl %eax, %edx leaq .LC13(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %edi call exit@PLT .L47: movl $1, %edi call exit@PLT .L48: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC16: .string "_Z4hashPcS_i" .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 .LC16(%rip), %rdx movq %rdx, %rcx leaq _Z4hashPcS_i(%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 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC14: .long 0 .long 1083129856 .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 "hash.hip" .globl _Z19__device_stub__hashPcS_i # -- Begin function _Z19__device_stub__hashPcS_i .p2align 4, 0x90 .type _Z19__device_stub__hashPcS_i,@function _Z19__device_stub__hashPcS_i: # @_Z19__device_stub__hashPcS_i .cfi_startproc # %bb.0: subq $104, %rsp .cfi_def_cfa_offset 112 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movl %edx, 12(%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 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 $_Z4hashPcS_i, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $120, %rsp .cfi_adjust_cfa_offset -120 retq .Lfunc_end0: .size _Z19__device_stub__hashPcS_i, .Lfunc_end0-_Z19__device_stub__hashPcS_i .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI1_0: .quad 0x408f400000000000 # double 1000 .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 $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 $1, %edi movl $123374234, %esi # imm = 0x75A8A9A callq calloc testq %rax, %rax je .LBB1_23 # %bb.1: movq %rax, %rbx movl $1, %edi movl $61687117, %esi # imm = 0x3AD454D callq calloc testq %rax, %rax je .LBB1_24 # %bb.2: movq %rax, %r14 leaq 24(%rsp), %rdi movl $123374234, %esi # imm = 0x75A8A9A callq hipMalloc testl %eax, %eax jne .LBB1_25 # %bb.3: leaq 16(%rsp), %rdi movl $61687117, %esi # imm = 0x3AD454D callq hipMalloc testl %eax, %eax jne .LBB1_27 # %bb.4: # %.preheader79.preheader movb $33, %al xorl %ecx, %ecx movl $2924233053, %edx # imm = 0xAE4C415D xorl %esi, %esi .p2align 4, 0x90 .LBB1_5: # %.preheader79 # =>This Inner Loop Header: Depth=1 movl %ecx, %edi imulq %rdx, %rdi shrq $38, %rdi imull $94, %edi, %edi movl %eax, %r8d subb %dil, %r8b movb %r8b, (%rbx,%rsi) incq %rsi incb %al incl %ecx cmpq $123374234, %rsi # imm = 0x75A8A9A jne .LBB1_5 # %bb.6: movq 24(%rsp), %rdi movl $123374234, %edx # imm = 0x75A8A9A movq %rbx, %rsi movl $1, %ecx callq hipMemcpy testl %eax, %eax jne .LBB1_30 # %bb.7: callq hipDeviceSynchronize leaq 40(%rsp), %rdi callq hipEventCreate testl %eax, %eax jne .LBB1_31 # %bb.8: leaq 8(%rsp), %rdi callq hipEventCreate testl %eax, %eax jne .LBB1_32 # %bb.9: movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord testl %eax, %eax jne .LBB1_33 # %bb.10: movabsq $4294968320, %r15 # imm = 0x100000400 movl $.Lstr, %edi callq puts@PLT movl $50, %ebp leaq 59218(%r15), %r12 leaq 48(%rsp), %r13 jmp .LBB1_12 .p2align 4, 0x90 .LBB1_11: # in Loop: Header=BB1_12 Depth=1 decl %ebp je .LBB1_14 .LBB1_12: # =>This Inner Loop Header: Depth=1 movq %r12, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_11 # %bb.13: # in Loop: Header=BB1_12 Depth=1 movq 24(%rsp), %rax movq 16(%rsp), %rcx movq %rax, 128(%rsp) movq %rcx, 120(%rsp) movl $61687117, 36(%rsp) # imm = 0x3AD454D leaq 128(%rsp), %rax movq %rax, 48(%rsp) leaq 120(%rsp), %rax movq %rax, 56(%rsp) leaq 36(%rsp), %rax movq %rax, 64(%rsp) leaq 104(%rsp), %rdi leaq 88(%rsp), %rsi leaq 80(%rsp), %rdx leaq 72(%rsp), %rcx callq __hipPopCallConfiguration movq 104(%rsp), %rsi movl 112(%rsp), %edx movq 88(%rsp), %rcx movl 96(%rsp), %r8d movl $_Z4hashPcS_i, %edi movq %r13, %r9 pushq 72(%rsp) .cfi_adjust_cfa_offset 8 pushq 88(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 jmp .LBB1_11 .LBB1_14: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord testl %eax, %eax jne .LBB1_34 # %bb.15: movq 8(%rsp), %rdi callq hipEventSynchronize testl %eax, %eax jne .LBB1_35 # %bb.16: movl $0, 48(%rsp) movq 40(%rsp), %rsi movq 8(%rsp), %rdx leaq 48(%rsp), %rdi callq hipEventElapsedTime testl %eax, %eax jne .LBB1_36 # %bb.17: movq 16(%rsp), %rsi movl $61687117, %edx # imm = 0x3AD454D movq %r14, %rdi movl $2, %ecx callq hipMemcpy testl %eax, %eax jne .LBB1_38 # %bb.18: # %.preheader.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_19: # %.preheader # =>This Inner Loop Header: Depth=1 movzbl (%r14,%rax), %ecx cmpb (%rbx,%rax,2), %cl jne .LBB1_22 # %bb.20: # in Loop: Header=BB1_19 Depth=1 incq %rax cmpq $61687117, %rax # imm = 0x3AD454D jne .LBB1_19 # %bb.21: movss 48(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 divsd .LCPI1_0(%rip), %xmm0 movl $.L.str.14, %edi movb $1, %al callq printf movq %rbx, %rdi callq free movq %r14, %rdi callq free movq 24(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree callq hipDeviceReset xorl %eax, %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 .LBB1_22: .cfi_def_cfa_offset 192 movl $1, %edi callq exit .LBB1_23: movq stderr(%rip), %rdi movl $.L.str.1, %esi jmp .LBB1_26 .LBB1_24: movq stderr(%rip), %rdi movl $.L.str.2, %esi jmp .LBB1_28 .LBB1_25: movq stderr(%rip), %rdi movl $.L.str.3, %esi .LBB1_26: movl $123374234, %edx # imm = 0x75A8A9A jmp .LBB1_29 .LBB1_27: movq stderr(%rip), %rdi movl $.L.str.4, %esi .LBB1_28: movl $61687117, %edx # imm = 0x3AD454D .LBB1_29: xorl %eax, %eax callq fprintf movl $1, %edi callq exit .LBB1_30: movl $.L.str.5, %edi movl %eax, %esi movl $100, %edx jmp .LBB1_39 .LBB1_31: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.6, %esi jmp .LBB1_37 .LBB1_32: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.7, %esi jmp .LBB1_37 .LBB1_33: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.8, %esi jmp .LBB1_37 .LBB1_34: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.10, %esi jmp .LBB1_37 .LBB1_35: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.11, %esi jmp .LBB1_37 .LBB1_36: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.12, %esi .LBB1_37: movq %rbx, %rdi movq %rax, %rdx xorl %eax, %eax callq fprintf movl $1, %edi callq exit .LBB1_38: movl $.L.str.13, %edi movl %eax, %esi movl $179, %edx .LBB1_39: xorl %eax, %eax callq printf movl $1, %edi callq exit .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 $_Z4hashPcS_i, %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 _Z4hashPcS_i,@object # @_Z4hashPcS_i .section .rodata,"a",@progbits .globl _Z4hashPcS_i .p2align 3, 0x0 _Z4hashPcS_i: .quad _Z19__device_stub__hashPcS_i .size _Z4hashPcS_i, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "Failed to allocate %d bytes for f." .size .L.str.1, 35 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Failed to allocate %d bytes for h." .size .L.str.2, 35 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Failed to hipMalloc %d bytes for d_f." .size .L.str.3, 38 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "Failed to hipMalloc %d bytes for d_h." .size .L.str.4, 38 .type .L.str.5,@object # @.str.5 .L.str.5: .asciz "hipMemcpy (d_f,f) returned error code %d, line(%d)\n" .size .L.str.5, 52 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "Failed to create start event (error code %s)!\n" .size .L.str.6, 47 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "Failed to create stop event (error code %s)!\n" .size .L.str.7, 46 .type .L.str.8,@object # @.str.8 .L.str.8: .asciz "Failed to record start event (error code %s)!\n" .size .L.str.8, 47 .type .L.str.10,@object # @.str.10 .L.str.10: .asciz "Failed to record stop event (error code %s)!\n" .size .L.str.10, 46 .type .L.str.11,@object # @.str.11 .L.str.11: .asciz "Failed to synchronize on the stop event (error code %s)!\n" .size .L.str.11, 58 .type .L.str.12,@object # @.str.12 .L.str.12: .asciz "Failed to get time elapsed between events (error code %s)!\n" .size .L.str.12, 60 .type .L.str.13,@object # @.str.13 .L.str.13: .asciz "hipMemcpy (h,d_h) returned error code %d, line(%d)\n" .size .L.str.13, 52 .type .L.str.14,@object # @.str.14 .L.str.14: .asciz "Performance= %.06f sec\n" .size .L.str.14, 24 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z4hashPcS_i" .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 "Running..." .size .Lstr, 11 .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 _Z19__device_stub__hashPcS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4hashPcS_i .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> #ifdef __DEVICE_EMULATION__ #define EMUSYNC __syncthreads() #else #define EMUSYNC (void*)(0) #endif void checkCUDAError(const char *msg); __device__ void sum_block(float *s, float *sdata) { int blockSize=blockDim.x; int tid=threadIdx.x; if (blockSize >= 512) { if (tid < 256) { sdata[tid] += sdata[tid + 256]; } __syncthreads(); } if (blockSize >= 256) { if (tid < 128) { sdata[tid] += sdata[tid + 128]; } __syncthreads(); } if (blockSize >= 128) { if (tid < 64) { sdata[tid] += sdata[tid + 64]; } __syncthreads(); } #ifndef __DEVICE_EMULATION__ if (tid < 32) #endif { if (blockSize >= 64) { sdata[tid] += sdata[tid + 32]; EMUSYNC; } if (blockSize >= 32) { sdata[tid] += sdata[tid + 16]; EMUSYNC; } if (blockSize >= 16) { sdata[tid] += sdata[tid + 8]; EMUSYNC; } if (blockSize >= 8) { sdata[tid] += sdata[tid + 4]; EMUSYNC; } if (blockSize >= 4) { sdata[tid] += sdata[tid + 2]; EMUSYNC; } if (blockSize >= 2) { sdata[tid] += sdata[tid + 1]; EMUSYNC; } } if (tid == 0) *s = sdata[0]; } __global__ void sum_global(float* s, float *array) { extern __shared__ float sdata[]; int tid=threadIdx.x; sdata[tid] = array[tid]; __syncthreads(); sum_block(s, sdata); } __global__ void calc_pi0(float *da_pi) { extern __shared__ float sdata[]; int i= blockIdx.x*blockDim.x + threadIdx.x; int tid=threadIdx.x; int n= blockDim.x*gridDim.x; float x = (i - 0.5)/n; sdata[tid] = 4.0/(1 + x*x); __syncthreads(); sum_block(da_pi+blockIdx.x, sdata); } int main( int argc, char** argv) { float pi=0.0; float *d_pi; float *da_pi; /* note: numBlocks and numThreadsPerBlocks must be power of 2 */ int numBlocks = 256; int numThreadsPerBlock = 256; int numThreads = numBlocks*numThreadsPerBlock; size_t memSize = numBlocks*sizeof(float); size_t sharedMemSize = numThreadsPerBlock*sizeof(float); cudaMalloc((void**)&da_pi, memSize); cudaMalloc((void**)&d_pi, sizeof(float)); dim3 dimGrid(numBlocks); dim3 dimBlock(numThreadsPerBlock); calc_pi0<<<dimGrid, dimBlock, sharedMemSize>>>(da_pi); cudaThreadSynchronize(); sum_global<<<1, dimGrid, sharedMemSize>>>(d_pi, da_pi); cudaThreadSynchronize(); checkCUDAError("kernel execution"); cudaMemcpy(&pi, d_pi, sizeof(float), cudaMemcpyDeviceToHost); checkCUDAError("cudaMemcpy"); cudaFree(da_pi); cudaFree(d_pi); pi/=numThreads; printf("pi=%f\n", pi); return 0; } void checkCUDAError(const char *msg) { cudaError_t err = cudaGetLastError(); if( cudaSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString( err) ); exit(-1); } }
.file "tmpxft_00113ca8_00000000-6_pi.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 _Z9sum_blockPfS_ .type _Z9sum_blockPfS_, @function _Z9sum_blockPfS_: .LFB2057: .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 .LFE2057: .size _Z9sum_blockPfS_, .-_Z9sum_blockPfS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Cuda error: %s: %s.\n" .text .globl _Z14checkCUDAErrorPKc .type _Z14checkCUDAErrorPKc, @function _Z14checkCUDAErrorPKc: .LFB2059: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movq %rdi, %rbx call cudaGetLastError@PLT testl %eax, %eax jne .L8 popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 ret .L8: .cfi_restore_state movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %r8 movq %rbx, %rcx leaq .LC0(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $-1, %edi call exit@PLT .cfi_endproc .LFE2059: .size _Z14checkCUDAErrorPKc, .-_Z14checkCUDAErrorPKc .globl _Z32__device_stub__Z10sum_globalPfS_PfS_ .type _Z32__device_stub__Z10sum_globalPfS_PfS_, @function _Z32__device_stub__Z10sum_globalPfS_PfS_: .LFB2084: .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 .L13 .L9: movq 104(%rsp), %rax subq %fs:40, %rax jne .L14 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L13: .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 _Z10sum_globalPfS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L9 .L14: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z32__device_stub__Z10sum_globalPfS_PfS_, .-_Z32__device_stub__Z10sum_globalPfS_PfS_ .globl _Z10sum_globalPfS_ .type _Z10sum_globalPfS_, @function _Z10sum_globalPfS_: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z32__device_stub__Z10sum_globalPfS_PfS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z10sum_globalPfS_, .-_Z10sum_globalPfS_ .globl _Z27__device_stub__Z8calc_pi0PfPf .type _Z27__device_stub__Z8calc_pi0PfPf, @function _Z27__device_stub__Z8calc_pi0PfPf: .LFB2086: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movq %rdi, 8(%rsp) movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax leaq 8(%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 .L21 .L17: movq 88(%rsp), %rax subq %fs:40, %rax jne .L22 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L21: .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 _Z8calc_pi0Pf(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L17 .L22: call __stack_chk_fail@PLT .cfi_endproc .LFE2086: .size _Z27__device_stub__Z8calc_pi0PfPf, .-_Z27__device_stub__Z8calc_pi0PfPf .globl _Z8calc_pi0Pf .type _Z8calc_pi0Pf, @function _Z8calc_pi0Pf: .LFB2087: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z27__device_stub__Z8calc_pi0PfPf addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2087: .size _Z8calc_pi0Pf, .-_Z8calc_pi0Pf .section .rodata.str1.1 .LC2: .string "kernel execution" .LC3: .string "cudaMemcpy" .LC5: .string "pi=%f\n" .text .globl main .type main, @function main: .LFB2058: .cfi_startproc endbr64 subq $88, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax movl $0x00000000, 12(%rsp) leaq 24(%rsp), %rdi movl $1024, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT movl $256, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $256, 48(%rsp) movl $1, 52(%rsp) movl $0, %r9d movl $1024, %r8d movq 48(%rsp), %rdx movl $1, %ecx movq 36(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L30 .L26: call cudaThreadSynchronize@PLT movl $1, 60(%rsp) movl $1, 64(%rsp) movl 44(%rsp), %ecx movl $0, %r9d movl $1024, %r8d movq 36(%rsp), %rdx movq 60(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L31 .L27: call cudaThreadSynchronize@PLT leaq .LC2(%rip), %rdi call _Z14checkCUDAErrorPKc leaq 12(%rsp), %rdi movl $2, %ecx movl $4, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT leaq .LC3(%rip), %rdi call _Z14checkCUDAErrorPKc movq 24(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movss .LC4(%rip), %xmm0 mulss 12(%rsp), %xmm0 movss %xmm0, 12(%rsp) cvtss2sd %xmm0, %xmm0 leaq .LC5(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L32 movl $0, %eax addq $88, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L30: .cfi_restore_state movq 24(%rsp), %rdi call _Z27__device_stub__Z8calc_pi0PfPf jmp .L26 .L31: movq 24(%rsp), %rsi movq 16(%rsp), %rdi call _Z32__device_stub__Z10sum_globalPfS_PfS_ jmp .L27 .L32: call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size main, .-main .section .rodata.str1.1 .LC6: .string "_Z8calc_pi0Pf" .LC7: .string "_Z10sum_globalPfS_" .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 .LC6(%rip), %rdx movq %rdx, %rcx leaq _Z8calc_pi0Pf(%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 .LC7(%rip), %rdx movq %rdx, %rcx leaq _Z10sum_globalPfS_(%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 .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.cst4,"aM",@progbits,4 .align 4 .LC4: .long 931135488 .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> #ifdef __DEVICE_EMULATION__ #define EMUSYNC __syncthreads() #else #define EMUSYNC (void*)(0) #endif void checkCUDAError(const char *msg); __device__ void sum_block(float *s, float *sdata) { int blockSize=blockDim.x; int tid=threadIdx.x; if (blockSize >= 512) { if (tid < 256) { sdata[tid] += sdata[tid + 256]; } __syncthreads(); } if (blockSize >= 256) { if (tid < 128) { sdata[tid] += sdata[tid + 128]; } __syncthreads(); } if (blockSize >= 128) { if (tid < 64) { sdata[tid] += sdata[tid + 64]; } __syncthreads(); } #ifndef __DEVICE_EMULATION__ if (tid < 32) #endif { if (blockSize >= 64) { sdata[tid] += sdata[tid + 32]; EMUSYNC; } if (blockSize >= 32) { sdata[tid] += sdata[tid + 16]; EMUSYNC; } if (blockSize >= 16) { sdata[tid] += sdata[tid + 8]; EMUSYNC; } if (blockSize >= 8) { sdata[tid] += sdata[tid + 4]; EMUSYNC; } if (blockSize >= 4) { sdata[tid] += sdata[tid + 2]; EMUSYNC; } if (blockSize >= 2) { sdata[tid] += sdata[tid + 1]; EMUSYNC; } } if (tid == 0) *s = sdata[0]; } __global__ void sum_global(float* s, float *array) { extern __shared__ float sdata[]; int tid=threadIdx.x; sdata[tid] = array[tid]; __syncthreads(); sum_block(s, sdata); } __global__ void calc_pi0(float *da_pi) { extern __shared__ float sdata[]; int i= blockIdx.x*blockDim.x + threadIdx.x; int tid=threadIdx.x; int n= blockDim.x*gridDim.x; float x = (i - 0.5)/n; sdata[tid] = 4.0/(1 + x*x); __syncthreads(); sum_block(da_pi+blockIdx.x, sdata); } int main( int argc, char** argv) { float pi=0.0; float *d_pi; float *da_pi; /* note: numBlocks and numThreadsPerBlocks must be power of 2 */ int numBlocks = 256; int numThreadsPerBlock = 256; int numThreads = numBlocks*numThreadsPerBlock; size_t memSize = numBlocks*sizeof(float); size_t sharedMemSize = numThreadsPerBlock*sizeof(float); cudaMalloc((void**)&da_pi, memSize); cudaMalloc((void**)&d_pi, sizeof(float)); dim3 dimGrid(numBlocks); dim3 dimBlock(numThreadsPerBlock); calc_pi0<<<dimGrid, dimBlock, sharedMemSize>>>(da_pi); cudaThreadSynchronize(); sum_global<<<1, dimGrid, sharedMemSize>>>(d_pi, da_pi); cudaThreadSynchronize(); checkCUDAError("kernel execution"); cudaMemcpy(&pi, d_pi, sizeof(float), cudaMemcpyDeviceToHost); checkCUDAError("cudaMemcpy"); cudaFree(da_pi); cudaFree(d_pi); pi/=numThreads; printf("pi=%f\n", pi); return 0; } void checkCUDAError(const char *msg) { cudaError_t err = cudaGetLastError(); if( cudaSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString( err) ); exit(-1); } }
#include <hip/hip_runtime.h> #include <stdio.h> #ifdef __DEVICE_EMULATION__ #define EMUSYNC __syncthreads() #else #define EMUSYNC (void*)(0) #endif void checkCUDAError(const char *msg); __device__ void sum_block(float *s, float *sdata) { int blockSize=blockDim.x; int tid=threadIdx.x; if (blockSize >= 512) { if (tid < 256) { sdata[tid] += sdata[tid + 256]; } __syncthreads(); } if (blockSize >= 256) { if (tid < 128) { sdata[tid] += sdata[tid + 128]; } __syncthreads(); } if (blockSize >= 128) { if (tid < 64) { sdata[tid] += sdata[tid + 64]; } __syncthreads(); } #ifndef __DEVICE_EMULATION__ if (tid < 32) #endif { if (blockSize >= 64) { sdata[tid] += sdata[tid + 32]; EMUSYNC; } if (blockSize >= 32) { sdata[tid] += sdata[tid + 16]; EMUSYNC; } if (blockSize >= 16) { sdata[tid] += sdata[tid + 8]; EMUSYNC; } if (blockSize >= 8) { sdata[tid] += sdata[tid + 4]; EMUSYNC; } if (blockSize >= 4) { sdata[tid] += sdata[tid + 2]; EMUSYNC; } if (blockSize >= 2) { sdata[tid] += sdata[tid + 1]; EMUSYNC; } } if (tid == 0) *s = sdata[0]; } __global__ void sum_global(float* s, float *array) { extern __shared__ float sdata[]; int tid=threadIdx.x; sdata[tid] = array[tid]; __syncthreads(); sum_block(s, sdata); } __global__ void calc_pi0(float *da_pi) { extern __shared__ float sdata[]; int i= blockIdx.x*blockDim.x + threadIdx.x; int tid=threadIdx.x; int n= blockDim.x*gridDim.x; float x = (i - 0.5)/n; sdata[tid] = 4.0/(1 + x*x); __syncthreads(); sum_block(da_pi+blockIdx.x, sdata); } int main( int argc, char** argv) { float pi=0.0; float *d_pi; float *da_pi; /* note: numBlocks and numThreadsPerBlocks must be power of 2 */ int numBlocks = 256; int numThreadsPerBlock = 256; int numThreads = numBlocks*numThreadsPerBlock; size_t memSize = numBlocks*sizeof(float); size_t sharedMemSize = numThreadsPerBlock*sizeof(float); hipMalloc((void**)&da_pi, memSize); hipMalloc((void**)&d_pi, sizeof(float)); dim3 dimGrid(numBlocks); dim3 dimBlock(numThreadsPerBlock); calc_pi0<<<dimGrid, dimBlock, sharedMemSize>>>(da_pi); hipDeviceSynchronize(); sum_global<<<1, dimGrid, sharedMemSize>>>(d_pi, da_pi); hipDeviceSynchronize(); checkCUDAError("kernel execution"); hipMemcpy(&pi, d_pi, sizeof(float), hipMemcpyDeviceToHost); checkCUDAError("hipMemcpy"); hipFree(da_pi); hipFree(d_pi); pi/=numThreads; printf("pi=%f\n", pi); return 0; } void checkCUDAError(const char *msg) { hipError_t err = hipGetLastError(); if( hipSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, hipGetErrorString( err) ); exit(-1); } }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <stdio.h> #ifdef __DEVICE_EMULATION__ #define EMUSYNC __syncthreads() #else #define EMUSYNC (void*)(0) #endif void checkCUDAError(const char *msg); __device__ void sum_block(float *s, float *sdata) { int blockSize=blockDim.x; int tid=threadIdx.x; if (blockSize >= 512) { if (tid < 256) { sdata[tid] += sdata[tid + 256]; } __syncthreads(); } if (blockSize >= 256) { if (tid < 128) { sdata[tid] += sdata[tid + 128]; } __syncthreads(); } if (blockSize >= 128) { if (tid < 64) { sdata[tid] += sdata[tid + 64]; } __syncthreads(); } #ifndef __DEVICE_EMULATION__ if (tid < 32) #endif { if (blockSize >= 64) { sdata[tid] += sdata[tid + 32]; EMUSYNC; } if (blockSize >= 32) { sdata[tid] += sdata[tid + 16]; EMUSYNC; } if (blockSize >= 16) { sdata[tid] += sdata[tid + 8]; EMUSYNC; } if (blockSize >= 8) { sdata[tid] += sdata[tid + 4]; EMUSYNC; } if (blockSize >= 4) { sdata[tid] += sdata[tid + 2]; EMUSYNC; } if (blockSize >= 2) { sdata[tid] += sdata[tid + 1]; EMUSYNC; } } if (tid == 0) *s = sdata[0]; } __global__ void sum_global(float* s, float *array) { extern __shared__ float sdata[]; int tid=threadIdx.x; sdata[tid] = array[tid]; __syncthreads(); sum_block(s, sdata); } __global__ void calc_pi0(float *da_pi) { extern __shared__ float sdata[]; int i= blockIdx.x*blockDim.x + threadIdx.x; int tid=threadIdx.x; int n= blockDim.x*gridDim.x; float x = (i - 0.5)/n; sdata[tid] = 4.0/(1 + x*x); __syncthreads(); sum_block(da_pi+blockIdx.x, sdata); } int main( int argc, char** argv) { float pi=0.0; float *d_pi; float *da_pi; /* note: numBlocks and numThreadsPerBlocks must be power of 2 */ int numBlocks = 256; int numThreadsPerBlock = 256; int numThreads = numBlocks*numThreadsPerBlock; size_t memSize = numBlocks*sizeof(float); size_t sharedMemSize = numThreadsPerBlock*sizeof(float); hipMalloc((void**)&da_pi, memSize); hipMalloc((void**)&d_pi, sizeof(float)); dim3 dimGrid(numBlocks); dim3 dimBlock(numThreadsPerBlock); calc_pi0<<<dimGrid, dimBlock, sharedMemSize>>>(da_pi); hipDeviceSynchronize(); sum_global<<<1, dimGrid, sharedMemSize>>>(d_pi, da_pi); hipDeviceSynchronize(); checkCUDAError("kernel execution"); hipMemcpy(&pi, d_pi, sizeof(float), hipMemcpyDeviceToHost); checkCUDAError("hipMemcpy"); hipFree(da_pi); hipFree(d_pi); pi/=numThreads; printf("pi=%f\n", pi); return 0; } void checkCUDAError(const char *msg) { hipError_t err = hipGetLastError(); if( hipSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, hipGetErrorString( err) ); exit(-1); } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z10sum_globalPfS_ .globl _Z10sum_globalPfS_ .p2align 8 .type _Z10sum_globalPfS_,@function _Z10sum_globalPfS_: s_clause 0x1 s_load_b64 s[4:5], s[0:1], 0x8 s_load_b32 s2, s[0:1], 0x1c v_lshlrev_b32_e32 v1, 2, v0 s_waitcnt lgkmcnt(0) global_load_b32 v2, v1, s[4:5] v_cmp_gt_u16_e64 s3, 0x200, s2 v_add_nc_u32_e32 v1, 0, v1 s_delay_alu instid0(VALU_DEP_2) s_and_b32 vcc_lo, exec_lo, s3 s_waitcnt vmcnt(0) ds_store_b32 v1, v2 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_cbranch_vccnz .LBB0_4 s_mov_b32 s3, exec_lo v_cmpx_gt_u32_e32 0x100, v0 s_cbranch_execz .LBB0_3 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_stride64_b32 v[1:2], v3 offset1:4 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_3: s_or_b32 exec_lo, exec_lo, s3 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB0_4: v_cmp_gt_u16_e64 s3, 0x100, s2 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s3 s_cbranch_vccnz .LBB0_8 s_mov_b32 s3, exec_lo v_cmpx_gt_u32_e32 0x80, v0 s_cbranch_execz .LBB0_7 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_stride64_b32 v[1:2], v3 offset1:2 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_7: s_or_b32 exec_lo, exec_lo, s3 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB0_8: v_cmp_gt_u16_e64 s3, 0x80, s2 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s3 s_cbranch_vccnz .LBB0_12 s_mov_b32 s3, exec_lo v_cmpx_gt_u32_e32 64, v0 s_cbranch_execz .LBB0_11 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_stride64_b32 v[1:2], v3 offset1:1 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_11: s_or_b32 exec_lo, exec_lo, s3 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB0_12: s_mov_b32 s3, exec_lo v_cmpx_gt_u32_e32 32, v0 s_cbranch_execz .LBB0_23 v_cmp_lt_u16_e64 s4, s2, 64 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s4 s_cbranch_vccnz .LBB0_15 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:32 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_15: v_cmp_lt_u16_e64 s4, s2, 32 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s4 s_and_b32 s4, 0xffff, s2 s_cbranch_vccnz .LBB0_17 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:16 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_17: s_cmp_lt_u32 s4, 16 s_cbranch_scc1 .LBB0_19 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:8 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_19: s_and_b32 s2, 0xffff, s2 s_cmp_lt_u32 s4, 8 s_cbranch_scc0 .LBB0_26 s_cmp_lt_u32 s2, 4 s_cbranch_scc0 .LBB0_27 .LBB0_21: s_cmp_lt_u32 s2, 2 s_cbranch_scc1 .LBB0_23 .LBB0_22: v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:1 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB0_23: s_or_b32 exec_lo, exec_lo, s3 s_delay_alu instid0(SALU_CYCLE_1) s_mov_b32 s2, exec_lo v_cmpx_eq_u32_e32 0, v0 s_cbranch_execz .LBB0_25 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, 0 s_load_b64 s[0:1], s[0:1], 0x0 ds_load_b32 v0, v0 s_waitcnt lgkmcnt(0) global_store_b32 v1, v0, s[0:1] .LBB0_25: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .LBB0_26: v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:4 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 s_cmp_lt_u32 s2, 4 s_cbranch_scc1 .LBB0_21 .LBB0_27: v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:2 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 s_cmp_lt_u32 s2, 2 s_cbranch_scc0 .LBB0_22 s_branch .LBB0_23 .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z10sum_globalPfS_ .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 4 .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 _Z10sum_globalPfS_, .Lfunc_end0-_Z10sum_globalPfS_ .section .AMDGPU.csdata,"",@progbits .text .protected _Z8calc_pi0Pf .globl _Z8calc_pi0Pf .p2align 8 .type _Z8calc_pi0Pf,@function _Z8calc_pi0Pf: s_clause 0x1 s_load_b32 s4, s[0:1], 0x14 s_load_b32 s5, s[0:1], 0x8 s_mov_b32 s2, s15 s_waitcnt lgkmcnt(0) s_and_b32 s3, s4, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_mad_u64_u32 v[1:2], null, s2, s3, v[0:1] s_mul_i32 s5, s5, s3 v_cvt_f64_i32_e32 v[3:4], s5 v_cmp_gt_u16_e64 s5, 0x200, s4 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_cvt_f64_i32_e32 v[1:2], v1 v_add_f64 v[1:2], v[1:2], -0.5 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_div_scale_f64 v[5:6], null, v[3:4], v[3:4], v[1:2] v_div_scale_f64 v[11:12], vcc_lo, v[1:2], v[3:4], v[1:2] v_rcp_f64_e32 v[7:8], v[5:6] s_waitcnt_depctr 0xfff v_fma_f64 v[9:10], -v[5:6], v[7:8], 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[7:8], v[7:8], v[9:10], v[7:8] v_fma_f64 v[9:10], -v[5:6], v[7:8], 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[7:8], v[7:8], v[9:10], v[7:8] v_mul_f64 v[9:10], v[11:12], v[7:8] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[5:6], -v[5:6], v[9:10], v[11:12] v_div_fmas_f64 v[5:6], v[5:6], v[7:8], v[9:10] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_div_fixup_f64 v[1:2], v[5:6], v[3:4], v[1:2] v_cvt_f32_f64_e32 v1, v[1:2] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f32 v1, v1, v1, 1.0 v_div_scale_f32 v2, null, v1, v1, 4.0 v_div_scale_f32 v5, vcc_lo, 4.0, v1, 4.0 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_rcp_f32_e32 v3, v2 s_waitcnt_depctr 0xfff v_fma_f32 v4, -v2, v3, 1.0 v_fmac_f32_e32 v3, v4, v3 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f32_e32 v4, v5, v3 v_fma_f32 v6, -v2, v4, v5 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fmac_f32_e32 v4, v6, v3 v_fma_f32 v2, -v2, v4, v5 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_div_fmas_f32 v2, v2, v3, v4 v_lshl_add_u32 v3, v0, 2, 0 s_and_b32 vcc_lo, exec_lo, s5 v_div_fixup_f32 v1, v2, v1, 4.0 ds_store_b32 v3, v1 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_cbranch_vccnz .LBB1_4 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 0x100, v0 s_cbranch_execz .LBB1_3 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_stride64_b32 v[1:2], v3 offset1:4 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_3: s_or_b32 exec_lo, exec_lo, s5 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB1_4: v_cmp_gt_u16_e64 s5, 0x100, s4 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s5 s_cbranch_vccnz .LBB1_8 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 0x80, v0 s_cbranch_execz .LBB1_7 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_stride64_b32 v[1:2], v3 offset1:2 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_7: s_or_b32 exec_lo, exec_lo, s5 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB1_8: v_cmp_gt_u16_e64 s5, 0x80, s4 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s5 s_cbranch_vccnz .LBB1_12 s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 64, v0 s_cbranch_execz .LBB1_11 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_stride64_b32 v[1:2], v3 offset1:1 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_11: s_or_b32 exec_lo, exec_lo, s5 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB1_12: s_mov_b32 s5, exec_lo v_cmpx_gt_u32_e32 32, v0 s_cbranch_execz .LBB1_23 v_cmp_lt_u16_e64 s6, s4, 64 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s6 s_cbranch_vccnz .LBB1_15 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:32 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_15: v_cmp_lt_u16_e64 s6, s4, 32 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s6 s_and_b32 s6, 0xffff, s4 s_cbranch_vccnz .LBB1_17 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:16 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_17: s_cmp_lt_u32 s6, 16 s_cbranch_scc1 .LBB1_19 v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:8 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_19: s_and_b32 s4, 0xffff, s4 s_cmp_lt_u32 s6, 8 s_cbranch_scc0 .LBB1_26 s_cmp_lt_u32 s4, 4 s_cbranch_scc0 .LBB1_27 .LBB1_21: s_cmp_lt_u32 s3, 2 s_cbranch_scc1 .LBB1_23 .LBB1_22: v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:1 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 .LBB1_23: s_or_b32 exec_lo, exec_lo, s5 s_mov_b32 s3, 0 s_mov_b32 s4, exec_lo v_cmpx_eq_u32_e32 0, v0 s_cbranch_execz .LBB1_25 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, 0 s_load_b64 s[0:1], s[0:1], 0x0 s_lshl_b64 s[2:3], s[2:3], 2 ds_load_b32 v0, v0 s_waitcnt lgkmcnt(0) s_add_u32 s0, s0, s2 s_addc_u32 s1, s1, s3 global_store_b32 v1, v0, s[0:1] .LBB1_25: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .LBB1_26: v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:4 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 s_cmp_lt_u32 s4, 4 s_cbranch_scc1 .LBB1_21 .LBB1_27: v_lshl_add_u32 v3, v0, 2, 0 ds_load_2addr_b32 v[1:2], v3 offset1:2 s_waitcnt lgkmcnt(0) v_add_f32_e32 v1, v2, v1 ds_store_b32 v3, v1 s_cmp_lt_u32 s3, 2 s_cbranch_scc0 .LBB1_22 s_branch .LBB1_23 .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z8calc_pi0Pf .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 264 .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_end1: .size _Z8calc_pi0Pf, .Lfunc_end1-_Z8calc_pi0Pf .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 - .offset: 136 .size: 4 .value_kind: hidden_dynamic_lds_size .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: _Z10sum_globalPfS_ .private_segment_fixed_size: 0 .sgpr_count: 8 .sgpr_spill_count: 0 .symbol: _Z10sum_globalPfS_.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 - .offset: 8 .size: 4 .value_kind: hidden_block_count_x - .offset: 12 .size: 4 .value_kind: hidden_block_count_y - .offset: 16 .size: 4 .value_kind: hidden_block_count_z - .offset: 20 .size: 2 .value_kind: hidden_group_size_x - .offset: 22 .size: 2 .value_kind: hidden_group_size_y - .offset: 24 .size: 2 .value_kind: hidden_group_size_z - .offset: 26 .size: 2 .value_kind: hidden_remainder_x - .offset: 28 .size: 2 .value_kind: hidden_remainder_y - .offset: 30 .size: 2 .value_kind: hidden_remainder_z - .offset: 48 .size: 8 .value_kind: hidden_global_offset_x - .offset: 56 .size: 8 .value_kind: hidden_global_offset_y - .offset: 64 .size: 8 .value_kind: hidden_global_offset_z - .offset: 72 .size: 2 .value_kind: hidden_grid_dims - .offset: 128 .size: 4 .value_kind: hidden_dynamic_lds_size .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 264 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z8calc_pi0Pf .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z8calc_pi0Pf.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 HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include <stdio.h> #ifdef __DEVICE_EMULATION__ #define EMUSYNC __syncthreads() #else #define EMUSYNC (void*)(0) #endif void checkCUDAError(const char *msg); __device__ void sum_block(float *s, float *sdata) { int blockSize=blockDim.x; int tid=threadIdx.x; if (blockSize >= 512) { if (tid < 256) { sdata[tid] += sdata[tid + 256]; } __syncthreads(); } if (blockSize >= 256) { if (tid < 128) { sdata[tid] += sdata[tid + 128]; } __syncthreads(); } if (blockSize >= 128) { if (tid < 64) { sdata[tid] += sdata[tid + 64]; } __syncthreads(); } #ifndef __DEVICE_EMULATION__ if (tid < 32) #endif { if (blockSize >= 64) { sdata[tid] += sdata[tid + 32]; EMUSYNC; } if (blockSize >= 32) { sdata[tid] += sdata[tid + 16]; EMUSYNC; } if (blockSize >= 16) { sdata[tid] += sdata[tid + 8]; EMUSYNC; } if (blockSize >= 8) { sdata[tid] += sdata[tid + 4]; EMUSYNC; } if (blockSize >= 4) { sdata[tid] += sdata[tid + 2]; EMUSYNC; } if (blockSize >= 2) { sdata[tid] += sdata[tid + 1]; EMUSYNC; } } if (tid == 0) *s = sdata[0]; } __global__ void sum_global(float* s, float *array) { extern __shared__ float sdata[]; int tid=threadIdx.x; sdata[tid] = array[tid]; __syncthreads(); sum_block(s, sdata); } __global__ void calc_pi0(float *da_pi) { extern __shared__ float sdata[]; int i= blockIdx.x*blockDim.x + threadIdx.x; int tid=threadIdx.x; int n= blockDim.x*gridDim.x; float x = (i - 0.5)/n; sdata[tid] = 4.0/(1 + x*x); __syncthreads(); sum_block(da_pi+blockIdx.x, sdata); } int main( int argc, char** argv) { float pi=0.0; float *d_pi; float *da_pi; /* note: numBlocks and numThreadsPerBlocks must be power of 2 */ int numBlocks = 256; int numThreadsPerBlock = 256; int numThreads = numBlocks*numThreadsPerBlock; size_t memSize = numBlocks*sizeof(float); size_t sharedMemSize = numThreadsPerBlock*sizeof(float); hipMalloc((void**)&da_pi, memSize); hipMalloc((void**)&d_pi, sizeof(float)); dim3 dimGrid(numBlocks); dim3 dimBlock(numThreadsPerBlock); calc_pi0<<<dimGrid, dimBlock, sharedMemSize>>>(da_pi); hipDeviceSynchronize(); sum_global<<<1, dimGrid, sharedMemSize>>>(d_pi, da_pi); hipDeviceSynchronize(); checkCUDAError("kernel execution"); hipMemcpy(&pi, d_pi, sizeof(float), hipMemcpyDeviceToHost); checkCUDAError("hipMemcpy"); hipFree(da_pi); hipFree(d_pi); pi/=numThreads; printf("pi=%f\n", pi); return 0; } void checkCUDAError(const char *msg) { hipError_t err = hipGetLastError(); if( hipSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, hipGetErrorString( err) ); exit(-1); } }
.text .file "pi.hip" .globl _Z25__device_stub__sum_globalPfS_ # -- Begin function _Z25__device_stub__sum_globalPfS_ .p2align 4, 0x90 .type _Z25__device_stub__sum_globalPfS_,@function _Z25__device_stub__sum_globalPfS_: # @_Z25__device_stub__sum_globalPfS_ .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 $_Z10sum_globalPfS_, %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 _Z25__device_stub__sum_globalPfS_, .Lfunc_end0-_Z25__device_stub__sum_globalPfS_ .cfi_endproc # -- End function .globl _Z23__device_stub__calc_pi0Pf # -- Begin function _Z23__device_stub__calc_pi0Pf .p2align 4, 0x90 .type _Z23__device_stub__calc_pi0Pf,@function _Z23__device_stub__calc_pi0Pf: # @_Z23__device_stub__calc_pi0Pf .cfi_startproc # %bb.0: subq $72, %rsp .cfi_def_cfa_offset 80 movq %rdi, 64(%rsp) leaq 64(%rsp), %rax movq %rax, (%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 movq %rsp, %r9 movl $_Z8calc_pi0Pf, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $88, %rsp .cfi_adjust_cfa_offset -88 retq .Lfunc_end1: .size _Z23__device_stub__calc_pi0Pf, .Lfunc_end1-_Z23__device_stub__calc_pi0Pf .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI2_0: .long 0x37800000 # float 1.52587891E-5 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $128, %rsp .cfi_def_cfa_offset 144 .cfi_offset %rbx, -16 movabsq $4294967552, %rbx # imm = 0x100000100 movl $0, 12(%rsp) leaq 32(%rsp), %rdi movl $1024, %esi # imm = 0x400 callq hipMalloc leaq 40(%rsp), %rdi movl $4, %esi callq hipMalloc movl $1024, %r8d # imm = 0x400 movq %rbx, %rdi movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_2 # %bb.1: movq 32(%rsp), %rax movq %rax, 80(%rsp) leaq 80(%rsp), %rax movq %rax, 16(%rsp) leaq 96(%rsp), %rdi leaq 48(%rsp), %rsi leaq 72(%rsp), %rdx leaq 64(%rsp), %rcx callq __hipPopCallConfiguration movq 96(%rsp), %rsi movl 104(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z8calc_pi0Pf, %edi pushq 64(%rsp) .cfi_adjust_cfa_offset 8 pushq 80(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_2: callq hipDeviceSynchronize leaq -255(%rbx), %rdi movl $1024, %r8d # imm = 0x400 movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_4 # %bb.3: movq 40(%rsp), %rax movq 32(%rsp), %rcx movq %rax, 72(%rsp) movq %rcx, 64(%rsp) leaq 72(%rsp), %rax movq %rax, 96(%rsp) leaq 64(%rsp), %rax movq %rax, 104(%rsp) leaq 48(%rsp), %rdi leaq 80(%rsp), %rsi leaq 16(%rsp), %rdx leaq 120(%rsp), %rcx callq __hipPopCallConfiguration movq 48(%rsp), %rsi movl 56(%rsp), %edx movq 80(%rsp), %rcx movl 88(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z10sum_globalPfS_, %edi pushq 120(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_4: callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB2_5 # %bb.7: # %_Z14checkCUDAErrorPKc.exit movq 40(%rsp), %rsi leaq 12(%rsp), %rdi movl $4, %edx movl $2, %ecx callq hipMemcpy callq hipGetLastError testl %eax, %eax jne .LBB2_8 # %bb.9: # %_Z14checkCUDAErrorPKc.exit30 movq 32(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movss 12(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero mulss .LCPI2_0(%rip), %xmm0 movss %xmm0, 12(%rsp) cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf xorl %eax, %eax addq $128, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .LBB2_5: .cfi_def_cfa_offset 144 movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %esi movl $.L.str, %edx jmp .LBB2_6 .LBB2_8: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %esi movl $.L.str.1, %edx .LBB2_6: movq %rbx, %rdi movq %rax, %rcx xorl %eax, %eax callq fprintf movl $-1, %edi callq exit .Lfunc_end2: .size main, .Lfunc_end2-main .cfi_endproc # -- End function .globl _Z14checkCUDAErrorPKc # -- Begin function _Z14checkCUDAErrorPKc .p2align 4, 0x90 .type _Z14checkCUDAErrorPKc,@function _Z14checkCUDAErrorPKc: # @_Z14checkCUDAErrorPKc .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 %rdi, %rbx callq hipGetLastError testl %eax, %eax jne .LBB3_2 # %bb.1: addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 retq .LBB3_2: .cfi_def_cfa_offset 32 movq stderr(%rip), %r14 movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %esi movq %r14, %rdi movq %rbx, %rdx movq %rax, %rcx xorl %eax, %eax callq fprintf movl $-1, %edi callq exit .Lfunc_end3: .size _Z14checkCUDAErrorPKc, .Lfunc_end3-_Z14checkCUDAErrorPKc .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 $_Z10sum_globalPfS_, %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 $_Z8calc_pi0Pf, %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 _Z10sum_globalPfS_,@object # @_Z10sum_globalPfS_ .section .rodata,"a",@progbits .globl _Z10sum_globalPfS_ .p2align 3, 0x0 _Z10sum_globalPfS_: .quad _Z25__device_stub__sum_globalPfS_ .size _Z10sum_globalPfS_, 8 .type _Z8calc_pi0Pf,@object # @_Z8calc_pi0Pf .globl _Z8calc_pi0Pf .p2align 3, 0x0 _Z8calc_pi0Pf: .quad _Z23__device_stub__calc_pi0Pf .size _Z8calc_pi0Pf, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "kernel execution" .size .L.str, 17 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "hipMemcpy" .size .L.str.1, 10 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "pi=%f\n" .size .L.str.2, 7 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Cuda error: %s: %s.\n" .size .L.str.3, 21 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z10sum_globalPfS_" .size .L__unnamed_1, 19 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z8calc_pi0Pf" .size .L__unnamed_2, 14 .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 _Z25__device_stub__sum_globalPfS_ .addrsig_sym _Z23__device_stub__calc_pi0Pf .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z10sum_globalPfS_ .addrsig_sym _Z8calc_pi0Pf .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_00113ca8_00000000-6_pi.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 _Z9sum_blockPfS_ .type _Z9sum_blockPfS_, @function _Z9sum_blockPfS_: .LFB2057: .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 .LFE2057: .size _Z9sum_blockPfS_, .-_Z9sum_blockPfS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Cuda error: %s: %s.\n" .text .globl _Z14checkCUDAErrorPKc .type _Z14checkCUDAErrorPKc, @function _Z14checkCUDAErrorPKc: .LFB2059: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movq %rdi, %rbx call cudaGetLastError@PLT testl %eax, %eax jne .L8 popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 ret .L8: .cfi_restore_state movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %r8 movq %rbx, %rcx leaq .LC0(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl $-1, %edi call exit@PLT .cfi_endproc .LFE2059: .size _Z14checkCUDAErrorPKc, .-_Z14checkCUDAErrorPKc .globl _Z32__device_stub__Z10sum_globalPfS_PfS_ .type _Z32__device_stub__Z10sum_globalPfS_PfS_, @function _Z32__device_stub__Z10sum_globalPfS_PfS_: .LFB2084: .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 .L13 .L9: movq 104(%rsp), %rax subq %fs:40, %rax jne .L14 addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L13: .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 _Z10sum_globalPfS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L9 .L14: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z32__device_stub__Z10sum_globalPfS_PfS_, .-_Z32__device_stub__Z10sum_globalPfS_PfS_ .globl _Z10sum_globalPfS_ .type _Z10sum_globalPfS_, @function _Z10sum_globalPfS_: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z32__device_stub__Z10sum_globalPfS_PfS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z10sum_globalPfS_, .-_Z10sum_globalPfS_ .globl _Z27__device_stub__Z8calc_pi0PfPf .type _Z27__device_stub__Z8calc_pi0PfPf, @function _Z27__device_stub__Z8calc_pi0PfPf: .LFB2086: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movq %rdi, 8(%rsp) movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax leaq 8(%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 .L21 .L17: movq 88(%rsp), %rax subq %fs:40, %rax jne .L22 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L21: .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 _Z8calc_pi0Pf(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L17 .L22: call __stack_chk_fail@PLT .cfi_endproc .LFE2086: .size _Z27__device_stub__Z8calc_pi0PfPf, .-_Z27__device_stub__Z8calc_pi0PfPf .globl _Z8calc_pi0Pf .type _Z8calc_pi0Pf, @function _Z8calc_pi0Pf: .LFB2087: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z27__device_stub__Z8calc_pi0PfPf addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2087: .size _Z8calc_pi0Pf, .-_Z8calc_pi0Pf .section .rodata.str1.1 .LC2: .string "kernel execution" .LC3: .string "cudaMemcpy" .LC5: .string "pi=%f\n" .text .globl main .type main, @function main: .LFB2058: .cfi_startproc endbr64 subq $88, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax movl $0x00000000, 12(%rsp) leaq 24(%rsp), %rdi movl $1024, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $4, %esi call cudaMalloc@PLT movl $256, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $256, 48(%rsp) movl $1, 52(%rsp) movl $0, %r9d movl $1024, %r8d movq 48(%rsp), %rdx movl $1, %ecx movq 36(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L30 .L26: call cudaThreadSynchronize@PLT movl $1, 60(%rsp) movl $1, 64(%rsp) movl 44(%rsp), %ecx movl $0, %r9d movl $1024, %r8d movq 36(%rsp), %rdx movq 60(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L31 .L27: call cudaThreadSynchronize@PLT leaq .LC2(%rip), %rdi call _Z14checkCUDAErrorPKc leaq 12(%rsp), %rdi movl $2, %ecx movl $4, %edx movq 16(%rsp), %rsi call cudaMemcpy@PLT leaq .LC3(%rip), %rdi call _Z14checkCUDAErrorPKc movq 24(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movss .LC4(%rip), %xmm0 mulss 12(%rsp), %xmm0 movss %xmm0, 12(%rsp) cvtss2sd %xmm0, %xmm0 leaq .LC5(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L32 movl $0, %eax addq $88, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L30: .cfi_restore_state movq 24(%rsp), %rdi call _Z27__device_stub__Z8calc_pi0PfPf jmp .L26 .L31: movq 24(%rsp), %rsi movq 16(%rsp), %rdi call _Z32__device_stub__Z10sum_globalPfS_PfS_ jmp .L27 .L32: call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size main, .-main .section .rodata.str1.1 .LC6: .string "_Z8calc_pi0Pf" .LC7: .string "_Z10sum_globalPfS_" .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 .LC6(%rip), %rdx movq %rdx, %rcx leaq _Z8calc_pi0Pf(%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 .LC7(%rip), %rdx movq %rdx, %rcx leaq _Z10sum_globalPfS_(%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 .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.cst4,"aM",@progbits,4 .align 4 .LC4: .long 931135488 .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 "pi.hip" .globl _Z25__device_stub__sum_globalPfS_ # -- Begin function _Z25__device_stub__sum_globalPfS_ .p2align 4, 0x90 .type _Z25__device_stub__sum_globalPfS_,@function _Z25__device_stub__sum_globalPfS_: # @_Z25__device_stub__sum_globalPfS_ .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 $_Z10sum_globalPfS_, %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 _Z25__device_stub__sum_globalPfS_, .Lfunc_end0-_Z25__device_stub__sum_globalPfS_ .cfi_endproc # -- End function .globl _Z23__device_stub__calc_pi0Pf # -- Begin function _Z23__device_stub__calc_pi0Pf .p2align 4, 0x90 .type _Z23__device_stub__calc_pi0Pf,@function _Z23__device_stub__calc_pi0Pf: # @_Z23__device_stub__calc_pi0Pf .cfi_startproc # %bb.0: subq $72, %rsp .cfi_def_cfa_offset 80 movq %rdi, 64(%rsp) leaq 64(%rsp), %rax movq %rax, (%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 movq %rsp, %r9 movl $_Z8calc_pi0Pf, %edi pushq 16(%rsp) .cfi_adjust_cfa_offset 8 pushq 32(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $88, %rsp .cfi_adjust_cfa_offset -88 retq .Lfunc_end1: .size _Z23__device_stub__calc_pi0Pf, .Lfunc_end1-_Z23__device_stub__calc_pi0Pf .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI2_0: .long 0x37800000 # float 1.52587891E-5 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $128, %rsp .cfi_def_cfa_offset 144 .cfi_offset %rbx, -16 movabsq $4294967552, %rbx # imm = 0x100000100 movl $0, 12(%rsp) leaq 32(%rsp), %rdi movl $1024, %esi # imm = 0x400 callq hipMalloc leaq 40(%rsp), %rdi movl $4, %esi callq hipMalloc movl $1024, %r8d # imm = 0x400 movq %rbx, %rdi movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_2 # %bb.1: movq 32(%rsp), %rax movq %rax, 80(%rsp) leaq 80(%rsp), %rax movq %rax, 16(%rsp) leaq 96(%rsp), %rdi leaq 48(%rsp), %rsi leaq 72(%rsp), %rdx leaq 64(%rsp), %rcx callq __hipPopCallConfiguration movq 96(%rsp), %rsi movl 104(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 16(%rsp), %r9 movl $_Z8calc_pi0Pf, %edi pushq 64(%rsp) .cfi_adjust_cfa_offset 8 pushq 80(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_2: callq hipDeviceSynchronize leaq -255(%rbx), %rdi movl $1024, %r8d # imm = 0x400 movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_4 # %bb.3: movq 40(%rsp), %rax movq 32(%rsp), %rcx movq %rax, 72(%rsp) movq %rcx, 64(%rsp) leaq 72(%rsp), %rax movq %rax, 96(%rsp) leaq 64(%rsp), %rax movq %rax, 104(%rsp) leaq 48(%rsp), %rdi leaq 80(%rsp), %rsi leaq 16(%rsp), %rdx leaq 120(%rsp), %rcx callq __hipPopCallConfiguration movq 48(%rsp), %rsi movl 56(%rsp), %edx movq 80(%rsp), %rcx movl 88(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z10sum_globalPfS_, %edi pushq 120(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_4: callq hipDeviceSynchronize callq hipGetLastError testl %eax, %eax jne .LBB2_5 # %bb.7: # %_Z14checkCUDAErrorPKc.exit movq 40(%rsp), %rsi leaq 12(%rsp), %rdi movl $4, %edx movl $2, %ecx callq hipMemcpy callq hipGetLastError testl %eax, %eax jne .LBB2_8 # %bb.9: # %_Z14checkCUDAErrorPKc.exit30 movq 32(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movss 12(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero mulss .LCPI2_0(%rip), %xmm0 movss %xmm0, 12(%rsp) cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf xorl %eax, %eax addq $128, %rsp .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .LBB2_5: .cfi_def_cfa_offset 144 movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %esi movl $.L.str, %edx jmp .LBB2_6 .LBB2_8: movq stderr(%rip), %rbx movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %esi movl $.L.str.1, %edx .LBB2_6: movq %rbx, %rdi movq %rax, %rcx xorl %eax, %eax callq fprintf movl $-1, %edi callq exit .Lfunc_end2: .size main, .Lfunc_end2-main .cfi_endproc # -- End function .globl _Z14checkCUDAErrorPKc # -- Begin function _Z14checkCUDAErrorPKc .p2align 4, 0x90 .type _Z14checkCUDAErrorPKc,@function _Z14checkCUDAErrorPKc: # @_Z14checkCUDAErrorPKc .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 %rdi, %rbx callq hipGetLastError testl %eax, %eax jne .LBB3_2 # %bb.1: addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 retq .LBB3_2: .cfi_def_cfa_offset 32 movq stderr(%rip), %r14 movl %eax, %edi callq hipGetErrorString movl $.L.str.3, %esi movq %r14, %rdi movq %rbx, %rdx movq %rax, %rcx xorl %eax, %eax callq fprintf movl $-1, %edi callq exit .Lfunc_end3: .size _Z14checkCUDAErrorPKc, .Lfunc_end3-_Z14checkCUDAErrorPKc .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 $_Z10sum_globalPfS_, %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 $_Z8calc_pi0Pf, %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 _Z10sum_globalPfS_,@object # @_Z10sum_globalPfS_ .section .rodata,"a",@progbits .globl _Z10sum_globalPfS_ .p2align 3, 0x0 _Z10sum_globalPfS_: .quad _Z25__device_stub__sum_globalPfS_ .size _Z10sum_globalPfS_, 8 .type _Z8calc_pi0Pf,@object # @_Z8calc_pi0Pf .globl _Z8calc_pi0Pf .p2align 3, 0x0 _Z8calc_pi0Pf: .quad _Z23__device_stub__calc_pi0Pf .size _Z8calc_pi0Pf, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "kernel execution" .size .L.str, 17 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "hipMemcpy" .size .L.str.1, 10 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "pi=%f\n" .size .L.str.2, 7 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Cuda error: %s: %s.\n" .size .L.str.3, 21 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z10sum_globalPfS_" .size .L__unnamed_1, 19 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z8calc_pi0Pf" .size .L__unnamed_2, 14 .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 _Z25__device_stub__sum_globalPfS_ .addrsig_sym _Z23__device_stub__calc_pi0Pf .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z10sum_globalPfS_ .addrsig_sym _Z8calc_pi0Pf .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 <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #define ASCIIMIN 32 #define ASCIIMAX 126 #define CHARS_PER_THREADS 256 #define THREADS_PER_BLOCK 256 void __global__ kernel(int nLines, char* dev_chars, int nChars, int* dev_counts, int nCounts) { const unsigned int tidb = threadIdx.x; const unsigned int ti = blockIdx.x*blockDim.x + tidb; __shared__ int shared_counts[ASCIIMAX - ASCIIMIN + 1]; if (tidb == 0) { for (int i = 0; i < ASCIIMAX - ASCIIMIN - 1; ++i) { shared_counts[i] = 0; } } __syncthreads(); if (ti < nLines) { for (int i = 0; i < CHARS_PER_THREADS; ++i) { int ascii = (int)dev_chars[CHARS_PER_THREADS * ti + i]; atomicAdd(&shared_counts[ascii - ASCIIMIN], 1); } } __syncthreads(); if (tidb == 0) { for (int i = 0; i < nCounts; ++i) { atomicAdd(&dev_counts[i], shared_counts[i]); } } } int isValid(char* c){ int asciicode = (int)*c; int valid = (asciicode <= 126); valid = valid && (asciicode >= 32); return valid; } int main(int argc, char** argv){ clock_t t1, t2; printf("Initialisation...\n"); t1 = clock(); //Declarations FILE* inputFile = NULL; FILE* outputFile = NULL; char* inputFileName = NULL; char* outputFileName = NULL; int nChars = 0; char* chars; int nCounts = ASCIIMAX - ASCIIMIN + 1; int* counts; char* dev_chars; int* dev_counts; int opt; //Get comand line options while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch(opt) { case 'i': inputFileName = optarg; break; case 'o': outputFileName = optarg; break; } } //Count number of chars in inputFile inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; nChars = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)) ++nChars; } fclose(inputFile); //Allocate memory counts = (int*) malloc(nCounts * sizeof(int)); chars = (char*) malloc(nChars * sizeof(char)); if(chars == NULL) { printf("Input file too large!\n"); return 1; } printf("%d chars processed\n", nChars); cudaMalloc( (void**)&dev_chars, nChars * sizeof(char)); cudaMalloc( (void**)&dev_counts, nCounts * sizeof(int)); //Filling chars array inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; int i = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)){ if (c>=65 && c<=90) chars[i] = (char)(c + 32); else chars[i] = c; ++i; } } fclose(inputFile); t1 = clock() - t1; printf("Process...\n"); t2 = clock(); //Initialize counter array for (int i = 0; i < nCounts; ++i){ counts[i] = 0; } cudaMemcpy(dev_chars, chars, nChars * sizeof(char), cudaMemcpyHostToDevice); cudaMemcpy(dev_counts, counts, nCounts * sizeof(int), cudaMemcpyHostToDevice); //Count chars for (int i = 0; i < nChars; ++i){ int ascii = (int)chars[i]; ++counts[ascii - ASCIIMIN]; } int nLines = (nChars + CHARS_PER_THREADS - 1) / CHARS_PER_THREADS; kernel<<<(nLines + THREADS_PER_BLOCK - 1 ) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(nLines, dev_chars, nChars, dev_counts, nCounts); cudaMemcpy(counts, dev_counts, nCounts * sizeof(int), cudaMemcpyDeviceToHost); t2 = clock() - t2; //Write in outputFile outputFile = fopen(outputFileName, "w+"); if (!outputFile) return 1; for (int i = 0; i < 127 - ASCIIMIN; ++i){ if (i + ASCIIMIN < 65 || i + ASCIIMIN > 90) { fprintf(outputFile, "%c:%d\n", (char)(i + ASCIIMIN), (int)counts[i]); } } fclose(outputFile); //Return memory cudaFree(dev_chars); cudaFree(dev_counts); free(chars); free(counts); printf("Timings:\nInitialisation: %f\nProcess: %f\n", (float)1000 * t1/CLOCKS_PER_SEC, (float)1000 * t2/CLOCKS_PER_SEC); return 0; }
code for sm_80 Function : _Z6kerneliPciPii .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 R19, SR_TID.X ; /* 0x0000000000137919 */ /* 0x000e220000002100 */ /*0020*/ BSSY B0, 0x200 ; /* 0x000001d000007945 */ /* 0x000fe60003800000 */ /*0030*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e620000002500 */ /*0040*/ ISETP.NE.AND P0, PT, R19, RZ, PT ; /* 0x000000ff1300720c */ /* 0x001fe20003f05270 */ /*0050*/ IMAD R0, R0, c[0x0][0x0], R19 ; /* 0x0000000000007a24 */ /* 0x002fd800078e0213 */ /*0060*/ @P0 BRA 0x1f0 ; /* 0x0000018000000947 */ /* 0x000fea0003800000 */ /*0070*/ STS.128 [RZ], RZ ; /* 0x000000ffff007388 */ /* 0x000fe80000000c00 */ /*0080*/ STS.128 [0x10], RZ ; /* 0x000010ffff007388 */ /* 0x000fe80000000c00 */ /*0090*/ STS.128 [0x20], RZ ; /* 0x000020ffff007388 */ /* 0x000fe80000000c00 */ /*00a0*/ STS.128 [0x30], RZ ; /* 0x000030ffff007388 */ /* 0x000fe80000000c00 */ /*00b0*/ STS.128 [0x40], RZ ; /* 0x000040ffff007388 */ /* 0x000fe80000000c00 */ /*00c0*/ STS.128 [0x50], RZ ; /* 0x000050ffff007388 */ /* 0x000fe80000000c00 */ /*00d0*/ STS.128 [0x60], RZ ; /* 0x000060ffff007388 */ /* 0x000fe80000000c00 */ /*00e0*/ STS.128 [0x70], RZ ; /* 0x000070ffff007388 */ /* 0x000fe80000000c00 */ /*00f0*/ STS.128 [0x80], RZ ; /* 0x000080ffff007388 */ /* 0x000fe80000000c00 */ /*0100*/ STS.128 [0x90], RZ ; /* 0x000090ffff007388 */ /* 0x000fe80000000c00 */ /*0110*/ STS.128 [0xa0], RZ ; /* 0x0000a0ffff007388 */ /* 0x000fe80000000c00 */ /*0120*/ STS.128 [0xb0], RZ ; /* 0x0000b0ffff007388 */ /* 0x000fe80000000c00 */ /*0130*/ STS.128 [0xc0], RZ ; /* 0x0000c0ffff007388 */ /* 0x000fe80000000c00 */ /*0140*/ STS.128 [0xd0], RZ ; /* 0x0000d0ffff007388 */ /* 0x000fe80000000c00 */ /*0150*/ STS.128 [0xe0], RZ ; /* 0x0000e0ffff007388 */ /* 0x000fe80000000c00 */ /*0160*/ STS.128 [0xf0], RZ ; /* 0x0000f0ffff007388 */ /* 0x000fe80000000c00 */ /*0170*/ STS.128 [0x100], RZ ; /* 0x000100ffff007388 */ /* 0x000fe80000000c00 */ /*0180*/ STS.128 [0x110], RZ ; /* 0x000110ffff007388 */ /* 0x000fe80000000c00 */ /*0190*/ STS.128 [0x120], RZ ; /* 0x000120ffff007388 */ /* 0x000fe80000000c00 */ /*01a0*/ STS.128 [0x130], RZ ; /* 0x000130ffff007388 */ /* 0x000fe80000000c00 */ /*01b0*/ STS.128 [0x140], RZ ; /* 0x000140ffff007388 */ /* 0x000fe80000000c00 */ /*01c0*/ STS.128 [0x150], RZ ; /* 0x000150ffff007388 */ /* 0x000fe80000000c00 */ /*01d0*/ STS.128 [0x160], RZ ; /* 0x000160ffff007388 */ /* 0x000fe80000000c00 */ /*01e0*/ STS [0x170], RZ ; /* 0x000170ffff007388 */ /* 0x000fe40000000800 */ /*01f0*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0200*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fe20000010000 */ /*0210*/ ISETP.GE.U32.AND P0, PT, R0, c[0x0][0x160], PT ; /* 0x0000580000007a0c */ /* 0x000fca0003f06070 */ /*0220*/ ULDC.64 UR8, c[0x0][0x118] ; /* 0x0000460000087ab9 */ /* 0x000fd00000000a00 */ /*0230*/ @P0 BRA 0x4e0 ; /* 0x000002a000000947 */ /* 0x000fea0003800000 */ /*0240*/ LEA R0, P0, R0, c[0x0][0x168], 0x8 ; /* 0x00005a0000007a11 */ /* 0x000fc800078040ff */ /*0250*/ IADD3 R2, P1, R0, 0x7, RZ ; /* 0x0000000700027810 */ /* 0x000fe20007f3e0ff */ /*0260*/ IMAD.MOV.U32 R0, RZ, RZ, RZ ; /* 0x000000ffff007224 */ /* 0x000fc600078e00ff */ /*0270*/ IADD3.X R3, RZ, c[0x0][0x16c], RZ, P1, P0 ; /* 0x00005b00ff037a10 */ /* 0x000fca0000fe04ff */ /*0280*/ LDG.E.S8 R20, [R2.64+-0x7] ; /* 0xfffff90802147981 */ /* 0x0010a8000c1e1300 */ /*0290*/ LDG.E.S8 R4, [R2.64+-0x6] ; /* 0xfffffa0802047981 */ /* 0x0000e8000c1e1300 */ /*02a0*/ LDG.E.S8 R5, [R2.64+-0x5] ; /* 0xfffffb0802057981 */ /* 0x000128000c1e1300 */ /*02b0*/ LDG.E.S8 R6, [R2.64+-0x4] ; /* 0xfffffc0802067981 */ /* 0x000168000c1e1300 */ /*02c0*/ LDG.E.S8 R7, [R2.64+-0x3] ; /* 0xfffffd0802077981 */ /* 0x000168000c1e1300 */ /*02d0*/ LDG.E.S8 R8, [R2.64+-0x2] ; /* 0xfffffe0802087981 */ /* 0x000168000c1e1300 */ /*02e0*/ LDG.E.S8 R9, [R2.64+-0x1] ; /* 0xffffff0802097981 */ /* 0x000168000c1e1300 */ /*02f0*/ LDG.E.S8 R10, [R2.64] ; /* 0x00000008020a7981 */ /* 0x000168000c1e1300 */ /*0300*/ LDG.E.S8 R11, [R2.64+0x1] ; /* 0x00000108020b7981 */ /* 0x000168000c1e1300 */ /*0310*/ LDG.E.S8 R12, [R2.64+0x2] ; /* 0x00000208020c7981 */ /* 0x000168000c1e1300 */ /*0320*/ LDG.E.S8 R13, [R2.64+0x3] ; /* 0x00000308020d7981 */ /* 0x000168000c1e1300 */ /*0330*/ LDG.E.S8 R14, [R2.64+0x4] ; /* 0x00000408020e7981 */ /* 0x000168000c1e1300 */ /*0340*/ LDG.E.S8 R15, [R2.64+0x5] ; /* 0x00000508020f7981 */ /* 0x000168000c1e1300 */ /*0350*/ LDG.E.S8 R16, [R2.64+0x6] ; /* 0x0000060802107981 */ /* 0x000168000c1e1300 */ /*0360*/ LDG.E.S8 R17, [R2.64+0x7] ; /* 0x0000070802117981 */ /* 0x000168000c1e1300 */ /*0370*/ LDG.E.S8 R18, [R2.64+0x8] ; /* 0x0000080802127981 */ /* 0x000162000c1e1300 */ /*0380*/ YIELD ; /* 0x0000000000007946 */ /* 0x000fe20003800000 */ /*0390*/ IADD3 R0, R0, 0x10, RZ ; /* 0x0000001000007810 */ /* 0x000fc80007ffe0ff */ /*03a0*/ ISETP.NE.AND P0, PT, R0, 0x100, PT ; /* 0x000001000000780c */ /* 0x000fe40003f05270 */ /*03b0*/ IADD3 R2, P1, R2, 0x10, RZ ; /* 0x0000001002027810 */ /* 0x001fca0007f3e0ff */ /*03c0*/ IMAD.X R3, RZ, RZ, R3, P1 ; /* 0x000000ffff037224 */ /* 0x000fe200008e0603 */ /*03d0*/ ATOMS.POPC.INC.32 RZ, [R20.X4+URZ+-0x80] ; /* 0xffff800014ff7f8c */ /* 0x0041e8000d00403f */ /*03e0*/ ATOMS.POPC.INC.32 RZ, [R4.X4+URZ+-0x80] ; /* 0xffff800004ff7f8c */ /* 0x0081e8000d00403f */ /*03f0*/ ATOMS.POPC.INC.32 RZ, [R5.X4+URZ+-0x80] ; /* 0xffff800005ff7f8c */ /* 0x0101e8000d00403f */ /*0400*/ ATOMS.POPC.INC.32 RZ, [R6.X4+URZ+-0x80] ; /* 0xffff800006ff7f8c */ /* 0x0201e8000d00403f */ /*0410*/ ATOMS.POPC.INC.32 RZ, [R7.X4+URZ+-0x80] ; /* 0xffff800007ff7f8c */ /* 0x0001e8000d00403f */ /*0420*/ ATOMS.POPC.INC.32 RZ, [R8.X4+URZ+-0x80] ; /* 0xffff800008ff7f8c */ /* 0x0001e8000d00403f */ /*0430*/ ATOMS.POPC.INC.32 RZ, [R9.X4+URZ+-0x80] ; /* 0xffff800009ff7f8c */ /* 0x0001e8000d00403f */ /*0440*/ ATOMS.POPC.INC.32 RZ, [R10.X4+URZ+-0x80] ; /* 0xffff80000aff7f8c */ /* 0x0001e8000d00403f */ /*0450*/ ATOMS.POPC.INC.32 RZ, [R11.X4+URZ+-0x80] ; /* 0xffff80000bff7f8c */ /* 0x0001e8000d00403f */ /*0460*/ ATOMS.POPC.INC.32 RZ, [R12.X4+URZ+-0x80] ; /* 0xffff80000cff7f8c */ /* 0x0001e8000d00403f */ /*0470*/ ATOMS.POPC.INC.32 RZ, [R13.X4+URZ+-0x80] ; /* 0xffff80000dff7f8c */ /* 0x0001e8000d00403f */ /*0480*/ ATOMS.POPC.INC.32 RZ, [R14.X4+URZ+-0x80] ; /* 0xffff80000eff7f8c */ /* 0x0001e8000d00403f */ /*0490*/ ATOMS.POPC.INC.32 RZ, [R15.X4+URZ+-0x80] ; /* 0xffff80000fff7f8c */ /* 0x0001e8000d00403f */ /*04a0*/ ATOMS.POPC.INC.32 RZ, [R16.X4+URZ+-0x80] ; /* 0xffff800010ff7f8c */ /* 0x0001e8000d00403f */ /*04b0*/ ATOMS.POPC.INC.32 RZ, [R17.X4+URZ+-0x80] ; /* 0xffff800011ff7f8c */ /* 0x0001e8000d00403f */ /*04c0*/ ATOMS.POPC.INC.32 RZ, [R18.X4+URZ+-0x80] ; /* 0xffff800012ff7f8c */ /* 0x0001e2000d00403f */ /*04d0*/ @P0 BRA 0x280 ; /* 0xfffffda000000947 */ /* 0x000fea000383ffff */ /*04e0*/ WARPSYNC 0xffffffff ; /* 0xffffffff00007948 */ /* 0x000fe40003800000 */ /*04f0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fe20000010000 */ /*0500*/ IMAD.MOV.U32 R0, RZ, RZ, c[0x0][0x180] ; /* 0x00006000ff007624 */ /* 0x000fca00078e00ff */ /*0510*/ ISETP.GE.AND P0, PT, R0, 0x1, PT ; /* 0x000000010000780c */ /* 0x000fc80003f06270 */ /*0520*/ ISETP.NE.OR P0, PT, R19, RZ, !P0 ; /* 0x000000ff1300720c */ /* 0x000fda0004705670 */ /*0530*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0540*/ IADD3 R2, R0.reuse, -0x1, RZ ; /* 0xffffffff00027810 */ /* 0x040fe20007ffe0ff */ /*0550*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0560*/ LOP3.LUT R0, R0, 0x3, RZ, 0xc0, !PT ; /* 0x0000000300007812 */ /* 0x000fe400078ec0ff */ /*0570*/ ISETP.GE.U32.AND P1, PT, R2, 0x3, PT ; /* 0x000000030200780c */ /* 0x000fe40003f26070 */ /*0580*/ ISETP.NE.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fd60003f05270 */ /*0590*/ @!P1 BRA 0x760 ; /* 0x000001c000009947 */ /* 0x000fea0003800000 */ /*05a0*/ S2R R12, SR_LANEID ; /* 0x00000000000c7919 */ /* 0x001e220000000000 */ /*05b0*/ IADD3 R8, -R0, c[0x0][0x180], RZ ; /* 0x0000600000087a10 */ /* 0x000fe20007ffe1ff */ /*05c0*/ IMAD.MOV.U32 R10, RZ, RZ, c[0x0][0x178] ; /* 0x00005e00ff0a7624 */ /* 0x000fe200078e00ff */ /*05d0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*05e0*/ IMAD.MOV.U32 R13, RZ, RZ, c[0x0][0x17c] ; /* 0x00005f00ff0d7624 */ /* 0x000fe200078e00ff */ /*05f0*/ UMOV UR5, URZ ; /* 0x0000003f00057c82 */ /* 0x000fe40008000000 */ /*0600*/ LDS.128 R4, [UR5] ; /* 0x00000005ff047984 */ /* 0x000e620008000c00 */ /*0610*/ VOTEU.ANY UR6, UPT, PT ; /* 0x0000000000067886 */ /* 0x000fe200038e0100 */ /*0620*/ IMAD.MOV.U32 R2, RZ, RZ, R10 ; /* 0x000000ffff027224 */ /* 0x000fe200078e000a */ /*0630*/ UFLO.U32 UR7, UR6 ; /* 0x00000006000772bd */ /* 0x000fe200080e0000 */ /*0640*/ IMAD.MOV.U32 R3, RZ, RZ, R13 ; /* 0x000000ffff037224 */ /* 0x000fe200078e000d */ /*0650*/ UPOPC UR6, UR6 ; /* 0x00000006000672bf */ /* 0x000fc80008000000 */ /*0660*/ ISETP.EQ.U32.AND P1, PT, R12, UR7, PT ; /* 0x000000070c007c0c */ /* 0x001fe4000bf22070 */ /*0670*/ IADD3 R8, R8, -0x4, RZ ; /* 0xfffffffc08087810 */ /* 0x000fe40007ffe0ff */ /*0680*/ IADD3 R10, P2, R2, 0x10, RZ ; /* 0x00000010020a7810 */ /* 0x000fe20007f5e0ff */ /*0690*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*06a0*/ UIADD3 UR5, UR5, 0x10, URZ ; /* 0x0000001005057890 */ /* 0x000fe2000fffe03f */ /*06b0*/ IMAD R9, R4, UR6, RZ ; /* 0x0000000604097c24 */ /* 0x002fe4000f8e02ff */ /*06c0*/ IMAD R5, R5, UR6, RZ ; /* 0x0000000605057c24 */ /* 0x000fc4000f8e02ff */ /*06d0*/ IMAD R11, R6, UR6, RZ ; /* 0x00000006060b7c24 */ /* 0x000fe2000f8e02ff */ /*06e0*/ @P1 RED.E.ADD.STRONG.GPU [R2.64], R9 ; /* 0x000000090200198e */ /* 0x0001e2000c10e188 */ /*06f0*/ IMAD R7, R7, UR6, RZ ; /* 0x0000000607077c24 */ /* 0x000fc6000f8e02ff */ /*0700*/ @P1 RED.E.ADD.STRONG.GPU [R2.64+0x4], R5 ; /* 0x000004050200198e */ /* 0x0001e8000c10e188 */ /*0710*/ @P1 RED.E.ADD.STRONG.GPU [R2.64+0x8], R11 ; /* 0x0000080b0200198e */ /* 0x0001e8000c10e188 */ /*0720*/ @P1 RED.E.ADD.STRONG.GPU [R2.64+0xc], R7 ; /* 0x00000c070200198e */ /* 0x0001e2000c10e188 */ /*0730*/ ISETP.NE.AND P1, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe20003f25270 */ /*0740*/ IMAD.X R13, RZ, RZ, R3, P2 ; /* 0x000000ffff0d7224 */ /* 0x000fd800010e0603 */ /*0750*/ @P1 BRA 0x600 ; /* 0xfffffea000001947 */ /* 0x001fea000383ffff */ /*0760*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*0770*/ S2R R6, SR_LANEID ; /* 0x0000000000067919 */ /* 0x001e220000000000 */ /*0780*/ UMOV UR5, 0x4 ; /* 0x0000000400057882 */ /* 0x000fe40000000000 */ /*0790*/ ULDC.64 UR6, c[0x0][0x178] ; /* 0x00005e0000067ab9 */ /* 0x000fe40000000a00 */ /*07a0*/ UIMAD.WIDE UR6, UR4, UR5, UR6 ; /* 0x00000005040672a5 */ /* 0x000fe4000f8e0206 */ /*07b0*/ USHF.L.U32 UR4, UR4, 0x2, URZ ; /* 0x0000000204047899 */ /* 0x000fd2000800063f */ /*07c0*/ LDS R4, [UR4] ; /* 0x00000004ff047984 */ /* 0x000e620008000800 */ /*07d0*/ VOTEU.ANY UR5, UPT, PT ; /* 0x0000000000057886 */ /* 0x000fe200038e0100 */ /*07e0*/ IMAD.U32 R2, RZ, RZ, UR6 ; /* 0x00000006ff027e24 */ /* 0x000fe2000f8e00ff */ /*07f0*/ UFLO.U32 UR10, UR5 ; /* 0x00000005000a72bd */ /* 0x000fe200080e0000 */ /*0800*/ IMAD.U32 R3, RZ, RZ, UR7 ; /* 0x00000007ff037e24 */ /* 0x000fe2000f8e00ff */ /*0810*/ UPOPC UR5, UR5 ; /* 0x00000005000572bf */ /* 0x000fc80008000000 */ /*0820*/ ISETP.EQ.U32.AND P0, PT, R6, UR10, PT ; /* 0x0000000a06007c0c */ /* 0x001fe4000bf02070 */ /*0830*/ IADD3 R0, R0, -0x1, RZ ; /* 0xffffffff00007810 */ /* 0x000fe20007ffe0ff */ /*0840*/ UIADD3 UR6, UP0, UR6, 0x4, URZ ; /* 0x0000000406067890 */ /* 0x000fe4000ff1e03f */ /*0850*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*0860*/ UIADD3.X UR7, URZ, UR7, URZ, UP0, !UPT ; /* 0x000000073f077290 */ /* 0x000fe200087fe43f */ /*0870*/ IMAD R5, R4, UR5, RZ ; /* 0x0000000504057c24 */ /* 0x002fca000f8e02ff */ /*0880*/ @P0 RED.E.ADD.STRONG.GPU [R2.64], R5 ; /* 0x000000050200098e */ /* 0x0001e2000c10e188 */ /*0890*/ ISETP.NE.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fda0003f05270 */ /*08a0*/ @P0 BRA 0x7c0 ; /* 0xffffff1000000947 */ /* 0x001fea000383ffff */ /*08b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*08c0*/ BRA 0x8c0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*08d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*08e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*08f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0900*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0910*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0920*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0930*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0940*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0950*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0960*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0970*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #define ASCIIMIN 32 #define ASCIIMAX 126 #define CHARS_PER_THREADS 256 #define THREADS_PER_BLOCK 256 void __global__ kernel(int nLines, char* dev_chars, int nChars, int* dev_counts, int nCounts) { const unsigned int tidb = threadIdx.x; const unsigned int ti = blockIdx.x*blockDim.x + tidb; __shared__ int shared_counts[ASCIIMAX - ASCIIMIN + 1]; if (tidb == 0) { for (int i = 0; i < ASCIIMAX - ASCIIMIN - 1; ++i) { shared_counts[i] = 0; } } __syncthreads(); if (ti < nLines) { for (int i = 0; i < CHARS_PER_THREADS; ++i) { int ascii = (int)dev_chars[CHARS_PER_THREADS * ti + i]; atomicAdd(&shared_counts[ascii - ASCIIMIN], 1); } } __syncthreads(); if (tidb == 0) { for (int i = 0; i < nCounts; ++i) { atomicAdd(&dev_counts[i], shared_counts[i]); } } } int isValid(char* c){ int asciicode = (int)*c; int valid = (asciicode <= 126); valid = valid && (asciicode >= 32); return valid; } int main(int argc, char** argv){ clock_t t1, t2; printf("Initialisation...\n"); t1 = clock(); //Declarations FILE* inputFile = NULL; FILE* outputFile = NULL; char* inputFileName = NULL; char* outputFileName = NULL; int nChars = 0; char* chars; int nCounts = ASCIIMAX - ASCIIMIN + 1; int* counts; char* dev_chars; int* dev_counts; int opt; //Get comand line options while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch(opt) { case 'i': inputFileName = optarg; break; case 'o': outputFileName = optarg; break; } } //Count number of chars in inputFile inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; nChars = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)) ++nChars; } fclose(inputFile); //Allocate memory counts = (int*) malloc(nCounts * sizeof(int)); chars = (char*) malloc(nChars * sizeof(char)); if(chars == NULL) { printf("Input file too large!\n"); return 1; } printf("%d chars processed\n", nChars); cudaMalloc( (void**)&dev_chars, nChars * sizeof(char)); cudaMalloc( (void**)&dev_counts, nCounts * sizeof(int)); //Filling chars array inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; int i = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)){ if (c>=65 && c<=90) chars[i] = (char)(c + 32); else chars[i] = c; ++i; } } fclose(inputFile); t1 = clock() - t1; printf("Process...\n"); t2 = clock(); //Initialize counter array for (int i = 0; i < nCounts; ++i){ counts[i] = 0; } cudaMemcpy(dev_chars, chars, nChars * sizeof(char), cudaMemcpyHostToDevice); cudaMemcpy(dev_counts, counts, nCounts * sizeof(int), cudaMemcpyHostToDevice); //Count chars for (int i = 0; i < nChars; ++i){ int ascii = (int)chars[i]; ++counts[ascii - ASCIIMIN]; } int nLines = (nChars + CHARS_PER_THREADS - 1) / CHARS_PER_THREADS; kernel<<<(nLines + THREADS_PER_BLOCK - 1 ) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(nLines, dev_chars, nChars, dev_counts, nCounts); cudaMemcpy(counts, dev_counts, nCounts * sizeof(int), cudaMemcpyDeviceToHost); t2 = clock() - t2; //Write in outputFile outputFile = fopen(outputFileName, "w+"); if (!outputFile) return 1; for (int i = 0; i < 127 - ASCIIMIN; ++i){ if (i + ASCIIMIN < 65 || i + ASCIIMIN > 90) { fprintf(outputFile, "%c:%d\n", (char)(i + ASCIIMIN), (int)counts[i]); } } fclose(outputFile); //Return memory cudaFree(dev_chars); cudaFree(dev_counts); free(chars); free(counts); printf("Timings:\nInitialisation: %f\nProcess: %f\n", (float)1000 * t1/CLOCKS_PER_SEC, (float)1000 * t2/CLOCKS_PER_SEC); return 0; }
.file "tmpxft_0010d16d_00000000-6_template.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2074: .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 .LFE2074: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z7isValidPc .type _Z7isValidPc, @function _Z7isValidPc: .LFB2070: .cfi_startproc endbr64 movzbl (%rdi), %eax subl $32, %eax cmpb $94, %al setbe %al movzbl %al, %eax ret .cfi_endproc .LFE2070: .size _Z7isValidPc, .-_Z7isValidPc .globl _Z30__device_stub__Z6kerneliPciPiiiPciPii .type _Z30__device_stub__Z6kerneliPciPiiiPciPii, @function _Z30__device_stub__Z6kerneliPciPiiiPciPii: .LFB2096: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movl %edi, 28(%rsp) movq %rsi, 16(%rsp) movl %edx, 24(%rsp) movq %rcx, 8(%rsp) movl %r8d, 4(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 28(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 24(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) leaq 4(%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 .L8 .L4: movq 136(%rsp), %rax subq %fs:40, %rax jne .L9 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L8: .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 _Z6kerneliPciPii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L4 .L9: call __stack_chk_fail@PLT .cfi_endproc .LFE2096: .size _Z30__device_stub__Z6kerneliPciPiiiPciPii, .-_Z30__device_stub__Z6kerneliPciPiiiPciPii .globl _Z6kerneliPciPii .type _Z6kerneliPciPii, @function _Z6kerneliPciPii: .LFB2097: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z6kerneliPciPiiiPciPii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2097: .size _Z6kerneliPciPii, .-_Z6kerneliPciPii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Initialisation...\n" .LC1: .string "i:o:" .LC2: .string "r" .LC3: .string "Input file too large!\n" .LC4: .string "%d chars processed\n" .LC5: .string "Process...\n" .LC6: .string "w+" .LC7: .string "%c:%d\n" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC10: .string "Timings:\nInitialisation: %f\nProcess: %f\n" .text .globl main .type main, @function main: .LFB2071: .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 $88, %rsp .cfi_def_cfa_offset 144 movl %edi, %ebp movq %rsi, %rbx movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq .LC0(%rip), %rsi movl $2, %edi call __printf_chk@PLT call clock@PLT movq %rax, 24(%rsp) movl $0, %r15d movl $0, %r12d leaq .LC1(%rip), %r13 jmp .L13 .L14: movq optarg(%rip), %r12 .L13: movq %r13, %rdx movq %rbx, %rsi movl %ebp, %edi call getopt@PLT cmpl $-1, %eax je .L46 cmpl $105, %eax je .L14 cmpl $111, %eax cmove optarg(%rip), %r15 jmp .L13 .L46: leaq .LC2(%rip), %rsi movq %r12, %rdi call fopen@PLT movq %rax, %rbx testq %rax, %rax je .L37 movq %rax, %rdi call getc@PLT movb %al, 60(%rsp) cmpb $-1, %al je .L38 movl $0, %ebp leaq 60(%rsp), %r13 .L21: movq %r13, %rdi call _Z7isValidPc cmpl $1, %eax sbbl $-1, %ebp movq %rbx, %rdi call getc@PLT movb %al, 60(%rsp) cmpb $-1, %al jne .L21 .L19: movq %rbx, %rdi call fclose@PLT movl $380, %edi call malloc@PLT movq %rax, %rbx movslq %ebp, %rax movq %rax, 16(%rsp) movq %rax, %rdi call malloc@PLT movq %rax, 8(%rsp) testq %rax, %rax je .L47 movl %ebp, %edx leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 32(%rsp), %rdi movq 16(%rsp), %rsi call cudaMalloc@PLT leaq 40(%rsp), %rdi movl $380, %esi call cudaMalloc@PLT leaq .LC2(%rip), %rsi movq %r12, %rdi call fopen@PLT movq %rax, %r13 testq %rax, %rax je .L39 movq %rax, %rdi call getc@PLT movl %eax, %r12d movb %al, 60(%rsp) cmpb $-1, %al je .L23 movl $0, %r14d leaq 60(%rsp), %rax movq %rax, (%rsp) jmp .L27 .L38: movl $0, %ebp jmp .L19 .L47: leaq .LC3(%rip), %rsi movl $2, %edi call __printf_chk@PLT movl $1, %eax jmp .L12 .L25: movslq %r14d, %rax movq 8(%rsp), %rcx movb %r12b, (%rcx,%rax) .L26: addl $1, %r14d .L24: movq %r13, %rdi call getc@PLT movl %eax, %r12d movb %al, 60(%rsp) cmpb $-1, %al je .L23 .L27: movq (%rsp), %rdi call _Z7isValidPc testl %eax, %eax je .L24 leal -65(%r12), %eax cmpb $25, %al ja .L25 movslq %r14d, %rax addl $32, %r12d movq 8(%rsp), %rcx movb %r12b, (%rcx,%rax) jmp .L26 .L23: movq %r13, %rdi call fclose@PLT call clock@PLT movq 24(%rsp), %rcx subq %rcx, %rax movq %rax, %r14 leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call clock@PLT movq %rax, %r12 movq %rbx, %rax leaq 380(%rbx), %rdx .L28: movl $0, (%rax) addq $4, %rax cmpq %rdx, %rax jne .L28 movl $1, %ecx movq 16(%rsp), %r13 movq %r13, %rdx movq 8(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $380, %edx movq %rbx, %rsi movq 40(%rsp), %rdi call cudaMemcpy@PLT testl %ebp, %ebp jle .L29 movq 8(%rsp), %rsi movq %rsi, %rax movq %r13, %rcx addq %rsi, %rcx .L30: movsbq (%rax), %rdx addl $1, -128(%rbx,%rdx,4) addq $1, %rax cmpq %rcx, %rax jne .L30 .L29: leal 510(%rbp), %r13d movl %ebp, %eax addl $255, %eax cmovns %eax, %r13d sarl $8, %r13d movl $256, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leal 510(%r13), %eax movl %r13d, %edx addl $255, %edx cmovns %edx, %eax sarl $8, %eax movl %eax, 48(%rsp) movl $1, 52(%rsp) movl $0, %r9d movl $0, %r8d movq 60(%rsp), %rdx movl $1, %ecx movq 48(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L48 .L31: movl $2, %ecx movl $380, %edx movq 40(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT call clock@PLT subq %r12, %rax movq %rax, %rbp leaq .LC6(%rip), %rsi movq %r15, %rdi call fopen@PLT movq %rax, %r13 testq %rax, %rax je .L40 movl $0, %r12d .L34: leal -33(%r12), %eax cmpl $25, %eax ja .L49 addq $1, %r12 jmp .L34 .L48: movl $95, %r8d movq 40(%rsp), %rcx movl %ebp, %edx movq 32(%rsp), %rsi movl %r13d, %edi call _Z30__device_stub__Z6kerneliPciPiiiPciPii jmp .L31 .L49: leal 32(%r12), %ecx movl (%rbx,%r12,4), %r8d leaq .LC7(%rip), %rdx movl $2, %esi movq %r13, %rdi movl $0, %eax call __fprintf_chk@PLT addq $1, %r12 cmpq $95, %r12 jne .L34 movq %r13, %rdi call fclose@PLT movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call free@PLT movq %rbx, %rdi call free@PLT pxor %xmm1, %xmm1 cvtsi2ssq %rbp, %xmm1 movss .LC8(%rip), %xmm3 mulss %xmm3, %xmm1 movss .LC9(%rip), %xmm2 divss %xmm2, %xmm1 pxor %xmm0, %xmm0 cvtsi2ssq %r14, %xmm0 mulss %xmm3, %xmm0 divss %xmm2, %xmm0 cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 leaq .LC10(%rip), %rsi movl $2, %edi movl $2, %eax call __printf_chk@PLT movl $0, %eax .L12: movq 72(%rsp), %rdx subq %fs:40, %rdx jne .L50 addq $88, %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 .L37: .cfi_restore_state movl $1, %eax jmp .L12 .L39: movl $1, %eax jmp .L12 .L40: movl $1, %eax jmp .L12 .L50: call __stack_chk_fail@PLT .cfi_endproc .LFE2071: .size main, .-main .section .rodata.str1.1 .LC11: .string "_Z6kerneliPciPii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2099: .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 .LC11(%rip), %rdx movq %rdx, %rcx leaq _Z6kerneliPciPii(%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 .LFE2099: .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 .LC8: .long 1148846080 .align 4 .LC9: .long 1232348160 .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 <unistd.h> #include <string.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #define ASCIIMIN 32 #define ASCIIMAX 126 #define CHARS_PER_THREADS 256 #define THREADS_PER_BLOCK 256 void __global__ kernel(int nLines, char* dev_chars, int nChars, int* dev_counts, int nCounts) { const unsigned int tidb = threadIdx.x; const unsigned int ti = blockIdx.x*blockDim.x + tidb; __shared__ int shared_counts[ASCIIMAX - ASCIIMIN + 1]; if (tidb == 0) { for (int i = 0; i < ASCIIMAX - ASCIIMIN - 1; ++i) { shared_counts[i] = 0; } } __syncthreads(); if (ti < nLines) { for (int i = 0; i < CHARS_PER_THREADS; ++i) { int ascii = (int)dev_chars[CHARS_PER_THREADS * ti + i]; atomicAdd(&shared_counts[ascii - ASCIIMIN], 1); } } __syncthreads(); if (tidb == 0) { for (int i = 0; i < nCounts; ++i) { atomicAdd(&dev_counts[i], shared_counts[i]); } } } int isValid(char* c){ int asciicode = (int)*c; int valid = (asciicode <= 126); valid = valid && (asciicode >= 32); return valid; } int main(int argc, char** argv){ clock_t t1, t2; printf("Initialisation...\n"); t1 = clock(); //Declarations FILE* inputFile = NULL; FILE* outputFile = NULL; char* inputFileName = NULL; char* outputFileName = NULL; int nChars = 0; char* chars; int nCounts = ASCIIMAX - ASCIIMIN + 1; int* counts; char* dev_chars; int* dev_counts; int opt; //Get comand line options while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch(opt) { case 'i': inputFileName = optarg; break; case 'o': outputFileName = optarg; break; } } //Count number of chars in inputFile inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; nChars = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)) ++nChars; } fclose(inputFile); //Allocate memory counts = (int*) malloc(nCounts * sizeof(int)); chars = (char*) malloc(nChars * sizeof(char)); if(chars == NULL) { printf("Input file too large!\n"); return 1; } printf("%d chars processed\n", nChars); cudaMalloc( (void**)&dev_chars, nChars * sizeof(char)); cudaMalloc( (void**)&dev_counts, nCounts * sizeof(int)); //Filling chars array inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; int i = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)){ if (c>=65 && c<=90) chars[i] = (char)(c + 32); else chars[i] = c; ++i; } } fclose(inputFile); t1 = clock() - t1; printf("Process...\n"); t2 = clock(); //Initialize counter array for (int i = 0; i < nCounts; ++i){ counts[i] = 0; } cudaMemcpy(dev_chars, chars, nChars * sizeof(char), cudaMemcpyHostToDevice); cudaMemcpy(dev_counts, counts, nCounts * sizeof(int), cudaMemcpyHostToDevice); //Count chars for (int i = 0; i < nChars; ++i){ int ascii = (int)chars[i]; ++counts[ascii - ASCIIMIN]; } int nLines = (nChars + CHARS_PER_THREADS - 1) / CHARS_PER_THREADS; kernel<<<(nLines + THREADS_PER_BLOCK - 1 ) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(nLines, dev_chars, nChars, dev_counts, nCounts); cudaMemcpy(counts, dev_counts, nCounts * sizeof(int), cudaMemcpyDeviceToHost); t2 = clock() - t2; //Write in outputFile outputFile = fopen(outputFileName, "w+"); if (!outputFile) return 1; for (int i = 0; i < 127 - ASCIIMIN; ++i){ if (i + ASCIIMIN < 65 || i + ASCIIMIN > 90) { fprintf(outputFile, "%c:%d\n", (char)(i + ASCIIMIN), (int)counts[i]); } } fclose(outputFile); //Return memory cudaFree(dev_chars); cudaFree(dev_counts); free(chars); free(counts); printf("Timings:\nInitialisation: %f\nProcess: %f\n", (float)1000 * t1/CLOCKS_PER_SEC, (float)1000 * t2/CLOCKS_PER_SEC); return 0; }
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <time.h> #include <hip/hip_runtime.h> #define ASCIIMIN 32 #define ASCIIMAX 126 #define CHARS_PER_THREADS 256 #define THREADS_PER_BLOCK 256 void __global__ kernel(int nLines, char* dev_chars, int nChars, int* dev_counts, int nCounts) { const unsigned int tidb = threadIdx.x; const unsigned int ti = blockIdx.x*blockDim.x + tidb; __shared__ int shared_counts[ASCIIMAX - ASCIIMIN + 1]; if (tidb == 0) { for (int i = 0; i < ASCIIMAX - ASCIIMIN - 1; ++i) { shared_counts[i] = 0; } } __syncthreads(); if (ti < nLines) { for (int i = 0; i < CHARS_PER_THREADS; ++i) { int ascii = (int)dev_chars[CHARS_PER_THREADS * ti + i]; atomicAdd(&shared_counts[ascii - ASCIIMIN], 1); } } __syncthreads(); if (tidb == 0) { for (int i = 0; i < nCounts; ++i) { atomicAdd(&dev_counts[i], shared_counts[i]); } } } int isValid(char* c){ int asciicode = (int)*c; int valid = (asciicode <= 126); valid = valid && (asciicode >= 32); return valid; } int main(int argc, char** argv){ clock_t t1, t2; printf("Initialisation...\n"); t1 = clock(); //Declarations FILE* inputFile = NULL; FILE* outputFile = NULL; char* inputFileName = NULL; char* outputFileName = NULL; int nChars = 0; char* chars; int nCounts = ASCIIMAX - ASCIIMIN + 1; int* counts; char* dev_chars; int* dev_counts; int opt; //Get comand line options while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch(opt) { case 'i': inputFileName = optarg; break; case 'o': outputFileName = optarg; break; } } //Count number of chars in inputFile inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; nChars = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)) ++nChars; } fclose(inputFile); //Allocate memory counts = (int*) malloc(nCounts * sizeof(int)); chars = (char*) malloc(nChars * sizeof(char)); if(chars == NULL) { printf("Input file too large!\n"); return 1; } printf("%d chars processed\n", nChars); hipMalloc( (void**)&dev_chars, nChars * sizeof(char)); hipMalloc( (void**)&dev_counts, nCounts * sizeof(int)); //Filling chars array inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; int i = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)){ if (c>=65 && c<=90) chars[i] = (char)(c + 32); else chars[i] = c; ++i; } } fclose(inputFile); t1 = clock() - t1; printf("Process...\n"); t2 = clock(); //Initialize counter array for (int i = 0; i < nCounts; ++i){ counts[i] = 0; } hipMemcpy(dev_chars, chars, nChars * sizeof(char), hipMemcpyHostToDevice); hipMemcpy(dev_counts, counts, nCounts * sizeof(int), hipMemcpyHostToDevice); //Count chars for (int i = 0; i < nChars; ++i){ int ascii = (int)chars[i]; ++counts[ascii - ASCIIMIN]; } int nLines = (nChars + CHARS_PER_THREADS - 1) / CHARS_PER_THREADS; kernel<<<(nLines + THREADS_PER_BLOCK - 1 ) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(nLines, dev_chars, nChars, dev_counts, nCounts); hipMemcpy(counts, dev_counts, nCounts * sizeof(int), hipMemcpyDeviceToHost); t2 = clock() - t2; //Write in outputFile outputFile = fopen(outputFileName, "w+"); if (!outputFile) return 1; for (int i = 0; i < 127 - ASCIIMIN; ++i){ if (i + ASCIIMIN < 65 || i + ASCIIMIN > 90) { fprintf(outputFile, "%c:%d\n", (char)(i + ASCIIMIN), (int)counts[i]); } } fclose(outputFile); //Return memory hipFree(dev_chars); hipFree(dev_counts); free(chars); free(counts); printf("Timings:\nInitialisation: %f\nProcess: %f\n", (float)1000 * t1/CLOCKS_PER_SEC, (float)1000 * t2/CLOCKS_PER_SEC); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <time.h> #include <hip/hip_runtime.h> #define ASCIIMIN 32 #define ASCIIMAX 126 #define CHARS_PER_THREADS 256 #define THREADS_PER_BLOCK 256 void __global__ kernel(int nLines, char* dev_chars, int nChars, int* dev_counts, int nCounts) { const unsigned int tidb = threadIdx.x; const unsigned int ti = blockIdx.x*blockDim.x + tidb; __shared__ int shared_counts[ASCIIMAX - ASCIIMIN + 1]; if (tidb == 0) { for (int i = 0; i < ASCIIMAX - ASCIIMIN - 1; ++i) { shared_counts[i] = 0; } } __syncthreads(); if (ti < nLines) { for (int i = 0; i < CHARS_PER_THREADS; ++i) { int ascii = (int)dev_chars[CHARS_PER_THREADS * ti + i]; atomicAdd(&shared_counts[ascii - ASCIIMIN], 1); } } __syncthreads(); if (tidb == 0) { for (int i = 0; i < nCounts; ++i) { atomicAdd(&dev_counts[i], shared_counts[i]); } } } int isValid(char* c){ int asciicode = (int)*c; int valid = (asciicode <= 126); valid = valid && (asciicode >= 32); return valid; } int main(int argc, char** argv){ clock_t t1, t2; printf("Initialisation...\n"); t1 = clock(); //Declarations FILE* inputFile = NULL; FILE* outputFile = NULL; char* inputFileName = NULL; char* outputFileName = NULL; int nChars = 0; char* chars; int nCounts = ASCIIMAX - ASCIIMIN + 1; int* counts; char* dev_chars; int* dev_counts; int opt; //Get comand line options while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch(opt) { case 'i': inputFileName = optarg; break; case 'o': outputFileName = optarg; break; } } //Count number of chars in inputFile inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; nChars = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)) ++nChars; } fclose(inputFile); //Allocate memory counts = (int*) malloc(nCounts * sizeof(int)); chars = (char*) malloc(nChars * sizeof(char)); if(chars == NULL) { printf("Input file too large!\n"); return 1; } printf("%d chars processed\n", nChars); hipMalloc( (void**)&dev_chars, nChars * sizeof(char)); hipMalloc( (void**)&dev_counts, nCounts * sizeof(int)); //Filling chars array inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; int i = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)){ if (c>=65 && c<=90) chars[i] = (char)(c + 32); else chars[i] = c; ++i; } } fclose(inputFile); t1 = clock() - t1; printf("Process...\n"); t2 = clock(); //Initialize counter array for (int i = 0; i < nCounts; ++i){ counts[i] = 0; } hipMemcpy(dev_chars, chars, nChars * sizeof(char), hipMemcpyHostToDevice); hipMemcpy(dev_counts, counts, nCounts * sizeof(int), hipMemcpyHostToDevice); //Count chars for (int i = 0; i < nChars; ++i){ int ascii = (int)chars[i]; ++counts[ascii - ASCIIMIN]; } int nLines = (nChars + CHARS_PER_THREADS - 1) / CHARS_PER_THREADS; kernel<<<(nLines + THREADS_PER_BLOCK - 1 ) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(nLines, dev_chars, nChars, dev_counts, nCounts); hipMemcpy(counts, dev_counts, nCounts * sizeof(int), hipMemcpyDeviceToHost); t2 = clock() - t2; //Write in outputFile outputFile = fopen(outputFileName, "w+"); if (!outputFile) return 1; for (int i = 0; i < 127 - ASCIIMIN; ++i){ if (i + ASCIIMIN < 65 || i + ASCIIMIN > 90) { fprintf(outputFile, "%c:%d\n", (char)(i + ASCIIMIN), (int)counts[i]); } } fclose(outputFile); //Return memory hipFree(dev_chars); hipFree(dev_counts); free(chars); free(counts); printf("Timings:\nInitialisation: %f\nProcess: %f\n", (float)1000 * t1/CLOCKS_PER_SEC, (float)1000 * t2/CLOCKS_PER_SEC); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6kerneliPciPii .globl _Z6kerneliPciPii .p2align 8 .type _Z6kerneliPciPii,@function _Z6kerneliPciPii: v_cmp_eq_u32_e32 vcc_lo, 0, v0 s_mov_b32 s3, 0 s_and_saveexec_b32 s2, vcc_lo s_cbranch_execz .LBB0_3 v_mov_b32_e32 v1, 0 .LBB0_2: v_mov_b32_e32 v2, s3 s_add_i32 s3, s3, 4 s_delay_alu instid0(SALU_CYCLE_1) s_cmpk_lg_i32 s3, 0x174 ds_store_b32 v2, v1 s_cbranch_scc1 .LBB0_2 .LBB0_3: s_or_b32 exec_lo, exec_lo, s2 s_clause 0x1 s_load_b32 s2, s[0:1], 0x34 s_load_b32 s3, s[0:1], 0x0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_and_b32 s2, 0xffff, s2 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_cmp_gt_u32_e64 s2, s3, v1 s_delay_alu instid0(VALU_DEP_1) s_and_saveexec_b32 s3, s2 s_cbranch_execz .LBB0_6 s_load_b64 s[4:5], s[0:1], 0x8 v_lshlrev_b32_e32 v0, 8, v1 v_mov_b32_e32 v2, 1 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v0, s2, s4, v0 v_add_co_ci_u32_e64 v1, null, s5, 0, s2 s_mov_b64 s[4:5], 0 .LBB0_5: s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1) v_add_co_u32 v3, s2, v0, s4 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v4, s2, s5, v1, s2 s_add_u32 s4, s4, 1 s_addc_u32 s5, s5, 0 s_cmpk_lg_i32 s4, 0x100 global_load_i8 v3, v[3:4], off s_waitcnt vmcnt(0) v_lshl_add_u32 v3, v3, 2, 0xffffff80 ds_add_u32 v3, v2 s_cbranch_scc1 .LBB0_5 .LBB0_6: s_or_b32 exec_lo, exec_lo, s3 s_load_b32 s2, s[0:1], 0x20 s_mov_b32 s3, 0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_cmp_gt_i32 s2, 0 s_cselect_b32 s4, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s4, vcc_lo, s4 s_and_saveexec_b32 s5, s4 s_cbranch_execz .LBB0_11 s_load_b64 s[0:1], s[0:1], 0x18 v_mov_b32_e32 v0, 0 s_branch .LBB0_9 .p2align 6 .LBB0_8: s_or_b32 exec_lo, exec_lo, s4 s_add_i32 s2, s2, -1 s_waitcnt lgkmcnt(0) s_add_u32 s0, s0, 4 s_addc_u32 s1, s1, 0 s_add_i32 s3, s3, 4 s_cmp_lg_u32 s2, 0 s_cbranch_scc0 .LBB0_11 .LBB0_9: s_mov_b32 s5, exec_lo s_mov_b32 s4, exec_lo v_mbcnt_lo_u32_b32 v1, s5, 0 s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v1 s_cbranch_execz .LBB0_8 v_mov_b32_e32 v1, s3 s_bcnt1_i32_b32 s5, s5 ds_load_b32 v1, v1 s_waitcnt lgkmcnt(0) v_mul_lo_u32 v1, v1, s5 global_atomic_add_u32 v0, v1, s[0:1] s_branch .LBB0_8 .LBB0_11: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6kerneliPciPii .amdhsa_group_segment_fixed_size 380 .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 5 .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 _Z6kerneliPciPii, .Lfunc_end0-_Z6kerneliPciPii .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 - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: by_value - .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: 380 .kernarg_segment_align: 8 .kernarg_segment_size: 296 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z6kerneliPciPii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6kerneliPciPii.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 <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <time.h> #include <hip/hip_runtime.h> #define ASCIIMIN 32 #define ASCIIMAX 126 #define CHARS_PER_THREADS 256 #define THREADS_PER_BLOCK 256 void __global__ kernel(int nLines, char* dev_chars, int nChars, int* dev_counts, int nCounts) { const unsigned int tidb = threadIdx.x; const unsigned int ti = blockIdx.x*blockDim.x + tidb; __shared__ int shared_counts[ASCIIMAX - ASCIIMIN + 1]; if (tidb == 0) { for (int i = 0; i < ASCIIMAX - ASCIIMIN - 1; ++i) { shared_counts[i] = 0; } } __syncthreads(); if (ti < nLines) { for (int i = 0; i < CHARS_PER_THREADS; ++i) { int ascii = (int)dev_chars[CHARS_PER_THREADS * ti + i]; atomicAdd(&shared_counts[ascii - ASCIIMIN], 1); } } __syncthreads(); if (tidb == 0) { for (int i = 0; i < nCounts; ++i) { atomicAdd(&dev_counts[i], shared_counts[i]); } } } int isValid(char* c){ int asciicode = (int)*c; int valid = (asciicode <= 126); valid = valid && (asciicode >= 32); return valid; } int main(int argc, char** argv){ clock_t t1, t2; printf("Initialisation...\n"); t1 = clock(); //Declarations FILE* inputFile = NULL; FILE* outputFile = NULL; char* inputFileName = NULL; char* outputFileName = NULL; int nChars = 0; char* chars; int nCounts = ASCIIMAX - ASCIIMIN + 1; int* counts; char* dev_chars; int* dev_counts; int opt; //Get comand line options while ((opt = getopt (argc, argv, "i:o:")) != -1) { switch(opt) { case 'i': inputFileName = optarg; break; case 'o': outputFileName = optarg; break; } } //Count number of chars in inputFile inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; nChars = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)) ++nChars; } fclose(inputFile); //Allocate memory counts = (int*) malloc(nCounts * sizeof(int)); chars = (char*) malloc(nChars * sizeof(char)); if(chars == NULL) { printf("Input file too large!\n"); return 1; } printf("%d chars processed\n", nChars); hipMalloc( (void**)&dev_chars, nChars * sizeof(char)); hipMalloc( (void**)&dev_counts, nCounts * sizeof(int)); //Filling chars array inputFile = fopen(inputFileName,"r"); if (!inputFile) return 1; int i = 0; for (char c = getc(inputFile); c != EOF; c = getc(inputFile)){ if(isValid(&c)){ if (c>=65 && c<=90) chars[i] = (char)(c + 32); else chars[i] = c; ++i; } } fclose(inputFile); t1 = clock() - t1; printf("Process...\n"); t2 = clock(); //Initialize counter array for (int i = 0; i < nCounts; ++i){ counts[i] = 0; } hipMemcpy(dev_chars, chars, nChars * sizeof(char), hipMemcpyHostToDevice); hipMemcpy(dev_counts, counts, nCounts * sizeof(int), hipMemcpyHostToDevice); //Count chars for (int i = 0; i < nChars; ++i){ int ascii = (int)chars[i]; ++counts[ascii - ASCIIMIN]; } int nLines = (nChars + CHARS_PER_THREADS - 1) / CHARS_PER_THREADS; kernel<<<(nLines + THREADS_PER_BLOCK - 1 ) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(nLines, dev_chars, nChars, dev_counts, nCounts); hipMemcpy(counts, dev_counts, nCounts * sizeof(int), hipMemcpyDeviceToHost); t2 = clock() - t2; //Write in outputFile outputFile = fopen(outputFileName, "w+"); if (!outputFile) return 1; for (int i = 0; i < 127 - ASCIIMIN; ++i){ if (i + ASCIIMIN < 65 || i + ASCIIMIN > 90) { fprintf(outputFile, "%c:%d\n", (char)(i + ASCIIMIN), (int)counts[i]); } } fclose(outputFile); //Return memory hipFree(dev_chars); hipFree(dev_counts); free(chars); free(counts); printf("Timings:\nInitialisation: %f\nProcess: %f\n", (float)1000 * t1/CLOCKS_PER_SEC, (float)1000 * t2/CLOCKS_PER_SEC); return 0; }
.text .file "template.hip" .globl _Z21__device_stub__kerneliPciPii # -- Begin function _Z21__device_stub__kerneliPciPii .p2align 4, 0x90 .type _Z21__device_stub__kerneliPciPii,@function _Z21__device_stub__kerneliPciPii: # @_Z21__device_stub__kerneliPciPii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movl %edi, 12(%rsp) movq %rsi, 72(%rsp) movl %edx, 8(%rsp) movq %rcx, 64(%rsp) movl %r8d, 4(%rsp) leaq 12(%rsp), %rax movq %rax, 80(%rsp) leaq 72(%rsp), %rax movq %rax, 88(%rsp) leaq 8(%rsp), %rax movq %rax, 96(%rsp) leaq 64(%rsp), %rax movq %rax, 104(%rsp) leaq 4(%rsp), %rax movq %rax, 112(%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 $_Z6kerneliPciPii, %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 _Z21__device_stub__kerneliPciPii, .Lfunc_end0-_Z21__device_stub__kerneliPciPii .cfi_endproc # -- End function .globl _Z7isValidPc # -- Begin function _Z7isValidPc .p2align 4, 0x90 .type _Z7isValidPc,@function _Z7isValidPc: # @_Z7isValidPc .cfi_startproc # %bb.0: movzbl (%rdi), %ecx addb $-32, %cl xorl %eax, %eax cmpb $95, %cl setb %al retq .Lfunc_end1: .size _Z7isValidPc, .Lfunc_end1-_Z7isValidPc .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI2_0: .long 0x447a0000 # float 1000 .LCPI2_1: .long 0x49742400 # float 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 $168, %rsp .cfi_def_cfa_offset 224 .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 movl $.Lstr, %edi callq puts@PLT callq clock movq %rax, %r12 xorl %r13d, %r13d xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 movl $.L.str.1, %edx movl %ebp, %edi movq %rbx, %rsi callq getopt cmpl $-1, %eax je .LBB2_6 # %bb.2: # in Loop: Header=BB2_1 Depth=1 cmpl $111, %eax je .LBB2_5 # %bb.3: # in Loop: Header=BB2_1 Depth=1 cmpl $105, %eax jne .LBB2_1 # %bb.4: # in Loop: Header=BB2_1 Depth=1 movq optarg(%rip), %r14 jmp .LBB2_1 .LBB2_5: # in Loop: Header=BB2_1 Depth=1 movq optarg(%rip), %r13 jmp .LBB2_1 .LBB2_6: movl $.L.str.2, %esi movq %r14, %rdi callq fopen movl $1, %ebx testq %rax, %rax je .LBB2_29 # %bb.7: movq %rax, %r15 movq %r13, 56(%rsp) # 8-byte Spill movq %r12, 48(%rsp) # 8-byte Spill movq %rax, %rdi callq getc xorl %r13d, %r13d cmpb $-1, %al je .LBB2_10 # %bb.8: # %.lr.ph.preheader xorl %r13d, %r13d .p2align 4, 0x90 .LBB2_9: # %.lr.ph # =>This Inner Loop Header: Depth=1 addb $-32, %al cmpb $95, %al adcl $0, %r13d movq %r15, %rdi callq getc cmpb $-1, %al jne .LBB2_9 .LBB2_10: # %._crit_edge movq %r15, %rdi callq fclose movl $380, %edi # imm = 0x17C callq malloc movq %rax, %r15 movl %r13d, %ebp movq %rbp, %rdi callq malloc testq %rax, %rax je .LBB2_11 # %bb.12: movq %rax, %r12 movl $.L.str.4, %edi movl %r13d, %esi xorl %eax, %eax callq printf leaq 8(%rsp), %rdi movq %rbp, %rsi callq hipMalloc movq %rsp, %rdi movl $380, %esi # imm = 0x17C callq hipMalloc movl $.L.str.2, %esi movq %r14, %rdi callq fopen testq %rax, %rax je .LBB2_29 # %bb.13: movq %rax, %r14 movq %rax, %rdi callq getc # kill: def $eax killed $eax def $rax cmpb $-1, %al jne .LBB2_14 .LBB2_18: # %._crit_edge116 movq %r14, %rdi callq fclose callq clock movq %rax, 40(%rsp) # 8-byte Spill movl $.Lstr.1, %edi callq puts@PLT callq clock movq %rax, 32(%rsp) # 8-byte Spill movl $380, %edx # imm = 0x17C movq %r15, %rdi xorl %esi, %esi callq memset@PLT movq 8(%rsp), %rdi movq %r12, %rsi movq %rbp, %rdx movl $1, %ecx callq hipMemcpy movq (%rsp), %rdi movl $380, %edx # imm = 0x17C movq %r15, %rsi movl $1, %ecx callq hipMemcpy testl %r13d, %r13d je .LBB2_21 # %bb.19: # %.lr.ph120.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB2_20: # %.lr.ph120 # =>This Inner Loop Header: Depth=1 movsbq (%r12,%rax), %rcx incl -128(%r15,%rcx,4) incq %rax cmpq %rax, %rbp jne .LBB2_20 .LBB2_21: # %._crit_edge121 leal 255(%r13), %r14d shrl $8, %r14d leal 255(%r14), %edi shrl $8, %edi movabsq $4294967296, %rdx # imm = 0x100000000 orq %rdx, %rdi orq $256, %rdx # imm = 0x100 movl $1, %ebx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_23 # %bb.22: movq 8(%rsp), %rax movq (%rsp), %rcx movl %r14d, 28(%rsp) movq %rax, 120(%rsp) movl %r13d, 24(%rsp) movq %rcx, 112(%rsp) movl $95, 20(%rsp) leaq 28(%rsp), %rax movq %rax, 128(%rsp) leaq 120(%rsp), %rax movq %rax, 136(%rsp) leaq 24(%rsp), %rax movq %rax, 144(%rsp) leaq 112(%rsp), %rax movq %rax, 152(%rsp) leaq 20(%rsp), %rax movq %rax, 160(%rsp) leaq 96(%rsp), %rdi leaq 80(%rsp), %rsi leaq 72(%rsp), %rdx leaq 64(%rsp), %rcx callq __hipPopCallConfiguration movq 96(%rsp), %rsi movl 104(%rsp), %edx movq 80(%rsp), %rcx movl 88(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z6kerneliPciPii, %edi pushq 64(%rsp) .cfi_adjust_cfa_offset 8 pushq 80(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_23: movq (%rsp), %rsi movl $380, %edx # imm = 0x17C movq %r15, %rdi movl $2, %ecx callq hipMemcpy callq clock movq %rax, %r14 movl $.L.str.6, %esi movq 56(%rsp), %rdi # 8-byte Reload callq fopen testq %rax, %rax movq 40(%rsp), %rbp # 8-byte Reload je .LBB2_29 # %bb.24: # %.preheader.preheader movq %rax, %r13 subq 48(%rsp), %rbp # 8-byte Folded Reload subq 32(%rsp), %r14 # 8-byte Folded Reload xorl %ebx, %ebx jmp .LBB2_25 .p2align 4, 0x90 .LBB2_27: # in Loop: Header=BB2_25 Depth=1 incq %rbx cmpq $95, %rbx je .LBB2_28 .LBB2_25: # %.preheader # =>This Inner Loop Header: Depth=1 leal -59(%rbx), %eax cmpl $-27, %eax ja .LBB2_27 # %bb.26: # in Loop: Header=BB2_25 Depth=1 movl (%r15,%rbx,4), %ecx leal 32(%rbx), %edx movl $.L.str.7, %esi movq %r13, %rdi xorl %eax, %eax callq fprintf jmp .LBB2_27 .LBB2_11: movl $.Lstr.2, %edi callq puts@PLT jmp .LBB2_29 .LBB2_28: movq %r13, %rdi callq fclose movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree movq %r12, %rdi callq free movq %r15, %rdi callq free cvtsi2ss %rbp, %xmm0 movss .LCPI2_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss %xmm1, %xmm0 movss .LCPI2_1(%rip), %xmm2 # xmm2 = mem[0],zero,zero,zero divss %xmm2, %xmm0 cvtsi2ss %r14, %xmm3 cvtss2sd %xmm0, %xmm0 mulss %xmm1, %xmm3 divss %xmm2, %xmm3 xorps %xmm1, %xmm1 cvtss2sd %xmm3, %xmm1 movl $.L.str.8, %edi movb $2, %al callq printf xorl %ebx, %ebx .LBB2_29: movl %ebx, %eax addq $168, %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 .LBB2_14: # %.lr.ph115.preheader .cfi_def_cfa_offset 224 xorl %ebx, %ebx jmp .LBB2_15 .p2align 4, 0x90 .LBB2_17: # in Loop: Header=BB2_15 Depth=1 movq %r14, %rdi callq getc # kill: def $eax killed $eax def $rax cmpb $-1, %al je .LBB2_18 .LBB2_15: # %.lr.ph115 # =>This Inner Loop Header: Depth=1 leal -127(%rax), %ecx cmpb $-95, %cl jb .LBB2_17 # %bb.16: # in Loop: Header=BB2_15 Depth=1 leal -65(%rax), %ecx movzbl %al, %edx orb $32, %al cmpb $26, %cl movzbl %al, %eax cmovael %edx, %eax movslq %ebx, %rbx movb %al, (%r12,%rbx) incl %ebx jmp .LBB2_17 .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z6kerneliPciPii, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type _Z6kerneliPciPii,@object # @_Z6kerneliPciPii .section .rodata,"a",@progbits .globl _Z6kerneliPciPii .p2align 3, 0x0 _Z6kerneliPciPii: .quad _Z21__device_stub__kerneliPciPii .size _Z6kerneliPciPii, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "i:o:" .size .L.str.1, 5 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "r" .size .L.str.2, 2 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "%d chars processed\n" .size .L.str.4, 20 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "w+" .size .L.str.6, 3 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "%c:%d\n" .size .L.str.7, 7 .type .L.str.8,@object # @.str.8 .L.str.8: .asciz "Timings:\nInitialisation: %f\nProcess: %f\n" .size .L.str.8, 48 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6kerneliPciPii" .size .L__unnamed_1, 17 .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 "Initialisation..." .size .Lstr, 18 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Process..." .size .Lstr.1, 11 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "Input file too large!" .size .Lstr.2, 22 .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 _Z21__device_stub__kerneliPciPii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6kerneliPciPii .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 : _Z6kerneliPciPii .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 R19, SR_TID.X ; /* 0x0000000000137919 */ /* 0x000e220000002100 */ /*0020*/ BSSY B0, 0x200 ; /* 0x000001d000007945 */ /* 0x000fe60003800000 */ /*0030*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e620000002500 */ /*0040*/ ISETP.NE.AND P0, PT, R19, RZ, PT ; /* 0x000000ff1300720c */ /* 0x001fe20003f05270 */ /*0050*/ IMAD R0, R0, c[0x0][0x0], R19 ; /* 0x0000000000007a24 */ /* 0x002fd800078e0213 */ /*0060*/ @P0 BRA 0x1f0 ; /* 0x0000018000000947 */ /* 0x000fea0003800000 */ /*0070*/ STS.128 [RZ], RZ ; /* 0x000000ffff007388 */ /* 0x000fe80000000c00 */ /*0080*/ STS.128 [0x10], RZ ; /* 0x000010ffff007388 */ /* 0x000fe80000000c00 */ /*0090*/ STS.128 [0x20], RZ ; /* 0x000020ffff007388 */ /* 0x000fe80000000c00 */ /*00a0*/ STS.128 [0x30], RZ ; /* 0x000030ffff007388 */ /* 0x000fe80000000c00 */ /*00b0*/ STS.128 [0x40], RZ ; /* 0x000040ffff007388 */ /* 0x000fe80000000c00 */ /*00c0*/ STS.128 [0x50], RZ ; /* 0x000050ffff007388 */ /* 0x000fe80000000c00 */ /*00d0*/ STS.128 [0x60], RZ ; /* 0x000060ffff007388 */ /* 0x000fe80000000c00 */ /*00e0*/ STS.128 [0x70], RZ ; /* 0x000070ffff007388 */ /* 0x000fe80000000c00 */ /*00f0*/ STS.128 [0x80], RZ ; /* 0x000080ffff007388 */ /* 0x000fe80000000c00 */ /*0100*/ STS.128 [0x90], RZ ; /* 0x000090ffff007388 */ /* 0x000fe80000000c00 */ /*0110*/ STS.128 [0xa0], RZ ; /* 0x0000a0ffff007388 */ /* 0x000fe80000000c00 */ /*0120*/ STS.128 [0xb0], RZ ; /* 0x0000b0ffff007388 */ /* 0x000fe80000000c00 */ /*0130*/ STS.128 [0xc0], RZ ; /* 0x0000c0ffff007388 */ /* 0x000fe80000000c00 */ /*0140*/ STS.128 [0xd0], RZ ; /* 0x0000d0ffff007388 */ /* 0x000fe80000000c00 */ /*0150*/ STS.128 [0xe0], RZ ; /* 0x0000e0ffff007388 */ /* 0x000fe80000000c00 */ /*0160*/ STS.128 [0xf0], RZ ; /* 0x0000f0ffff007388 */ /* 0x000fe80000000c00 */ /*0170*/ STS.128 [0x100], RZ ; /* 0x000100ffff007388 */ /* 0x000fe80000000c00 */ /*0180*/ STS.128 [0x110], RZ ; /* 0x000110ffff007388 */ /* 0x000fe80000000c00 */ /*0190*/ STS.128 [0x120], RZ ; /* 0x000120ffff007388 */ /* 0x000fe80000000c00 */ /*01a0*/ STS.128 [0x130], RZ ; /* 0x000130ffff007388 */ /* 0x000fe80000000c00 */ /*01b0*/ STS.128 [0x140], RZ ; /* 0x000140ffff007388 */ /* 0x000fe80000000c00 */ /*01c0*/ STS.128 [0x150], RZ ; /* 0x000150ffff007388 */ /* 0x000fe80000000c00 */ /*01d0*/ STS.128 [0x160], RZ ; /* 0x000160ffff007388 */ /* 0x000fe80000000c00 */ /*01e0*/ STS [0x170], RZ ; /* 0x000170ffff007388 */ /* 0x000fe40000000800 */ /*01f0*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0200*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fe20000010000 */ /*0210*/ ISETP.GE.U32.AND P0, PT, R0, c[0x0][0x160], PT ; /* 0x0000580000007a0c */ /* 0x000fca0003f06070 */ /*0220*/ ULDC.64 UR8, c[0x0][0x118] ; /* 0x0000460000087ab9 */ /* 0x000fd00000000a00 */ /*0230*/ @P0 BRA 0x4e0 ; /* 0x000002a000000947 */ /* 0x000fea0003800000 */ /*0240*/ LEA R0, P0, R0, c[0x0][0x168], 0x8 ; /* 0x00005a0000007a11 */ /* 0x000fc800078040ff */ /*0250*/ IADD3 R2, P1, R0, 0x7, RZ ; /* 0x0000000700027810 */ /* 0x000fe20007f3e0ff */ /*0260*/ IMAD.MOV.U32 R0, RZ, RZ, RZ ; /* 0x000000ffff007224 */ /* 0x000fc600078e00ff */ /*0270*/ IADD3.X R3, RZ, c[0x0][0x16c], RZ, P1, P0 ; /* 0x00005b00ff037a10 */ /* 0x000fca0000fe04ff */ /*0280*/ LDG.E.S8 R20, [R2.64+-0x7] ; /* 0xfffff90802147981 */ /* 0x0010a8000c1e1300 */ /*0290*/ LDG.E.S8 R4, [R2.64+-0x6] ; /* 0xfffffa0802047981 */ /* 0x0000e8000c1e1300 */ /*02a0*/ LDG.E.S8 R5, [R2.64+-0x5] ; /* 0xfffffb0802057981 */ /* 0x000128000c1e1300 */ /*02b0*/ LDG.E.S8 R6, [R2.64+-0x4] ; /* 0xfffffc0802067981 */ /* 0x000168000c1e1300 */ /*02c0*/ LDG.E.S8 R7, [R2.64+-0x3] ; /* 0xfffffd0802077981 */ /* 0x000168000c1e1300 */ /*02d0*/ LDG.E.S8 R8, [R2.64+-0x2] ; /* 0xfffffe0802087981 */ /* 0x000168000c1e1300 */ /*02e0*/ LDG.E.S8 R9, [R2.64+-0x1] ; /* 0xffffff0802097981 */ /* 0x000168000c1e1300 */ /*02f0*/ LDG.E.S8 R10, [R2.64] ; /* 0x00000008020a7981 */ /* 0x000168000c1e1300 */ /*0300*/ LDG.E.S8 R11, [R2.64+0x1] ; /* 0x00000108020b7981 */ /* 0x000168000c1e1300 */ /*0310*/ LDG.E.S8 R12, [R2.64+0x2] ; /* 0x00000208020c7981 */ /* 0x000168000c1e1300 */ /*0320*/ LDG.E.S8 R13, [R2.64+0x3] ; /* 0x00000308020d7981 */ /* 0x000168000c1e1300 */ /*0330*/ LDG.E.S8 R14, [R2.64+0x4] ; /* 0x00000408020e7981 */ /* 0x000168000c1e1300 */ /*0340*/ LDG.E.S8 R15, [R2.64+0x5] ; /* 0x00000508020f7981 */ /* 0x000168000c1e1300 */ /*0350*/ LDG.E.S8 R16, [R2.64+0x6] ; /* 0x0000060802107981 */ /* 0x000168000c1e1300 */ /*0360*/ LDG.E.S8 R17, [R2.64+0x7] ; /* 0x0000070802117981 */ /* 0x000168000c1e1300 */ /*0370*/ LDG.E.S8 R18, [R2.64+0x8] ; /* 0x0000080802127981 */ /* 0x000162000c1e1300 */ /*0380*/ YIELD ; /* 0x0000000000007946 */ /* 0x000fe20003800000 */ /*0390*/ IADD3 R0, R0, 0x10, RZ ; /* 0x0000001000007810 */ /* 0x000fc80007ffe0ff */ /*03a0*/ ISETP.NE.AND P0, PT, R0, 0x100, PT ; /* 0x000001000000780c */ /* 0x000fe40003f05270 */ /*03b0*/ IADD3 R2, P1, R2, 0x10, RZ ; /* 0x0000001002027810 */ /* 0x001fca0007f3e0ff */ /*03c0*/ IMAD.X R3, RZ, RZ, R3, P1 ; /* 0x000000ffff037224 */ /* 0x000fe200008e0603 */ /*03d0*/ ATOMS.POPC.INC.32 RZ, [R20.X4+URZ+-0x80] ; /* 0xffff800014ff7f8c */ /* 0x0041e8000d00403f */ /*03e0*/ ATOMS.POPC.INC.32 RZ, [R4.X4+URZ+-0x80] ; /* 0xffff800004ff7f8c */ /* 0x0081e8000d00403f */ /*03f0*/ ATOMS.POPC.INC.32 RZ, [R5.X4+URZ+-0x80] ; /* 0xffff800005ff7f8c */ /* 0x0101e8000d00403f */ /*0400*/ ATOMS.POPC.INC.32 RZ, [R6.X4+URZ+-0x80] ; /* 0xffff800006ff7f8c */ /* 0x0201e8000d00403f */ /*0410*/ ATOMS.POPC.INC.32 RZ, [R7.X4+URZ+-0x80] ; /* 0xffff800007ff7f8c */ /* 0x0001e8000d00403f */ /*0420*/ ATOMS.POPC.INC.32 RZ, [R8.X4+URZ+-0x80] ; /* 0xffff800008ff7f8c */ /* 0x0001e8000d00403f */ /*0430*/ ATOMS.POPC.INC.32 RZ, [R9.X4+URZ+-0x80] ; /* 0xffff800009ff7f8c */ /* 0x0001e8000d00403f */ /*0440*/ ATOMS.POPC.INC.32 RZ, [R10.X4+URZ+-0x80] ; /* 0xffff80000aff7f8c */ /* 0x0001e8000d00403f */ /*0450*/ ATOMS.POPC.INC.32 RZ, [R11.X4+URZ+-0x80] ; /* 0xffff80000bff7f8c */ /* 0x0001e8000d00403f */ /*0460*/ ATOMS.POPC.INC.32 RZ, [R12.X4+URZ+-0x80] ; /* 0xffff80000cff7f8c */ /* 0x0001e8000d00403f */ /*0470*/ ATOMS.POPC.INC.32 RZ, [R13.X4+URZ+-0x80] ; /* 0xffff80000dff7f8c */ /* 0x0001e8000d00403f */ /*0480*/ ATOMS.POPC.INC.32 RZ, [R14.X4+URZ+-0x80] ; /* 0xffff80000eff7f8c */ /* 0x0001e8000d00403f */ /*0490*/ ATOMS.POPC.INC.32 RZ, [R15.X4+URZ+-0x80] ; /* 0xffff80000fff7f8c */ /* 0x0001e8000d00403f */ /*04a0*/ ATOMS.POPC.INC.32 RZ, [R16.X4+URZ+-0x80] ; /* 0xffff800010ff7f8c */ /* 0x0001e8000d00403f */ /*04b0*/ ATOMS.POPC.INC.32 RZ, [R17.X4+URZ+-0x80] ; /* 0xffff800011ff7f8c */ /* 0x0001e8000d00403f */ /*04c0*/ ATOMS.POPC.INC.32 RZ, [R18.X4+URZ+-0x80] ; /* 0xffff800012ff7f8c */ /* 0x0001e2000d00403f */ /*04d0*/ @P0 BRA 0x280 ; /* 0xfffffda000000947 */ /* 0x000fea000383ffff */ /*04e0*/ WARPSYNC 0xffffffff ; /* 0xffffffff00007948 */ /* 0x000fe40003800000 */ /*04f0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fe20000010000 */ /*0500*/ IMAD.MOV.U32 R0, RZ, RZ, c[0x0][0x180] ; /* 0x00006000ff007624 */ /* 0x000fca00078e00ff */ /*0510*/ ISETP.GE.AND P0, PT, R0, 0x1, PT ; /* 0x000000010000780c */ /* 0x000fc80003f06270 */ /*0520*/ ISETP.NE.OR P0, PT, R19, RZ, !P0 ; /* 0x000000ff1300720c */ /* 0x000fda0004705670 */ /*0530*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0540*/ IADD3 R2, R0.reuse, -0x1, RZ ; /* 0xffffffff00027810 */ /* 0x040fe20007ffe0ff */ /*0550*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0560*/ LOP3.LUT R0, R0, 0x3, RZ, 0xc0, !PT ; /* 0x0000000300007812 */ /* 0x000fe400078ec0ff */ /*0570*/ ISETP.GE.U32.AND P1, PT, R2, 0x3, PT ; /* 0x000000030200780c */ /* 0x000fe40003f26070 */ /*0580*/ ISETP.NE.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fd60003f05270 */ /*0590*/ @!P1 BRA 0x760 ; /* 0x000001c000009947 */ /* 0x000fea0003800000 */ /*05a0*/ S2R R12, SR_LANEID ; /* 0x00000000000c7919 */ /* 0x001e220000000000 */ /*05b0*/ IADD3 R8, -R0, c[0x0][0x180], RZ ; /* 0x0000600000087a10 */ /* 0x000fe20007ffe1ff */ /*05c0*/ IMAD.MOV.U32 R10, RZ, RZ, c[0x0][0x178] ; /* 0x00005e00ff0a7624 */ /* 0x000fe200078e00ff */ /*05d0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*05e0*/ IMAD.MOV.U32 R13, RZ, RZ, c[0x0][0x17c] ; /* 0x00005f00ff0d7624 */ /* 0x000fe200078e00ff */ /*05f0*/ UMOV UR5, URZ ; /* 0x0000003f00057c82 */ /* 0x000fe40008000000 */ /*0600*/ LDS.128 R4, [UR5] ; /* 0x00000005ff047984 */ /* 0x000e620008000c00 */ /*0610*/ VOTEU.ANY UR6, UPT, PT ; /* 0x0000000000067886 */ /* 0x000fe200038e0100 */ /*0620*/ IMAD.MOV.U32 R2, RZ, RZ, R10 ; /* 0x000000ffff027224 */ /* 0x000fe200078e000a */ /*0630*/ UFLO.U32 UR7, UR6 ; /* 0x00000006000772bd */ /* 0x000fe200080e0000 */ /*0640*/ IMAD.MOV.U32 R3, RZ, RZ, R13 ; /* 0x000000ffff037224 */ /* 0x000fe200078e000d */ /*0650*/ UPOPC UR6, UR6 ; /* 0x00000006000672bf */ /* 0x000fc80008000000 */ /*0660*/ ISETP.EQ.U32.AND P1, PT, R12, UR7, PT ; /* 0x000000070c007c0c */ /* 0x001fe4000bf22070 */ /*0670*/ IADD3 R8, R8, -0x4, RZ ; /* 0xfffffffc08087810 */ /* 0x000fe40007ffe0ff */ /*0680*/ IADD3 R10, P2, R2, 0x10, RZ ; /* 0x00000010020a7810 */ /* 0x000fe20007f5e0ff */ /*0690*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*06a0*/ UIADD3 UR5, UR5, 0x10, URZ ; /* 0x0000001005057890 */ /* 0x000fe2000fffe03f */ /*06b0*/ IMAD R9, R4, UR6, RZ ; /* 0x0000000604097c24 */ /* 0x002fe4000f8e02ff */ /*06c0*/ IMAD R5, R5, UR6, RZ ; /* 0x0000000605057c24 */ /* 0x000fc4000f8e02ff */ /*06d0*/ IMAD R11, R6, UR6, RZ ; /* 0x00000006060b7c24 */ /* 0x000fe2000f8e02ff */ /*06e0*/ @P1 RED.E.ADD.STRONG.GPU [R2.64], R9 ; /* 0x000000090200198e */ /* 0x0001e2000c10e188 */ /*06f0*/ IMAD R7, R7, UR6, RZ ; /* 0x0000000607077c24 */ /* 0x000fc6000f8e02ff */ /*0700*/ @P1 RED.E.ADD.STRONG.GPU [R2.64+0x4], R5 ; /* 0x000004050200198e */ /* 0x0001e8000c10e188 */ /*0710*/ @P1 RED.E.ADD.STRONG.GPU [R2.64+0x8], R11 ; /* 0x0000080b0200198e */ /* 0x0001e8000c10e188 */ /*0720*/ @P1 RED.E.ADD.STRONG.GPU [R2.64+0xc], R7 ; /* 0x00000c070200198e */ /* 0x0001e2000c10e188 */ /*0730*/ ISETP.NE.AND P1, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe20003f25270 */ /*0740*/ IMAD.X R13, RZ, RZ, R3, P2 ; /* 0x000000ffff0d7224 */ /* 0x000fd800010e0603 */ /*0750*/ @P1 BRA 0x600 ; /* 0xfffffea000001947 */ /* 0x001fea000383ffff */ /*0760*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*0770*/ S2R R6, SR_LANEID ; /* 0x0000000000067919 */ /* 0x001e220000000000 */ /*0780*/ UMOV UR5, 0x4 ; /* 0x0000000400057882 */ /* 0x000fe40000000000 */ /*0790*/ ULDC.64 UR6, c[0x0][0x178] ; /* 0x00005e0000067ab9 */ /* 0x000fe40000000a00 */ /*07a0*/ UIMAD.WIDE UR6, UR4, UR5, UR6 ; /* 0x00000005040672a5 */ /* 0x000fe4000f8e0206 */ /*07b0*/ USHF.L.U32 UR4, UR4, 0x2, URZ ; /* 0x0000000204047899 */ /* 0x000fd2000800063f */ /*07c0*/ LDS R4, [UR4] ; /* 0x00000004ff047984 */ /* 0x000e620008000800 */ /*07d0*/ VOTEU.ANY UR5, UPT, PT ; /* 0x0000000000057886 */ /* 0x000fe200038e0100 */ /*07e0*/ IMAD.U32 R2, RZ, RZ, UR6 ; /* 0x00000006ff027e24 */ /* 0x000fe2000f8e00ff */ /*07f0*/ UFLO.U32 UR10, UR5 ; /* 0x00000005000a72bd */ /* 0x000fe200080e0000 */ /*0800*/ IMAD.U32 R3, RZ, RZ, UR7 ; /* 0x00000007ff037e24 */ /* 0x000fe2000f8e00ff */ /*0810*/ UPOPC UR5, UR5 ; /* 0x00000005000572bf */ /* 0x000fc80008000000 */ /*0820*/ ISETP.EQ.U32.AND P0, PT, R6, UR10, PT ; /* 0x0000000a06007c0c */ /* 0x001fe4000bf02070 */ /*0830*/ IADD3 R0, R0, -0x1, RZ ; /* 0xffffffff00007810 */ /* 0x000fe20007ffe0ff */ /*0840*/ UIADD3 UR6, UP0, UR6, 0x4, URZ ; /* 0x0000000406067890 */ /* 0x000fe4000ff1e03f */ /*0850*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*0860*/ UIADD3.X UR7, URZ, UR7, URZ, UP0, !UPT ; /* 0x000000073f077290 */ /* 0x000fe200087fe43f */ /*0870*/ IMAD R5, R4, UR5, RZ ; /* 0x0000000504057c24 */ /* 0x002fca000f8e02ff */ /*0880*/ @P0 RED.E.ADD.STRONG.GPU [R2.64], R5 ; /* 0x000000050200098e */ /* 0x0001e2000c10e188 */ /*0890*/ ISETP.NE.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fda0003f05270 */ /*08a0*/ @P0 BRA 0x7c0 ; /* 0xffffff1000000947 */ /* 0x001fea000383ffff */ /*08b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*08c0*/ BRA 0x8c0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*08d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*08e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*08f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0900*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0910*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0920*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0930*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0940*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0950*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0960*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0970*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6kerneliPciPii .globl _Z6kerneliPciPii .p2align 8 .type _Z6kerneliPciPii,@function _Z6kerneliPciPii: v_cmp_eq_u32_e32 vcc_lo, 0, v0 s_mov_b32 s3, 0 s_and_saveexec_b32 s2, vcc_lo s_cbranch_execz .LBB0_3 v_mov_b32_e32 v1, 0 .LBB0_2: v_mov_b32_e32 v2, s3 s_add_i32 s3, s3, 4 s_delay_alu instid0(SALU_CYCLE_1) s_cmpk_lg_i32 s3, 0x174 ds_store_b32 v2, v1 s_cbranch_scc1 .LBB0_2 .LBB0_3: s_or_b32 exec_lo, exec_lo, s2 s_clause 0x1 s_load_b32 s2, s[0:1], 0x34 s_load_b32 s3, s[0:1], 0x0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_and_b32 s2, 0xffff, s2 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_cmp_gt_u32_e64 s2, s3, v1 s_delay_alu instid0(VALU_DEP_1) s_and_saveexec_b32 s3, s2 s_cbranch_execz .LBB0_6 s_load_b64 s[4:5], s[0:1], 0x8 v_lshlrev_b32_e32 v0, 8, v1 v_mov_b32_e32 v2, 1 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v0, s2, s4, v0 v_add_co_ci_u32_e64 v1, null, s5, 0, s2 s_mov_b64 s[4:5], 0 .LBB0_5: s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1) v_add_co_u32 v3, s2, v0, s4 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v4, s2, s5, v1, s2 s_add_u32 s4, s4, 1 s_addc_u32 s5, s5, 0 s_cmpk_lg_i32 s4, 0x100 global_load_i8 v3, v[3:4], off s_waitcnt vmcnt(0) v_lshl_add_u32 v3, v3, 2, 0xffffff80 ds_add_u32 v3, v2 s_cbranch_scc1 .LBB0_5 .LBB0_6: s_or_b32 exec_lo, exec_lo, s3 s_load_b32 s2, s[0:1], 0x20 s_mov_b32 s3, 0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_cmp_gt_i32 s2, 0 s_cselect_b32 s4, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s4, vcc_lo, s4 s_and_saveexec_b32 s5, s4 s_cbranch_execz .LBB0_11 s_load_b64 s[0:1], s[0:1], 0x18 v_mov_b32_e32 v0, 0 s_branch .LBB0_9 .p2align 6 .LBB0_8: s_or_b32 exec_lo, exec_lo, s4 s_add_i32 s2, s2, -1 s_waitcnt lgkmcnt(0) s_add_u32 s0, s0, 4 s_addc_u32 s1, s1, 0 s_add_i32 s3, s3, 4 s_cmp_lg_u32 s2, 0 s_cbranch_scc0 .LBB0_11 .LBB0_9: s_mov_b32 s5, exec_lo s_mov_b32 s4, exec_lo v_mbcnt_lo_u32_b32 v1, s5, 0 s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v1 s_cbranch_execz .LBB0_8 v_mov_b32_e32 v1, s3 s_bcnt1_i32_b32 s5, s5 ds_load_b32 v1, v1 s_waitcnt lgkmcnt(0) v_mul_lo_u32 v1, v1, s5 global_atomic_add_u32 v0, v1, s[0:1] s_branch .LBB0_8 .LBB0_11: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6kerneliPciPii .amdhsa_group_segment_fixed_size 380 .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 5 .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 _Z6kerneliPciPii, .Lfunc_end0-_Z6kerneliPciPii .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 - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .offset: 16 .size: 4 .value_kind: by_value - .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: 380 .kernarg_segment_align: 8 .kernarg_segment_size: 296 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z6kerneliPciPii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6kerneliPciPii.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_0010d16d_00000000-6_template.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2074: .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 .LFE2074: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z7isValidPc .type _Z7isValidPc, @function _Z7isValidPc: .LFB2070: .cfi_startproc endbr64 movzbl (%rdi), %eax subl $32, %eax cmpb $94, %al setbe %al movzbl %al, %eax ret .cfi_endproc .LFE2070: .size _Z7isValidPc, .-_Z7isValidPc .globl _Z30__device_stub__Z6kerneliPciPiiiPciPii .type _Z30__device_stub__Z6kerneliPciPiiiPciPii, @function _Z30__device_stub__Z6kerneliPciPiiiPciPii: .LFB2096: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movl %edi, 28(%rsp) movq %rsi, 16(%rsp) movl %edx, 24(%rsp) movq %rcx, 8(%rsp) movl %r8d, 4(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 28(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 24(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) leaq 4(%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 .L8 .L4: movq 136(%rsp), %rax subq %fs:40, %rax jne .L9 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L8: .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 _Z6kerneliPciPii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L4 .L9: call __stack_chk_fail@PLT .cfi_endproc .LFE2096: .size _Z30__device_stub__Z6kerneliPciPiiiPciPii, .-_Z30__device_stub__Z6kerneliPciPiiiPciPii .globl _Z6kerneliPciPii .type _Z6kerneliPciPii, @function _Z6kerneliPciPii: .LFB2097: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z6kerneliPciPiiiPciPii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2097: .size _Z6kerneliPciPii, .-_Z6kerneliPciPii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Initialisation...\n" .LC1: .string "i:o:" .LC2: .string "r" .LC3: .string "Input file too large!\n" .LC4: .string "%d chars processed\n" .LC5: .string "Process...\n" .LC6: .string "w+" .LC7: .string "%c:%d\n" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC10: .string "Timings:\nInitialisation: %f\nProcess: %f\n" .text .globl main .type main, @function main: .LFB2071: .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 $88, %rsp .cfi_def_cfa_offset 144 movl %edi, %ebp movq %rsi, %rbx movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq .LC0(%rip), %rsi movl $2, %edi call __printf_chk@PLT call clock@PLT movq %rax, 24(%rsp) movl $0, %r15d movl $0, %r12d leaq .LC1(%rip), %r13 jmp .L13 .L14: movq optarg(%rip), %r12 .L13: movq %r13, %rdx movq %rbx, %rsi movl %ebp, %edi call getopt@PLT cmpl $-1, %eax je .L46 cmpl $105, %eax je .L14 cmpl $111, %eax cmove optarg(%rip), %r15 jmp .L13 .L46: leaq .LC2(%rip), %rsi movq %r12, %rdi call fopen@PLT movq %rax, %rbx testq %rax, %rax je .L37 movq %rax, %rdi call getc@PLT movb %al, 60(%rsp) cmpb $-1, %al je .L38 movl $0, %ebp leaq 60(%rsp), %r13 .L21: movq %r13, %rdi call _Z7isValidPc cmpl $1, %eax sbbl $-1, %ebp movq %rbx, %rdi call getc@PLT movb %al, 60(%rsp) cmpb $-1, %al jne .L21 .L19: movq %rbx, %rdi call fclose@PLT movl $380, %edi call malloc@PLT movq %rax, %rbx movslq %ebp, %rax movq %rax, 16(%rsp) movq %rax, %rdi call malloc@PLT movq %rax, 8(%rsp) testq %rax, %rax je .L47 movl %ebp, %edx leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 32(%rsp), %rdi movq 16(%rsp), %rsi call cudaMalloc@PLT leaq 40(%rsp), %rdi movl $380, %esi call cudaMalloc@PLT leaq .LC2(%rip), %rsi movq %r12, %rdi call fopen@PLT movq %rax, %r13 testq %rax, %rax je .L39 movq %rax, %rdi call getc@PLT movl %eax, %r12d movb %al, 60(%rsp) cmpb $-1, %al je .L23 movl $0, %r14d leaq 60(%rsp), %rax movq %rax, (%rsp) jmp .L27 .L38: movl $0, %ebp jmp .L19 .L47: leaq .LC3(%rip), %rsi movl $2, %edi call __printf_chk@PLT movl $1, %eax jmp .L12 .L25: movslq %r14d, %rax movq 8(%rsp), %rcx movb %r12b, (%rcx,%rax) .L26: addl $1, %r14d .L24: movq %r13, %rdi call getc@PLT movl %eax, %r12d movb %al, 60(%rsp) cmpb $-1, %al je .L23 .L27: movq (%rsp), %rdi call _Z7isValidPc testl %eax, %eax je .L24 leal -65(%r12), %eax cmpb $25, %al ja .L25 movslq %r14d, %rax addl $32, %r12d movq 8(%rsp), %rcx movb %r12b, (%rcx,%rax) jmp .L26 .L23: movq %r13, %rdi call fclose@PLT call clock@PLT movq 24(%rsp), %rcx subq %rcx, %rax movq %rax, %r14 leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call clock@PLT movq %rax, %r12 movq %rbx, %rax leaq 380(%rbx), %rdx .L28: movl $0, (%rax) addq $4, %rax cmpq %rdx, %rax jne .L28 movl $1, %ecx movq 16(%rsp), %r13 movq %r13, %rdx movq 8(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $380, %edx movq %rbx, %rsi movq 40(%rsp), %rdi call cudaMemcpy@PLT testl %ebp, %ebp jle .L29 movq 8(%rsp), %rsi movq %rsi, %rax movq %r13, %rcx addq %rsi, %rcx .L30: movsbq (%rax), %rdx addl $1, -128(%rbx,%rdx,4) addq $1, %rax cmpq %rcx, %rax jne .L30 .L29: leal 510(%rbp), %r13d movl %ebp, %eax addl $255, %eax cmovns %eax, %r13d sarl $8, %r13d movl $256, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leal 510(%r13), %eax movl %r13d, %edx addl $255, %edx cmovns %edx, %eax sarl $8, %eax movl %eax, 48(%rsp) movl $1, 52(%rsp) movl $0, %r9d movl $0, %r8d movq 60(%rsp), %rdx movl $1, %ecx movq 48(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L48 .L31: movl $2, %ecx movl $380, %edx movq 40(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT call clock@PLT subq %r12, %rax movq %rax, %rbp leaq .LC6(%rip), %rsi movq %r15, %rdi call fopen@PLT movq %rax, %r13 testq %rax, %rax je .L40 movl $0, %r12d .L34: leal -33(%r12), %eax cmpl $25, %eax ja .L49 addq $1, %r12 jmp .L34 .L48: movl $95, %r8d movq 40(%rsp), %rcx movl %ebp, %edx movq 32(%rsp), %rsi movl %r13d, %edi call _Z30__device_stub__Z6kerneliPciPiiiPciPii jmp .L31 .L49: leal 32(%r12), %ecx movl (%rbx,%r12,4), %r8d leaq .LC7(%rip), %rdx movl $2, %esi movq %r13, %rdi movl $0, %eax call __fprintf_chk@PLT addq $1, %r12 cmpq $95, %r12 jne .L34 movq %r13, %rdi call fclose@PLT movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 8(%rsp), %rdi call free@PLT movq %rbx, %rdi call free@PLT pxor %xmm1, %xmm1 cvtsi2ssq %rbp, %xmm1 movss .LC8(%rip), %xmm3 mulss %xmm3, %xmm1 movss .LC9(%rip), %xmm2 divss %xmm2, %xmm1 pxor %xmm0, %xmm0 cvtsi2ssq %r14, %xmm0 mulss %xmm3, %xmm0 divss %xmm2, %xmm0 cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 leaq .LC10(%rip), %rsi movl $2, %edi movl $2, %eax call __printf_chk@PLT movl $0, %eax .L12: movq 72(%rsp), %rdx subq %fs:40, %rdx jne .L50 addq $88, %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 .L37: .cfi_restore_state movl $1, %eax jmp .L12 .L39: movl $1, %eax jmp .L12 .L40: movl $1, %eax jmp .L12 .L50: call __stack_chk_fail@PLT .cfi_endproc .LFE2071: .size main, .-main .section .rodata.str1.1 .LC11: .string "_Z6kerneliPciPii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2099: .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 .LC11(%rip), %rdx movq %rdx, %rcx leaq _Z6kerneliPciPii(%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 .LFE2099: .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 .LC8: .long 1148846080 .align 4 .LC9: .long 1232348160 .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 "template.hip" .globl _Z21__device_stub__kerneliPciPii # -- Begin function _Z21__device_stub__kerneliPciPii .p2align 4, 0x90 .type _Z21__device_stub__kerneliPciPii,@function _Z21__device_stub__kerneliPciPii: # @_Z21__device_stub__kerneliPciPii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movl %edi, 12(%rsp) movq %rsi, 72(%rsp) movl %edx, 8(%rsp) movq %rcx, 64(%rsp) movl %r8d, 4(%rsp) leaq 12(%rsp), %rax movq %rax, 80(%rsp) leaq 72(%rsp), %rax movq %rax, 88(%rsp) leaq 8(%rsp), %rax movq %rax, 96(%rsp) leaq 64(%rsp), %rax movq %rax, 104(%rsp) leaq 4(%rsp), %rax movq %rax, 112(%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 $_Z6kerneliPciPii, %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 _Z21__device_stub__kerneliPciPii, .Lfunc_end0-_Z21__device_stub__kerneliPciPii .cfi_endproc # -- End function .globl _Z7isValidPc # -- Begin function _Z7isValidPc .p2align 4, 0x90 .type _Z7isValidPc,@function _Z7isValidPc: # @_Z7isValidPc .cfi_startproc # %bb.0: movzbl (%rdi), %ecx addb $-32, %cl xorl %eax, %eax cmpb $95, %cl setb %al retq .Lfunc_end1: .size _Z7isValidPc, .Lfunc_end1-_Z7isValidPc .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI2_0: .long 0x447a0000 # float 1000 .LCPI2_1: .long 0x49742400 # float 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 $168, %rsp .cfi_def_cfa_offset 224 .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 movl $.Lstr, %edi callq puts@PLT callq clock movq %rax, %r12 xorl %r13d, %r13d xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 movl $.L.str.1, %edx movl %ebp, %edi movq %rbx, %rsi callq getopt cmpl $-1, %eax je .LBB2_6 # %bb.2: # in Loop: Header=BB2_1 Depth=1 cmpl $111, %eax je .LBB2_5 # %bb.3: # in Loop: Header=BB2_1 Depth=1 cmpl $105, %eax jne .LBB2_1 # %bb.4: # in Loop: Header=BB2_1 Depth=1 movq optarg(%rip), %r14 jmp .LBB2_1 .LBB2_5: # in Loop: Header=BB2_1 Depth=1 movq optarg(%rip), %r13 jmp .LBB2_1 .LBB2_6: movl $.L.str.2, %esi movq %r14, %rdi callq fopen movl $1, %ebx testq %rax, %rax je .LBB2_29 # %bb.7: movq %rax, %r15 movq %r13, 56(%rsp) # 8-byte Spill movq %r12, 48(%rsp) # 8-byte Spill movq %rax, %rdi callq getc xorl %r13d, %r13d cmpb $-1, %al je .LBB2_10 # %bb.8: # %.lr.ph.preheader xorl %r13d, %r13d .p2align 4, 0x90 .LBB2_9: # %.lr.ph # =>This Inner Loop Header: Depth=1 addb $-32, %al cmpb $95, %al adcl $0, %r13d movq %r15, %rdi callq getc cmpb $-1, %al jne .LBB2_9 .LBB2_10: # %._crit_edge movq %r15, %rdi callq fclose movl $380, %edi # imm = 0x17C callq malloc movq %rax, %r15 movl %r13d, %ebp movq %rbp, %rdi callq malloc testq %rax, %rax je .LBB2_11 # %bb.12: movq %rax, %r12 movl $.L.str.4, %edi movl %r13d, %esi xorl %eax, %eax callq printf leaq 8(%rsp), %rdi movq %rbp, %rsi callq hipMalloc movq %rsp, %rdi movl $380, %esi # imm = 0x17C callq hipMalloc movl $.L.str.2, %esi movq %r14, %rdi callq fopen testq %rax, %rax je .LBB2_29 # %bb.13: movq %rax, %r14 movq %rax, %rdi callq getc # kill: def $eax killed $eax def $rax cmpb $-1, %al jne .LBB2_14 .LBB2_18: # %._crit_edge116 movq %r14, %rdi callq fclose callq clock movq %rax, 40(%rsp) # 8-byte Spill movl $.Lstr.1, %edi callq puts@PLT callq clock movq %rax, 32(%rsp) # 8-byte Spill movl $380, %edx # imm = 0x17C movq %r15, %rdi xorl %esi, %esi callq memset@PLT movq 8(%rsp), %rdi movq %r12, %rsi movq %rbp, %rdx movl $1, %ecx callq hipMemcpy movq (%rsp), %rdi movl $380, %edx # imm = 0x17C movq %r15, %rsi movl $1, %ecx callq hipMemcpy testl %r13d, %r13d je .LBB2_21 # %bb.19: # %.lr.ph120.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB2_20: # %.lr.ph120 # =>This Inner Loop Header: Depth=1 movsbq (%r12,%rax), %rcx incl -128(%r15,%rcx,4) incq %rax cmpq %rax, %rbp jne .LBB2_20 .LBB2_21: # %._crit_edge121 leal 255(%r13), %r14d shrl $8, %r14d leal 255(%r14), %edi shrl $8, %edi movabsq $4294967296, %rdx # imm = 0x100000000 orq %rdx, %rdi orq $256, %rdx # imm = 0x100 movl $1, %ebx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_23 # %bb.22: movq 8(%rsp), %rax movq (%rsp), %rcx movl %r14d, 28(%rsp) movq %rax, 120(%rsp) movl %r13d, 24(%rsp) movq %rcx, 112(%rsp) movl $95, 20(%rsp) leaq 28(%rsp), %rax movq %rax, 128(%rsp) leaq 120(%rsp), %rax movq %rax, 136(%rsp) leaq 24(%rsp), %rax movq %rax, 144(%rsp) leaq 112(%rsp), %rax movq %rax, 152(%rsp) leaq 20(%rsp), %rax movq %rax, 160(%rsp) leaq 96(%rsp), %rdi leaq 80(%rsp), %rsi leaq 72(%rsp), %rdx leaq 64(%rsp), %rcx callq __hipPopCallConfiguration movq 96(%rsp), %rsi movl 104(%rsp), %edx movq 80(%rsp), %rcx movl 88(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z6kerneliPciPii, %edi pushq 64(%rsp) .cfi_adjust_cfa_offset 8 pushq 80(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_23: movq (%rsp), %rsi movl $380, %edx # imm = 0x17C movq %r15, %rdi movl $2, %ecx callq hipMemcpy callq clock movq %rax, %r14 movl $.L.str.6, %esi movq 56(%rsp), %rdi # 8-byte Reload callq fopen testq %rax, %rax movq 40(%rsp), %rbp # 8-byte Reload je .LBB2_29 # %bb.24: # %.preheader.preheader movq %rax, %r13 subq 48(%rsp), %rbp # 8-byte Folded Reload subq 32(%rsp), %r14 # 8-byte Folded Reload xorl %ebx, %ebx jmp .LBB2_25 .p2align 4, 0x90 .LBB2_27: # in Loop: Header=BB2_25 Depth=1 incq %rbx cmpq $95, %rbx je .LBB2_28 .LBB2_25: # %.preheader # =>This Inner Loop Header: Depth=1 leal -59(%rbx), %eax cmpl $-27, %eax ja .LBB2_27 # %bb.26: # in Loop: Header=BB2_25 Depth=1 movl (%r15,%rbx,4), %ecx leal 32(%rbx), %edx movl $.L.str.7, %esi movq %r13, %rdi xorl %eax, %eax callq fprintf jmp .LBB2_27 .LBB2_11: movl $.Lstr.2, %edi callq puts@PLT jmp .LBB2_29 .LBB2_28: movq %r13, %rdi callq fclose movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree movq %r12, %rdi callq free movq %r15, %rdi callq free cvtsi2ss %rbp, %xmm0 movss .LCPI2_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero mulss %xmm1, %xmm0 movss .LCPI2_1(%rip), %xmm2 # xmm2 = mem[0],zero,zero,zero divss %xmm2, %xmm0 cvtsi2ss %r14, %xmm3 cvtss2sd %xmm0, %xmm0 mulss %xmm1, %xmm3 divss %xmm2, %xmm3 xorps %xmm1, %xmm1 cvtss2sd %xmm3, %xmm1 movl $.L.str.8, %edi movb $2, %al callq printf xorl %ebx, %ebx .LBB2_29: movl %ebx, %eax addq $168, %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 .LBB2_14: # %.lr.ph115.preheader .cfi_def_cfa_offset 224 xorl %ebx, %ebx jmp .LBB2_15 .p2align 4, 0x90 .LBB2_17: # in Loop: Header=BB2_15 Depth=1 movq %r14, %rdi callq getc # kill: def $eax killed $eax def $rax cmpb $-1, %al je .LBB2_18 .LBB2_15: # %.lr.ph115 # =>This Inner Loop Header: Depth=1 leal -127(%rax), %ecx cmpb $-95, %cl jb .LBB2_17 # %bb.16: # in Loop: Header=BB2_15 Depth=1 leal -65(%rax), %ecx movzbl %al, %edx orb $32, %al cmpb $26, %cl movzbl %al, %eax cmovael %edx, %eax movslq %ebx, %rbx movb %al, (%r12,%rbx) incl %ebx jmp .LBB2_17 .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z6kerneliPciPii, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type _Z6kerneliPciPii,@object # @_Z6kerneliPciPii .section .rodata,"a",@progbits .globl _Z6kerneliPciPii .p2align 3, 0x0 _Z6kerneliPciPii: .quad _Z21__device_stub__kerneliPciPii .size _Z6kerneliPciPii, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "i:o:" .size .L.str.1, 5 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "r" .size .L.str.2, 2 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "%d chars processed\n" .size .L.str.4, 20 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "w+" .size .L.str.6, 3 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "%c:%d\n" .size .L.str.7, 7 .type .L.str.8,@object # @.str.8 .L.str.8: .asciz "Timings:\nInitialisation: %f\nProcess: %f\n" .size .L.str.8, 48 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6kerneliPciPii" .size .L__unnamed_1, 17 .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 "Initialisation..." .size .Lstr, 18 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Process..." .size .Lstr.1, 11 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "Input file too large!" .size .Lstr.2, 22 .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 _Z21__device_stub__kerneliPciPii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6kerneliPciPii .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 <vector> #include <iostream> #include <fstream> __device__ void remove_index_from_array(char* arr, int index, int temp_length) { for (int i = 0; i < temp_length - 1; i++) { if (i >= index) { arr[i] = arr[i+1]; } } } __device__ void remove_index_from_shared_memory_array(char* arr, int index, int temp_length, int threadId, int word_length) { for (int i = word_length * threadId; i < word_length * threadId + temp_length - 1; i++) { //printf("thread_id = %d | arr[%d] = %d | index = %d\n", threadId, i, arr[i], index); if (i >= index) { //printf("thread_id = %d | arr[%d] = %d | index = %d | arr[%d] = %c | arr[%d] = %c\n", threadId, i, arr[i], index, i, arr[i], i+1, arr[i+1]); arr[i] = arr[i + 1]; } } } __global__ void find_all_permutations_kernel_shared_memory(char* word, int word_length, unsigned long long num_perm, char* permutations) { extern __shared__ char temp_word[ ]; unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; // populate shared memory with word for (int j = beg * word_length; j < beg * word_length + word_length; j++) { //printf("temp[%d] = %c\n", j, word[j % word_length]); temp_word[j] = word[j % word_length]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; int true_index = index + beg * word_length; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, true_index, temp_word[true_index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp_word[true_index]; permutations_index++; // remove temp[index] char* ptr_to_smem = (char *) temp_word; remove_index_from_shared_memory_array(ptr_to_smem, true_index, temp_length, beg, word_length); temp_length--; } } } __global__ void find_all_permutations_kernel(char* word, int word_length, unsigned long long num_perm, char* permutations) { unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; char temp[12]; for (int j = 0; j < word_length; j++) { temp[j] = word[j]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, index, temp[index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp[index]; permutations_index++; // remove temp[index] remove_index_from_array(temp, index, temp_length); temp_length--; } } } void generateWord(char* word, int* word_length); char* find_all_permutations(int blockSize, int blockNum, int word_length) { // ALLOCATE float elapsed = 0; cudaEvent_t start, stop; char* word = (char *) malloc(word_length * sizeof(char)); unsigned long long num_perm = 1; for (int k = 1; k <= word_length; num_perm *= k++); // generate word given length generateWord(word, &word_length); printf("Word = %s\n", word); printf("word length %d\n", word_length); // this will contain all of the permutations of the word above char* permutations = (char *) malloc(word_length * num_perm * sizeof(char)); char* cuda_permutations; char* cuda_word; cudaEventCreate(&start); cudaEventCreate(&stop); cudaMalloc((void **) &cuda_permutations, word_length * num_perm * sizeof(char)); cudaMalloc((void **) &cuda_word, word_length * sizeof(char)); cudaMemcpy(cuda_permutations, permutations, word_length * num_perm * sizeof(char), cudaMemcpyHostToDevice); cudaMemcpy(cuda_word, word, word_length * sizeof(char), cudaMemcpyHostToDevice); cudaEventRecord(start, 0); // call kernel find_all_permutations_kernel<<<blockNum, blockSize>>>(cuda_word, word_length, num_perm, cuda_permutations); cudaDeviceSynchronize(); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [No shared memory]: %.5f ms\n", elapsed); cudaEventRecord(start, 0); // call kernel find_all_permutations_kernel_shared_memory<<<blockNum, blockSize, blockSize * word_length * sizeof(char)>>>(cuda_word, word_length, num_perm, cuda_permutations); cudaDeviceSynchronize(); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [Shared memory]: %.5f ms\n", elapsed); cudaMemcpy(permutations, cuda_permutations, word_length * num_perm * sizeof(char), cudaMemcpyDeviceToHost); // DEALLOCATE cudaFree(cuda_permutations); cudaFree(cuda_word); cudaEventDestroy(start); cudaEventDestroy(stop); free(word); return permutations; } /* Generate the random word given a word_length */ void generateWord(char* word, int* word_length) { int rand_num; const char capital_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (*word_length <= 0) { printf("Invalid size. Defaulting to size 10.\n"); *word_length = 10; } for (int i = 0; i < *word_length; i++) { rand_num = rand() % (sizeof(capital_letters) - 1); word[i] = capital_letters[rand_num]; } }
.file "tmpxft_000679e3_00000000-6_permutations.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB4169: .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 .LFE4169: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z23remove_index_from_arrayPcii .type _Z23remove_index_from_arrayPcii, @function _Z23remove_index_from_arrayPcii: .LFB4163: .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 .LFE4163: .size _Z23remove_index_from_arrayPcii, .-_Z23remove_index_from_arrayPcii .globl _Z37remove_index_from_shared_memory_arrayPciiii .type _Z37remove_index_from_shared_memory_arrayPciiii, @function _Z37remove_index_from_shared_memory_arrayPciiii: .LFB4164: .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 .LFE4164: .size _Z37remove_index_from_shared_memory_arrayPciiii, .-_Z37remove_index_from_shared_memory_arrayPciiii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Invalid size. Defaulting to size 10.\n" .text .globl _Z12generateWordPcPi .type _Z12generateWordPcPi, @function _Z12generateWordPcPi: .LFB4166: .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 $56, %rsp .cfi_def_cfa_offset 96 movq %rdi, %r12 movq %rsi, %rbp movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax movabsq $5208208757389214273, %rax movabsq $5786930140093827657, %rdx movq %rax, (%rsp) movq %rdx, 8(%rsp) movabsq $6003950658608057676, %rax movabsq $25430983861228884, %rdx movq %rax, 11(%rsp) movq %rdx, 19(%rsp) cmpl $0, (%rsi) jle .L14 .L8: movl $0, %ebx movabsq $5675921253449092805, %r13 .L9: call rand@PLT movslq %eax, %rcx movq %rcx, %rax mulq %r13 shrq $3, %rdx leaq (%rdx,%rdx,2), %rax leaq (%rdx,%rax,4), %rax addq %rax, %rax subq %rax, %rcx movslq %ecx, %rcx movzbl (%rsp,%rcx), %eax movb %al, (%r12,%rbx) addq $1, %rbx cmpl %ebx, 0(%rbp) jg .L9 movq 40(%rsp), %rax subq %fs:40, %rax jne .L15 addq $56, %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 .L14: .cfi_restore_state leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $10, 0(%rbp) jmp .L8 .L15: call __stack_chk_fail@PLT .cfi_endproc .LFE4166: .size _Z12generateWordPcPi, .-_Z12generateWordPcPi .globl _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ .type _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_, @function _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_: .LFB4191: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movq %rdx, 8(%rsp) movq %rcx, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) movq %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 .L20 .L16: movq 136(%rsp), %rax subq %fs:40, %rax jne .L21 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L20: .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 _Z42find_all_permutations_kernel_shared_memoryPciyS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L16 .L21: call __stack_chk_fail@PLT .cfi_endproc .LFE4191: .size _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_, .-_Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ .globl _Z42find_all_permutations_kernel_shared_memoryPciyS_ .type _Z42find_all_permutations_kernel_shared_memoryPciyS_, @function _Z42find_all_permutations_kernel_shared_memoryPciyS_: .LFB4192: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE4192: .size _Z42find_all_permutations_kernel_shared_memoryPciyS_, .-_Z42find_all_permutations_kernel_shared_memoryPciyS_ .globl _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ .type _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_, @function _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_: .LFB4193: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movq %rdx, 8(%rsp) movq %rcx, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) movq %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 .L28 .L24: movq 136(%rsp), %rax subq %fs:40, %rax jne .L29 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L28: .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 _Z28find_all_permutations_kernelPciyS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L24 .L29: call __stack_chk_fail@PLT .cfi_endproc .LFE4193: .size _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_, .-_Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ .globl _Z28find_all_permutations_kernelPciyS_ .type _Z28find_all_permutations_kernelPciyS_, @function _Z28find_all_permutations_kernelPciyS_: .LFB4194: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE4194: .size _Z28find_all_permutations_kernelPciyS_, .-_Z28find_all_permutations_kernelPciyS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC2: .string "Word = %s\n" .LC3: .string "word length %d\n" .section .rodata.str1.8 .align 8 .LC4: .string "Elapsed time [No shared memory]: %.5f ms\n" .align 8 .LC5: .string "Elapsed time [Shared memory]: %.5f ms\n" .text .globl _Z21find_all_permutationsiii .type _Z21find_all_permutationsiii, @function _Z21find_all_permutationsiii: .LFB4165: .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 movl %edi, %ebp movl %esi, 8(%rsp) movl %edx, %ebx movl %edx, 12(%rsp) movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax movl $0x00000000, 28(%rsp) movslq %edx, %rdi call malloc@PLT movq %rax, %r12 testl %ebx, %ebx jle .L38 leal 1(%rbx), %edx movl $1, %eax movl $1, %ebx .L34: imulq %rax, %rbx addq $1, %rax cmpq %rdx, %rax jne .L34 .L33: leaq 12(%rsp), %rsi movq %r12, %rdi call _Z12generateWordPcPi movq %r12, %rdx leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl 12(%rsp), %r14d movl %r14d, %edx leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movslq %r14d, %r15 movq %r15, %r13 imulq %rbx, %r13 movq %r13, %rdi call malloc@PLT movq %rax, (%rsp) leaq 32(%rsp), %rdi call cudaEventCreate@PLT leaq 40(%rsp), %rdi call cudaEventCreate@PLT leaq 48(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 56(%rsp), %rdi movq %r15, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r13, %rdx movq (%rsp), %rsi movq 48(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r15, %rdx movq %r12, %rsi movq 56(%rsp), %rdi call cudaMemcpy@PLT movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movl %ebp, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl 8(%rsp), %eax movl %eax, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $0, %r9d movl $0, %r8d movq 76(%rsp), %rdx movl $1, %ecx movq 64(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L41 .L35: call cudaDeviceSynchronize@PLT movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 28(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 28(%rsp), %xmm0 leaq .LC4(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movl %ebp, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl 8(%rsp), %eax movl %eax, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) imull %r14d, %ebp movl $0, %r9d movslq %ebp, %r8 movq 76(%rsp), %rdx movl $1, %ecx movq 64(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L42 .L36: call cudaDeviceSynchronize@PLT movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 28(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 28(%rsp), %xmm0 leaq .LC5(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $2, %ecx movq %r13, %rdx movq 48(%rsp), %rsi movq (%rsp), %rdi call cudaMemcpy@PLT movq 48(%rsp), %rdi call cudaFree@PLT movq 56(%rsp), %rdi call cudaFree@PLT movq 32(%rsp), %rdi call cudaEventDestroy@PLT movq 40(%rsp), %rdi call cudaEventDestroy@PLT movq %r12, %rdi call free@PLT movq 88(%rsp), %rax subq %fs:40, %rax jne .L43 movq (%rsp), %rax 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 .L38: .cfi_restore_state movl $1, %ebx jmp .L33 .L41: movq 48(%rsp), %rcx movq %rbx, %rdx movl %r14d, %esi movq 56(%rsp), %rdi call _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ jmp .L35 .L42: movq 48(%rsp), %rcx movq %rbx, %rdx movl %r14d, %esi movq 56(%rsp), %rdi call _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ jmp .L36 .L43: call __stack_chk_fail@PLT .cfi_endproc .LFE4165: .size _Z21find_all_permutationsiii, .-_Z21find_all_permutationsiii .section .rodata.str1.8 .align 8 .LC6: .string "_Z28find_all_permutations_kernelPciyS_" .align 8 .LC7: .string "_Z42find_all_permutations_kernel_shared_memoryPciyS_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB4196: .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 .LC6(%rip), %rdx movq %rdx, %rcx leaq _Z28find_all_permutations_kernelPciyS_(%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 .LC7(%rip), %rdx movq %rdx, %rcx leaq _Z42find_all_permutations_kernel_shared_memoryPciyS_(%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 .LFE4196: .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 <vector> #include <iostream> #include <fstream> __device__ void remove_index_from_array(char* arr, int index, int temp_length) { for (int i = 0; i < temp_length - 1; i++) { if (i >= index) { arr[i] = arr[i+1]; } } } __device__ void remove_index_from_shared_memory_array(char* arr, int index, int temp_length, int threadId, int word_length) { for (int i = word_length * threadId; i < word_length * threadId + temp_length - 1; i++) { //printf("thread_id = %d | arr[%d] = %d | index = %d\n", threadId, i, arr[i], index); if (i >= index) { //printf("thread_id = %d | arr[%d] = %d | index = %d | arr[%d] = %c | arr[%d] = %c\n", threadId, i, arr[i], index, i, arr[i], i+1, arr[i+1]); arr[i] = arr[i + 1]; } } } __global__ void find_all_permutations_kernel_shared_memory(char* word, int word_length, unsigned long long num_perm, char* permutations) { extern __shared__ char temp_word[ ]; unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; // populate shared memory with word for (int j = beg * word_length; j < beg * word_length + word_length; j++) { //printf("temp[%d] = %c\n", j, word[j % word_length]); temp_word[j] = word[j % word_length]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; int true_index = index + beg * word_length; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, true_index, temp_word[true_index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp_word[true_index]; permutations_index++; // remove temp[index] char* ptr_to_smem = (char *) temp_word; remove_index_from_shared_memory_array(ptr_to_smem, true_index, temp_length, beg, word_length); temp_length--; } } } __global__ void find_all_permutations_kernel(char* word, int word_length, unsigned long long num_perm, char* permutations) { unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; char temp[12]; for (int j = 0; j < word_length; j++) { temp[j] = word[j]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, index, temp[index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp[index]; permutations_index++; // remove temp[index] remove_index_from_array(temp, index, temp_length); temp_length--; } } } void generateWord(char* word, int* word_length); char* find_all_permutations(int blockSize, int blockNum, int word_length) { // ALLOCATE float elapsed = 0; cudaEvent_t start, stop; char* word = (char *) malloc(word_length * sizeof(char)); unsigned long long num_perm = 1; for (int k = 1; k <= word_length; num_perm *= k++); // generate word given length generateWord(word, &word_length); printf("Word = %s\n", word); printf("word length %d\n", word_length); // this will contain all of the permutations of the word above char* permutations = (char *) malloc(word_length * num_perm * sizeof(char)); char* cuda_permutations; char* cuda_word; cudaEventCreate(&start); cudaEventCreate(&stop); cudaMalloc((void **) &cuda_permutations, word_length * num_perm * sizeof(char)); cudaMalloc((void **) &cuda_word, word_length * sizeof(char)); cudaMemcpy(cuda_permutations, permutations, word_length * num_perm * sizeof(char), cudaMemcpyHostToDevice); cudaMemcpy(cuda_word, word, word_length * sizeof(char), cudaMemcpyHostToDevice); cudaEventRecord(start, 0); // call kernel find_all_permutations_kernel<<<blockNum, blockSize>>>(cuda_word, word_length, num_perm, cuda_permutations); cudaDeviceSynchronize(); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [No shared memory]: %.5f ms\n", elapsed); cudaEventRecord(start, 0); // call kernel find_all_permutations_kernel_shared_memory<<<blockNum, blockSize, blockSize * word_length * sizeof(char)>>>(cuda_word, word_length, num_perm, cuda_permutations); cudaDeviceSynchronize(); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [Shared memory]: %.5f ms\n", elapsed); cudaMemcpy(permutations, cuda_permutations, word_length * num_perm * sizeof(char), cudaMemcpyDeviceToHost); // DEALLOCATE cudaFree(cuda_permutations); cudaFree(cuda_word); cudaEventDestroy(start); cudaEventDestroy(stop); free(word); return permutations; } /* Generate the random word given a word_length */ void generateWord(char* word, int* word_length) { int rand_num; const char capital_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (*word_length <= 0) { printf("Invalid size. Defaulting to size 10.\n"); *word_length = 10; } for (int i = 0; i < *word_length; i++) { rand_num = rand() % (sizeof(capital_letters) - 1); word[i] = capital_letters[rand_num]; } }
#include <hip/hip_runtime.h> #include <vector> #include <iostream> #include <fstream> __device__ void remove_index_from_array(char* arr, int index, int temp_length) { for (int i = 0; i < temp_length - 1; i++) { if (i >= index) { arr[i] = arr[i+1]; } } } __device__ void remove_index_from_shared_memory_array(char* arr, int index, int temp_length, int threadId, int word_length) { for (int i = word_length * threadId; i < word_length * threadId + temp_length - 1; i++) { //printf("thread_id = %d | arr[%d] = %d | index = %d\n", threadId, i, arr[i], index); if (i >= index) { //printf("thread_id = %d | arr[%d] = %d | index = %d | arr[%d] = %c | arr[%d] = %c\n", threadId, i, arr[i], index, i, arr[i], i+1, arr[i+1]); arr[i] = arr[i + 1]; } } } __global__ void find_all_permutations_kernel_shared_memory(char* word, int word_length, unsigned long long num_perm, char* permutations) { extern __shared__ char temp_word[ ]; unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; // populate shared memory with word for (int j = beg * word_length; j < beg * word_length + word_length; j++) { //printf("temp[%d] = %c\n", j, word[j % word_length]); temp_word[j] = word[j % word_length]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; int true_index = index + beg * word_length; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, true_index, temp_word[true_index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp_word[true_index]; permutations_index++; // remove temp[index] char* ptr_to_smem = (char *) temp_word; remove_index_from_shared_memory_array(ptr_to_smem, true_index, temp_length, beg, word_length); temp_length--; } } } __global__ void find_all_permutations_kernel(char* word, int word_length, unsigned long long num_perm, char* permutations) { unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; char temp[12]; for (int j = 0; j < word_length; j++) { temp[j] = word[j]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, index, temp[index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp[index]; permutations_index++; // remove temp[index] remove_index_from_array(temp, index, temp_length); temp_length--; } } } void generateWord(char* word, int* word_length); char* find_all_permutations(int blockSize, int blockNum, int word_length) { // ALLOCATE float elapsed = 0; hipEvent_t start, stop; char* word = (char *) malloc(word_length * sizeof(char)); unsigned long long num_perm = 1; for (int k = 1; k <= word_length; num_perm *= k++); // generate word given length generateWord(word, &word_length); printf("Word = %s\n", word); printf("word length %d\n", word_length); // this will contain all of the permutations of the word above char* permutations = (char *) malloc(word_length * num_perm * sizeof(char)); char* cuda_permutations; char* cuda_word; hipEventCreate(&start); hipEventCreate(&stop); hipMalloc((void **) &cuda_permutations, word_length * num_perm * sizeof(char)); hipMalloc((void **) &cuda_word, word_length * sizeof(char)); hipMemcpy(cuda_permutations, permutations, word_length * num_perm * sizeof(char), hipMemcpyHostToDevice); hipMemcpy(cuda_word, word, word_length * sizeof(char), hipMemcpyHostToDevice); hipEventRecord(start, 0); // call kernel find_all_permutations_kernel<<<blockNum, blockSize>>>(cuda_word, word_length, num_perm, cuda_permutations); hipDeviceSynchronize(); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [No shared memory]: %.5f ms\n", elapsed); hipEventRecord(start, 0); // call kernel find_all_permutations_kernel_shared_memory<<<blockNum, blockSize, blockSize * word_length * sizeof(char)>>>(cuda_word, word_length, num_perm, cuda_permutations); hipDeviceSynchronize(); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [Shared memory]: %.5f ms\n", elapsed); hipMemcpy(permutations, cuda_permutations, word_length * num_perm * sizeof(char), hipMemcpyDeviceToHost); // DEALLOCATE hipFree(cuda_permutations); hipFree(cuda_word); hipEventDestroy(start); hipEventDestroy(stop); free(word); return permutations; } /* Generate the random word given a word_length */ void generateWord(char* word, int* word_length) { int rand_num; const char capital_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (*word_length <= 0) { printf("Invalid size. Defaulting to size 10.\n"); *word_length = 10; } for (int i = 0; i < *word_length; i++) { rand_num = rand() % (sizeof(capital_letters) - 1); word[i] = capital_letters[rand_num]; } }
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include <vector> #include <iostream> #include <fstream> __device__ void remove_index_from_array(char* arr, int index, int temp_length) { for (int i = 0; i < temp_length - 1; i++) { if (i >= index) { arr[i] = arr[i+1]; } } } __device__ void remove_index_from_shared_memory_array(char* arr, int index, int temp_length, int threadId, int word_length) { for (int i = word_length * threadId; i < word_length * threadId + temp_length - 1; i++) { //printf("thread_id = %d | arr[%d] = %d | index = %d\n", threadId, i, arr[i], index); if (i >= index) { //printf("thread_id = %d | arr[%d] = %d | index = %d | arr[%d] = %c | arr[%d] = %c\n", threadId, i, arr[i], index, i, arr[i], i+1, arr[i+1]); arr[i] = arr[i + 1]; } } } __global__ void find_all_permutations_kernel_shared_memory(char* word, int word_length, unsigned long long num_perm, char* permutations) { extern __shared__ char temp_word[ ]; unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; // populate shared memory with word for (int j = beg * word_length; j < beg * word_length + word_length; j++) { //printf("temp[%d] = %c\n", j, word[j % word_length]); temp_word[j] = word[j % word_length]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; int true_index = index + beg * word_length; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, true_index, temp_word[true_index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp_word[true_index]; permutations_index++; // remove temp[index] char* ptr_to_smem = (char *) temp_word; remove_index_from_shared_memory_array(ptr_to_smem, true_index, temp_length, beg, word_length); temp_length--; } } } __global__ void find_all_permutations_kernel(char* word, int word_length, unsigned long long num_perm, char* permutations) { unsigned long long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long long thread_num = blockDim.x * gridDim.x; unsigned long long warp_id = thread_id / 32; unsigned long long warp_num = thread_num % 32 == 0 ? thread_num / 32 : thread_num / 32 + 1; unsigned long long load = num_perm % warp_num == 0 ? num_perm / warp_num : num_perm / warp_num + 1; unsigned long long beg = load * warp_id; unsigned long long end = min(num_perm, beg + load); unsigned long long lane = thread_id % 32; beg += lane; for(int i = beg; i < end; i += 32) { //char* temp = word; unsigned long long divisor = num_perm; int temp_length = word_length; char temp[12]; for (int j = 0; j < word_length; j++) { temp[j] = word[j]; } //printf("divisor = %llu | num_perm = %llu | word_length %d\n", divisor, num_perm, word_length); unsigned long long permutations_index = 0; for (int digit = word_length; digit > 0; digit--) { //printf("divisor before = %llu, digit = %d\n", divisor, digit); divisor /= digit; //printf("divisor after = %llu\n", divisor); unsigned long long t = i / divisor; int index = t % digit; //printf("permutations[%llu] = temp[%d] = %c | divisor = %llu | digit = %d | t = %llu\n", i*word_length + permutations_index, index, temp[index], divisor, digit, t); permutations[i*word_length + permutations_index] = temp[index]; permutations_index++; // remove temp[index] remove_index_from_array(temp, index, temp_length); temp_length--; } } } void generateWord(char* word, int* word_length); char* find_all_permutations(int blockSize, int blockNum, int word_length) { // ALLOCATE float elapsed = 0; hipEvent_t start, stop; char* word = (char *) malloc(word_length * sizeof(char)); unsigned long long num_perm = 1; for (int k = 1; k <= word_length; num_perm *= k++); // generate word given length generateWord(word, &word_length); printf("Word = %s\n", word); printf("word length %d\n", word_length); // this will contain all of the permutations of the word above char* permutations = (char *) malloc(word_length * num_perm * sizeof(char)); char* cuda_permutations; char* cuda_word; hipEventCreate(&start); hipEventCreate(&stop); hipMalloc((void **) &cuda_permutations, word_length * num_perm * sizeof(char)); hipMalloc((void **) &cuda_word, word_length * sizeof(char)); hipMemcpy(cuda_permutations, permutations, word_length * num_perm * sizeof(char), hipMemcpyHostToDevice); hipMemcpy(cuda_word, word, word_length * sizeof(char), hipMemcpyHostToDevice); hipEventRecord(start, 0); // call kernel find_all_permutations_kernel<<<blockNum, blockSize>>>(cuda_word, word_length, num_perm, cuda_permutations); hipDeviceSynchronize(); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [No shared memory]: %.5f ms\n", elapsed); hipEventRecord(start, 0); // call kernel find_all_permutations_kernel_shared_memory<<<blockNum, blockSize, blockSize * word_length * sizeof(char)>>>(cuda_word, word_length, num_perm, cuda_permutations); hipDeviceSynchronize(); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&elapsed, start, stop); printf("Elapsed time [Shared memory]: %.5f ms\n", elapsed); hipMemcpy(permutations, cuda_permutations, word_length * num_perm * sizeof(char), hipMemcpyDeviceToHost); // DEALLOCATE hipFree(cuda_permutations); hipFree(cuda_word); hipEventDestroy(start); hipEventDestroy(stop); free(word); return permutations; } /* Generate the random word given a word_length */ void generateWord(char* word, int* word_length) { int rand_num; const char capital_letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (*word_length <= 0) { printf("Invalid size. Defaulting to size 10.\n"); *word_length = 10; } for (int i = 0; i < *word_length; i++) { rand_num = rand() % (sizeof(capital_letters) - 1); word[i] = capital_letters[rand_num]; } }
.text .file "permutations.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ # -- Begin function _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .p2align 4, 0x90 .type _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_,@function _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_: # @_Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 4(%rsp) movq %rdx, 64(%rsp) movq %rcx, 56(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%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 $_Z42find_all_permutations_kernel_shared_memoryPciyS_, %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 _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_, .Lfunc_end0-_Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .cfi_endproc # -- End function .globl _Z43__device_stub__find_all_permutations_kernelPciyS_ # -- Begin function _Z43__device_stub__find_all_permutations_kernelPciyS_ .p2align 4, 0x90 .type _Z43__device_stub__find_all_permutations_kernelPciyS_,@function _Z43__device_stub__find_all_permutations_kernelPciyS_: # @_Z43__device_stub__find_all_permutations_kernelPciyS_ .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 4(%rsp) movq %rdx, 64(%rsp) movq %rcx, 56(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%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 $_Z28find_all_permutations_kernelPciyS_, %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_end1: .size _Z43__device_stub__find_all_permutations_kernelPciyS_, .Lfunc_end1-_Z43__device_stub__find_all_permutations_kernelPciyS_ .cfi_endproc # -- End function .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 # -- Begin function _Z21find_all_permutationsiii .LCPI2_0: .byte 65 # 0x41 .byte 66 # 0x42 .byte 67 # 0x43 .byte 68 # 0x44 .byte 69 # 0x45 .byte 70 # 0x46 .byte 71 # 0x47 .byte 72 # 0x48 .byte 73 # 0x49 .byte 74 # 0x4a .byte 75 # 0x4b .byte 76 # 0x4c .byte 77 # 0x4d .byte 78 # 0x4e .byte 79 # 0x4f .byte 80 # 0x50 .text .globl _Z21find_all_permutationsiii .p2align 4, 0x90 .type _Z21find_all_permutationsiii,@function _Z21find_all_permutationsiii: # @_Z21find_all_permutationsiii .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 $184, %rsp .cfi_def_cfa_offset 240 .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, %r14d movl %esi, 120(%rsp) # 4-byte Spill movl %edi, %ebp movl $0, 4(%rsp) movslq %edx, %r15 movq %r15, %rdi callq malloc movq %rax, %rbx testl %r15d, %r15d jle .LBB2_1 # %bb.11: # %.lr.ph.preheader leal 1(%r14), %eax movl $1, %ecx movl $1, %r12d .p2align 4, 0x90 .LBB2_12: # %.lr.ph # =>This Inner Loop Header: Depth=1 imulq %rcx, %r12 incq %rcx cmpq %rcx, %rax jne .LBB2_12 jmp .LBB2_2 .LBB2_1: movl $1, %r12d .LBB2_2: # %._crit_edge movl %ebp, 124(%rsp) # 4-byte Spill movaps .LCPI2_0(%rip), %xmm0 # xmm0 = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] movaps %xmm0, 128(%rsp) movabsq $6365651522798441041, %rax # imm = 0x5857565554535251 movq %rax, 144(%rsp) movw $23129, 152(%rsp) # imm = 0x5A59 movb $0, 154(%rsp) testl %r14d, %r14d jg .LBB2_4 # %bb.3: movl $.Lstr, %edi callq puts@PLT movl $10, %r14d .LBB2_4: cmpl $1, %r14d movl %r14d, %r15d adcl $0, %r15d xorl %ebp, %ebp movabsq $5675921253449092805, %r13 # imm = 0x4EC4EC4EC4EC4EC5 .p2align 4, 0x90 .LBB2_5: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 callq rand movslq %eax, %rcx movq %rcx, %rax mulq %r13 shrq $3, %rdx leaq (%rdx,%rdx,4), %rax leaq (%rax,%rax,4), %rax addq %rdx, %rax subq %rax, %rcx movzbl 128(%rsp,%rcx), %eax movb %al, (%rbx,%rbp) incq %rbp cmpq %rbp, %r15 jne .LBB2_5 # %bb.6: # %_Z12generateWordPcPi.exit movl $.L.str, %edi movq %rbx, %rsi xorl %eax, %eax callq printf movl $.L.str.1, %edi movl %r14d, %esi xorl %eax, %eax callq printf movl %r14d, %r15d movq %r12, %rbp imulq %r15, %rbp movq %rbp, %rdi callq malloc movq %rax, %r13 leaq 32(%rsp), %rdi callq hipEventCreate leaq 8(%rsp), %rdi callq hipEventCreate leaq 24(%rsp), %rdi movq %rbp, %rsi callq hipMalloc leaq 40(%rsp), %rdi movq %r15, %rsi callq hipMalloc movq 24(%rsp), %rdi movq %r13, 176(%rsp) # 8-byte Spill movq %r13, %rsi movq %rbp, 168(%rsp) # 8-byte Spill movq %rbp, %rdx movl $1, %ecx callq hipMemcpy movq 40(%rsp), %rdi movq %rbx, %rsi movq %r15, %rdx movl $1, %ecx callq hipMemcpy movq 32(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movl 120(%rsp), %r13d # 4-byte Reload movabsq $4294967296, %rax # imm = 0x100000000 orq %rax, %r13 movl 124(%rsp), %ebp # 4-byte Reload movl %ebp, %r15d orq %rax, %r15 movq %r13, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_8 # %bb.7: movq 40(%rsp), %rax movq 24(%rsp), %rcx movq %rax, 112(%rsp) movl %r14d, 20(%rsp) movq %r12, 104(%rsp) movq %rcx, 96(%rsp) leaq 112(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 104(%rsp), %rax movq %rax, 144(%rsp) leaq 96(%rsp), %rax movq %rax, 152(%rsp) leaq 80(%rsp), %rdi leaq 64(%rsp), %rsi leaq 56(%rsp), %rdx leaq 48(%rsp), %rcx callq __hipPopCallConfiguration movq 80(%rsp), %rsi movl 88(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z28find_all_permutations_kernelPciyS_, %edi pushq 48(%rsp) .cfi_adjust_cfa_offset 8 pushq 64(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_8: callq hipDeviceSynchronize movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 32(%rsp), %rsi movq 8(%rsp), %rdx leaq 4(%rsp), %rdi callq hipEventElapsedTime movss 4(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf movq 32(%rsp), %rdi xorl %esi, %esi callq hipEventRecord imull %r14d, %ebp movslq %ebp, %r8 movq %r13, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_10 # %bb.9: movq 40(%rsp), %rax movq 24(%rsp), %rcx movq %rax, 112(%rsp) movl %r14d, 20(%rsp) movq %r12, 104(%rsp) movq %rcx, 96(%rsp) leaq 112(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 104(%rsp), %rax movq %rax, 144(%rsp) leaq 96(%rsp), %rax movq %rax, 152(%rsp) leaq 80(%rsp), %rdi leaq 64(%rsp), %rsi leaq 56(%rsp), %rdx leaq 48(%rsp), %rcx callq __hipPopCallConfiguration movq 80(%rsp), %rsi movl 88(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z42find_all_permutations_kernel_shared_memoryPciyS_, %edi pushq 48(%rsp) .cfi_adjust_cfa_offset 8 pushq 64(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_10: callq hipDeviceSynchronize movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 32(%rsp), %rsi movq 8(%rsp), %rdx leaq 4(%rsp), %rdi callq hipEventElapsedTime movss 4(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.3, %edi movb $1, %al callq printf movq 24(%rsp), %rsi movq 176(%rsp), %r14 # 8-byte Reload movq %r14, %rdi movq 168(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy movq 24(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 32(%rsp), %rdi callq hipEventDestroy movq 8(%rsp), %rdi callq hipEventDestroy movq %rbx, %rdi callq free movq %r14, %rax addq $184, %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 .Lfunc_end2: .size _Z21find_all_permutationsiii, .Lfunc_end2-_Z21find_all_permutationsiii .cfi_endproc # -- End function .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 # -- Begin function _Z12generateWordPcPi .LCPI3_0: .byte 65 # 0x41 .byte 66 # 0x42 .byte 67 # 0x43 .byte 68 # 0x44 .byte 69 # 0x45 .byte 70 # 0x46 .byte 71 # 0x47 .byte 72 # 0x48 .byte 73 # 0x49 .byte 74 # 0x4a .byte 75 # 0x4b .byte 76 # 0x4c .byte 77 # 0x4d .byte 78 # 0x4e .byte 79 # 0x4f .byte 80 # 0x50 .text .globl _Z12generateWordPcPi .p2align 4, 0x90 .type _Z12generateWordPcPi,@function _Z12generateWordPcPi: # @_Z12generateWordPcPi .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $40, %rsp .cfi_def_cfa_offset 80 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movq %rsi, %rbx movq %rdi, %r14 movaps .LCPI3_0(%rip), %xmm0 # xmm0 = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] movaps %xmm0, (%rsp) movabsq $6365651522798441041, %rax # imm = 0x5857565554535251 movq %rax, 16(%rsp) movw $23129, 24(%rsp) # imm = 0x5A59 movb $0, 26(%rsp) cmpl $0, (%rsi) jg .LBB3_2 # %bb.1: movl $.Lstr, %edi callq puts@PLT movl $10, (%rbx) .LBB3_2: cmpl $0, (%rbx) jle .LBB3_5 # %bb.3: # %.lr.ph.preheader xorl %r15d, %r15d movabsq $5675921253449092805, %r12 # imm = 0x4EC4EC4EC4EC4EC5 .p2align 4, 0x90 .LBB3_4: # %.lr.ph # =>This Inner Loop Header: Depth=1 callq rand movslq %eax, %rcx movq %rcx, %rax mulq %r12 shrq $3, %rdx leaq (%rdx,%rdx,4), %rax leaq (%rax,%rax,4), %rax addq %rdx, %rax subq %rax, %rcx movzbl (%rsp,%rcx), %eax movb %al, (%r14,%r15) incq %r15 movslq (%rbx), %rax cmpq %rax, %r15 jl .LBB3_4 .LBB3_5: # %._crit_edge addq $40, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size _Z12generateWordPcPi, .Lfunc_end3-_Z12generateWordPcPi .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 $_Z42find_all_permutations_kernel_shared_memoryPciyS_, %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 $_Z28find_all_permutations_kernelPciyS_, %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 _Z42find_all_permutations_kernel_shared_memoryPciyS_,@object # @_Z42find_all_permutations_kernel_shared_memoryPciyS_ .section .rodata,"a",@progbits .globl _Z42find_all_permutations_kernel_shared_memoryPciyS_ .p2align 3, 0x0 _Z42find_all_permutations_kernel_shared_memoryPciyS_: .quad _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .size _Z42find_all_permutations_kernel_shared_memoryPciyS_, 8 .type _Z28find_all_permutations_kernelPciyS_,@object # @_Z28find_all_permutations_kernelPciyS_ .globl _Z28find_all_permutations_kernelPciyS_ .p2align 3, 0x0 _Z28find_all_permutations_kernelPciyS_: .quad _Z43__device_stub__find_all_permutations_kernelPciyS_ .size _Z28find_all_permutations_kernelPciyS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Word = %s\n" .size .L.str, 11 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "word length %d\n" .size .L.str.1, 16 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Elapsed time [No shared memory]: %.5f ms\n" .size .L.str.2, 42 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Elapsed time [Shared memory]: %.5f ms\n" .size .L.str.3, 39 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z42find_all_permutations_kernel_shared_memoryPciyS_" .size .L__unnamed_1, 53 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z28find_all_permutations_kernelPciyS_" .size .L__unnamed_2, 39 .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 "Invalid size. Defaulting to size 10." .size .Lstr, 37 .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 _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .addrsig_sym _Z43__device_stub__find_all_permutations_kernelPciyS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z42find_all_permutations_kernel_shared_memoryPciyS_ .addrsig_sym _Z28find_all_permutations_kernelPciyS_ .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_000679e3_00000000-6_permutations.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB4169: .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 .LFE4169: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z23remove_index_from_arrayPcii .type _Z23remove_index_from_arrayPcii, @function _Z23remove_index_from_arrayPcii: .LFB4163: .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 .LFE4163: .size _Z23remove_index_from_arrayPcii, .-_Z23remove_index_from_arrayPcii .globl _Z37remove_index_from_shared_memory_arrayPciiii .type _Z37remove_index_from_shared_memory_arrayPciiii, @function _Z37remove_index_from_shared_memory_arrayPciiii: .LFB4164: .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 .LFE4164: .size _Z37remove_index_from_shared_memory_arrayPciiii, .-_Z37remove_index_from_shared_memory_arrayPciiii .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Invalid size. Defaulting to size 10.\n" .text .globl _Z12generateWordPcPi .type _Z12generateWordPcPi, @function _Z12generateWordPcPi: .LFB4166: .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 $56, %rsp .cfi_def_cfa_offset 96 movq %rdi, %r12 movq %rsi, %rbp movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax movabsq $5208208757389214273, %rax movabsq $5786930140093827657, %rdx movq %rax, (%rsp) movq %rdx, 8(%rsp) movabsq $6003950658608057676, %rax movabsq $25430983861228884, %rdx movq %rax, 11(%rsp) movq %rdx, 19(%rsp) cmpl $0, (%rsi) jle .L14 .L8: movl $0, %ebx movabsq $5675921253449092805, %r13 .L9: call rand@PLT movslq %eax, %rcx movq %rcx, %rax mulq %r13 shrq $3, %rdx leaq (%rdx,%rdx,2), %rax leaq (%rdx,%rax,4), %rax addq %rax, %rax subq %rax, %rcx movslq %ecx, %rcx movzbl (%rsp,%rcx), %eax movb %al, (%r12,%rbx) addq $1, %rbx cmpl %ebx, 0(%rbp) jg .L9 movq 40(%rsp), %rax subq %fs:40, %rax jne .L15 addq $56, %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 .L14: .cfi_restore_state leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $10, 0(%rbp) jmp .L8 .L15: call __stack_chk_fail@PLT .cfi_endproc .LFE4166: .size _Z12generateWordPcPi, .-_Z12generateWordPcPi .globl _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ .type _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_, @function _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_: .LFB4191: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movq %rdx, 8(%rsp) movq %rcx, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) movq %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 .L20 .L16: movq 136(%rsp), %rax subq %fs:40, %rax jne .L21 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L20: .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 _Z42find_all_permutations_kernel_shared_memoryPciyS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L16 .L21: call __stack_chk_fail@PLT .cfi_endproc .LFE4191: .size _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_, .-_Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ .globl _Z42find_all_permutations_kernel_shared_memoryPciyS_ .type _Z42find_all_permutations_kernel_shared_memoryPciyS_, @function _Z42find_all_permutations_kernel_shared_memoryPciyS_: .LFB4192: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE4192: .size _Z42find_all_permutations_kernel_shared_memoryPciyS_, .-_Z42find_all_permutations_kernel_shared_memoryPciyS_ .globl _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ .type _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_, @function _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_: .LFB4193: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movq %rdx, 8(%rsp) movq %rcx, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) movq %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 .L28 .L24: movq 136(%rsp), %rax subq %fs:40, %rax jne .L29 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L28: .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 _Z28find_all_permutations_kernelPciyS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L24 .L29: call __stack_chk_fail@PLT .cfi_endproc .LFE4193: .size _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_, .-_Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ .globl _Z28find_all_permutations_kernelPciyS_ .type _Z28find_all_permutations_kernelPciyS_, @function _Z28find_all_permutations_kernelPciyS_: .LFB4194: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE4194: .size _Z28find_all_permutations_kernelPciyS_, .-_Z28find_all_permutations_kernelPciyS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC2: .string "Word = %s\n" .LC3: .string "word length %d\n" .section .rodata.str1.8 .align 8 .LC4: .string "Elapsed time [No shared memory]: %.5f ms\n" .align 8 .LC5: .string "Elapsed time [Shared memory]: %.5f ms\n" .text .globl _Z21find_all_permutationsiii .type _Z21find_all_permutationsiii, @function _Z21find_all_permutationsiii: .LFB4165: .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 movl %edi, %ebp movl %esi, 8(%rsp) movl %edx, %ebx movl %edx, 12(%rsp) movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax movl $0x00000000, 28(%rsp) movslq %edx, %rdi call malloc@PLT movq %rax, %r12 testl %ebx, %ebx jle .L38 leal 1(%rbx), %edx movl $1, %eax movl $1, %ebx .L34: imulq %rax, %rbx addq $1, %rax cmpq %rdx, %rax jne .L34 .L33: leaq 12(%rsp), %rsi movq %r12, %rdi call _Z12generateWordPcPi movq %r12, %rdx leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl 12(%rsp), %r14d movl %r14d, %edx leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movslq %r14d, %r15 movq %r15, %r13 imulq %rbx, %r13 movq %r13, %rdi call malloc@PLT movq %rax, (%rsp) leaq 32(%rsp), %rdi call cudaEventCreate@PLT leaq 40(%rsp), %rdi call cudaEventCreate@PLT leaq 48(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 56(%rsp), %rdi movq %r15, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r13, %rdx movq (%rsp), %rsi movq 48(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r15, %rdx movq %r12, %rsi movq 56(%rsp), %rdi call cudaMemcpy@PLT movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movl %ebp, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl 8(%rsp), %eax movl %eax, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) movl $0, %r9d movl $0, %r8d movq 76(%rsp), %rdx movl $1, %ecx movq 64(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L41 .L35: call cudaDeviceSynchronize@PLT movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 28(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 28(%rsp), %xmm0 leaq .LC4(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movl %ebp, 76(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl 8(%rsp), %eax movl %eax, 64(%rsp) movl $1, 68(%rsp) movl $1, 72(%rsp) imull %r14d, %ebp movl $0, %r9d movslq %ebp, %r8 movq 76(%rsp), %rdx movl $1, %ecx movq 64(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L42 .L36: call cudaDeviceSynchronize@PLT movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 28(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 28(%rsp), %xmm0 leaq .LC5(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $2, %ecx movq %r13, %rdx movq 48(%rsp), %rsi movq (%rsp), %rdi call cudaMemcpy@PLT movq 48(%rsp), %rdi call cudaFree@PLT movq 56(%rsp), %rdi call cudaFree@PLT movq 32(%rsp), %rdi call cudaEventDestroy@PLT movq 40(%rsp), %rdi call cudaEventDestroy@PLT movq %r12, %rdi call free@PLT movq 88(%rsp), %rax subq %fs:40, %rax jne .L43 movq (%rsp), %rax 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 .L38: .cfi_restore_state movl $1, %ebx jmp .L33 .L41: movq 48(%rsp), %rcx movq %rbx, %rdx movl %r14d, %esi movq 56(%rsp), %rdi call _Z52__device_stub__Z28find_all_permutations_kernelPciyS_PciyS_ jmp .L35 .L42: movq 48(%rsp), %rcx movq %rbx, %rdx movl %r14d, %esi movq 56(%rsp), %rdi call _Z66__device_stub__Z42find_all_permutations_kernel_shared_memoryPciyS_PciyS_ jmp .L36 .L43: call __stack_chk_fail@PLT .cfi_endproc .LFE4165: .size _Z21find_all_permutationsiii, .-_Z21find_all_permutationsiii .section .rodata.str1.8 .align 8 .LC6: .string "_Z28find_all_permutations_kernelPciyS_" .align 8 .LC7: .string "_Z42find_all_permutations_kernel_shared_memoryPciyS_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB4196: .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 .LC6(%rip), %rdx movq %rdx, %rcx leaq _Z28find_all_permutations_kernelPciyS_(%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 .LC7(%rip), %rdx movq %rdx, %rcx leaq _Z42find_all_permutations_kernel_shared_memoryPciyS_(%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 .LFE4196: .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 "permutations.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ # -- Begin function _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .p2align 4, 0x90 .type _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_,@function _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_: # @_Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 4(%rsp) movq %rdx, 64(%rsp) movq %rcx, 56(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%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 $_Z42find_all_permutations_kernel_shared_memoryPciyS_, %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 _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_, .Lfunc_end0-_Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .cfi_endproc # -- End function .globl _Z43__device_stub__find_all_permutations_kernelPciyS_ # -- Begin function _Z43__device_stub__find_all_permutations_kernelPciyS_ .p2align 4, 0x90 .type _Z43__device_stub__find_all_permutations_kernelPciyS_,@function _Z43__device_stub__find_all_permutations_kernelPciyS_: # @_Z43__device_stub__find_all_permutations_kernelPciyS_ .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 4(%rsp) movq %rdx, 64(%rsp) movq %rcx, 56(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 4(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%rsp), %rax movq %rax, 96(%rsp) leaq 56(%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 $_Z28find_all_permutations_kernelPciyS_, %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_end1: .size _Z43__device_stub__find_all_permutations_kernelPciyS_, .Lfunc_end1-_Z43__device_stub__find_all_permutations_kernelPciyS_ .cfi_endproc # -- End function .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 # -- Begin function _Z21find_all_permutationsiii .LCPI2_0: .byte 65 # 0x41 .byte 66 # 0x42 .byte 67 # 0x43 .byte 68 # 0x44 .byte 69 # 0x45 .byte 70 # 0x46 .byte 71 # 0x47 .byte 72 # 0x48 .byte 73 # 0x49 .byte 74 # 0x4a .byte 75 # 0x4b .byte 76 # 0x4c .byte 77 # 0x4d .byte 78 # 0x4e .byte 79 # 0x4f .byte 80 # 0x50 .text .globl _Z21find_all_permutationsiii .p2align 4, 0x90 .type _Z21find_all_permutationsiii,@function _Z21find_all_permutationsiii: # @_Z21find_all_permutationsiii .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 $184, %rsp .cfi_def_cfa_offset 240 .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, %r14d movl %esi, 120(%rsp) # 4-byte Spill movl %edi, %ebp movl $0, 4(%rsp) movslq %edx, %r15 movq %r15, %rdi callq malloc movq %rax, %rbx testl %r15d, %r15d jle .LBB2_1 # %bb.11: # %.lr.ph.preheader leal 1(%r14), %eax movl $1, %ecx movl $1, %r12d .p2align 4, 0x90 .LBB2_12: # %.lr.ph # =>This Inner Loop Header: Depth=1 imulq %rcx, %r12 incq %rcx cmpq %rcx, %rax jne .LBB2_12 jmp .LBB2_2 .LBB2_1: movl $1, %r12d .LBB2_2: # %._crit_edge movl %ebp, 124(%rsp) # 4-byte Spill movaps .LCPI2_0(%rip), %xmm0 # xmm0 = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] movaps %xmm0, 128(%rsp) movabsq $6365651522798441041, %rax # imm = 0x5857565554535251 movq %rax, 144(%rsp) movw $23129, 152(%rsp) # imm = 0x5A59 movb $0, 154(%rsp) testl %r14d, %r14d jg .LBB2_4 # %bb.3: movl $.Lstr, %edi callq puts@PLT movl $10, %r14d .LBB2_4: cmpl $1, %r14d movl %r14d, %r15d adcl $0, %r15d xorl %ebp, %ebp movabsq $5675921253449092805, %r13 # imm = 0x4EC4EC4EC4EC4EC5 .p2align 4, 0x90 .LBB2_5: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 callq rand movslq %eax, %rcx movq %rcx, %rax mulq %r13 shrq $3, %rdx leaq (%rdx,%rdx,4), %rax leaq (%rax,%rax,4), %rax addq %rdx, %rax subq %rax, %rcx movzbl 128(%rsp,%rcx), %eax movb %al, (%rbx,%rbp) incq %rbp cmpq %rbp, %r15 jne .LBB2_5 # %bb.6: # %_Z12generateWordPcPi.exit movl $.L.str, %edi movq %rbx, %rsi xorl %eax, %eax callq printf movl $.L.str.1, %edi movl %r14d, %esi xorl %eax, %eax callq printf movl %r14d, %r15d movq %r12, %rbp imulq %r15, %rbp movq %rbp, %rdi callq malloc movq %rax, %r13 leaq 32(%rsp), %rdi callq hipEventCreate leaq 8(%rsp), %rdi callq hipEventCreate leaq 24(%rsp), %rdi movq %rbp, %rsi callq hipMalloc leaq 40(%rsp), %rdi movq %r15, %rsi callq hipMalloc movq 24(%rsp), %rdi movq %r13, 176(%rsp) # 8-byte Spill movq %r13, %rsi movq %rbp, 168(%rsp) # 8-byte Spill movq %rbp, %rdx movl $1, %ecx callq hipMemcpy movq 40(%rsp), %rdi movq %rbx, %rsi movq %r15, %rdx movl $1, %ecx callq hipMemcpy movq 32(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movl 120(%rsp), %r13d # 4-byte Reload movabsq $4294967296, %rax # imm = 0x100000000 orq %rax, %r13 movl 124(%rsp), %ebp # 4-byte Reload movl %ebp, %r15d orq %rax, %r15 movq %r13, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_8 # %bb.7: movq 40(%rsp), %rax movq 24(%rsp), %rcx movq %rax, 112(%rsp) movl %r14d, 20(%rsp) movq %r12, 104(%rsp) movq %rcx, 96(%rsp) leaq 112(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 104(%rsp), %rax movq %rax, 144(%rsp) leaq 96(%rsp), %rax movq %rax, 152(%rsp) leaq 80(%rsp), %rdi leaq 64(%rsp), %rsi leaq 56(%rsp), %rdx leaq 48(%rsp), %rcx callq __hipPopCallConfiguration movq 80(%rsp), %rsi movl 88(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z28find_all_permutations_kernelPciyS_, %edi pushq 48(%rsp) .cfi_adjust_cfa_offset 8 pushq 64(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_8: callq hipDeviceSynchronize movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 32(%rsp), %rsi movq 8(%rsp), %rdx leaq 4(%rsp), %rdi callq hipEventElapsedTime movss 4(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf movq 32(%rsp), %rdi xorl %esi, %esi callq hipEventRecord imull %r14d, %ebp movslq %ebp, %r8 movq %r13, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_10 # %bb.9: movq 40(%rsp), %rax movq 24(%rsp), %rcx movq %rax, 112(%rsp) movl %r14d, 20(%rsp) movq %r12, 104(%rsp) movq %rcx, 96(%rsp) leaq 112(%rsp), %rax movq %rax, 128(%rsp) leaq 20(%rsp), %rax movq %rax, 136(%rsp) leaq 104(%rsp), %rax movq %rax, 144(%rsp) leaq 96(%rsp), %rax movq %rax, 152(%rsp) leaq 80(%rsp), %rdi leaq 64(%rsp), %rsi leaq 56(%rsp), %rdx leaq 48(%rsp), %rcx callq __hipPopCallConfiguration movq 80(%rsp), %rsi movl 88(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z42find_all_permutations_kernel_shared_memoryPciyS_, %edi pushq 48(%rsp) .cfi_adjust_cfa_offset 8 pushq 64(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_10: callq hipDeviceSynchronize movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 32(%rsp), %rsi movq 8(%rsp), %rdx leaq 4(%rsp), %rdi callq hipEventElapsedTime movss 4(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.3, %edi movb $1, %al callq printf movq 24(%rsp), %rsi movq 176(%rsp), %r14 # 8-byte Reload movq %r14, %rdi movq 168(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy movq 24(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 32(%rsp), %rdi callq hipEventDestroy movq 8(%rsp), %rdi callq hipEventDestroy movq %rbx, %rdi callq free movq %r14, %rax addq $184, %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 .Lfunc_end2: .size _Z21find_all_permutationsiii, .Lfunc_end2-_Z21find_all_permutationsiii .cfi_endproc # -- End function .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 # -- Begin function _Z12generateWordPcPi .LCPI3_0: .byte 65 # 0x41 .byte 66 # 0x42 .byte 67 # 0x43 .byte 68 # 0x44 .byte 69 # 0x45 .byte 70 # 0x46 .byte 71 # 0x47 .byte 72 # 0x48 .byte 73 # 0x49 .byte 74 # 0x4a .byte 75 # 0x4b .byte 76 # 0x4c .byte 77 # 0x4d .byte 78 # 0x4e .byte 79 # 0x4f .byte 80 # 0x50 .text .globl _Z12generateWordPcPi .p2align 4, 0x90 .type _Z12generateWordPcPi,@function _Z12generateWordPcPi: # @_Z12generateWordPcPi .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $40, %rsp .cfi_def_cfa_offset 80 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movq %rsi, %rbx movq %rdi, %r14 movaps .LCPI3_0(%rip), %xmm0 # xmm0 = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80] movaps %xmm0, (%rsp) movabsq $6365651522798441041, %rax # imm = 0x5857565554535251 movq %rax, 16(%rsp) movw $23129, 24(%rsp) # imm = 0x5A59 movb $0, 26(%rsp) cmpl $0, (%rsi) jg .LBB3_2 # %bb.1: movl $.Lstr, %edi callq puts@PLT movl $10, (%rbx) .LBB3_2: cmpl $0, (%rbx) jle .LBB3_5 # %bb.3: # %.lr.ph.preheader xorl %r15d, %r15d movabsq $5675921253449092805, %r12 # imm = 0x4EC4EC4EC4EC4EC5 .p2align 4, 0x90 .LBB3_4: # %.lr.ph # =>This Inner Loop Header: Depth=1 callq rand movslq %eax, %rcx movq %rcx, %rax mulq %r12 shrq $3, %rdx leaq (%rdx,%rdx,4), %rax leaq (%rax,%rax,4), %rax addq %rdx, %rax subq %rax, %rcx movzbl (%rsp,%rcx), %eax movb %al, (%r14,%r15) incq %r15 movslq (%rbx), %rax cmpq %rax, %r15 jl .LBB3_4 .LBB3_5: # %._crit_edge addq $40, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size _Z12generateWordPcPi, .Lfunc_end3-_Z12generateWordPcPi .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 $_Z42find_all_permutations_kernel_shared_memoryPciyS_, %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 $_Z28find_all_permutations_kernelPciyS_, %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 _Z42find_all_permutations_kernel_shared_memoryPciyS_,@object # @_Z42find_all_permutations_kernel_shared_memoryPciyS_ .section .rodata,"a",@progbits .globl _Z42find_all_permutations_kernel_shared_memoryPciyS_ .p2align 3, 0x0 _Z42find_all_permutations_kernel_shared_memoryPciyS_: .quad _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .size _Z42find_all_permutations_kernel_shared_memoryPciyS_, 8 .type _Z28find_all_permutations_kernelPciyS_,@object # @_Z28find_all_permutations_kernelPciyS_ .globl _Z28find_all_permutations_kernelPciyS_ .p2align 3, 0x0 _Z28find_all_permutations_kernelPciyS_: .quad _Z43__device_stub__find_all_permutations_kernelPciyS_ .size _Z28find_all_permutations_kernelPciyS_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Word = %s\n" .size .L.str, 11 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "word length %d\n" .size .L.str.1, 16 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Elapsed time [No shared memory]: %.5f ms\n" .size .L.str.2, 42 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "Elapsed time [Shared memory]: %.5f ms\n" .size .L.str.3, 39 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z42find_all_permutations_kernel_shared_memoryPciyS_" .size .L__unnamed_1, 53 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z28find_all_permutations_kernelPciyS_" .size .L__unnamed_2, 39 .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 "Invalid size. Defaulting to size 10." .size .Lstr, 37 .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 _Z57__device_stub__find_all_permutations_kernel_shared_memoryPciyS_ .addrsig_sym _Z43__device_stub__find_all_permutations_kernelPciyS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z42find_all_permutations_kernel_shared_memoryPciyS_ .addrsig_sym _Z28find_all_permutations_kernelPciyS_ .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 <stdio.h> #include <stdlib.h> __global__ void gpuVecAdd(float *A, float *B, float *C) { // TODO: write kernel code here int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void init(float *V, int N) { for (int i = 0; i < N; i++) { V[i] = rand() % 100; } } void verify(float *A, float *B, float *C, int N) { for (int i = 0; i < 16384; i++) { if (A[i] + B[i] != C[i]) { printf("Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n", i, A[i], i, B[i], i, C[i]); return; } } printf("Verification success!\n"); } int main() { int N = 16384; float *A = (float*)malloc(sizeof(float) * N); float *B = (float*)malloc(sizeof(float) * N); float *C = (float*)malloc(sizeof(float) * N); init(A, N); init(B, N); // Memory objects of the device float *d_A, *d_B, *d_C; // TODO: allocate memory objects d_A, d_B, and d_C. cudaMalloc(&d_A, sizeof(float) * N); cudaMalloc(&d_B, sizeof(float) * N); cudaMalloc(&d_C, sizeof(float) * N); // TODO: copy "A" to "d_A" (host to device). cudaMemcpy(d_A, A, sizeof(float) * N, cudaMemcpyHostToDevice); // TODO: copy "B" to "d_B" (host to device). cudaMemcpy(d_B, B, sizeof(float) * N, cudaMemcpyHostToDevice); // TODO: launch the kernel. dim3 dimBlock(32, 1); dim3 dimGrid(N/32, 1); gpuVecAdd<<< dimGrid, dimBlock >>> (d_A, d_B, d_C); // TODO: copy "d_C" to "C" (device to host). cudaMemcpy(C, d_C, sizeof(float) * N, cudaMemcpyDeviceToHost); verify(A, B, C, N); // TODO: release d_A, d_B, and d_C. cudaFree(d_A); cudaFree(d_B); cudaFree(d_C); free(A); free(B); free(C); return 0; }
code for sm_80 Function : _Z9gpuVecAddPfS_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 R6, SR_CTAID.X ; /* 0x0000000000067919 */ /* 0x000e220000002500 */ /*0020*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0050*/ IMAD R6, R6, c[0x0][0x0], R3 ; /* 0x0000000006067a24 */ /* 0x001fca00078e0203 */ /*0060*/ IMAD.WIDE R2, R6, R7, c[0x0][0x160] ; /* 0x0000580006027625 */ /* 0x000fc800078e0207 */ /*0070*/ IMAD.WIDE R4, R6.reuse, R7.reuse, c[0x0][0x168] ; /* 0x00005a0006047625 */ /* 0x0c0fe400078e0207 */ /*0080*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea8000c1e1900 */ /*0090*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea2000c1e1900 */ /*00a0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x170] ; /* 0x00005c0006067625 */ /* 0x000fc800078e0207 */ /*00b0*/ FADD R9, R2, R5 ; /* 0x0000000502097221 */ /* 0x004fca0000000000 */ /*00c0*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*00d0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00e0*/ BRA 0xe0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 CUDA host assembly.
#include <stdio.h> #include <stdlib.h> __global__ void gpuVecAdd(float *A, float *B, float *C) { // TODO: write kernel code here int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void init(float *V, int N) { for (int i = 0; i < N; i++) { V[i] = rand() % 100; } } void verify(float *A, float *B, float *C, int N) { for (int i = 0; i < 16384; i++) { if (A[i] + B[i] != C[i]) { printf("Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n", i, A[i], i, B[i], i, C[i]); return; } } printf("Verification success!\n"); } int main() { int N = 16384; float *A = (float*)malloc(sizeof(float) * N); float *B = (float*)malloc(sizeof(float) * N); float *C = (float*)malloc(sizeof(float) * N); init(A, N); init(B, N); // Memory objects of the device float *d_A, *d_B, *d_C; // TODO: allocate memory objects d_A, d_B, and d_C. cudaMalloc(&d_A, sizeof(float) * N); cudaMalloc(&d_B, sizeof(float) * N); cudaMalloc(&d_C, sizeof(float) * N); // TODO: copy "A" to "d_A" (host to device). cudaMemcpy(d_A, A, sizeof(float) * N, cudaMemcpyHostToDevice); // TODO: copy "B" to "d_B" (host to device). cudaMemcpy(d_B, B, sizeof(float) * N, cudaMemcpyHostToDevice); // TODO: launch the kernel. dim3 dimBlock(32, 1); dim3 dimGrid(N/32, 1); gpuVecAdd<<< dimGrid, dimBlock >>> (d_A, d_B, d_C); // TODO: copy "d_C" to "C" (device to host). cudaMemcpy(C, d_C, sizeof(float) * N, cudaMemcpyDeviceToHost); verify(A, B, C, N); // TODO: release d_A, d_B, and d_C. cudaFree(d_A); cudaFree(d_B); cudaFree(d_C); free(A); free(B); free(C); return 0; }
.file "tmpxft_000b4f9a_00000000-6_vec_add.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 _Z4initPfi .type _Z4initPfi, @function _Z4initPfi: .LFB2057: .cfi_startproc endbr64 testl %esi, %esi jle .L8 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 %rdi, %rbx movslq %esi, %rsi leaq (%rdi,%rsi,4), %rbp .L5: call rand@PLT movslq %eax, %rdx imulq $1374389535, %rdx, %rdx sarq $37, %rdx movl %eax, %ecx sarl $31, %ecx subl %ecx, %edx imull $100, %edx, %edx subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 movss %xmm0, (%rbx) addq $4, %rbx cmpq %rbp, %rbx jne .L5 addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L8: .cfi_restore 3 .cfi_restore 6 ret .cfi_endproc .LFE2057: .size _Z4initPfi, .-_Z4initPfi .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "Verification success!\n" .text .globl _Z6verifyPfS_S_i .type _Z6verifyPfS_S_i, @function _Z6verifyPfS_S_i: .LFB2058: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movl $0, %r8d .L15: movss (%rdi,%r8,4), %xmm0 movss (%rsi,%r8,4), %xmm1 movss (%rdx,%r8,4), %xmm2 movaps %xmm0, %xmm3 addss %xmm1, %xmm3 ucomiss %xmm2, %xmm3 jp .L16 jne .L16 addq $1, %r8 cmpq $16384, %r8 jne .L15 leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L11 .L16: movl %r8d, %edx cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm2, %xmm2 cvtss2sd %xmm1, %xmm1 movl %r8d, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $3, %eax call __printf_chk@PLT .L11: addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z6verifyPfS_S_i, .-_Z6verifyPfS_S_i .globl _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ .type _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_, @function _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_: .LFB2084: .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 .L23 .L19: movq 120(%rsp), %rax subq %fs:40, %rax jne .L24 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L23: .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 _Z9gpuVecAddPfS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L19 .L24: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_, .-_Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ .globl _Z9gpuVecAddPfS_S_ .type _Z9gpuVecAddPfS_S_, @function _Z9gpuVecAddPfS_S_: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z9gpuVecAddPfS_S_, .-_Z9gpuVecAddPfS_S_ .globl main .type main, @function main: .LFB2059: .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 $64, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $65536, %edi call malloc@PLT movq %rax, %rbp movl $65536, %edi call malloc@PLT movq %rax, %rbx movl $65536, %edi call malloc@PLT movq %rax, %r12 movl $16384, %esi movq %rbp, %rdi call _Z4initPfi movl $16384, %esi movq %rbx, %rdi call _Z4initPfi leaq 8(%rsp), %rdi movl $65536, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $65536, %esi call cudaMalloc@PLT leaq 24(%rsp), %rdi movl $65536, %esi call cudaMalloc@PLT movl $1, %ecx movl $65536, %edx movq %rbp, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $65536, %edx movq %rbx, %rsi movq 16(%rsp), %rdi call cudaMemcpy@PLT movl $32, 32(%rsp) movl $1, 36(%rsp) movl $512, 44(%rsp) movl $1, 48(%rsp) movl $0, %r9d movl $0, %r8d movq 32(%rsp), %rdx movl $1, %ecx movq 44(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L31 .L28: movl $2, %ecx movl $65536, %edx movq 24(%rsp), %rsi movq %r12, %rdi call cudaMemcpy@PLT movl $16384, %ecx movq %r12, %rdx movq %rbx, %rsi movq %rbp, %rdi call _Z6verifyPfS_S_i movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT movq %rbp, %rdi call free@PLT movq %rbx, %rdi call free@PLT movq %r12, %rdi call free@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L32 movl $0, %eax addq $64, %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 .L31: .cfi_restore_state movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ jmp .L28 .L32: call __stack_chk_fail@PLT .cfi_endproc .LFE2059: .size main, .-main .section .rodata.str1.1 .LC2: .string "_Z9gpuVecAddPfS_S_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2087: .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 _Z9gpuVecAddPfS_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 .LFE2087: .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 <stdio.h> #include <stdlib.h> __global__ void gpuVecAdd(float *A, float *B, float *C) { // TODO: write kernel code here int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void init(float *V, int N) { for (int i = 0; i < N; i++) { V[i] = rand() % 100; } } void verify(float *A, float *B, float *C, int N) { for (int i = 0; i < 16384; i++) { if (A[i] + B[i] != C[i]) { printf("Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n", i, A[i], i, B[i], i, C[i]); return; } } printf("Verification success!\n"); } int main() { int N = 16384; float *A = (float*)malloc(sizeof(float) * N); float *B = (float*)malloc(sizeof(float) * N); float *C = (float*)malloc(sizeof(float) * N); init(A, N); init(B, N); // Memory objects of the device float *d_A, *d_B, *d_C; // TODO: allocate memory objects d_A, d_B, and d_C. cudaMalloc(&d_A, sizeof(float) * N); cudaMalloc(&d_B, sizeof(float) * N); cudaMalloc(&d_C, sizeof(float) * N); // TODO: copy "A" to "d_A" (host to device). cudaMemcpy(d_A, A, sizeof(float) * N, cudaMemcpyHostToDevice); // TODO: copy "B" to "d_B" (host to device). cudaMemcpy(d_B, B, sizeof(float) * N, cudaMemcpyHostToDevice); // TODO: launch the kernel. dim3 dimBlock(32, 1); dim3 dimGrid(N/32, 1); gpuVecAdd<<< dimGrid, dimBlock >>> (d_A, d_B, d_C); // TODO: copy "d_C" to "C" (device to host). cudaMemcpy(C, d_C, sizeof(float) * N, cudaMemcpyDeviceToHost); verify(A, B, C, N); // TODO: release d_A, d_B, and d_C. cudaFree(d_A); cudaFree(d_B); cudaFree(d_C); free(A); free(B); free(C); return 0; }
#include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> __global__ void gpuVecAdd(float *A, float *B, float *C) { // TODO: write kernel code here int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void init(float *V, int N) { for (int i = 0; i < N; i++) { V[i] = rand() % 100; } } void verify(float *A, float *B, float *C, int N) { for (int i = 0; i < 16384; i++) { if (A[i] + B[i] != C[i]) { printf("Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n", i, A[i], i, B[i], i, C[i]); return; } } printf("Verification success!\n"); } int main() { int N = 16384; float *A = (float*)malloc(sizeof(float) * N); float *B = (float*)malloc(sizeof(float) * N); float *C = (float*)malloc(sizeof(float) * N); init(A, N); init(B, N); // Memory objects of the device float *d_A, *d_B, *d_C; // TODO: allocate memory objects d_A, d_B, and d_C. hipMalloc(&d_A, sizeof(float) * N); hipMalloc(&d_B, sizeof(float) * N); hipMalloc(&d_C, sizeof(float) * N); // TODO: copy "A" to "d_A" (host to device). hipMemcpy(d_A, A, sizeof(float) * N, hipMemcpyHostToDevice); // TODO: copy "B" to "d_B" (host to device). hipMemcpy(d_B, B, sizeof(float) * N, hipMemcpyHostToDevice); // TODO: launch the kernel. dim3 dimBlock(32, 1); dim3 dimGrid(N/32, 1); gpuVecAdd<<< dimGrid, dimBlock >>> (d_A, d_B, d_C); // TODO: copy "d_C" to "C" (device to host). hipMemcpy(C, d_C, sizeof(float) * N, hipMemcpyDeviceToHost); verify(A, B, C, N); // TODO: release d_A, d_B, and d_C. hipFree(d_A); hipFree(d_B); hipFree(d_C); free(A); free(B); free(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 <stdio.h> #include <stdlib.h> __global__ void gpuVecAdd(float *A, float *B, float *C) { // TODO: write kernel code here int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void init(float *V, int N) { for (int i = 0; i < N; i++) { V[i] = rand() % 100; } } void verify(float *A, float *B, float *C, int N) { for (int i = 0; i < 16384; i++) { if (A[i] + B[i] != C[i]) { printf("Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n", i, A[i], i, B[i], i, C[i]); return; } } printf("Verification success!\n"); } int main() { int N = 16384; float *A = (float*)malloc(sizeof(float) * N); float *B = (float*)malloc(sizeof(float) * N); float *C = (float*)malloc(sizeof(float) * N); init(A, N); init(B, N); // Memory objects of the device float *d_A, *d_B, *d_C; // TODO: allocate memory objects d_A, d_B, and d_C. hipMalloc(&d_A, sizeof(float) * N); hipMalloc(&d_B, sizeof(float) * N); hipMalloc(&d_C, sizeof(float) * N); // TODO: copy "A" to "d_A" (host to device). hipMemcpy(d_A, A, sizeof(float) * N, hipMemcpyHostToDevice); // TODO: copy "B" to "d_B" (host to device). hipMemcpy(d_B, B, sizeof(float) * N, hipMemcpyHostToDevice); // TODO: launch the kernel. dim3 dimBlock(32, 1); dim3 dimGrid(N/32, 1); gpuVecAdd<<< dimGrid, dimBlock >>> (d_A, d_B, d_C); // TODO: copy "d_C" to "C" (device to host). hipMemcpy(C, d_C, sizeof(float) * N, hipMemcpyDeviceToHost); verify(A, B, C, N); // TODO: release d_A, d_B, and d_C. hipFree(d_A); hipFree(d_B); hipFree(d_C); free(A); free(B); free(C); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z9gpuVecAddPfS_S_ .globl _Z9gpuVecAddPfS_S_ .p2align 8 .type _Z9gpuVecAddPfS_S_,@function _Z9gpuVecAddPfS_S_: s_clause 0x2 s_load_b32 s2, s[0:1], 0x24 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 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[0:1], 2, v[1:2] v_add_co_u32 v2, vcc_lo, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 global_load_b32 v2, v[2:3], off global_load_b32 v3, v[4:5], off v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v2, v2, v3 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 _Z9gpuVecAddPfS_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 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 _Z9gpuVecAddPfS_S_, .Lfunc_end0-_Z9gpuVecAddPfS_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: _Z9gpuVecAddPfS_S_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z9gpuVecAddPfS_S_.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 <stdio.h> #include <stdlib.h> __global__ void gpuVecAdd(float *A, float *B, float *C) { // TODO: write kernel code here int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void init(float *V, int N) { for (int i = 0; i < N; i++) { V[i] = rand() % 100; } } void verify(float *A, float *B, float *C, int N) { for (int i = 0; i < 16384; i++) { if (A[i] + B[i] != C[i]) { printf("Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n", i, A[i], i, B[i], i, C[i]); return; } } printf("Verification success!\n"); } int main() { int N = 16384; float *A = (float*)malloc(sizeof(float) * N); float *B = (float*)malloc(sizeof(float) * N); float *C = (float*)malloc(sizeof(float) * N); init(A, N); init(B, N); // Memory objects of the device float *d_A, *d_B, *d_C; // TODO: allocate memory objects d_A, d_B, and d_C. hipMalloc(&d_A, sizeof(float) * N); hipMalloc(&d_B, sizeof(float) * N); hipMalloc(&d_C, sizeof(float) * N); // TODO: copy "A" to "d_A" (host to device). hipMemcpy(d_A, A, sizeof(float) * N, hipMemcpyHostToDevice); // TODO: copy "B" to "d_B" (host to device). hipMemcpy(d_B, B, sizeof(float) * N, hipMemcpyHostToDevice); // TODO: launch the kernel. dim3 dimBlock(32, 1); dim3 dimGrid(N/32, 1); gpuVecAdd<<< dimGrid, dimBlock >>> (d_A, d_B, d_C); // TODO: copy "d_C" to "C" (device to host). hipMemcpy(C, d_C, sizeof(float) * N, hipMemcpyDeviceToHost); verify(A, B, C, N); // TODO: release d_A, d_B, and d_C. hipFree(d_A); hipFree(d_B); hipFree(d_C); free(A); free(B); free(C); return 0; }
.text .file "vec_add.hip" .globl _Z24__device_stub__gpuVecAddPfS_S_ # -- Begin function _Z24__device_stub__gpuVecAddPfS_S_ .p2align 4, 0x90 .type _Z24__device_stub__gpuVecAddPfS_S_,@function _Z24__device_stub__gpuVecAddPfS_S_: # @_Z24__device_stub__gpuVecAddPfS_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 $_Z9gpuVecAddPfS_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 _Z24__device_stub__gpuVecAddPfS_S_, .Lfunc_end0-_Z24__device_stub__gpuVecAddPfS_S_ .cfi_endproc # -- End function .globl _Z4initPfi # -- Begin function _Z4initPfi .p2align 4, 0x90 .type _Z4initPfi,@function _Z4initPfi: # @_Z4initPfi .cfi_startproc # %bb.0: testl %esi, %esi jle .LBB1_4 # %bb.1: # %.lr.ph.preheader 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 movq %rdi, %rbx movl %esi, %r14d xorl %r15d, %r15d .p2align 4, 0x90 .LBB1_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 callq rand cltq imulq $1374389535, %rax, %rcx # imm = 0x51EB851F movq %rcx, %rdx shrq $63, %rdx sarq $37, %rcx addl %edx, %ecx imull $100, %ecx, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%rbx,%r15,4) incq %r15 cmpq %r15, %r14 jne .LBB1_2 # %bb.3: 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_4: # %._crit_edge retq .Lfunc_end1: .size _Z4initPfi, .Lfunc_end1-_Z4initPfi .cfi_endproc # -- End function .globl _Z6verifyPfS_S_i # -- Begin function _Z6verifyPfS_S_i .p2align 4, 0x90 .type _Z6verifyPfS_S_i,@function _Z6verifyPfS_S_i: # @_Z6verifyPfS_S_i .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset %rbx, -16 movss (%rdi), %xmm0 # xmm0 = mem[0],zero,zero,zero movss (%rsi), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss (%rdx), %xmm2 # xmm2 = mem[0],zero,zero,zero ucomiss %xmm2, %xmm3 jne .LBB2_6 jnp .LBB2_1 .LBB2_6: # %.critedge47 cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi xorl %esi, %esi xorl %edx, %edx xorl %ecx, %ecx movb $3, %al popq %rbx .cfi_def_cfa_offset 8 jmp printf # TAILCALL .LBB2_1: # %.lr.ph.preheader .cfi_def_cfa_offset 16 movq $-1, %rbx .p2align 4, 0x90 .LBB2_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 cmpq $16382, %rbx # imm = 0x3FFE je .LBB2_5 # %bb.3: # in Loop: Header=BB2_2 Depth=1 movss 8(%rdi,%rbx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero movss 8(%rsi,%rbx,4), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss 8(%rdx,%rbx,4), %xmm2 # xmm2 = mem[0],zero,zero,zero incq %rbx ucomiss %xmm2, %xmm3 jne .LBB2_4 jnp .LBB2_2 .LBB2_4: # %._crit_edge leal 1(%rbx), %ecx cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi movl %ecx, %esi movl %ecx, %edx movb $3, %al callq printf cmpq $16382, %rbx # imm = 0x3FFE jbe .LBB2_7 .LBB2_5: # %.critedge movl $.Lstr, %edi popq %rbx .cfi_def_cfa_offset 8 jmp puts@PLT # TAILCALL .LBB2_7: .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size _Z6verifyPfS_S_i, .Lfunc_end2-_Z6verifyPfS_S_i .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $120, %rsp .cfi_def_cfa_offset 160 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $65536, %edi # imm = 0x10000 callq malloc movq %rax, %rbx movl $65536, %edi # imm = 0x10000 callq malloc movq %rax, %r14 movl $65536, %edi # imm = 0x10000 callq malloc movq %rax, %r15 xorl %r12d, %r12d .p2align 4, 0x90 .LBB3_1: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 callq rand cltq imulq $1374389535, %rax, %rcx # imm = 0x51EB851F movq %rcx, %rdx shrq $63, %rdx sarq $37, %rcx addl %edx, %ecx imull $100, %ecx, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%rbx,%r12,4) incq %r12 cmpq $16384, %r12 # imm = 0x4000 jne .LBB3_1 # %bb.2: # %.lr.ph.i29.preheader xorl %r12d, %r12d .p2align 4, 0x90 .LBB3_3: # %.lr.ph.i29 # =>This Inner Loop Header: Depth=1 callq rand cltq imulq $1374389535, %rax, %rcx # imm = 0x51EB851F movq %rcx, %rdx shrq $63, %rdx sarq $37, %rcx addl %edx, %ecx imull $100, %ecx, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%r14,%r12,4) incq %r12 cmpq $16384, %r12 # imm = 0x4000 jne .LBB3_3 # %bb.4: # %_Z4initPfi.exit33 leaq 16(%rsp), %rdi movl $65536, %esi # imm = 0x10000 callq hipMalloc leaq 8(%rsp), %rdi movl $65536, %esi # imm = 0x10000 callq hipMalloc movq %rsp, %rdi movl $65536, %esi # imm = 0x10000 callq hipMalloc movq 16(%rsp), %rdi movl $65536, %edx # imm = 0x10000 movq %rbx, %rsi movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi movl $65536, %edx # imm = 0x10000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy movabsq $4294967328, %rdx # imm = 0x100000020 leaq 480(%rdx), %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_6 # %bb.5: 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 $_Z9gpuVecAddPfS_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 .LBB3_6: movq (%rsp), %rsi movl $65536, %edx # imm = 0x10000 movq %r15, %rdi movl $2, %ecx callq hipMemcpy movss (%rbx), %xmm0 # xmm0 = mem[0],zero,zero,zero movss (%r14), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss (%r15), %xmm2 # xmm2 = mem[0],zero,zero,zero ucomiss %xmm2, %xmm3 jne .LBB3_12 jnp .LBB3_7 .LBB3_12: # %_Z6verifyPfS_S_i.exit.critedge cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi xorl %esi, %esi xorl %edx, %edx xorl %ecx, %ecx movb $3, %al callq printf jmp .LBB3_13 .LBB3_7: # %.lr.ph.preheader movq $-1, %r12 .p2align 4, 0x90 .LBB3_8: # %.lr.ph # =>This Inner Loop Header: Depth=1 cmpq $16382, %r12 # imm = 0x3FFE je .LBB3_11 # %bb.9: # in Loop: Header=BB3_8 Depth=1 movss 8(%rbx,%r12,4), %xmm0 # xmm0 = mem[0],zero,zero,zero movss 8(%r14,%r12,4), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss 8(%r15,%r12,4), %xmm2 # xmm2 = mem[0],zero,zero,zero incq %r12 ucomiss %xmm2, %xmm3 jne .LBB3_10 jnp .LBB3_8 .LBB3_10: # %._crit_edge leal 1(%r12), %ecx cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi movl %ecx, %esi movl %ecx, %edx movb $3, %al callq printf cmpq $16382, %r12 # imm = 0x3FFE jbe .LBB3_13 .LBB3_11: # %.critedge.i movl $.Lstr, %edi callq puts@PLT .LBB3_13: # %_Z6verifyPfS_S_i.exit movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree movq %rbx, %rdi callq free movq %r14, %rdi callq free movq %r15, %rdi callq free xorl %eax, %eax addq $120, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .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: subq $40, %rsp .cfi_def_cfa_offset 48 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), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z9gpuVecAddPfS_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_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 _Z9gpuVecAddPfS_S_,@object # @_Z9gpuVecAddPfS_S_ .section .rodata,"a",@progbits .globl _Z9gpuVecAddPfS_S_ .p2align 3, 0x0 _Z9gpuVecAddPfS_S_: .quad _Z24__device_stub__gpuVecAddPfS_S_ .size _Z9gpuVecAddPfS_S_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n" .size .L.str, 57 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z9gpuVecAddPfS_S_" .size .L__unnamed_1, 19 .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 "Verification success!" .size .Lstr, 22 .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 _Z24__device_stub__gpuVecAddPfS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z9gpuVecAddPfS_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 : _Z9gpuVecAddPfS_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 R6, SR_CTAID.X ; /* 0x0000000000067919 */ /* 0x000e220000002500 */ /*0020*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0050*/ IMAD R6, R6, c[0x0][0x0], R3 ; /* 0x0000000006067a24 */ /* 0x001fca00078e0203 */ /*0060*/ IMAD.WIDE R2, R6, R7, c[0x0][0x160] ; /* 0x0000580006027625 */ /* 0x000fc800078e0207 */ /*0070*/ IMAD.WIDE R4, R6.reuse, R7.reuse, c[0x0][0x168] ; /* 0x00005a0006047625 */ /* 0x0c0fe400078e0207 */ /*0080*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea8000c1e1900 */ /*0090*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea2000c1e1900 */ /*00a0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x170] ; /* 0x00005c0006067625 */ /* 0x000fc800078e0207 */ /*00b0*/ FADD R9, R2, R5 ; /* 0x0000000502097221 */ /* 0x004fca0000000000 */ /*00c0*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*00d0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00e0*/ BRA 0xe0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z9gpuVecAddPfS_S_ .globl _Z9gpuVecAddPfS_S_ .p2align 8 .type _Z9gpuVecAddPfS_S_,@function _Z9gpuVecAddPfS_S_: s_clause 0x2 s_load_b32 s2, s[0:1], 0x24 s_load_b128 s[4:7], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 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[0:1], 2, v[1:2] v_add_co_u32 v2, vcc_lo, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 global_load_b32 v2, v[2:3], off global_load_b32 v3, v[4:5], off v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v2, v2, v3 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 _Z9gpuVecAddPfS_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 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 _Z9gpuVecAddPfS_S_, .Lfunc_end0-_Z9gpuVecAddPfS_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: _Z9gpuVecAddPfS_S_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z9gpuVecAddPfS_S_.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_000b4f9a_00000000-6_vec_add.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 _Z4initPfi .type _Z4initPfi, @function _Z4initPfi: .LFB2057: .cfi_startproc endbr64 testl %esi, %esi jle .L8 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 %rdi, %rbx movslq %esi, %rsi leaq (%rdi,%rsi,4), %rbp .L5: call rand@PLT movslq %eax, %rdx imulq $1374389535, %rdx, %rdx sarq $37, %rdx movl %eax, %ecx sarl $31, %ecx subl %ecx, %edx imull $100, %edx, %edx subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 movss %xmm0, (%rbx) addq $4, %rbx cmpq %rbp, %rbx jne .L5 addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L8: .cfi_restore 3 .cfi_restore 6 ret .cfi_endproc .LFE2057: .size _Z4initPfi, .-_Z4initPfi .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n" .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "Verification success!\n" .text .globl _Z6verifyPfS_S_i .type _Z6verifyPfS_S_i, @function _Z6verifyPfS_S_i: .LFB2058: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movl $0, %r8d .L15: movss (%rdi,%r8,4), %xmm0 movss (%rsi,%r8,4), %xmm1 movss (%rdx,%r8,4), %xmm2 movaps %xmm0, %xmm3 addss %xmm1, %xmm3 ucomiss %xmm2, %xmm3 jp .L16 jne .L16 addq $1, %r8 cmpq $16384, %r8 jne .L15 leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L11 .L16: movl %r8d, %edx cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm2, %xmm2 cvtss2sd %xmm1, %xmm1 movl %r8d, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $3, %eax call __printf_chk@PLT .L11: addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z6verifyPfS_S_i, .-_Z6verifyPfS_S_i .globl _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ .type _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_, @function _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_: .LFB2084: .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 .L23 .L19: movq 120(%rsp), %rax subq %fs:40, %rax jne .L24 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L23: .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 _Z9gpuVecAddPfS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L19 .L24: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_, .-_Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ .globl _Z9gpuVecAddPfS_S_ .type _Z9gpuVecAddPfS_S_, @function _Z9gpuVecAddPfS_S_: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z9gpuVecAddPfS_S_, .-_Z9gpuVecAddPfS_S_ .globl main .type main, @function main: .LFB2059: .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 $64, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $65536, %edi call malloc@PLT movq %rax, %rbp movl $65536, %edi call malloc@PLT movq %rax, %rbx movl $65536, %edi call malloc@PLT movq %rax, %r12 movl $16384, %esi movq %rbp, %rdi call _Z4initPfi movl $16384, %esi movq %rbx, %rdi call _Z4initPfi leaq 8(%rsp), %rdi movl $65536, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $65536, %esi call cudaMalloc@PLT leaq 24(%rsp), %rdi movl $65536, %esi call cudaMalloc@PLT movl $1, %ecx movl $65536, %edx movq %rbp, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $65536, %edx movq %rbx, %rsi movq 16(%rsp), %rdi call cudaMemcpy@PLT movl $32, 32(%rsp) movl $1, 36(%rsp) movl $512, 44(%rsp) movl $1, 48(%rsp) movl $0, %r9d movl $0, %r8d movq 32(%rsp), %rdx movl $1, %ecx movq 44(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L31 .L28: movl $2, %ecx movl $65536, %edx movq 24(%rsp), %rsi movq %r12, %rdi call cudaMemcpy@PLT movl $16384, %ecx movq %r12, %rdx movq %rbx, %rsi movq %rbp, %rdi call _Z6verifyPfS_S_i movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq 24(%rsp), %rdi call cudaFree@PLT movq %rbp, %rdi call free@PLT movq %rbx, %rdi call free@PLT movq %r12, %rdi call free@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L32 movl $0, %eax addq $64, %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 .L31: .cfi_restore_state movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z32__device_stub__Z9gpuVecAddPfS_S_PfS_S_ jmp .L28 .L32: call __stack_chk_fail@PLT .cfi_endproc .LFE2059: .size main, .-main .section .rodata.str1.1 .LC2: .string "_Z9gpuVecAddPfS_S_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2087: .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 _Z9gpuVecAddPfS_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 .LFE2087: .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 "vec_add.hip" .globl _Z24__device_stub__gpuVecAddPfS_S_ # -- Begin function _Z24__device_stub__gpuVecAddPfS_S_ .p2align 4, 0x90 .type _Z24__device_stub__gpuVecAddPfS_S_,@function _Z24__device_stub__gpuVecAddPfS_S_: # @_Z24__device_stub__gpuVecAddPfS_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 $_Z9gpuVecAddPfS_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 _Z24__device_stub__gpuVecAddPfS_S_, .Lfunc_end0-_Z24__device_stub__gpuVecAddPfS_S_ .cfi_endproc # -- End function .globl _Z4initPfi # -- Begin function _Z4initPfi .p2align 4, 0x90 .type _Z4initPfi,@function _Z4initPfi: # @_Z4initPfi .cfi_startproc # %bb.0: testl %esi, %esi jle .LBB1_4 # %bb.1: # %.lr.ph.preheader 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 movq %rdi, %rbx movl %esi, %r14d xorl %r15d, %r15d .p2align 4, 0x90 .LBB1_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 callq rand cltq imulq $1374389535, %rax, %rcx # imm = 0x51EB851F movq %rcx, %rdx shrq $63, %rdx sarq $37, %rcx addl %edx, %ecx imull $100, %ecx, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%rbx,%r15,4) incq %r15 cmpq %r15, %r14 jne .LBB1_2 # %bb.3: 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_4: # %._crit_edge retq .Lfunc_end1: .size _Z4initPfi, .Lfunc_end1-_Z4initPfi .cfi_endproc # -- End function .globl _Z6verifyPfS_S_i # -- Begin function _Z6verifyPfS_S_i .p2align 4, 0x90 .type _Z6verifyPfS_S_i,@function _Z6verifyPfS_S_i: # @_Z6verifyPfS_S_i .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset %rbx, -16 movss (%rdi), %xmm0 # xmm0 = mem[0],zero,zero,zero movss (%rsi), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss (%rdx), %xmm2 # xmm2 = mem[0],zero,zero,zero ucomiss %xmm2, %xmm3 jne .LBB2_6 jnp .LBB2_1 .LBB2_6: # %.critedge47 cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi xorl %esi, %esi xorl %edx, %edx xorl %ecx, %ecx movb $3, %al popq %rbx .cfi_def_cfa_offset 8 jmp printf # TAILCALL .LBB2_1: # %.lr.ph.preheader .cfi_def_cfa_offset 16 movq $-1, %rbx .p2align 4, 0x90 .LBB2_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 cmpq $16382, %rbx # imm = 0x3FFE je .LBB2_5 # %bb.3: # in Loop: Header=BB2_2 Depth=1 movss 8(%rdi,%rbx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero movss 8(%rsi,%rbx,4), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss 8(%rdx,%rbx,4), %xmm2 # xmm2 = mem[0],zero,zero,zero incq %rbx ucomiss %xmm2, %xmm3 jne .LBB2_4 jnp .LBB2_2 .LBB2_4: # %._crit_edge leal 1(%rbx), %ecx cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi movl %ecx, %esi movl %ecx, %edx movb $3, %al callq printf cmpq $16382, %rbx # imm = 0x3FFE jbe .LBB2_7 .LBB2_5: # %.critedge movl $.Lstr, %edi popq %rbx .cfi_def_cfa_offset 8 jmp puts@PLT # TAILCALL .LBB2_7: .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size _Z6verifyPfS_S_i, .Lfunc_end2-_Z6verifyPfS_S_i .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $120, %rsp .cfi_def_cfa_offset 160 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $65536, %edi # imm = 0x10000 callq malloc movq %rax, %rbx movl $65536, %edi # imm = 0x10000 callq malloc movq %rax, %r14 movl $65536, %edi # imm = 0x10000 callq malloc movq %rax, %r15 xorl %r12d, %r12d .p2align 4, 0x90 .LBB3_1: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 callq rand cltq imulq $1374389535, %rax, %rcx # imm = 0x51EB851F movq %rcx, %rdx shrq $63, %rdx sarq $37, %rcx addl %edx, %ecx imull $100, %ecx, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%rbx,%r12,4) incq %r12 cmpq $16384, %r12 # imm = 0x4000 jne .LBB3_1 # %bb.2: # %.lr.ph.i29.preheader xorl %r12d, %r12d .p2align 4, 0x90 .LBB3_3: # %.lr.ph.i29 # =>This Inner Loop Header: Depth=1 callq rand cltq imulq $1374389535, %rax, %rcx # imm = 0x51EB851F movq %rcx, %rdx shrq $63, %rdx sarq $37, %rcx addl %edx, %ecx imull $100, %ecx, %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%r14,%r12,4) incq %r12 cmpq $16384, %r12 # imm = 0x4000 jne .LBB3_3 # %bb.4: # %_Z4initPfi.exit33 leaq 16(%rsp), %rdi movl $65536, %esi # imm = 0x10000 callq hipMalloc leaq 8(%rsp), %rdi movl $65536, %esi # imm = 0x10000 callq hipMalloc movq %rsp, %rdi movl $65536, %esi # imm = 0x10000 callq hipMalloc movq 16(%rsp), %rdi movl $65536, %edx # imm = 0x10000 movq %rbx, %rsi movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi movl $65536, %edx # imm = 0x10000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy movabsq $4294967328, %rdx # imm = 0x100000020 leaq 480(%rdx), %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB3_6 # %bb.5: 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 $_Z9gpuVecAddPfS_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 .LBB3_6: movq (%rsp), %rsi movl $65536, %edx # imm = 0x10000 movq %r15, %rdi movl $2, %ecx callq hipMemcpy movss (%rbx), %xmm0 # xmm0 = mem[0],zero,zero,zero movss (%r14), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss (%r15), %xmm2 # xmm2 = mem[0],zero,zero,zero ucomiss %xmm2, %xmm3 jne .LBB3_12 jnp .LBB3_7 .LBB3_12: # %_Z6verifyPfS_S_i.exit.critedge cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi xorl %esi, %esi xorl %edx, %edx xorl %ecx, %ecx movb $3, %al callq printf jmp .LBB3_13 .LBB3_7: # %.lr.ph.preheader movq $-1, %r12 .p2align 4, 0x90 .LBB3_8: # %.lr.ph # =>This Inner Loop Header: Depth=1 cmpq $16382, %r12 # imm = 0x3FFE je .LBB3_11 # %bb.9: # in Loop: Header=BB3_8 Depth=1 movss 8(%rbx,%r12,4), %xmm0 # xmm0 = mem[0],zero,zero,zero movss 8(%r14,%r12,4), %xmm1 # xmm1 = mem[0],zero,zero,zero movaps %xmm0, %xmm3 addss %xmm1, %xmm3 movss 8(%r15,%r12,4), %xmm2 # xmm2 = mem[0],zero,zero,zero incq %r12 ucomiss %xmm2, %xmm3 jne .LBB3_10 jnp .LBB3_8 .LBB3_10: # %._crit_edge leal 1(%r12), %ecx cvtss2sd %xmm0, %xmm0 cvtss2sd %xmm1, %xmm1 cvtss2sd %xmm2, %xmm2 movl $.L.str, %edi movl %ecx, %esi movl %ecx, %edx movb $3, %al callq printf cmpq $16382, %r12 # imm = 0x3FFE jbe .LBB3_13 .LBB3_11: # %.critedge.i movl $.Lstr, %edi callq puts@PLT .LBB3_13: # %_Z6verifyPfS_S_i.exit movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree movq %rbx, %rdi callq free movq %r14, %rdi callq free movq %r15, %rdi callq free xorl %eax, %eax addq $120, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .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: subq $40, %rsp .cfi_def_cfa_offset 48 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), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z9gpuVecAddPfS_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_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 _Z9gpuVecAddPfS_S_,@object # @_Z9gpuVecAddPfS_S_ .section .rodata,"a",@progbits .globl _Z9gpuVecAddPfS_S_ .p2align 3, 0x0 _Z9gpuVecAddPfS_S_: .quad _Z24__device_stub__gpuVecAddPfS_S_ .size _Z9gpuVecAddPfS_S_, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Verification failed! A[%d] = %d, B[%d] = %d, C[%d] = %d\n" .size .L.str, 57 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z9gpuVecAddPfS_S_" .size .L__unnamed_1, 19 .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 "Verification success!" .size .Lstr, 22 .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 _Z24__device_stub__gpuVecAddPfS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z9gpuVecAddPfS_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 <iostream> void fillMatrixA(float* A, int height, int width) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { A[width * i + j] = (i == j) ? 1 : 0; } } } void fillMatrixB(float* B, int height, int width) { fillMatrixA(B, height, width); } __global__ void transposeMatrix(float* B, float* B_T, int B_height, int B_width) { int threadIdxG_x = blockIdx.x * blockDim.x + threadIdx.x; int threadIdxG_y = blockIdx.y * blockDim.y + threadIdx.y; B_T[B_height * threadIdxG_y + threadIdxG_x] = B[B_width * threadIdxG_x + threadIdxG_y]; } __global__ void matrixMul(float* A, float* B_T, float* C, const int mid_size) { // cond: B must be already transposed, // sizes A, B, C are matched, // mid_size equals to A_width and B_T width, // block must be as square !!! int block_side_size = blockDim.x; int block_size = blockDim.x * blockDim.x; extern __shared__ float sh_A_block[ ]; float* sh_B_block = sh_A_block + block_size; int block_cnt = mid_size / block_side_size; for (int matrix_block_idx = 0; matrix_block_idx < block_cnt; ++matrix_block_idx) { int A_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int A_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int A_global_idx = A_global_idx_x * mid_size + A_global_idx_y; sh_A_block[threadIdx.x * block_side_size + threadIdx.y] = A[A_global_idx]; int B_T_global_idx_x = blockIdx.y * block_side_size + threadIdx.x; int B_T_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int B_T_global_idx = B_T_global_idx_x * mid_size + B_T_global_idx_y; sh_B_block[threadIdx.x * block_side_size + threadIdx.y] = B_T[B_T_global_idx]; __syncthreads(); int C_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int C_global_idx_y = blockIdx.y * block_side_size + threadIdx.y; int C_global_idx = C_global_idx_x * gridDim.y * block_side_size + C_global_idx_y; for (int k = 0; k < block_side_size; ++k) { C[C_global_idx] += sh_A_block[threadIdx.x * block_side_size + k] * sh_B_block[threadIdx.y * block_side_size + k]; } } } int main() { // cond: sizes A and B are matched, // height and width are multiples of the block size (block is square), const int k_block_side_size = 16; const int k_A_height = 128; // to change const int k_A_width = 384; // to change const int k_B_width = 256; // to change const int k_B_height = k_A_width; const int k_C_height = k_A_height; const int k_C_width = k_B_width; float* h_A = new float[k_A_height * k_A_width]; float* h_B = new float[k_B_height * k_B_width]; float* h_C = new float[k_C_height * k_C_width]; fillMatrixA(h_A, k_A_height, k_A_width); fillMatrixB(h_B, k_B_height, k_B_width); float* d_A; float* d_B; float* d_B_T; float* d_C; cudaMalloc(&d_A, sizeof(float) * k_A_height * k_A_width); cudaMalloc(&d_B, sizeof(float) * k_B_height * k_B_width); cudaMalloc(&d_B_T, sizeof(float) * k_B_width * k_B_height); cudaMalloc(&d_C, sizeof(float) * k_C_height * k_C_width); cudaMemcpy(d_A, h_A, sizeof(float) * k_A_height * k_A_width, cudaMemcpyHostToDevice); cudaMemcpy(d_B, h_B, sizeof(float) * k_B_height * k_B_width, cudaMemcpyHostToDevice); dim3 block_size(k_block_side_size, k_block_side_size); dim3 num_blocks_B(k_B_height / k_block_side_size, k_B_width / k_block_side_size); transposeMatrix<<< num_blocks_B, block_size >>>(d_B, d_B_T, k_B_height, k_B_width); dim3 num_blocks_C(k_C_height / k_block_side_size, k_C_width / k_block_side_size); matrixMul<<< num_blocks_C, block_size, sizeof(float) * 2 * k_block_side_size * k_block_side_size >>>(d_A, d_B_T, d_C, k_A_width); cudaMemcpy(h_C, d_C, sizeof(float) * k_C_height * k_C_width, cudaMemcpyDeviceToHost); for (int i = 0; i < k_C_height; ++i) { for (int j = 0; j < k_C_width; ++j) { std::cout << i << ' ' << j << ' ' << h_C[k_C_width * i + j] << std::endl; } } delete[] h_A; delete[] h_B; delete[] h_C; cudaFree(d_A); cudaFree(d_B); cudaFree(d_B_T); cudaFree(d_C); return 0; }
code for sm_80 Function : _Z9matrixMulPfS_S_i .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*/ IABS R4, c[0x0][0x0] ; /* 0x0000000000047a13 */ /* 0x000fe20000000000 */ /*0020*/ ULDC UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe20000000800 */ /*0030*/ IABS R6, c[0x0][0x178] ; /* 0x00005e0000067a13 */ /* 0x000fe20000000000 */ /*0040*/ ULDC UR5, c[0x0][0x0] ; /* 0x0000000000057ab9 */ /* 0x000fe20000000800 */ /*0050*/ I2F.RP R0, R4 ; /* 0x0000000400007306 */ /* 0x000e220000209400 */ /*0060*/ ULOP3.LUT UR4, UR4, UR5, URZ, 0x3c, !UPT ; /* 0x0000000504047292 */ /* 0x000fcc000f8e3c3f */ /*0070*/ ISETP.LE.AND P1, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf23270 */ /*0080*/ MUFU.RCP R0, R0 ; /* 0x0000000000007308 */ /* 0x001e240000001000 */ /*0090*/ IADD3 R2, R0, 0xffffffe, RZ ; /* 0x0ffffffe00027810 */ /* 0x001fcc0007ffe0ff */ /*00a0*/ F2I.FTZ.U32.TRUNC.NTZ R3, R2 ; /* 0x0000000200037305 */ /* 0x000064000021f000 */ /*00b0*/ HFMA2.MMA R2, -RZ, RZ, 0, 0 ; /* 0x00000000ff027435 */ /* 0x001fe200000001ff */ /*00c0*/ IMAD.MOV R5, RZ, RZ, -R3 ; /* 0x000000ffff057224 */ /* 0x002fc800078e0a03 */ /*00d0*/ IMAD R5, R5, R4, RZ ; /* 0x0000000405057224 */ /* 0x000fca00078e02ff */ /*00e0*/ IMAD.HI.U32 R3, R3, R5, R2 ; /* 0x0000000503037227 */ /* 0x000fc800078e0002 */ /*00f0*/ IMAD.MOV.U32 R5, RZ, RZ, R6 ; /* 0x000000ffff057224 */ /* 0x000fc800078e0006 */ /*0100*/ IMAD.HI.U32 R0, R3, R5, RZ ; /* 0x0000000503007227 */ /* 0x000fca00078e00ff */ /*0110*/ IADD3 R3, -R0, RZ, RZ ; /* 0x000000ff00037210 */ /* 0x000fca0007ffe1ff */ /*0120*/ IMAD R3, R4, R3, R5 ; /* 0x0000000304037224 */ /* 0x000fca00078e0205 */ /*0130*/ ISETP.GT.U32.AND P2, PT, R4, R3, PT ; /* 0x000000030400720c */ /* 0x000fda0003f44070 */ /*0140*/ @!P2 IMAD.IADD R3, R3, 0x1, -R4 ; /* 0x000000010303a824 */ /* 0x000fe200078e0a04 */ /*0150*/ @!P2 IADD3 R0, R0, 0x1, RZ ; /* 0x000000010000a810 */ /* 0x000fe40007ffe0ff */ /*0160*/ ISETP.NE.AND P2, PT, RZ, c[0x0][0x0], PT ; /* 0x00000000ff007a0c */ /* 0x000fe40003f45270 */ /*0170*/ ISETP.GE.U32.AND P0, PT, R3, R4, PT ; /* 0x000000040300720c */ /* 0x000fda0003f06070 */ /*0180*/ @P0 IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100000810 */ /* 0x000fc80007ffe0ff */ /*0190*/ @!P1 IADD3 R0, -R0, RZ, RZ ; /* 0x000000ff00009210 */ /* 0x000fe40007ffe1ff */ /*01a0*/ @!P2 LOP3.LUT R0, RZ, c[0x0][0x0], RZ, 0x33, !PT ; /* 0x00000000ff00aa12 */ /* 0x000fc800078e33ff */ /*01b0*/ ISETP.GE.AND P0, PT, R0, 0x1, PT ; /* 0x000000010000780c */ /* 0x000fda0003f06270 */ /*01c0*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*01d0*/ S2R R10, SR_TID.X ; /* 0x00000000000a7919 */ /* 0x000e220000002100 */ /*01e0*/ MOV R14, c[0x0][0x0] ; /* 0x00000000000e7a02 */ /* 0x000fe20000000f00 */ /*01f0*/ IMAD.MOV.U32 R7, RZ, RZ, 0x4 ; /* 0x00000004ff077424 */ /* 0x000fe200078e00ff */ /*0200*/ MOV R13, RZ ; /* 0x000000ff000d7202 */ /* 0x000fe20000000f00 */ /*0210*/ S2R R9, SR_CTAID.X ; /* 0x0000000000097919 */ /* 0x000e620000002500 */ /*0220*/ IADD3 R22, R14.reuse, -0x1, RZ ; /* 0xffffffff0e167810 */ /* 0x040fe20007ffe0ff */ /*0230*/ IMAD R3, R14, c[0x0][0x10], RZ ; /* 0x000004000e037a24 */ /* 0x000fe200078e02ff */ /*0240*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0250*/ S2R R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000ea80000002600 */ /*0260*/ S2R R8, SR_TID.Y ; /* 0x0000000000087919 */ /* 0x000ee20000002200 */ /*0270*/ IMAD R11, R10, c[0x0][0x0], RZ ; /* 0x000000000a0b7a24 */ /* 0x001fc400078e02ff */ /*0280*/ IMAD R9, R9, c[0x0][0x0], R10 ; /* 0x0000000009097a24 */ /* 0x002fc600078e020a */ /*0290*/ LEA R18, R11, 0x8, 0x2 ; /* 0x000000080b127811 */ /* 0x000fe200078e10ff */ /*02a0*/ IMAD R10, R5.reuse, c[0x0][0x0], R10 ; /* 0x00000000050a7a24 */ /* 0x044fe400078e020a */ /*02b0*/ IMAD R2, R5, c[0x0][0x0], R8 ; /* 0x0000000005027a24 */ /* 0x008fe200078e0208 */ /*02c0*/ IADD3 R12, R11, R8, RZ ; /* 0x000000080b0c7210 */ /* 0x000fe40007ffe0ff */ /*02d0*/ IADD3 R5, R8, c[0x0][0x0], RZ ; /* 0x0000000008057a10 */ /* 0x000fe20007ffe0ff */ /*02e0*/ IMAD R4, R9, R3, R2 ; /* 0x0000000309047224 */ /* 0x000fe400078e0202 */ /*02f0*/ IMAD R3, R14.reuse, c[0x0][0x0], RZ ; /* 0x000000000e037a24 */ /* 0x040fe200078e02ff */ /*0300*/ LOP3.LUT R14, R14, 0x3, RZ, 0xc0, !PT ; /* 0x000000030e0e7812 */ /* 0x000fe200078ec0ff */ /*0310*/ IMAD.SHL.U32 R2, R12, 0x4, RZ ; /* 0x000000040c027824 */ /* 0x000fc400078e00ff */ /*0320*/ IMAD R5, R5, c[0x0][0x0], RZ ; /* 0x0000000005057a24 */ /* 0x000fe200078e02ff */ /*0330*/ IADD3 R17, -R14, c[0x0][0x0], RZ ; /* 0x000000000e117a10 */ /* 0x000fe20007ffe1ff */ /*0340*/ IMAD R16, R8, c[0x0][0x0], R3 ; /* 0x0000000008107a24 */ /* 0x000fe200078e0203 */ /*0350*/ LEA R15, R3, R2, 0x2 ; /* 0x00000002030f7211 */ /* 0x000fe200078e10ff */ /*0360*/ IMAD.WIDE R2, R4, R7, c[0x0][0x170] ; /* 0x00005c0004027625 */ /* 0x000fe200078e0207 */ /*0370*/ LEA R19, R5, 0x8, 0x2 ; /* 0x0000000805137811 */ /* 0x000fc600078e10ff */ /*0380*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0390*/ IMAD R4, R13, c[0x0][0x0], R8 ; /* 0x000000000d047a24 */ /* 0x000fc800078e0208 */ /*03a0*/ IMAD R5, R9, c[0x0][0x178], R4.reuse ; /* 0x00005e0009057a24 */ /* 0x100fe400078e0204 */ /*03b0*/ IMAD R6, R10, c[0x0][0x178], R4 ; /* 0x00005e000a067a24 */ /* 0x000fc600078e0204 */ /*03c0*/ IMAD.WIDE R4, R5, R7, c[0x0][0x160] ; /* 0x0000580005047625 */ /* 0x000fc800078e0207 */ /*03d0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x168] ; /* 0x00005a0006067625 */ /* 0x000fe400078e0207 */ /*03e0*/ LDG.E R5, [R4.64] ; /* 0x0000000604057981 */ /* 0x000ea8000c1e1900 */ /*03f0*/ LDG.E R6, [R6.64] ; /* 0x0000000606067981 */ /* 0x000ee2000c1e1900 */ /*0400*/ IMAD.MOV.U32 R20, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff147624 */ /* 0x000fe200078e00ff */ /*0410*/ IADD3 R13, R13, 0x1, RZ ; /* 0x000000010d0d7810 */ /* 0x000fc80007ffe0ff */ /*0420*/ ISETP.GE.AND P0, PT, R20, 0x1, PT ; /* 0x000000011400780c */ /* 0x000fe40003f06270 */ /*0430*/ ISETP.GE.AND P1, PT, R13, R0, PT ; /* 0x000000000d00720c */ /* 0x000fe20003f26270 */ /*0440*/ STS [R12.X4], R5 ; /* 0x000000050c007388 */ /* 0x0041e80000004800 */ /*0450*/ STS [R15], R6 ; /* 0x000000060f007388 */ /* 0x0081e80000000800 */ /*0460*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0470*/ @!P0 BRA 0xd20 ; /* 0x000008a000008947 */ /* 0x000fea0003800000 */ /*0480*/ ISETP.GE.U32.AND P0, PT, R22, 0x3, PT ; /* 0x000000031600780c */ /* 0x001fe20003f06070 */ /*0490*/ LDG.E R21, [R2.64] ; /* 0x0000000602157981 */ /* 0x000162000c1e1900 */ /*04a0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fd60008000000 */ /*04b0*/ @!P0 BRA 0xbf0 ; /* 0x0000073000008947 */ /* 0x000fea0003800000 */ /*04c0*/ ISETP.GT.AND P0, PT, R17, RZ, PT ; /* 0x000000ff1100720c */ /* 0x001fe20003f04270 */ /*04d0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*04e0*/ MOV R4, R19 ; /* 0x0000001300047202 */ /* 0x000fe20000000f00 */ /*04f0*/ IMAD.MOV.U32 R6, RZ, RZ, R17 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0011 */ /*0500*/ MOV R5, R18 ; /* 0x0000001200057202 */ /* 0x000fd20000000f00 */ /*0510*/ @!P0 BRA 0xad0 ; /* 0x000005b000008947 */ /* 0x000fea0003800000 */ /*0520*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fe40003f44270 */ /*0530*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0540*/ @!P2 BRA 0x8c0 ; /* 0x000003700000a947 */ /* 0x000fea0003800000 */ /*0550*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0560*/ LDS R24, [R4+-0x8] ; /* 0xfffff80004187984 */ /* 0x000fe20000000800 */ /*0570*/ IADD3 R6, R6, -0x10, RZ ; /* 0xfffffff006067810 */ /* 0x000fe20007ffe0ff */ /*0580*/ UIADD3 UR4, UR4, 0x10, URZ ; /* 0x0000001004047890 */ /* 0x000fe4000fffe03f */ /*0590*/ LDS R23, [R5+-0x8] ; /* 0xfffff80005177984 */ /* 0x000e220000000800 */ /*05a0*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fc60003f44270 */ /*05b0*/ LDS R26, [R4+-0x4] ; /* 0xfffffc00041a7984 */ /* 0x000fe80000000800 */ /*05c0*/ LDS R25, [R5+-0x4] ; /* 0xfffffc0005197984 */ /* 0x000e680000000800 */ /*05d0*/ LDS R7, [R4] ; /* 0x0000000004077984 */ /* 0x000fe80000000800 */ /*05e0*/ LDS R20, [R5] ; /* 0x0000000005147984 */ /* 0x000ea20000000800 */ /*05f0*/ FFMA R23, R24, R23, R21 ; /* 0x0000001718177223 */ /* 0x021fc60000000015 */ /*0600*/ LDS R21, [R4+0x4] ; /* 0x0000040004157984 */ /* 0x000fe80000000800 */ /*0610*/ LDS R24, [R5+0x4] ; /* 0x0000040005187984 */ /* 0x000e220000000800 */ /*0620*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*0630*/ LDS R26, [R4+0x8] ; /* 0x00000800041a7984 */ /* 0x000fe80000000800 */ /*0640*/ LDS R25, [R5+0x8] ; /* 0x0000080005197984 */ /* 0x000e620000000800 */ /*0650*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*0660*/ LDS R7, [R4+0xc] ; /* 0x00000c0004077984 */ /* 0x000fe80000000800 */ /*0670*/ LDS R20, [R5+0xc] ; /* 0x00000c0005147984 */ /* 0x000ea20000000800 */ /*0680*/ FFMA R23, R21, R24, R23 ; /* 0x0000001815177223 */ /* 0x001fc60000000017 */ /*0690*/ LDS R21, [R4+0x10] ; /* 0x0000100004157984 */ /* 0x000fe80000000800 */ /*06a0*/ LDS R24, [R5+0x10] ; /* 0x0000100005187984 */ /* 0x000e220000000800 */ /*06b0*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*06c0*/ LDS R26, [R4+0x14] ; /* 0x00001400041a7984 */ /* 0x000fe80000000800 */ /*06d0*/ LDS R25, [R5+0x14] ; /* 0x0000140005197984 */ /* 0x000e620000000800 */ /*06e0*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*06f0*/ LDS R7, [R4+0x18] ; /* 0x0000180004077984 */ /* 0x000fe80000000800 */ /*0700*/ LDS R20, [R5+0x18] ; /* 0x0000180005147984 */ /* 0x000ea20000000800 */ /*0710*/ FFMA R23, R21, R24, R23 ; /* 0x0000001815177223 */ /* 0x001fc60000000017 */ /*0720*/ LDS R21, [R4+0x1c] ; /* 0x00001c0004157984 */ /* 0x000fe80000000800 */ /*0730*/ LDS R24, [R5+0x1c] ; /* 0x00001c0005187984 */ /* 0x000e220000000800 */ /*0740*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*0750*/ LDS R26, [R4+0x20] ; /* 0x00002000041a7984 */ /* 0x000fe80000000800 */ /*0760*/ LDS R25, [R5+0x20] ; /* 0x0000200005197984 */ /* 0x000e620000000800 */ /*0770*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*0780*/ LDS R7, [R4+0x24] ; /* 0x0000240004077984 */ /* 0x000fe80000000800 */ /*0790*/ LDS R20, [R5+0x24] ; /* 0x0000240005147984 */ /* 0x000ea20000000800 */ /*07a0*/ FFMA R23, R21, R24, R23 ; /* 0x0000001815177223 */ /* 0x001fc60000000017 */ /*07b0*/ LDS R21, [R4+0x28] ; /* 0x0000280004157984 */ /* 0x000fe80000000800 */ /*07c0*/ LDS R24, [R5+0x28] ; /* 0x0000280005187984 */ /* 0x000e220000000800 */ /*07d0*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*07e0*/ LDS R26, [R4+0x2c] ; /* 0x00002c00041a7984 */ /* 0x000fe80000000800 */ /*07f0*/ LDS R25, [R5+0x2c] ; /* 0x00002c0005197984 */ /* 0x000e620000000800 */ /*0800*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*0810*/ LDS R7, [R4+0x30] ; /* 0x0000300004077984 */ /* 0x000fe80000000800 */ /*0820*/ LDS R20, [R5+0x30] ; /* 0x0000300005147984 */ /* 0x000ea20000000800 */ /*0830*/ FFMA R21, R21, R24, R23 ; /* 0x0000001815157223 */ /* 0x001fc60000000017 */ /*0840*/ LDS R24, [R4+0x34] ; /* 0x0000340004187984 */ /* 0x0001e80000000800 */ /*0850*/ LDS R23, [R5+0x34] ; /* 0x0000340005177984 */ /* 0x0007220000000800 */ /*0860*/ FFMA R21, R26, R25, R21 ; /* 0x000000191a157223 */ /* 0x002fe20000000015 */ /*0870*/ IADD3 R4, R4, 0x40, RZ ; /* 0x0000004004047810 */ /* 0x001fe40007ffe0ff */ /*0880*/ IADD3 R5, R5, 0x40, RZ ; /* 0x0000004005057810 */ /* 0x008fe20007ffe0ff */ /*0890*/ FFMA R21, R7, R20, R21 ; /* 0x0000001407157223 */ /* 0x004fc80000000015 */ /*08a0*/ FFMA R21, R24, R23, R21 ; /* 0x0000001718157223 */ /* 0x010fe20000000015 */ /*08b0*/ @P2 BRA 0x560 ; /* 0xfffffca000002947 */ /* 0x000fea000383ffff */ /*08c0*/ ISETP.GT.AND P2, PT, R6, 0x4, PT ; /* 0x000000040600780c */ /* 0x000fda0003f44270 */ /*08d0*/ @!P2 BRA 0xab0 ; /* 0x000001d00000a947 */ /* 0x000fea0003800000 */ /*08e0*/ LDS R20, [R4+-0x8] ; /* 0xfffff80004147984 */ /* 0x000fe20000000800 */ /*08f0*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe20003f0e170 */ /*0900*/ UIADD3 UR4, UR4, 0x8, URZ ; /* 0x0000000804047890 */ /* 0x000fe2000fffe03f */ /*0910*/ IADD3 R6, R6, -0x8, RZ ; /* 0xfffffff806067810 */ /* 0x000fe20007ffe0ff */ /*0920*/ LDS R7, [R5+-0x8] ; /* 0xfffff80005077984 */ /* 0x000e280000000800 */ /*0930*/ LDS R24, [R4+-0x4] ; /* 0xfffffc0004187984 */ /* 0x000fe80000000800 */ /*0940*/ LDS R23, [R5+-0x4] ; /* 0xfffffc0005177984 */ /* 0x000e680000000800 */ /*0950*/ LDS R26, [R4] ; /* 0x00000000041a7984 */ /* 0x000fe80000000800 */ /*0960*/ LDS R25, [R5+0x4] ; /* 0x0000040005197984 */ /* 0x000fe20000000800 */ /*0970*/ FFMA R7, R20, R7, R21 ; /* 0x0000000714077223 */ /* 0x021fc60000000015 */ /*0980*/ LDS R21, [R5] ; /* 0x0000000005157984 */ /* 0x000e280000000800 */ /*0990*/ LDS R20, [R5+0x8] ; /* 0x0000080005147984 */ /* 0x000fe20000000800 */ /*09a0*/ FFMA R23, R24, R23, R7 ; /* 0x0000001718177223 */ /* 0x002fc60000000007 */ /*09b0*/ LDS R24, [R4+0x4] ; /* 0x0000040004187984 */ /* 0x000e680000000800 */ /*09c0*/ LDS R7, [R4+0x8] ; /* 0x0000080004077984 */ /* 0x000ea20000000800 */ /*09d0*/ FFMA R21, R26, R21, R23 ; /* 0x000000151a157223 */ /* 0x001fc60000000017 */ /*09e0*/ LDS R23, [R5+0xc] ; /* 0x00000c0005177984 */ /* 0x000fe80000000800 */ /*09f0*/ LDS R26, [R4+0x14] ; /* 0x00001400041a7984 */ /* 0x000fe20000000800 */ /*0a00*/ FFMA R21, R24, R25, R21 ; /* 0x0000001918157223 */ /* 0x002fc60000000015 */ /*0a10*/ LDS R24, [R4+0xc] ; /* 0x00000c0004187984 */ /* 0x000e220000000800 */ /*0a20*/ FFMA R7, R7, R20, R21 ; /* 0x0000001407077223 */ /* 0x004fc60000000015 */ /*0a30*/ LDS R20, [R4+0x10] ; /* 0x0000100004147984 */ /* 0x0003e80000000800 */ /*0a40*/ LDS R21, [R5+0x10] ; /* 0x0000100005157984 */ /* 0x000ea80000000800 */ /*0a50*/ LDS R25, [R5+0x14] ; /* 0x0000140005197984 */ /* 0x0007220000000800 */ /*0a60*/ IADD3 R4, R4, 0x20, RZ ; /* 0x0000002004047810 */ /* 0x002fe40007ffe0ff */ /*0a70*/ IADD3 R5, R5, 0x20, RZ ; /* 0x0000002005057810 */ /* 0x008fe20007ffe0ff */ /*0a80*/ FFMA R7, R24, R23, R7 ; /* 0x0000001718077223 */ /* 0x001fc80000000007 */ /*0a90*/ FFMA R21, R20, R21, R7 ; /* 0x0000001514157223 */ /* 0x004fc80000000007 */ /*0aa0*/ FFMA R21, R26, R25, R21 ; /* 0x000000191a157223 */ /* 0x010fe40000000015 */ /*0ab0*/ ISETP.NE.OR P0, PT, R6, RZ, P0 ; /* 0x000000ff0600720c */ /* 0x000fda0000705670 */ /*0ac0*/ @!P0 BRA 0xbf0 ; /* 0x0000012000008947 */ /* 0x000fea0003800000 */ /*0ad0*/ LDS R24, [R4+-0x8] ; /* 0xfffff80004187984 */ /* 0x000fe20000000800 */ /*0ae0*/ IADD3 R6, R6, -0x4, RZ ; /* 0xfffffffc06067810 */ /* 0x000fe20007ffe0ff */ /*0af0*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*0b00*/ LDS R23, [R5+-0x8] ; /* 0xfffff80005177984 */ /* 0x000e220000000800 */ /*0b10*/ ISETP.NE.AND P0, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fc60003f05270 */ /*0b20*/ LDS R26, [R4+-0x4] ; /* 0xfffffc00041a7984 */ /* 0x000fe80000000800 */ /*0b30*/ LDS R25, [R5+-0x4] ; /* 0xfffffc0005197984 */ /* 0x000e680000000800 */ /*0b40*/ LDS R7, [R4] ; /* 0x0000000004077984 */ /* 0x000fe80000000800 */ /*0b50*/ LDS R20, [R5] ; /* 0x0000000005147984 */ /* 0x000ea20000000800 */ /*0b60*/ FFMA R23, R24, R23, R21 ; /* 0x0000001718177223 */ /* 0x021fc60000000015 */ /*0b70*/ LDS R24, [R4+0x4] ; /* 0x0000040004187984 */ /* 0x0001e80000000800 */ /*0b80*/ LDS R21, [R5+0x4] ; /* 0x0000040005157984 */ /* 0x0007220000000800 */ /*0b90*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fe20000000017 */ /*0ba0*/ IADD3 R4, R4, 0x10, RZ ; /* 0x0000001004047810 */ /* 0x001fe40007ffe0ff */ /*0bb0*/ IADD3 R5, R5, 0x10, RZ ; /* 0x0000001005057810 */ /* 0x008fe20007ffe0ff */ /*0bc0*/ FFMA R7, R7, R20, R23 ; /* 0x0000001407077223 */ /* 0x004fc80000000017 */ /*0bd0*/ FFMA R21, R24, R21, R7 ; /* 0x0000001518157223 */ /* 0x010fe20000000007 */ /*0be0*/ @P0 BRA 0xad0 ; /* 0xfffffee000000947 */ /* 0x000fea000383ffff */ /*0bf0*/ ISETP.NE.AND P0, PT, R14, RZ, PT ; /* 0x000000ff0e00720c */ /* 0x001fda0003f05270 */ /*0c00*/ @!P0 BRA 0xd10 ; /* 0x0000010000008947 */ /* 0x000fea0003800000 */ /*0c10*/ IADD3 R5, R16, UR4, RZ ; /* 0x0000000410057c10 */ /* 0x000fe4000fffe0ff */ /*0c20*/ IADD3 R4, R11, UR4, RZ ; /* 0x000000040b047c10 */ /* 0x000fe4000fffe0ff */ /*0c30*/ SHF.L.U32 R23, R5, 0x2, RZ ; /* 0x0000000205177819 */ /* 0x000fe400000006ff */ /*0c40*/ SHF.L.U32 R20, R4, 0x2, RZ ; /* 0x0000000204147819 */ /* 0x000fe400000006ff */ /*0c50*/ ISETP.NE.AND P0, PT, R14, 0x1, PT ; /* 0x000000010e00780c */ /* 0x000fe20003f05270 */ /*0c60*/ LDS R4, [R23] ; /* 0x0000000017047984 */ /* 0x000fe80000000800 */ /*0c70*/ LDS R5, [R20] ; /* 0x0000000014057984 */ /* 0x000e240000000800 */ /*0c80*/ FFMA R21, R4, R5, R21 ; /* 0x0000000504157223 */ /* 0x021fcc0000000015 */ /*0c90*/ @!P0 BRA 0xd10 ; /* 0x0000007000008947 */ /* 0x000fea0003800000 */ /*0ca0*/ ISETP.NE.AND P0, PT, R14, 0x2, PT ; /* 0x000000020e00780c */ /* 0x000fe20003f05270 */ /*0cb0*/ LDS R4, [R23+0x4] ; /* 0x0000040017047984 */ /* 0x000fe80000000800 */ /*0cc0*/ LDS R5, [R20+0x4] ; /* 0x0000040014057984 */ /* 0x000e300000000800 */ /*0cd0*/ @P0 LDS R6, [R23+0x8] ; /* 0x0000080017060984 */ /* 0x000fe80000000800 */ /*0ce0*/ @P0 LDS R7, [R20+0x8] ; /* 0x0000080014070984 */ /* 0x000e620000000800 */ /*0cf0*/ FFMA R21, R4, R5, R21 ; /* 0x0000000504157223 */ /* 0x001fc80000000015 */ /*0d00*/ @P0 FFMA R21, R6, R7, R21 ; /* 0x0000000706150223 */ /* 0x002fca0000000015 */ /*0d10*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0201e4000c101906 */ /*0d20*/ @!P1 BRA 0x380 ; /* 0xfffff65000009947 */ /* 0x001fea000383ffff */ /*0d30*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0d40*/ BRA 0xd40; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0d50*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d60*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d80*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d90*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0da0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0db0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0dc0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0dd0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0de0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0df0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z15transposeMatrixPfS_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.X ; /* 0x0000000000007919 */ /* 0x000e220000002500 */ /*0020*/ HFMA2.MMA R4, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff047435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e280000002100 */ /*0050*/ S2R R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000e680000002600 */ /*0060*/ S2R R2, SR_TID.Y ; /* 0x0000000000027919 */ /* 0x000e620000002200 */ /*0070*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fc400078e0203 */ /*0080*/ IMAD R5, R5, c[0x0][0x4], R2 ; /* 0x0000010005057a24 */ /* 0x002fc800078e0202 */ /*0090*/ IMAD R2, R0, c[0x0][0x174], R5 ; /* 0x00005d0000027a24 */ /* 0x000fc800078e0205 */ /*00a0*/ IMAD.WIDE R2, R2, R4, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x000fcc00078e0204 */ /*00b0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD R5, R5, c[0x0][0x170], R0 ; /* 0x00005c0005057a24 */ /* 0x000fc800078e0200 */ /*00d0*/ IMAD.WIDE R4, R5, R4, c[0x0][0x168] ; /* 0x00005a0005047625 */ /* 0x000fca00078e0204 */ /*00e0*/ STG.E [R4.64], R3 ; /* 0x0000000304007986 */ /* 0x004fe2000c101904 */ /*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 <iostream> void fillMatrixA(float* A, int height, int width) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { A[width * i + j] = (i == j) ? 1 : 0; } } } void fillMatrixB(float* B, int height, int width) { fillMatrixA(B, height, width); } __global__ void transposeMatrix(float* B, float* B_T, int B_height, int B_width) { int threadIdxG_x = blockIdx.x * blockDim.x + threadIdx.x; int threadIdxG_y = blockIdx.y * blockDim.y + threadIdx.y; B_T[B_height * threadIdxG_y + threadIdxG_x] = B[B_width * threadIdxG_x + threadIdxG_y]; } __global__ void matrixMul(float* A, float* B_T, float* C, const int mid_size) { // cond: B must be already transposed, // sizes A, B, C are matched, // mid_size equals to A_width and B_T width, // block must be as square !!! int block_side_size = blockDim.x; int block_size = blockDim.x * blockDim.x; extern __shared__ float sh_A_block[ ]; float* sh_B_block = sh_A_block + block_size; int block_cnt = mid_size / block_side_size; for (int matrix_block_idx = 0; matrix_block_idx < block_cnt; ++matrix_block_idx) { int A_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int A_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int A_global_idx = A_global_idx_x * mid_size + A_global_idx_y; sh_A_block[threadIdx.x * block_side_size + threadIdx.y] = A[A_global_idx]; int B_T_global_idx_x = blockIdx.y * block_side_size + threadIdx.x; int B_T_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int B_T_global_idx = B_T_global_idx_x * mid_size + B_T_global_idx_y; sh_B_block[threadIdx.x * block_side_size + threadIdx.y] = B_T[B_T_global_idx]; __syncthreads(); int C_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int C_global_idx_y = blockIdx.y * block_side_size + threadIdx.y; int C_global_idx = C_global_idx_x * gridDim.y * block_side_size + C_global_idx_y; for (int k = 0; k < block_side_size; ++k) { C[C_global_idx] += sh_A_block[threadIdx.x * block_side_size + k] * sh_B_block[threadIdx.y * block_side_size + k]; } } } int main() { // cond: sizes A and B are matched, // height and width are multiples of the block size (block is square), const int k_block_side_size = 16; const int k_A_height = 128; // to change const int k_A_width = 384; // to change const int k_B_width = 256; // to change const int k_B_height = k_A_width; const int k_C_height = k_A_height; const int k_C_width = k_B_width; float* h_A = new float[k_A_height * k_A_width]; float* h_B = new float[k_B_height * k_B_width]; float* h_C = new float[k_C_height * k_C_width]; fillMatrixA(h_A, k_A_height, k_A_width); fillMatrixB(h_B, k_B_height, k_B_width); float* d_A; float* d_B; float* d_B_T; float* d_C; cudaMalloc(&d_A, sizeof(float) * k_A_height * k_A_width); cudaMalloc(&d_B, sizeof(float) * k_B_height * k_B_width); cudaMalloc(&d_B_T, sizeof(float) * k_B_width * k_B_height); cudaMalloc(&d_C, sizeof(float) * k_C_height * k_C_width); cudaMemcpy(d_A, h_A, sizeof(float) * k_A_height * k_A_width, cudaMemcpyHostToDevice); cudaMemcpy(d_B, h_B, sizeof(float) * k_B_height * k_B_width, cudaMemcpyHostToDevice); dim3 block_size(k_block_side_size, k_block_side_size); dim3 num_blocks_B(k_B_height / k_block_side_size, k_B_width / k_block_side_size); transposeMatrix<<< num_blocks_B, block_size >>>(d_B, d_B_T, k_B_height, k_B_width); dim3 num_blocks_C(k_C_height / k_block_side_size, k_C_width / k_block_side_size); matrixMul<<< num_blocks_C, block_size, sizeof(float) * 2 * k_block_side_size * k_block_side_size >>>(d_A, d_B_T, d_C, k_A_width); cudaMemcpy(h_C, d_C, sizeof(float) * k_C_height * k_C_width, cudaMemcpyDeviceToHost); for (int i = 0; i < k_C_height; ++i) { for (int j = 0; j < k_C_width; ++j) { std::cout << i << ' ' << j << ' ' << h_C[k_C_width * i + j] << std::endl; } } delete[] h_A; delete[] h_B; delete[] h_C; cudaFree(d_A); cudaFree(d_B); cudaFree(d_B_T); cudaFree(d_C); return 0; }
.file "tmpxft_0019fe68_00000000-6_shared.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3674: .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 .LFE3674: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z11fillMatrixAPfii .type _Z11fillMatrixAPfii, @function _Z11fillMatrixAPfii: .LFB3669: .cfi_startproc endbr64 testl %esi, %esi jle .L3 movl $0, %r10d movl $0, %ecx movslq %edx, %r9 pxor %xmm1, %xmm1 movss .LC0(%rip), %xmm2 jmp .L5 .L6: movss %xmm0, (%r8,%rax,4) addq $1, %rax cmpq %r9, %rax je .L9 .L7: movaps %xmm1, %xmm0 cmpl %eax, %ecx jne .L6 movaps %xmm2, %xmm0 jmp .L6 .L9: addl $1, %ecx addl %edx, %r10d cmpl %ecx, %esi je .L3 .L5: testl %edx, %edx jle .L9 movslq %r10d, %rax leaq (%rdi,%rax,4), %r8 movl $0, %eax jmp .L7 .L3: ret .cfi_endproc .LFE3669: .size _Z11fillMatrixAPfii, .-_Z11fillMatrixAPfii .globl _Z11fillMatrixBPfii .type _Z11fillMatrixBPfii, @function _Z11fillMatrixBPfii: .LFB3670: .cfi_startproc endbr64 call _Z11fillMatrixAPfii ret .cfi_endproc .LFE3670: .size _Z11fillMatrixBPfii, .-_Z11fillMatrixBPfii .globl _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii .type _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii, @function _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii: .LFB3696: .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 .L17 .L13: movq 136(%rsp), %rax subq %fs:40, %rax jne .L18 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L17: .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 _Z15transposeMatrixPfS_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L13 .L18: call __stack_chk_fail@PLT .cfi_endproc .LFE3696: .size _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii, .-_Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii .globl _Z15transposeMatrixPfS_ii .type _Z15transposeMatrixPfS_ii, @function _Z15transposeMatrixPfS_ii: .LFB3697: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3697: .size _Z15transposeMatrixPfS_ii, .-_Z15transposeMatrixPfS_ii .globl _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i .type _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i, @function _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i: .LFB3698: .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 .L25 .L21: movq 136(%rsp), %rax subq %fs:40, %rax jne .L26 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L25: .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 _Z9matrixMulPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L21 .L26: call __stack_chk_fail@PLT .cfi_endproc .LFE3698: .size _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i, .-_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i .globl _Z9matrixMulPfS_S_i .type _Z9matrixMulPfS_S_i, @function _Z9matrixMulPfS_S_i: .LFB3699: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3699: .size _Z9matrixMulPfS_S_i, .-_Z9matrixMulPfS_S_i .globl main .type main, @function main: .LFB3671: .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 $136, %rsp .cfi_def_cfa_offset 192 movq %fs:40, %rax movq %rax, 120(%rsp) xorl %eax, %eax movl $196608, %edi call _Znam@PLT movq %rax, %r14 movq %rax, 16(%rsp) movl $393216, %edi call _Znam@PLT movq %rax, %rbx movq %rax, 24(%rsp) movl $131072, %edi call _Znam@PLT movq %rax, 8(%rsp) movl $384, %edx movl $128, %esi movq %r14, %rdi call _Z11fillMatrixAPfii movl $256, %edx movl $384, %esi movq %rbx, %rdi call _Z11fillMatrixAPfii leaq 48(%rsp), %rdi movl $196608, %esi call cudaMalloc@PLT leaq 56(%rsp), %rdi movl $393216, %esi call cudaMalloc@PLT leaq 64(%rsp), %rdi movl $393216, %esi call cudaMalloc@PLT leaq 72(%rsp), %rdi movl $131072, %esi call cudaMalloc@PLT movl $1, %ecx movl $196608, %edx movq %r14, %rsi movq 48(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $393216, %edx movq %rbx, %rsi movq 56(%rsp), %rdi call cudaMemcpy@PLT movl $16, 84(%rsp) movl $16, 88(%rsp) movl $1, 92(%rsp) movl $24, 96(%rsp) movl $16, 100(%rsp) movl $1, 104(%rsp) movl $0, %r9d movl $0, %r8d movq 84(%rsp), %rdx movl $1, %ecx movq 96(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L46 .L30: movl $8, 108(%rsp) movl $16, 112(%rsp) movl $1, 116(%rsp) movl 92(%rsp), %ecx movl $0, %r9d movl $2048, %r8d movq 84(%rsp), %rdx movq 108(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L47 .L31: movl $2, %ecx movl $131072, %edx movq 72(%rsp), %rsi movq 8(%rsp), %r13 movq %r13, %rdi call cudaMemcpy@PLT movl $0, %r12d leaq _ZSt4cout(%rip), %r14 jmp .L32 .L46: movl $256, %ecx movl $384, %edx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii jmp .L30 .L47: movl $384, %ecx movq 72(%rsp), %rdx movq 64(%rsp), %rsi movq 48(%rsp), %rdi call _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i jmp .L31 .L33: movl $32, %esi movq %rbx, %rdi call _ZNSo3putEc@PLT jmp .L34 .L35: movl $32, %esi movq %rbx, %rdi call _ZNSo3putEc@PLT .L36: pxor %xmm0, %xmm0 cvtss2sd 0(%r13,%rbp,4), %xmm0 movq %rbx, %rdi call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rbx movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %r15 testq %r15, %r15 je .L48 cmpb $0, 56(%r15) je .L39 movzbl 67(%r15), %esi .L40: movsbl %sil, %esi movq %rbx, %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT addq $1, %rbp cmpq $256, %rbp je .L49 .L41: movl %ebp, %r15d movl %r12d, %esi movq %r14, %rdi call _ZNSolsEi@PLT movq %rax, %rbx movb $32, 47(%rsp) movq (%rax), %rax movq -24(%rax), %rax cmpq $0, 16(%rbx,%rax) je .L33 leaq 47(%rsp), %rsi movl $1, %edx movq %rbx, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq %rax, %rbx .L34: movl %r15d, %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rbx movb $32, 47(%rsp) movq (%rax), %rax movq -24(%rax), %rax cmpq $0, 16(%rbx,%rax) je .L35 leaq 47(%rsp), %rsi movl $1, %edx movq %rbx, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq %rax, %rbx jmp .L36 .L48: movq 120(%rsp), %rax subq %fs:40, %rax jne .L50 call _ZSt16__throw_bad_castv@PLT .L50: call __stack_chk_fail@PLT .L39: movq %r15, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%r15), %rax movl $10, %esi movq %r15, %rdi call *48(%rax) movl %eax, %esi jmp .L40 .L49: addl $1, %r12d addq $1024, %r13 cmpl $128, %r12d je .L42 .L32: movl $0, %ebp jmp .L41 .L42: movq 16(%rsp), %rdi call _ZdaPv@PLT movq 24(%rsp), %rdi call _ZdaPv@PLT movq 8(%rsp), %rdi call _ZdaPv@PLT movq 48(%rsp), %rdi call cudaFree@PLT movq 56(%rsp), %rdi call cudaFree@PLT movq 64(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT movq 120(%rsp), %rax subq %fs:40, %rax jne .L51 movl $0, %eax addq $136, %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 .L51: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE3671: .size main, .-main .section .rodata.str1.1,"aMS",@progbits,1 .LC2: .string "_Z9matrixMulPfS_S_i" .LC3: .string "_Z15transposeMatrixPfS_ii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3701: .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 .LC2(%rip), %rdx movq %rdx, %rcx leaq _Z9matrixMulPfS_S_i(%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 .LC3(%rip), %rdx movq %rdx, %rcx leaq _Z15transposeMatrixPfS_ii(%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 .LFE3701: .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 1065353216 .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> void fillMatrixA(float* A, int height, int width) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { A[width * i + j] = (i == j) ? 1 : 0; } } } void fillMatrixB(float* B, int height, int width) { fillMatrixA(B, height, width); } __global__ void transposeMatrix(float* B, float* B_T, int B_height, int B_width) { int threadIdxG_x = blockIdx.x * blockDim.x + threadIdx.x; int threadIdxG_y = blockIdx.y * blockDim.y + threadIdx.y; B_T[B_height * threadIdxG_y + threadIdxG_x] = B[B_width * threadIdxG_x + threadIdxG_y]; } __global__ void matrixMul(float* A, float* B_T, float* C, const int mid_size) { // cond: B must be already transposed, // sizes A, B, C are matched, // mid_size equals to A_width and B_T width, // block must be as square !!! int block_side_size = blockDim.x; int block_size = blockDim.x * blockDim.x; extern __shared__ float sh_A_block[ ]; float* sh_B_block = sh_A_block + block_size; int block_cnt = mid_size / block_side_size; for (int matrix_block_idx = 0; matrix_block_idx < block_cnt; ++matrix_block_idx) { int A_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int A_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int A_global_idx = A_global_idx_x * mid_size + A_global_idx_y; sh_A_block[threadIdx.x * block_side_size + threadIdx.y] = A[A_global_idx]; int B_T_global_idx_x = blockIdx.y * block_side_size + threadIdx.x; int B_T_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int B_T_global_idx = B_T_global_idx_x * mid_size + B_T_global_idx_y; sh_B_block[threadIdx.x * block_side_size + threadIdx.y] = B_T[B_T_global_idx]; __syncthreads(); int C_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int C_global_idx_y = blockIdx.y * block_side_size + threadIdx.y; int C_global_idx = C_global_idx_x * gridDim.y * block_side_size + C_global_idx_y; for (int k = 0; k < block_side_size; ++k) { C[C_global_idx] += sh_A_block[threadIdx.x * block_side_size + k] * sh_B_block[threadIdx.y * block_side_size + k]; } } } int main() { // cond: sizes A and B are matched, // height and width are multiples of the block size (block is square), const int k_block_side_size = 16; const int k_A_height = 128; // to change const int k_A_width = 384; // to change const int k_B_width = 256; // to change const int k_B_height = k_A_width; const int k_C_height = k_A_height; const int k_C_width = k_B_width; float* h_A = new float[k_A_height * k_A_width]; float* h_B = new float[k_B_height * k_B_width]; float* h_C = new float[k_C_height * k_C_width]; fillMatrixA(h_A, k_A_height, k_A_width); fillMatrixB(h_B, k_B_height, k_B_width); float* d_A; float* d_B; float* d_B_T; float* d_C; cudaMalloc(&d_A, sizeof(float) * k_A_height * k_A_width); cudaMalloc(&d_B, sizeof(float) * k_B_height * k_B_width); cudaMalloc(&d_B_T, sizeof(float) * k_B_width * k_B_height); cudaMalloc(&d_C, sizeof(float) * k_C_height * k_C_width); cudaMemcpy(d_A, h_A, sizeof(float) * k_A_height * k_A_width, cudaMemcpyHostToDevice); cudaMemcpy(d_B, h_B, sizeof(float) * k_B_height * k_B_width, cudaMemcpyHostToDevice); dim3 block_size(k_block_side_size, k_block_side_size); dim3 num_blocks_B(k_B_height / k_block_side_size, k_B_width / k_block_side_size); transposeMatrix<<< num_blocks_B, block_size >>>(d_B, d_B_T, k_B_height, k_B_width); dim3 num_blocks_C(k_C_height / k_block_side_size, k_C_width / k_block_side_size); matrixMul<<< num_blocks_C, block_size, sizeof(float) * 2 * k_block_side_size * k_block_side_size >>>(d_A, d_B_T, d_C, k_A_width); cudaMemcpy(h_C, d_C, sizeof(float) * k_C_height * k_C_width, cudaMemcpyDeviceToHost); for (int i = 0; i < k_C_height; ++i) { for (int j = 0; j < k_C_width; ++j) { std::cout << i << ' ' << j << ' ' << h_C[k_C_width * i + j] << std::endl; } } delete[] h_A; delete[] h_B; delete[] h_C; cudaFree(d_A); cudaFree(d_B); cudaFree(d_B_T); cudaFree(d_C); return 0; }
#include <hip/hip_runtime.h> #include <iostream> void fillMatrixA(float* A, int height, int width) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { A[width * i + j] = (i == j) ? 1 : 0; } } } void fillMatrixB(float* B, int height, int width) { fillMatrixA(B, height, width); } __global__ void transposeMatrix(float* B, float* B_T, int B_height, int B_width) { int threadIdxG_x = blockIdx.x * blockDim.x + threadIdx.x; int threadIdxG_y = blockIdx.y * blockDim.y + threadIdx.y; B_T[B_height * threadIdxG_y + threadIdxG_x] = B[B_width * threadIdxG_x + threadIdxG_y]; } __global__ void matrixMul(float* A, float* B_T, float* C, const int mid_size) { // cond: B must be already transposed, // sizes A, B, C are matched, // mid_size equals to A_width and B_T width, // block must be as square !!! int block_side_size = blockDim.x; int block_size = blockDim.x * blockDim.x; extern __shared__ float sh_A_block[ ]; float* sh_B_block = sh_A_block + block_size; int block_cnt = mid_size / block_side_size; for (int matrix_block_idx = 0; matrix_block_idx < block_cnt; ++matrix_block_idx) { int A_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int A_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int A_global_idx = A_global_idx_x * mid_size + A_global_idx_y; sh_A_block[threadIdx.x * block_side_size + threadIdx.y] = A[A_global_idx]; int B_T_global_idx_x = blockIdx.y * block_side_size + threadIdx.x; int B_T_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int B_T_global_idx = B_T_global_idx_x * mid_size + B_T_global_idx_y; sh_B_block[threadIdx.x * block_side_size + threadIdx.y] = B_T[B_T_global_idx]; __syncthreads(); int C_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int C_global_idx_y = blockIdx.y * block_side_size + threadIdx.y; int C_global_idx = C_global_idx_x * gridDim.y * block_side_size + C_global_idx_y; for (int k = 0; k < block_side_size; ++k) { C[C_global_idx] += sh_A_block[threadIdx.x * block_side_size + k] * sh_B_block[threadIdx.y * block_side_size + k]; } } } int main() { // cond: sizes A and B are matched, // height and width are multiples of the block size (block is square), const int k_block_side_size = 16; const int k_A_height = 128; // to change const int k_A_width = 384; // to change const int k_B_width = 256; // to change const int k_B_height = k_A_width; const int k_C_height = k_A_height; const int k_C_width = k_B_width; float* h_A = new float[k_A_height * k_A_width]; float* h_B = new float[k_B_height * k_B_width]; float* h_C = new float[k_C_height * k_C_width]; fillMatrixA(h_A, k_A_height, k_A_width); fillMatrixB(h_B, k_B_height, k_B_width); float* d_A; float* d_B; float* d_B_T; float* d_C; hipMalloc(&d_A, sizeof(float) * k_A_height * k_A_width); hipMalloc(&d_B, sizeof(float) * k_B_height * k_B_width); hipMalloc(&d_B_T, sizeof(float) * k_B_width * k_B_height); hipMalloc(&d_C, sizeof(float) * k_C_height * k_C_width); hipMemcpy(d_A, h_A, sizeof(float) * k_A_height * k_A_width, hipMemcpyHostToDevice); hipMemcpy(d_B, h_B, sizeof(float) * k_B_height * k_B_width, hipMemcpyHostToDevice); dim3 block_size(k_block_side_size, k_block_side_size); dim3 num_blocks_B(k_B_height / k_block_side_size, k_B_width / k_block_side_size); transposeMatrix<<< num_blocks_B, block_size >>>(d_B, d_B_T, k_B_height, k_B_width); dim3 num_blocks_C(k_C_height / k_block_side_size, k_C_width / k_block_side_size); matrixMul<<< num_blocks_C, block_size, sizeof(float) * 2 * k_block_side_size * k_block_side_size >>>(d_A, d_B_T, d_C, k_A_width); hipMemcpy(h_C, d_C, sizeof(float) * k_C_height * k_C_width, hipMemcpyDeviceToHost); for (int i = 0; i < k_C_height; ++i) { for (int j = 0; j < k_C_width; ++j) { std::cout << i << ' ' << j << ' ' << h_C[k_C_width * i + j] << std::endl; } } delete[] h_A; delete[] h_B; delete[] h_C; hipFree(d_A); hipFree(d_B); hipFree(d_B_T); 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 <iostream> void fillMatrixA(float* A, int height, int width) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { A[width * i + j] = (i == j) ? 1 : 0; } } } void fillMatrixB(float* B, int height, int width) { fillMatrixA(B, height, width); } __global__ void transposeMatrix(float* B, float* B_T, int B_height, int B_width) { int threadIdxG_x = blockIdx.x * blockDim.x + threadIdx.x; int threadIdxG_y = blockIdx.y * blockDim.y + threadIdx.y; B_T[B_height * threadIdxG_y + threadIdxG_x] = B[B_width * threadIdxG_x + threadIdxG_y]; } __global__ void matrixMul(float* A, float* B_T, float* C, const int mid_size) { // cond: B must be already transposed, // sizes A, B, C are matched, // mid_size equals to A_width and B_T width, // block must be as square !!! int block_side_size = blockDim.x; int block_size = blockDim.x * blockDim.x; extern __shared__ float sh_A_block[ ]; float* sh_B_block = sh_A_block + block_size; int block_cnt = mid_size / block_side_size; for (int matrix_block_idx = 0; matrix_block_idx < block_cnt; ++matrix_block_idx) { int A_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int A_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int A_global_idx = A_global_idx_x * mid_size + A_global_idx_y; sh_A_block[threadIdx.x * block_side_size + threadIdx.y] = A[A_global_idx]; int B_T_global_idx_x = blockIdx.y * block_side_size + threadIdx.x; int B_T_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int B_T_global_idx = B_T_global_idx_x * mid_size + B_T_global_idx_y; sh_B_block[threadIdx.x * block_side_size + threadIdx.y] = B_T[B_T_global_idx]; __syncthreads(); int C_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int C_global_idx_y = blockIdx.y * block_side_size + threadIdx.y; int C_global_idx = C_global_idx_x * gridDim.y * block_side_size + C_global_idx_y; for (int k = 0; k < block_side_size; ++k) { C[C_global_idx] += sh_A_block[threadIdx.x * block_side_size + k] * sh_B_block[threadIdx.y * block_side_size + k]; } } } int main() { // cond: sizes A and B are matched, // height and width are multiples of the block size (block is square), const int k_block_side_size = 16; const int k_A_height = 128; // to change const int k_A_width = 384; // to change const int k_B_width = 256; // to change const int k_B_height = k_A_width; const int k_C_height = k_A_height; const int k_C_width = k_B_width; float* h_A = new float[k_A_height * k_A_width]; float* h_B = new float[k_B_height * k_B_width]; float* h_C = new float[k_C_height * k_C_width]; fillMatrixA(h_A, k_A_height, k_A_width); fillMatrixB(h_B, k_B_height, k_B_width); float* d_A; float* d_B; float* d_B_T; float* d_C; hipMalloc(&d_A, sizeof(float) * k_A_height * k_A_width); hipMalloc(&d_B, sizeof(float) * k_B_height * k_B_width); hipMalloc(&d_B_T, sizeof(float) * k_B_width * k_B_height); hipMalloc(&d_C, sizeof(float) * k_C_height * k_C_width); hipMemcpy(d_A, h_A, sizeof(float) * k_A_height * k_A_width, hipMemcpyHostToDevice); hipMemcpy(d_B, h_B, sizeof(float) * k_B_height * k_B_width, hipMemcpyHostToDevice); dim3 block_size(k_block_side_size, k_block_side_size); dim3 num_blocks_B(k_B_height / k_block_side_size, k_B_width / k_block_side_size); transposeMatrix<<< num_blocks_B, block_size >>>(d_B, d_B_T, k_B_height, k_B_width); dim3 num_blocks_C(k_C_height / k_block_side_size, k_C_width / k_block_side_size); matrixMul<<< num_blocks_C, block_size, sizeof(float) * 2 * k_block_side_size * k_block_side_size >>>(d_A, d_B_T, d_C, k_A_width); hipMemcpy(h_C, d_C, sizeof(float) * k_C_height * k_C_width, hipMemcpyDeviceToHost); for (int i = 0; i < k_C_height; ++i) { for (int j = 0; j < k_C_width; ++j) { std::cout << i << ' ' << j << ' ' << h_C[k_C_width * i + j] << std::endl; } } delete[] h_A; delete[] h_B; delete[] h_C; hipFree(d_A); hipFree(d_B); hipFree(d_B_T); hipFree(d_C); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15transposeMatrixPfS_ii .globl _Z15transposeMatrixPfS_ii .p2align 8 .type _Z15transposeMatrixPfS_ii,@function _Z15transposeMatrixPfS_ii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x24 s_load_b64 s[4:5], s[0:1], 0x10 v_and_b32_e32 v1, 0x3ff, v0 v_bfe_u32 v0, v0, 10, 10 s_waitcnt lgkmcnt(0) s_and_b32 s3, s2, 0xffff s_lshr_b32 s2, s2, 16 v_mad_u64_u32 v[2:3], null, s14, s3, v[1:2] v_mad_u64_u32 v[3:4], null, s15, s2, v[0:1] s_load_b128 s[0:3], s[0:1], 0x0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, v2, s5, v[3:4] 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) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_load_b32 v4, v[0:1], off v_mad_u64_u32 v[0:1], null, v3, s4, v[2: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[0:1], 2, v[0:1] v_add_co_u32 v0, vcc_lo, s2, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_waitcnt vmcnt(0) 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 _Z15transposeMatrixPfS_ii .amdhsa_group_segment_fixed_size 0 .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 5 .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 _Z15transposeMatrixPfS_ii, .Lfunc_end0-_Z15transposeMatrixPfS_ii .section .AMDGPU.csdata,"",@progbits .text .protected _Z9matrixMulPfS_S_i .globl _Z9matrixMulPfS_S_i .p2align 8 .type _Z9matrixMulPfS_S_i,@function _Z9matrixMulPfS_S_i: s_clause 0x1 s_load_b32 s4, s[0:1], 0x2c s_load_b32 s7, s[0:1], 0x18 s_add_u32 s2, s0, 32 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s4, s4, 0xffff s_ashr_i32 s8, s7, 31 v_cvt_f32_u32_e32 v1, s4 s_sub_i32 s6, 0, s4 s_add_i32 s9, s7, s8 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_xor_b32 s9, s9, s8 v_rcp_iflag_f32_e32 v1, v1 s_waitcnt_depctr 0xfff v_mul_f32_e32 v1, 0x4f7ffffe, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cvt_u32_f32_e32 v1, v1 v_readfirstlane_b32 s5, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_mul_i32 s6, s6, s5 s_mul_hi_u32 s6, s5, s6 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s5, s5, s6 s_mul_hi_u32 s5, s9, s5 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_mul_i32 s6, s5, s4 s_sub_i32 s6, s9, s6 s_add_i32 s9, s5, 1 s_sub_i32 s10, s6, s4 s_cmp_ge_u32 s6, s4 s_cselect_b32 s5, s9, s5 s_cselect_b32 s6, s10, s6 s_add_i32 s9, s5, 1 s_cmp_ge_u32 s6, s4 s_mov_b32 s6, 0 s_cselect_b32 s5, s9, s5 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_xor_b32 s5, s5, s8 s_sub_i32 s5, s5, s8 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lt_i32 s5, 1 s_cbranch_scc1 .LBB1_5 v_and_b32_e32 v1, 0x3ff, v0 s_load_b32 s2, s[2:3], 0x4 v_bfe_u32 v0, v0, 10, 10 s_load_b64 s[8:9], s[0:1], 0x10 s_mul_i32 s15, s15, s4 v_mad_u64_u32 v[2:3], null, s14, s4, v[1:2] v_mul_u32_u24_e32 v10, s4, v1 v_add_nc_u32_e32 v1, s15, v1 s_mul_i32 s10, s4, s4 v_mul_u32_u24_e32 v6, s4, v0 s_lshl_b32 s10, s10, 2 v_add_lshl_u32 v7, v10, v0, 2 v_mul_lo_u32 v3, v2, s4 s_add_i32 s10, s10, 0 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mul_lo_u32 v3, v3, s2 s_load_b128 s[0:3], s[0:1], 0x0 v_add3_u32 v4, s15, v0, v3 v_mul_lo_u32 v3, v1, s7 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v5, 31, v4 v_lshlrev_b64 v[8:9], 2, v[4:5] v_mul_lo_u32 v5, v2, s7 v_lshl_add_u32 v4, v6, 2, s10 v_add_nc_u32_e32 v6, 0, v7 v_add_nc_u32_e32 v7, s10, v7 s_max_u32 s7, s4, 1 v_add_co_u32 v1, vcc_lo, s8, v8 v_add_co_ci_u32_e32 v2, vcc_lo, s9, v9, vcc_lo v_lshl_add_u32 v8, v10, 2, 0 s_set_inst_prefetch_distance 0x1 .p2align 6 .LBB1_2: s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[9:10], null, s6, s4, v[0:1] s_mov_b32 s8, s7 v_add_nc_u32_e32 v10, v9, v5 v_add_nc_u32_e32 v12, v9, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v11, 31, v10 v_ashrrev_i32_e32 v13, 31, v12 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[9:10], 2, v[10:11] v_lshlrev_b64 v[11:12], 2, v[12:13] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v9, vcc_lo, s0, v9 v_add_co_ci_u32_e32 v10, vcc_lo, s1, v10, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v11, vcc_lo, s2, v11 v_add_co_ci_u32_e32 v12, vcc_lo, s3, v12, vcc_lo global_load_b32 v9, v[9:10], off global_load_b32 v10, v[11:12], off v_mov_b32_e32 v11, v8 s_waitcnt vmcnt(1) ds_store_b32 v6, v9 s_waitcnt vmcnt(0) ds_store_b32 v7, v10 s_waitcnt lgkmcnt(0) s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv global_load_b32 v9, v[1:2], off v_mov_b32_e32 v10, v4 .LBB1_3: ds_load_b32 v12, v11 ds_load_b32 v13, v10 v_add_nc_u32_e32 v11, 4, v11 v_add_nc_u32_e32 v10, 4, v10 s_add_i32 s8, s8, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_eq_u32 s8, 0 s_waitcnt vmcnt(0) lgkmcnt(0) v_fmac_f32_e32 v9, v12, v13 s_cbranch_scc0 .LBB1_3 s_add_i32 s6, s6, 1 global_store_b32 v[1:2], v9, off s_cmp_eq_u32 s6, s5 s_cbranch_scc0 .LBB1_2 .LBB1_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 _Z9matrixMulPfS_S_i .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 14 .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 _Z9matrixMulPfS_S_i, .Lfunc_end1-_Z9matrixMulPfS_S_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 - .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: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15transposeMatrixPfS_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15transposeMatrixPfS_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 5 .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: 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 - .offset: 152 .size: 4 .value_kind: hidden_dynamic_lds_size .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: _Z9matrixMulPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z9matrixMulPfS_S_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 14 .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 <iostream> void fillMatrixA(float* A, int height, int width) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { A[width * i + j] = (i == j) ? 1 : 0; } } } void fillMatrixB(float* B, int height, int width) { fillMatrixA(B, height, width); } __global__ void transposeMatrix(float* B, float* B_T, int B_height, int B_width) { int threadIdxG_x = blockIdx.x * blockDim.x + threadIdx.x; int threadIdxG_y = blockIdx.y * blockDim.y + threadIdx.y; B_T[B_height * threadIdxG_y + threadIdxG_x] = B[B_width * threadIdxG_x + threadIdxG_y]; } __global__ void matrixMul(float* A, float* B_T, float* C, const int mid_size) { // cond: B must be already transposed, // sizes A, B, C are matched, // mid_size equals to A_width and B_T width, // block must be as square !!! int block_side_size = blockDim.x; int block_size = blockDim.x * blockDim.x; extern __shared__ float sh_A_block[ ]; float* sh_B_block = sh_A_block + block_size; int block_cnt = mid_size / block_side_size; for (int matrix_block_idx = 0; matrix_block_idx < block_cnt; ++matrix_block_idx) { int A_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int A_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int A_global_idx = A_global_idx_x * mid_size + A_global_idx_y; sh_A_block[threadIdx.x * block_side_size + threadIdx.y] = A[A_global_idx]; int B_T_global_idx_x = blockIdx.y * block_side_size + threadIdx.x; int B_T_global_idx_y = matrix_block_idx * block_side_size + threadIdx.y; int B_T_global_idx = B_T_global_idx_x * mid_size + B_T_global_idx_y; sh_B_block[threadIdx.x * block_side_size + threadIdx.y] = B_T[B_T_global_idx]; __syncthreads(); int C_global_idx_x = blockIdx.x * block_side_size + threadIdx.x; int C_global_idx_y = blockIdx.y * block_side_size + threadIdx.y; int C_global_idx = C_global_idx_x * gridDim.y * block_side_size + C_global_idx_y; for (int k = 0; k < block_side_size; ++k) { C[C_global_idx] += sh_A_block[threadIdx.x * block_side_size + k] * sh_B_block[threadIdx.y * block_side_size + k]; } } } int main() { // cond: sizes A and B are matched, // height and width are multiples of the block size (block is square), const int k_block_side_size = 16; const int k_A_height = 128; // to change const int k_A_width = 384; // to change const int k_B_width = 256; // to change const int k_B_height = k_A_width; const int k_C_height = k_A_height; const int k_C_width = k_B_width; float* h_A = new float[k_A_height * k_A_width]; float* h_B = new float[k_B_height * k_B_width]; float* h_C = new float[k_C_height * k_C_width]; fillMatrixA(h_A, k_A_height, k_A_width); fillMatrixB(h_B, k_B_height, k_B_width); float* d_A; float* d_B; float* d_B_T; float* d_C; hipMalloc(&d_A, sizeof(float) * k_A_height * k_A_width); hipMalloc(&d_B, sizeof(float) * k_B_height * k_B_width); hipMalloc(&d_B_T, sizeof(float) * k_B_width * k_B_height); hipMalloc(&d_C, sizeof(float) * k_C_height * k_C_width); hipMemcpy(d_A, h_A, sizeof(float) * k_A_height * k_A_width, hipMemcpyHostToDevice); hipMemcpy(d_B, h_B, sizeof(float) * k_B_height * k_B_width, hipMemcpyHostToDevice); dim3 block_size(k_block_side_size, k_block_side_size); dim3 num_blocks_B(k_B_height / k_block_side_size, k_B_width / k_block_side_size); transposeMatrix<<< num_blocks_B, block_size >>>(d_B, d_B_T, k_B_height, k_B_width); dim3 num_blocks_C(k_C_height / k_block_side_size, k_C_width / k_block_side_size); matrixMul<<< num_blocks_C, block_size, sizeof(float) * 2 * k_block_side_size * k_block_side_size >>>(d_A, d_B_T, d_C, k_A_width); hipMemcpy(h_C, d_C, sizeof(float) * k_C_height * k_C_width, hipMemcpyDeviceToHost); for (int i = 0; i < k_C_height; ++i) { for (int j = 0; j < k_C_width; ++j) { std::cout << i << ' ' << j << ' ' << h_C[k_C_width * i + j] << std::endl; } } delete[] h_A; delete[] h_B; delete[] h_C; hipFree(d_A); hipFree(d_B); hipFree(d_B_T); hipFree(d_C); return 0; }
.text .file "shared.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z11fillMatrixAPfii .LCPI0_0: .long 0x3f800000 # float 1 .text .globl _Z11fillMatrixAPfii .p2align 4, 0x90 .type _Z11fillMatrixAPfii,@function _Z11fillMatrixAPfii: # @_Z11fillMatrixAPfii .cfi_startproc # %bb.0: testl %esi, %esi jle .LBB0_8 # %bb.1: # %.preheader.lr.ph movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI0_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB0_2 .p2align 4, 0x90 .LBB0_7: # %._crit_edge # in Loop: Header=BB0_2 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB0_8 .LBB0_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB0_4 Depth 2 testl %edx, %edx jle .LBB0_7 # %bb.3: # %.lr.ph # in Loop: Header=BB0_2 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d jmp .LBB0_4 .p2align 4, 0x90 .LBB0_6: # in Loop: Header=BB0_4 Depth=2 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx je .LBB0_7 .LBB0_4: # Parent Loop BB0_2 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %r10, %r8 je .LBB0_6 # %bb.5: # in Loop: Header=BB0_4 Depth=2 xorps %xmm1, %xmm1 jmp .LBB0_6 .LBB0_8: # %._crit_edge15 retq .Lfunc_end0: .size _Z11fillMatrixAPfii, .Lfunc_end0-_Z11fillMatrixAPfii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z11fillMatrixBPfii .LCPI1_0: .long 0x3f800000 # float 1 .text .globl _Z11fillMatrixBPfii .p2align 4, 0x90 .type _Z11fillMatrixBPfii,@function _Z11fillMatrixBPfii: # @_Z11fillMatrixBPfii .cfi_startproc # %bb.0: testl %esi, %esi jle .LBB1_8 # %bb.1: # %.preheader.lr.ph.i movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI1_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB1_2 .p2align 4, 0x90 .LBB1_7: # %._crit_edge.i # in Loop: Header=BB1_2 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB1_8 .LBB1_2: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 testl %edx, %edx jle .LBB1_7 # %bb.3: # %.lr.ph.i # in Loop: Header=BB1_2 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d jmp .LBB1_4 .p2align 4, 0x90 .LBB1_6: # in Loop: Header=BB1_4 Depth=2 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx je .LBB1_7 .LBB1_4: # Parent Loop BB1_2 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %r10, %r8 je .LBB1_6 # %bb.5: # in Loop: Header=BB1_4 Depth=2 xorps %xmm1, %xmm1 jmp .LBB1_6 .LBB1_8: # %_Z11fillMatrixAPfii.exit retq .Lfunc_end1: .size _Z11fillMatrixBPfii, .Lfunc_end1-_Z11fillMatrixBPfii .cfi_endproc # -- End function .globl _Z30__device_stub__transposeMatrixPfS_ii # -- Begin function _Z30__device_stub__transposeMatrixPfS_ii .p2align 4, 0x90 .type _Z30__device_stub__transposeMatrixPfS_ii,@function _Z30__device_stub__transposeMatrixPfS_ii: # @_Z30__device_stub__transposeMatrixPfS_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 $_Z15transposeMatrixPfS_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_end2: .size _Z30__device_stub__transposeMatrixPfS_ii, .Lfunc_end2-_Z30__device_stub__transposeMatrixPfS_ii .cfi_endproc # -- End function .globl _Z24__device_stub__matrixMulPfS_S_i # -- Begin function _Z24__device_stub__matrixMulPfS_S_i .p2align 4, 0x90 .type _Z24__device_stub__matrixMulPfS_S_i,@function _Z24__device_stub__matrixMulPfS_S_i: # @_Z24__device_stub__matrixMulPfS_S_i .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 $_Z9matrixMulPfS_S_i, %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_end3: .size _Z24__device_stub__matrixMulPfS_S_i, .Lfunc_end3-_Z24__device_stub__matrixMulPfS_S_i .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI4_0: .long 0x3f800000 # float 1 .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 $168, %rsp .cfi_def_cfa_offset 224 .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 $196608, %edi # imm = 0x30000 callq _Znam movq %rax, %rbx movl $393216, %edi # imm = 0x60000 callq _Znam movq %rax, %r14 movl $131072, %edi # imm = 0x20000 callq _Znam movq %rax, %r15 xorl %eax, %eax movss .LCPI4_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero movq %rbx, %rcx jmp .LBB4_1 .p2align 4, 0x90 .LBB4_5: # %._crit_edge.i # in Loop: Header=BB4_1 Depth=1 incq %rax addq $1536, %rcx # imm = 0x600 cmpq $128, %rax je .LBB4_6 .LBB4_1: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB4_2 Depth 2 xorl %edx, %edx jmp .LBB4_2 .p2align 4, 0x90 .LBB4_4: # in Loop: Header=BB4_2 Depth=2 movss %xmm1, (%rcx,%rdx,4) incq %rdx cmpq $384, %rdx # imm = 0x180 je .LBB4_5 .LBB4_2: # Parent Loop BB4_1 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %rdx, %rax je .LBB4_4 # %bb.3: # in Loop: Header=BB4_2 Depth=2 xorps %xmm1, %xmm1 jmp .LBB4_4 .LBB4_6: # %.preheader.i.i.preheader xorl %eax, %eax movss .LCPI4_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero movq %r14, %rcx jmp .LBB4_7 .p2align 4, 0x90 .LBB4_11: # %._crit_edge.i.i # in Loop: Header=BB4_7 Depth=1 incq %rax addq $1024, %rcx # imm = 0x400 cmpq $384, %rax # imm = 0x180 je .LBB4_12 .LBB4_7: # %.preheader.i.i # =>This Loop Header: Depth=1 # Child Loop BB4_8 Depth 2 xorl %edx, %edx jmp .LBB4_8 .p2align 4, 0x90 .LBB4_10: # in Loop: Header=BB4_8 Depth=2 movss %xmm1, (%rcx,%rdx,4) incq %rdx cmpq $256, %rdx # imm = 0x100 je .LBB4_11 .LBB4_8: # Parent Loop BB4_7 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %rdx, %rax je .LBB4_10 # %bb.9: # in Loop: Header=BB4_8 Depth=2 xorps %xmm1, %xmm1 jmp .LBB4_10 .LBB4_12: # %_Z11fillMatrixBPfii.exit movabsq $68719476752, %r12 # imm = 0x1000000010 leaq 32(%rsp), %rdi movl $196608, %esi # imm = 0x30000 callq hipMalloc leaq 24(%rsp), %rdi movl $393216, %esi # imm = 0x60000 callq hipMalloc leaq 16(%rsp), %rdi movl $393216, %esi # imm = 0x60000 callq hipMalloc leaq 8(%rsp), %rdi movl $131072, %esi # imm = 0x20000 callq hipMalloc movq 32(%rsp), %rdi movl $196608, %edx # imm = 0x30000 movq %rbx, %rsi movl $1, %ecx callq hipMemcpy movq 24(%rsp), %rdi movl $393216, %edx # imm = 0x60000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy leaq 8(%r12), %rdi movl $1, %esi movq %r12, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_14 # %bb.13: movq 24(%rsp), %rax movq 16(%rsp), %rcx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movl $384, 40(%rsp) # imm = 0x180 movl $256, 4(%rsp) # imm = 0x100 leaq 104(%rsp), %rax movq %rax, 112(%rsp) leaq 96(%rsp), %rax movq %rax, 120(%rsp) leaq 40(%rsp), %rax movq %rax, 128(%rsp) leaq 4(%rsp), %rax movq %rax, 136(%rsp) leaq 72(%rsp), %rdi leaq 56(%rsp), %rsi leaq 88(%rsp), %rdx leaq 48(%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 $_Z15transposeMatrixPfS_ii, %edi pushq 48(%rsp) .cfi_adjust_cfa_offset 8 pushq 96(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB4_14: movq %r14, 152(%rsp) # 8-byte Spill movq %rbx, 160(%rsp) # 8-byte Spill leaq -8(%r12), %rdi movl $2048, %r8d # imm = 0x800 movl $1, %esi movq %r12, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_16 # %bb.15: movq 32(%rsp), %rax movq 16(%rsp), %rcx movq 8(%rsp), %rdx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movq %rdx, 88(%rsp) movl $384, 4(%rsp) # imm = 0x180 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 4(%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 $_Z9matrixMulPfS_S_i, %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 .LBB4_16: movq 8(%rsp), %rsi movl $131072, %edx # imm = 0x20000 movq %r15, %rdi movl $2, %ecx callq hipMemcpy xorl %r12d, %r12d leaq 112(%rsp), %r13 movq %r15, 144(%rsp) # 8-byte Spill jmp .LBB4_17 .p2align 4, 0x90 .LBB4_29: # in Loop: Header=BB4_17 Depth=1 incq %r12 addq $1024, %r15 # imm = 0x400 cmpq $128, %r12 je .LBB4_30 .LBB4_17: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB4_18 Depth 2 xorl %ebp, %ebp jmp .LBB4_18 .p2align 4, 0x90 .LBB4_27: # in Loop: Header=BB4_18 Depth=2 movq %r14, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r14), %rax movq %r14, %rdi movl $10, %esi callq *48(%rax) .LBB4_28: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit # in Loop: Header=BB4_18 Depth=2 movsbl %al, %esi movq %rbx, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv incq %rbp cmpq $256, %rbp # imm = 0x100 je .LBB4_29 .LBB4_18: # Parent Loop BB4_17 Depth=1 # => This Inner Loop Header: Depth=2 movl $_ZSt4cout, %edi movl %r12d, %esi callq _ZNSolsEi movb $32, 112(%rsp) movq (%rax), %rcx movq -24(%rcx), %rcx cmpq $0, 16(%rax,%rcx) je .LBB4_20 # %bb.19: # in Loop: Header=BB4_18 Depth=2 movl $1, %edx movq %rax, %rdi movq %r13, %rsi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq %rax, %rdi jmp .LBB4_21 .p2align 4, 0x90 .LBB4_20: # in Loop: Header=BB4_18 Depth=2 movq %rax, %rbx movq %rax, %rdi movl $32, %esi callq _ZNSo3putEc movq %rbx, %rdi .LBB4_21: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c.exit # in Loop: Header=BB4_18 Depth=2 movl %ebp, %esi callq _ZNSolsEi movb $32, 112(%rsp) movq (%rax), %rcx movq -24(%rcx), %rcx cmpq $0, 16(%rax,%rcx) je .LBB4_23 # %bb.22: # in Loop: Header=BB4_18 Depth=2 movl $1, %edx movq %rax, %rdi movq %r13, %rsi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq %rax, %rdi jmp .LBB4_24 .p2align 4, 0x90 .LBB4_23: # in Loop: Header=BB4_18 Depth=2 movq %rax, %rbx movq %rax, %rdi movl $32, %esi callq _ZNSo3putEc movq %rbx, %rdi .LBB4_24: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c.exit41 # in Loop: Header=BB4_18 Depth=2 movss (%r15,%rbp,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 callq _ZNSo9_M_insertIdEERSoT_ movq %rax, %rbx movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %r14 testq %r14, %r14 je .LBB4_31 # %bb.25: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i # in Loop: Header=BB4_18 Depth=2 cmpb $0, 56(%r14) je .LBB4_27 # %bb.26: # in Loop: Header=BB4_18 Depth=2 movzbl 67(%r14), %eax jmp .LBB4_28 .LBB4_30: movq 160(%rsp), %rdi # 8-byte Reload callq _ZdaPv movq 152(%rsp), %rdi # 8-byte Reload callq _ZdaPv movq 144(%rsp), %rdi # 8-byte Reload callq _ZdaPv movq 32(%rsp), %rdi callq hipFree movq 24(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree xorl %eax, %eax addq $168, %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_31: .cfi_def_cfa_offset 224 callq _ZSt16__throw_bad_castv .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 $_Z15transposeMatrixPfS_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 $_Z9matrixMulPfS_S_i, %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_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 _Z15transposeMatrixPfS_ii,@object # @_Z15transposeMatrixPfS_ii .section .rodata,"a",@progbits .globl _Z15transposeMatrixPfS_ii .p2align 3, 0x0 _Z15transposeMatrixPfS_ii: .quad _Z30__device_stub__transposeMatrixPfS_ii .size _Z15transposeMatrixPfS_ii, 8 .type _Z9matrixMulPfS_S_i,@object # @_Z9matrixMulPfS_S_i .globl _Z9matrixMulPfS_S_i .p2align 3, 0x0 _Z9matrixMulPfS_S_i: .quad _Z24__device_stub__matrixMulPfS_S_i .size _Z9matrixMulPfS_S_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z15transposeMatrixPfS_ii" .size .L__unnamed_1, 26 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z9matrixMulPfS_S_i" .size .L__unnamed_2, 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 _Z30__device_stub__transposeMatrixPfS_ii .addrsig_sym _Z24__device_stub__matrixMulPfS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15transposeMatrixPfS_ii .addrsig_sym _Z9matrixMulPfS_S_i .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 : _Z9matrixMulPfS_S_i .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*/ IABS R4, c[0x0][0x0] ; /* 0x0000000000047a13 */ /* 0x000fe20000000000 */ /*0020*/ ULDC UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe20000000800 */ /*0030*/ IABS R6, c[0x0][0x178] ; /* 0x00005e0000067a13 */ /* 0x000fe20000000000 */ /*0040*/ ULDC UR5, c[0x0][0x0] ; /* 0x0000000000057ab9 */ /* 0x000fe20000000800 */ /*0050*/ I2F.RP R0, R4 ; /* 0x0000000400007306 */ /* 0x000e220000209400 */ /*0060*/ ULOP3.LUT UR4, UR4, UR5, URZ, 0x3c, !UPT ; /* 0x0000000504047292 */ /* 0x000fcc000f8e3c3f */ /*0070*/ ISETP.LE.AND P1, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf23270 */ /*0080*/ MUFU.RCP R0, R0 ; /* 0x0000000000007308 */ /* 0x001e240000001000 */ /*0090*/ IADD3 R2, R0, 0xffffffe, RZ ; /* 0x0ffffffe00027810 */ /* 0x001fcc0007ffe0ff */ /*00a0*/ F2I.FTZ.U32.TRUNC.NTZ R3, R2 ; /* 0x0000000200037305 */ /* 0x000064000021f000 */ /*00b0*/ HFMA2.MMA R2, -RZ, RZ, 0, 0 ; /* 0x00000000ff027435 */ /* 0x001fe200000001ff */ /*00c0*/ IMAD.MOV R5, RZ, RZ, -R3 ; /* 0x000000ffff057224 */ /* 0x002fc800078e0a03 */ /*00d0*/ IMAD R5, R5, R4, RZ ; /* 0x0000000405057224 */ /* 0x000fca00078e02ff */ /*00e0*/ IMAD.HI.U32 R3, R3, R5, R2 ; /* 0x0000000503037227 */ /* 0x000fc800078e0002 */ /*00f0*/ IMAD.MOV.U32 R5, RZ, RZ, R6 ; /* 0x000000ffff057224 */ /* 0x000fc800078e0006 */ /*0100*/ IMAD.HI.U32 R0, R3, R5, RZ ; /* 0x0000000503007227 */ /* 0x000fca00078e00ff */ /*0110*/ IADD3 R3, -R0, RZ, RZ ; /* 0x000000ff00037210 */ /* 0x000fca0007ffe1ff */ /*0120*/ IMAD R3, R4, R3, R5 ; /* 0x0000000304037224 */ /* 0x000fca00078e0205 */ /*0130*/ ISETP.GT.U32.AND P2, PT, R4, R3, PT ; /* 0x000000030400720c */ /* 0x000fda0003f44070 */ /*0140*/ @!P2 IMAD.IADD R3, R3, 0x1, -R4 ; /* 0x000000010303a824 */ /* 0x000fe200078e0a04 */ /*0150*/ @!P2 IADD3 R0, R0, 0x1, RZ ; /* 0x000000010000a810 */ /* 0x000fe40007ffe0ff */ /*0160*/ ISETP.NE.AND P2, PT, RZ, c[0x0][0x0], PT ; /* 0x00000000ff007a0c */ /* 0x000fe40003f45270 */ /*0170*/ ISETP.GE.U32.AND P0, PT, R3, R4, PT ; /* 0x000000040300720c */ /* 0x000fda0003f06070 */ /*0180*/ @P0 IADD3 R0, R0, 0x1, RZ ; /* 0x0000000100000810 */ /* 0x000fc80007ffe0ff */ /*0190*/ @!P1 IADD3 R0, -R0, RZ, RZ ; /* 0x000000ff00009210 */ /* 0x000fe40007ffe1ff */ /*01a0*/ @!P2 LOP3.LUT R0, RZ, c[0x0][0x0], RZ, 0x33, !PT ; /* 0x00000000ff00aa12 */ /* 0x000fc800078e33ff */ /*01b0*/ ISETP.GE.AND P0, PT, R0, 0x1, PT ; /* 0x000000010000780c */ /* 0x000fda0003f06270 */ /*01c0*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*01d0*/ S2R R10, SR_TID.X ; /* 0x00000000000a7919 */ /* 0x000e220000002100 */ /*01e0*/ MOV R14, c[0x0][0x0] ; /* 0x00000000000e7a02 */ /* 0x000fe20000000f00 */ /*01f0*/ IMAD.MOV.U32 R7, RZ, RZ, 0x4 ; /* 0x00000004ff077424 */ /* 0x000fe200078e00ff */ /*0200*/ MOV R13, RZ ; /* 0x000000ff000d7202 */ /* 0x000fe20000000f00 */ /*0210*/ S2R R9, SR_CTAID.X ; /* 0x0000000000097919 */ /* 0x000e620000002500 */ /*0220*/ IADD3 R22, R14.reuse, -0x1, RZ ; /* 0xffffffff0e167810 */ /* 0x040fe20007ffe0ff */ /*0230*/ IMAD R3, R14, c[0x0][0x10], RZ ; /* 0x000004000e037a24 */ /* 0x000fe200078e02ff */ /*0240*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0250*/ S2R R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000ea80000002600 */ /*0260*/ S2R R8, SR_TID.Y ; /* 0x0000000000087919 */ /* 0x000ee20000002200 */ /*0270*/ IMAD R11, R10, c[0x0][0x0], RZ ; /* 0x000000000a0b7a24 */ /* 0x001fc400078e02ff */ /*0280*/ IMAD R9, R9, c[0x0][0x0], R10 ; /* 0x0000000009097a24 */ /* 0x002fc600078e020a */ /*0290*/ LEA R18, R11, 0x8, 0x2 ; /* 0x000000080b127811 */ /* 0x000fe200078e10ff */ /*02a0*/ IMAD R10, R5.reuse, c[0x0][0x0], R10 ; /* 0x00000000050a7a24 */ /* 0x044fe400078e020a */ /*02b0*/ IMAD R2, R5, c[0x0][0x0], R8 ; /* 0x0000000005027a24 */ /* 0x008fe200078e0208 */ /*02c0*/ IADD3 R12, R11, R8, RZ ; /* 0x000000080b0c7210 */ /* 0x000fe40007ffe0ff */ /*02d0*/ IADD3 R5, R8, c[0x0][0x0], RZ ; /* 0x0000000008057a10 */ /* 0x000fe20007ffe0ff */ /*02e0*/ IMAD R4, R9, R3, R2 ; /* 0x0000000309047224 */ /* 0x000fe400078e0202 */ /*02f0*/ IMAD R3, R14.reuse, c[0x0][0x0], RZ ; /* 0x000000000e037a24 */ /* 0x040fe200078e02ff */ /*0300*/ LOP3.LUT R14, R14, 0x3, RZ, 0xc0, !PT ; /* 0x000000030e0e7812 */ /* 0x000fe200078ec0ff */ /*0310*/ IMAD.SHL.U32 R2, R12, 0x4, RZ ; /* 0x000000040c027824 */ /* 0x000fc400078e00ff */ /*0320*/ IMAD R5, R5, c[0x0][0x0], RZ ; /* 0x0000000005057a24 */ /* 0x000fe200078e02ff */ /*0330*/ IADD3 R17, -R14, c[0x0][0x0], RZ ; /* 0x000000000e117a10 */ /* 0x000fe20007ffe1ff */ /*0340*/ IMAD R16, R8, c[0x0][0x0], R3 ; /* 0x0000000008107a24 */ /* 0x000fe200078e0203 */ /*0350*/ LEA R15, R3, R2, 0x2 ; /* 0x00000002030f7211 */ /* 0x000fe200078e10ff */ /*0360*/ IMAD.WIDE R2, R4, R7, c[0x0][0x170] ; /* 0x00005c0004027625 */ /* 0x000fe200078e0207 */ /*0370*/ LEA R19, R5, 0x8, 0x2 ; /* 0x0000000805137811 */ /* 0x000fc600078e10ff */ /*0380*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0390*/ IMAD R4, R13, c[0x0][0x0], R8 ; /* 0x000000000d047a24 */ /* 0x000fc800078e0208 */ /*03a0*/ IMAD R5, R9, c[0x0][0x178], R4.reuse ; /* 0x00005e0009057a24 */ /* 0x100fe400078e0204 */ /*03b0*/ IMAD R6, R10, c[0x0][0x178], R4 ; /* 0x00005e000a067a24 */ /* 0x000fc600078e0204 */ /*03c0*/ IMAD.WIDE R4, R5, R7, c[0x0][0x160] ; /* 0x0000580005047625 */ /* 0x000fc800078e0207 */ /*03d0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x168] ; /* 0x00005a0006067625 */ /* 0x000fe400078e0207 */ /*03e0*/ LDG.E R5, [R4.64] ; /* 0x0000000604057981 */ /* 0x000ea8000c1e1900 */ /*03f0*/ LDG.E R6, [R6.64] ; /* 0x0000000606067981 */ /* 0x000ee2000c1e1900 */ /*0400*/ IMAD.MOV.U32 R20, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff147624 */ /* 0x000fe200078e00ff */ /*0410*/ IADD3 R13, R13, 0x1, RZ ; /* 0x000000010d0d7810 */ /* 0x000fc80007ffe0ff */ /*0420*/ ISETP.GE.AND P0, PT, R20, 0x1, PT ; /* 0x000000011400780c */ /* 0x000fe40003f06270 */ /*0430*/ ISETP.GE.AND P1, PT, R13, R0, PT ; /* 0x000000000d00720c */ /* 0x000fe20003f26270 */ /*0440*/ STS [R12.X4], R5 ; /* 0x000000050c007388 */ /* 0x0041e80000004800 */ /*0450*/ STS [R15], R6 ; /* 0x000000060f007388 */ /* 0x0081e80000000800 */ /*0460*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0470*/ @!P0 BRA 0xd20 ; /* 0x000008a000008947 */ /* 0x000fea0003800000 */ /*0480*/ ISETP.GE.U32.AND P0, PT, R22, 0x3, PT ; /* 0x000000031600780c */ /* 0x001fe20003f06070 */ /*0490*/ LDG.E R21, [R2.64] ; /* 0x0000000602157981 */ /* 0x000162000c1e1900 */ /*04a0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fd60008000000 */ /*04b0*/ @!P0 BRA 0xbf0 ; /* 0x0000073000008947 */ /* 0x000fea0003800000 */ /*04c0*/ ISETP.GT.AND P0, PT, R17, RZ, PT ; /* 0x000000ff1100720c */ /* 0x001fe20003f04270 */ /*04d0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*04e0*/ MOV R4, R19 ; /* 0x0000001300047202 */ /* 0x000fe20000000f00 */ /*04f0*/ IMAD.MOV.U32 R6, RZ, RZ, R17 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0011 */ /*0500*/ MOV R5, R18 ; /* 0x0000001200057202 */ /* 0x000fd20000000f00 */ /*0510*/ @!P0 BRA 0xad0 ; /* 0x000005b000008947 */ /* 0x000fea0003800000 */ /*0520*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fe40003f44270 */ /*0530*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*0540*/ @!P2 BRA 0x8c0 ; /* 0x000003700000a947 */ /* 0x000fea0003800000 */ /*0550*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0560*/ LDS R24, [R4+-0x8] ; /* 0xfffff80004187984 */ /* 0x000fe20000000800 */ /*0570*/ IADD3 R6, R6, -0x10, RZ ; /* 0xfffffff006067810 */ /* 0x000fe20007ffe0ff */ /*0580*/ UIADD3 UR4, UR4, 0x10, URZ ; /* 0x0000001004047890 */ /* 0x000fe4000fffe03f */ /*0590*/ LDS R23, [R5+-0x8] ; /* 0xfffff80005177984 */ /* 0x000e220000000800 */ /*05a0*/ ISETP.GT.AND P2, PT, R6, 0xc, PT ; /* 0x0000000c0600780c */ /* 0x000fc60003f44270 */ /*05b0*/ LDS R26, [R4+-0x4] ; /* 0xfffffc00041a7984 */ /* 0x000fe80000000800 */ /*05c0*/ LDS R25, [R5+-0x4] ; /* 0xfffffc0005197984 */ /* 0x000e680000000800 */ /*05d0*/ LDS R7, [R4] ; /* 0x0000000004077984 */ /* 0x000fe80000000800 */ /*05e0*/ LDS R20, [R5] ; /* 0x0000000005147984 */ /* 0x000ea20000000800 */ /*05f0*/ FFMA R23, R24, R23, R21 ; /* 0x0000001718177223 */ /* 0x021fc60000000015 */ /*0600*/ LDS R21, [R4+0x4] ; /* 0x0000040004157984 */ /* 0x000fe80000000800 */ /*0610*/ LDS R24, [R5+0x4] ; /* 0x0000040005187984 */ /* 0x000e220000000800 */ /*0620*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*0630*/ LDS R26, [R4+0x8] ; /* 0x00000800041a7984 */ /* 0x000fe80000000800 */ /*0640*/ LDS R25, [R5+0x8] ; /* 0x0000080005197984 */ /* 0x000e620000000800 */ /*0650*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*0660*/ LDS R7, [R4+0xc] ; /* 0x00000c0004077984 */ /* 0x000fe80000000800 */ /*0670*/ LDS R20, [R5+0xc] ; /* 0x00000c0005147984 */ /* 0x000ea20000000800 */ /*0680*/ FFMA R23, R21, R24, R23 ; /* 0x0000001815177223 */ /* 0x001fc60000000017 */ /*0690*/ LDS R21, [R4+0x10] ; /* 0x0000100004157984 */ /* 0x000fe80000000800 */ /*06a0*/ LDS R24, [R5+0x10] ; /* 0x0000100005187984 */ /* 0x000e220000000800 */ /*06b0*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*06c0*/ LDS R26, [R4+0x14] ; /* 0x00001400041a7984 */ /* 0x000fe80000000800 */ /*06d0*/ LDS R25, [R5+0x14] ; /* 0x0000140005197984 */ /* 0x000e620000000800 */ /*06e0*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*06f0*/ LDS R7, [R4+0x18] ; /* 0x0000180004077984 */ /* 0x000fe80000000800 */ /*0700*/ LDS R20, [R5+0x18] ; /* 0x0000180005147984 */ /* 0x000ea20000000800 */ /*0710*/ FFMA R23, R21, R24, R23 ; /* 0x0000001815177223 */ /* 0x001fc60000000017 */ /*0720*/ LDS R21, [R4+0x1c] ; /* 0x00001c0004157984 */ /* 0x000fe80000000800 */ /*0730*/ LDS R24, [R5+0x1c] ; /* 0x00001c0005187984 */ /* 0x000e220000000800 */ /*0740*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*0750*/ LDS R26, [R4+0x20] ; /* 0x00002000041a7984 */ /* 0x000fe80000000800 */ /*0760*/ LDS R25, [R5+0x20] ; /* 0x0000200005197984 */ /* 0x000e620000000800 */ /*0770*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*0780*/ LDS R7, [R4+0x24] ; /* 0x0000240004077984 */ /* 0x000fe80000000800 */ /*0790*/ LDS R20, [R5+0x24] ; /* 0x0000240005147984 */ /* 0x000ea20000000800 */ /*07a0*/ FFMA R23, R21, R24, R23 ; /* 0x0000001815177223 */ /* 0x001fc60000000017 */ /*07b0*/ LDS R21, [R4+0x28] ; /* 0x0000280004157984 */ /* 0x000fe80000000800 */ /*07c0*/ LDS R24, [R5+0x28] ; /* 0x0000280005187984 */ /* 0x000e220000000800 */ /*07d0*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fc60000000017 */ /*07e0*/ LDS R26, [R4+0x2c] ; /* 0x00002c00041a7984 */ /* 0x000fe80000000800 */ /*07f0*/ LDS R25, [R5+0x2c] ; /* 0x00002c0005197984 */ /* 0x000e620000000800 */ /*0800*/ FFMA R23, R7, R20, R23 ; /* 0x0000001407177223 */ /* 0x004fc60000000017 */ /*0810*/ LDS R7, [R4+0x30] ; /* 0x0000300004077984 */ /* 0x000fe80000000800 */ /*0820*/ LDS R20, [R5+0x30] ; /* 0x0000300005147984 */ /* 0x000ea20000000800 */ /*0830*/ FFMA R21, R21, R24, R23 ; /* 0x0000001815157223 */ /* 0x001fc60000000017 */ /*0840*/ LDS R24, [R4+0x34] ; /* 0x0000340004187984 */ /* 0x0001e80000000800 */ /*0850*/ LDS R23, [R5+0x34] ; /* 0x0000340005177984 */ /* 0x0007220000000800 */ /*0860*/ FFMA R21, R26, R25, R21 ; /* 0x000000191a157223 */ /* 0x002fe20000000015 */ /*0870*/ IADD3 R4, R4, 0x40, RZ ; /* 0x0000004004047810 */ /* 0x001fe40007ffe0ff */ /*0880*/ IADD3 R5, R5, 0x40, RZ ; /* 0x0000004005057810 */ /* 0x008fe20007ffe0ff */ /*0890*/ FFMA R21, R7, R20, R21 ; /* 0x0000001407157223 */ /* 0x004fc80000000015 */ /*08a0*/ FFMA R21, R24, R23, R21 ; /* 0x0000001718157223 */ /* 0x010fe20000000015 */ /*08b0*/ @P2 BRA 0x560 ; /* 0xfffffca000002947 */ /* 0x000fea000383ffff */ /*08c0*/ ISETP.GT.AND P2, PT, R6, 0x4, PT ; /* 0x000000040600780c */ /* 0x000fda0003f44270 */ /*08d0*/ @!P2 BRA 0xab0 ; /* 0x000001d00000a947 */ /* 0x000fea0003800000 */ /*08e0*/ LDS R20, [R4+-0x8] ; /* 0xfffff80004147984 */ /* 0x000fe20000000800 */ /*08f0*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe20003f0e170 */ /*0900*/ UIADD3 UR4, UR4, 0x8, URZ ; /* 0x0000000804047890 */ /* 0x000fe2000fffe03f */ /*0910*/ IADD3 R6, R6, -0x8, RZ ; /* 0xfffffff806067810 */ /* 0x000fe20007ffe0ff */ /*0920*/ LDS R7, [R5+-0x8] ; /* 0xfffff80005077984 */ /* 0x000e280000000800 */ /*0930*/ LDS R24, [R4+-0x4] ; /* 0xfffffc0004187984 */ /* 0x000fe80000000800 */ /*0940*/ LDS R23, [R5+-0x4] ; /* 0xfffffc0005177984 */ /* 0x000e680000000800 */ /*0950*/ LDS R26, [R4] ; /* 0x00000000041a7984 */ /* 0x000fe80000000800 */ /*0960*/ LDS R25, [R5+0x4] ; /* 0x0000040005197984 */ /* 0x000fe20000000800 */ /*0970*/ FFMA R7, R20, R7, R21 ; /* 0x0000000714077223 */ /* 0x021fc60000000015 */ /*0980*/ LDS R21, [R5] ; /* 0x0000000005157984 */ /* 0x000e280000000800 */ /*0990*/ LDS R20, [R5+0x8] ; /* 0x0000080005147984 */ /* 0x000fe20000000800 */ /*09a0*/ FFMA R23, R24, R23, R7 ; /* 0x0000001718177223 */ /* 0x002fc60000000007 */ /*09b0*/ LDS R24, [R4+0x4] ; /* 0x0000040004187984 */ /* 0x000e680000000800 */ /*09c0*/ LDS R7, [R4+0x8] ; /* 0x0000080004077984 */ /* 0x000ea20000000800 */ /*09d0*/ FFMA R21, R26, R21, R23 ; /* 0x000000151a157223 */ /* 0x001fc60000000017 */ /*09e0*/ LDS R23, [R5+0xc] ; /* 0x00000c0005177984 */ /* 0x000fe80000000800 */ /*09f0*/ LDS R26, [R4+0x14] ; /* 0x00001400041a7984 */ /* 0x000fe20000000800 */ /*0a00*/ FFMA R21, R24, R25, R21 ; /* 0x0000001918157223 */ /* 0x002fc60000000015 */ /*0a10*/ LDS R24, [R4+0xc] ; /* 0x00000c0004187984 */ /* 0x000e220000000800 */ /*0a20*/ FFMA R7, R7, R20, R21 ; /* 0x0000001407077223 */ /* 0x004fc60000000015 */ /*0a30*/ LDS R20, [R4+0x10] ; /* 0x0000100004147984 */ /* 0x0003e80000000800 */ /*0a40*/ LDS R21, [R5+0x10] ; /* 0x0000100005157984 */ /* 0x000ea80000000800 */ /*0a50*/ LDS R25, [R5+0x14] ; /* 0x0000140005197984 */ /* 0x0007220000000800 */ /*0a60*/ IADD3 R4, R4, 0x20, RZ ; /* 0x0000002004047810 */ /* 0x002fe40007ffe0ff */ /*0a70*/ IADD3 R5, R5, 0x20, RZ ; /* 0x0000002005057810 */ /* 0x008fe20007ffe0ff */ /*0a80*/ FFMA R7, R24, R23, R7 ; /* 0x0000001718077223 */ /* 0x001fc80000000007 */ /*0a90*/ FFMA R21, R20, R21, R7 ; /* 0x0000001514157223 */ /* 0x004fc80000000007 */ /*0aa0*/ FFMA R21, R26, R25, R21 ; /* 0x000000191a157223 */ /* 0x010fe40000000015 */ /*0ab0*/ ISETP.NE.OR P0, PT, R6, RZ, P0 ; /* 0x000000ff0600720c */ /* 0x000fda0000705670 */ /*0ac0*/ @!P0 BRA 0xbf0 ; /* 0x0000012000008947 */ /* 0x000fea0003800000 */ /*0ad0*/ LDS R24, [R4+-0x8] ; /* 0xfffff80004187984 */ /* 0x000fe20000000800 */ /*0ae0*/ IADD3 R6, R6, -0x4, RZ ; /* 0xfffffffc06067810 */ /* 0x000fe20007ffe0ff */ /*0af0*/ UIADD3 UR4, UR4, 0x4, URZ ; /* 0x0000000404047890 */ /* 0x000fe4000fffe03f */ /*0b00*/ LDS R23, [R5+-0x8] ; /* 0xfffff80005177984 */ /* 0x000e220000000800 */ /*0b10*/ ISETP.NE.AND P0, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fc60003f05270 */ /*0b20*/ LDS R26, [R4+-0x4] ; /* 0xfffffc00041a7984 */ /* 0x000fe80000000800 */ /*0b30*/ LDS R25, [R5+-0x4] ; /* 0xfffffc0005197984 */ /* 0x000e680000000800 */ /*0b40*/ LDS R7, [R4] ; /* 0x0000000004077984 */ /* 0x000fe80000000800 */ /*0b50*/ LDS R20, [R5] ; /* 0x0000000005147984 */ /* 0x000ea20000000800 */ /*0b60*/ FFMA R23, R24, R23, R21 ; /* 0x0000001718177223 */ /* 0x021fc60000000015 */ /*0b70*/ LDS R24, [R4+0x4] ; /* 0x0000040004187984 */ /* 0x0001e80000000800 */ /*0b80*/ LDS R21, [R5+0x4] ; /* 0x0000040005157984 */ /* 0x0007220000000800 */ /*0b90*/ FFMA R23, R26, R25, R23 ; /* 0x000000191a177223 */ /* 0x002fe20000000017 */ /*0ba0*/ IADD3 R4, R4, 0x10, RZ ; /* 0x0000001004047810 */ /* 0x001fe40007ffe0ff */ /*0bb0*/ IADD3 R5, R5, 0x10, RZ ; /* 0x0000001005057810 */ /* 0x008fe20007ffe0ff */ /*0bc0*/ FFMA R7, R7, R20, R23 ; /* 0x0000001407077223 */ /* 0x004fc80000000017 */ /*0bd0*/ FFMA R21, R24, R21, R7 ; /* 0x0000001518157223 */ /* 0x010fe20000000007 */ /*0be0*/ @P0 BRA 0xad0 ; /* 0xfffffee000000947 */ /* 0x000fea000383ffff */ /*0bf0*/ ISETP.NE.AND P0, PT, R14, RZ, PT ; /* 0x000000ff0e00720c */ /* 0x001fda0003f05270 */ /*0c00*/ @!P0 BRA 0xd10 ; /* 0x0000010000008947 */ /* 0x000fea0003800000 */ /*0c10*/ IADD3 R5, R16, UR4, RZ ; /* 0x0000000410057c10 */ /* 0x000fe4000fffe0ff */ /*0c20*/ IADD3 R4, R11, UR4, RZ ; /* 0x000000040b047c10 */ /* 0x000fe4000fffe0ff */ /*0c30*/ SHF.L.U32 R23, R5, 0x2, RZ ; /* 0x0000000205177819 */ /* 0x000fe400000006ff */ /*0c40*/ SHF.L.U32 R20, R4, 0x2, RZ ; /* 0x0000000204147819 */ /* 0x000fe400000006ff */ /*0c50*/ ISETP.NE.AND P0, PT, R14, 0x1, PT ; /* 0x000000010e00780c */ /* 0x000fe20003f05270 */ /*0c60*/ LDS R4, [R23] ; /* 0x0000000017047984 */ /* 0x000fe80000000800 */ /*0c70*/ LDS R5, [R20] ; /* 0x0000000014057984 */ /* 0x000e240000000800 */ /*0c80*/ FFMA R21, R4, R5, R21 ; /* 0x0000000504157223 */ /* 0x021fcc0000000015 */ /*0c90*/ @!P0 BRA 0xd10 ; /* 0x0000007000008947 */ /* 0x000fea0003800000 */ /*0ca0*/ ISETP.NE.AND P0, PT, R14, 0x2, PT ; /* 0x000000020e00780c */ /* 0x000fe20003f05270 */ /*0cb0*/ LDS R4, [R23+0x4] ; /* 0x0000040017047984 */ /* 0x000fe80000000800 */ /*0cc0*/ LDS R5, [R20+0x4] ; /* 0x0000040014057984 */ /* 0x000e300000000800 */ /*0cd0*/ @P0 LDS R6, [R23+0x8] ; /* 0x0000080017060984 */ /* 0x000fe80000000800 */ /*0ce0*/ @P0 LDS R7, [R20+0x8] ; /* 0x0000080014070984 */ /* 0x000e620000000800 */ /*0cf0*/ FFMA R21, R4, R5, R21 ; /* 0x0000000504157223 */ /* 0x001fc80000000015 */ /*0d00*/ @P0 FFMA R21, R6, R7, R21 ; /* 0x0000000706150223 */ /* 0x002fca0000000015 */ /*0d10*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0201e4000c101906 */ /*0d20*/ @!P1 BRA 0x380 ; /* 0xfffff65000009947 */ /* 0x001fea000383ffff */ /*0d30*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0d40*/ BRA 0xd40; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0d50*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d60*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d70*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d80*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0d90*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0da0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0db0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0dc0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0dd0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0de0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0df0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z15transposeMatrixPfS_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.X ; /* 0x0000000000007919 */ /* 0x000e220000002500 */ /*0020*/ HFMA2.MMA R4, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff047435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e280000002100 */ /*0050*/ S2R R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000e680000002600 */ /*0060*/ S2R R2, SR_TID.Y ; /* 0x0000000000027919 */ /* 0x000e620000002200 */ /*0070*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fc400078e0203 */ /*0080*/ IMAD R5, R5, c[0x0][0x4], R2 ; /* 0x0000010005057a24 */ /* 0x002fc800078e0202 */ /*0090*/ IMAD R2, R0, c[0x0][0x174], R5 ; /* 0x00005d0000027a24 */ /* 0x000fc800078e0205 */ /*00a0*/ IMAD.WIDE R2, R2, R4, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x000fcc00078e0204 */ /*00b0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD R5, R5, c[0x0][0x170], R0 ; /* 0x00005c0005057a24 */ /* 0x000fc800078e0200 */ /*00d0*/ IMAD.WIDE R4, R5, R4, c[0x0][0x168] ; /* 0x00005a0005047625 */ /* 0x000fca00078e0204 */ /*00e0*/ STG.E [R4.64], R3 ; /* 0x0000000304007986 */ /* 0x004fe2000c101904 */ /*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 _Z15transposeMatrixPfS_ii .globl _Z15transposeMatrixPfS_ii .p2align 8 .type _Z15transposeMatrixPfS_ii,@function _Z15transposeMatrixPfS_ii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x24 s_load_b64 s[4:5], s[0:1], 0x10 v_and_b32_e32 v1, 0x3ff, v0 v_bfe_u32 v0, v0, 10, 10 s_waitcnt lgkmcnt(0) s_and_b32 s3, s2, 0xffff s_lshr_b32 s2, s2, 16 v_mad_u64_u32 v[2:3], null, s14, s3, v[1:2] v_mad_u64_u32 v[3:4], null, s15, s2, v[0:1] s_load_b128 s[0:3], s[0:1], 0x0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, v2, s5, v[3:4] 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) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_load_b32 v4, v[0:1], off v_mad_u64_u32 v[0:1], null, v3, s4, v[2: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[0:1], 2, v[0:1] v_add_co_u32 v0, vcc_lo, s2, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_waitcnt vmcnt(0) 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 _Z15transposeMatrixPfS_ii .amdhsa_group_segment_fixed_size 0 .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 5 .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 _Z15transposeMatrixPfS_ii, .Lfunc_end0-_Z15transposeMatrixPfS_ii .section .AMDGPU.csdata,"",@progbits .text .protected _Z9matrixMulPfS_S_i .globl _Z9matrixMulPfS_S_i .p2align 8 .type _Z9matrixMulPfS_S_i,@function _Z9matrixMulPfS_S_i: s_clause 0x1 s_load_b32 s4, s[0:1], 0x2c s_load_b32 s7, s[0:1], 0x18 s_add_u32 s2, s0, 32 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s4, s4, 0xffff s_ashr_i32 s8, s7, 31 v_cvt_f32_u32_e32 v1, s4 s_sub_i32 s6, 0, s4 s_add_i32 s9, s7, s8 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_xor_b32 s9, s9, s8 v_rcp_iflag_f32_e32 v1, v1 s_waitcnt_depctr 0xfff v_mul_f32_e32 v1, 0x4f7ffffe, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cvt_u32_f32_e32 v1, v1 v_readfirstlane_b32 s5, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_mul_i32 s6, s6, s5 s_mul_hi_u32 s6, s5, s6 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s5, s5, s6 s_mul_hi_u32 s5, s9, s5 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_mul_i32 s6, s5, s4 s_sub_i32 s6, s9, s6 s_add_i32 s9, s5, 1 s_sub_i32 s10, s6, s4 s_cmp_ge_u32 s6, s4 s_cselect_b32 s5, s9, s5 s_cselect_b32 s6, s10, s6 s_add_i32 s9, s5, 1 s_cmp_ge_u32 s6, s4 s_mov_b32 s6, 0 s_cselect_b32 s5, s9, s5 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_xor_b32 s5, s5, s8 s_sub_i32 s5, s5, s8 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lt_i32 s5, 1 s_cbranch_scc1 .LBB1_5 v_and_b32_e32 v1, 0x3ff, v0 s_load_b32 s2, s[2:3], 0x4 v_bfe_u32 v0, v0, 10, 10 s_load_b64 s[8:9], s[0:1], 0x10 s_mul_i32 s15, s15, s4 v_mad_u64_u32 v[2:3], null, s14, s4, v[1:2] v_mul_u32_u24_e32 v10, s4, v1 v_add_nc_u32_e32 v1, s15, v1 s_mul_i32 s10, s4, s4 v_mul_u32_u24_e32 v6, s4, v0 s_lshl_b32 s10, s10, 2 v_add_lshl_u32 v7, v10, v0, 2 v_mul_lo_u32 v3, v2, s4 s_add_i32 s10, s10, 0 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mul_lo_u32 v3, v3, s2 s_load_b128 s[0:3], s[0:1], 0x0 v_add3_u32 v4, s15, v0, v3 v_mul_lo_u32 v3, v1, s7 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v5, 31, v4 v_lshlrev_b64 v[8:9], 2, v[4:5] v_mul_lo_u32 v5, v2, s7 v_lshl_add_u32 v4, v6, 2, s10 v_add_nc_u32_e32 v6, 0, v7 v_add_nc_u32_e32 v7, s10, v7 s_max_u32 s7, s4, 1 v_add_co_u32 v1, vcc_lo, s8, v8 v_add_co_ci_u32_e32 v2, vcc_lo, s9, v9, vcc_lo v_lshl_add_u32 v8, v10, 2, 0 s_set_inst_prefetch_distance 0x1 .p2align 6 .LBB1_2: s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[9:10], null, s6, s4, v[0:1] s_mov_b32 s8, s7 v_add_nc_u32_e32 v10, v9, v5 v_add_nc_u32_e32 v12, v9, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v11, 31, v10 v_ashrrev_i32_e32 v13, 31, v12 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[9:10], 2, v[10:11] v_lshlrev_b64 v[11:12], 2, v[12:13] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v9, vcc_lo, s0, v9 v_add_co_ci_u32_e32 v10, vcc_lo, s1, v10, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v11, vcc_lo, s2, v11 v_add_co_ci_u32_e32 v12, vcc_lo, s3, v12, vcc_lo global_load_b32 v9, v[9:10], off global_load_b32 v10, v[11:12], off v_mov_b32_e32 v11, v8 s_waitcnt vmcnt(1) ds_store_b32 v6, v9 s_waitcnt vmcnt(0) ds_store_b32 v7, v10 s_waitcnt lgkmcnt(0) s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv global_load_b32 v9, v[1:2], off v_mov_b32_e32 v10, v4 .LBB1_3: ds_load_b32 v12, v11 ds_load_b32 v13, v10 v_add_nc_u32_e32 v11, 4, v11 v_add_nc_u32_e32 v10, 4, v10 s_add_i32 s8, s8, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_eq_u32 s8, 0 s_waitcnt vmcnt(0) lgkmcnt(0) v_fmac_f32_e32 v9, v12, v13 s_cbranch_scc0 .LBB1_3 s_add_i32 s6, s6, 1 global_store_b32 v[1:2], v9, off s_cmp_eq_u32 s6, s5 s_cbranch_scc0 .LBB1_2 .LBB1_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 _Z9matrixMulPfS_S_i .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 14 .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 _Z9matrixMulPfS_S_i, .Lfunc_end1-_Z9matrixMulPfS_S_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 - .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: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15transposeMatrixPfS_ii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15transposeMatrixPfS_ii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 5 .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: 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 - .offset: 152 .size: 4 .value_kind: hidden_dynamic_lds_size .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: _Z9matrixMulPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z9matrixMulPfS_S_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 14 .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_0019fe68_00000000-6_shared.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3674: .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 .LFE3674: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z11fillMatrixAPfii .type _Z11fillMatrixAPfii, @function _Z11fillMatrixAPfii: .LFB3669: .cfi_startproc endbr64 testl %esi, %esi jle .L3 movl $0, %r10d movl $0, %ecx movslq %edx, %r9 pxor %xmm1, %xmm1 movss .LC0(%rip), %xmm2 jmp .L5 .L6: movss %xmm0, (%r8,%rax,4) addq $1, %rax cmpq %r9, %rax je .L9 .L7: movaps %xmm1, %xmm0 cmpl %eax, %ecx jne .L6 movaps %xmm2, %xmm0 jmp .L6 .L9: addl $1, %ecx addl %edx, %r10d cmpl %ecx, %esi je .L3 .L5: testl %edx, %edx jle .L9 movslq %r10d, %rax leaq (%rdi,%rax,4), %r8 movl $0, %eax jmp .L7 .L3: ret .cfi_endproc .LFE3669: .size _Z11fillMatrixAPfii, .-_Z11fillMatrixAPfii .globl _Z11fillMatrixBPfii .type _Z11fillMatrixBPfii, @function _Z11fillMatrixBPfii: .LFB3670: .cfi_startproc endbr64 call _Z11fillMatrixAPfii ret .cfi_endproc .LFE3670: .size _Z11fillMatrixBPfii, .-_Z11fillMatrixBPfii .globl _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii .type _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii, @function _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii: .LFB3696: .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 .L17 .L13: movq 136(%rsp), %rax subq %fs:40, %rax jne .L18 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L17: .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 _Z15transposeMatrixPfS_ii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L13 .L18: call __stack_chk_fail@PLT .cfi_endproc .LFE3696: .size _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii, .-_Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii .globl _Z15transposeMatrixPfS_ii .type _Z15transposeMatrixPfS_ii, @function _Z15transposeMatrixPfS_ii: .LFB3697: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3697: .size _Z15transposeMatrixPfS_ii, .-_Z15transposeMatrixPfS_ii .globl _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i .type _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i, @function _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i: .LFB3698: .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 .L25 .L21: movq 136(%rsp), %rax subq %fs:40, %rax jne .L26 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L25: .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 _Z9matrixMulPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L21 .L26: call __stack_chk_fail@PLT .cfi_endproc .LFE3698: .size _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i, .-_Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i .globl _Z9matrixMulPfS_S_i .type _Z9matrixMulPfS_S_i, @function _Z9matrixMulPfS_S_i: .LFB3699: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3699: .size _Z9matrixMulPfS_S_i, .-_Z9matrixMulPfS_S_i .globl main .type main, @function main: .LFB3671: .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 $136, %rsp .cfi_def_cfa_offset 192 movq %fs:40, %rax movq %rax, 120(%rsp) xorl %eax, %eax movl $196608, %edi call _Znam@PLT movq %rax, %r14 movq %rax, 16(%rsp) movl $393216, %edi call _Znam@PLT movq %rax, %rbx movq %rax, 24(%rsp) movl $131072, %edi call _Znam@PLT movq %rax, 8(%rsp) movl $384, %edx movl $128, %esi movq %r14, %rdi call _Z11fillMatrixAPfii movl $256, %edx movl $384, %esi movq %rbx, %rdi call _Z11fillMatrixAPfii leaq 48(%rsp), %rdi movl $196608, %esi call cudaMalloc@PLT leaq 56(%rsp), %rdi movl $393216, %esi call cudaMalloc@PLT leaq 64(%rsp), %rdi movl $393216, %esi call cudaMalloc@PLT leaq 72(%rsp), %rdi movl $131072, %esi call cudaMalloc@PLT movl $1, %ecx movl $196608, %edx movq %r14, %rsi movq 48(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $393216, %edx movq %rbx, %rsi movq 56(%rsp), %rdi call cudaMemcpy@PLT movl $16, 84(%rsp) movl $16, 88(%rsp) movl $1, 92(%rsp) movl $24, 96(%rsp) movl $16, 100(%rsp) movl $1, 104(%rsp) movl $0, %r9d movl $0, %r8d movq 84(%rsp), %rdx movl $1, %ecx movq 96(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L46 .L30: movl $8, 108(%rsp) movl $16, 112(%rsp) movl $1, 116(%rsp) movl 92(%rsp), %ecx movl $0, %r9d movl $2048, %r8d movq 84(%rsp), %rdx movq 108(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L47 .L31: movl $2, %ecx movl $131072, %edx movq 72(%rsp), %rsi movq 8(%rsp), %r13 movq %r13, %rdi call cudaMemcpy@PLT movl $0, %r12d leaq _ZSt4cout(%rip), %r14 jmp .L32 .L46: movl $256, %ecx movl $384, %edx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z39__device_stub__Z15transposeMatrixPfS_iiPfS_ii jmp .L30 .L47: movl $384, %ecx movq 72(%rsp), %rdx movq 64(%rsp), %rsi movq 48(%rsp), %rdi call _Z33__device_stub__Z9matrixMulPfS_S_iPfS_S_i jmp .L31 .L33: movl $32, %esi movq %rbx, %rdi call _ZNSo3putEc@PLT jmp .L34 .L35: movl $32, %esi movq %rbx, %rdi call _ZNSo3putEc@PLT .L36: pxor %xmm0, %xmm0 cvtss2sd 0(%r13,%rbp,4), %xmm0 movq %rbx, %rdi call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rbx movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %r15 testq %r15, %r15 je .L48 cmpb $0, 56(%r15) je .L39 movzbl 67(%r15), %esi .L40: movsbl %sil, %esi movq %rbx, %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT addq $1, %rbp cmpq $256, %rbp je .L49 .L41: movl %ebp, %r15d movl %r12d, %esi movq %r14, %rdi call _ZNSolsEi@PLT movq %rax, %rbx movb $32, 47(%rsp) movq (%rax), %rax movq -24(%rax), %rax cmpq $0, 16(%rbx,%rax) je .L33 leaq 47(%rsp), %rsi movl $1, %edx movq %rbx, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq %rax, %rbx .L34: movl %r15d, %esi movq %rbx, %rdi call _ZNSolsEi@PLT movq %rax, %rbx movb $32, 47(%rsp) movq (%rax), %rax movq -24(%rax), %rax cmpq $0, 16(%rbx,%rax) je .L35 leaq 47(%rsp), %rsi movl $1, %edx movq %rbx, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq %rax, %rbx jmp .L36 .L48: movq 120(%rsp), %rax subq %fs:40, %rax jne .L50 call _ZSt16__throw_bad_castv@PLT .L50: call __stack_chk_fail@PLT .L39: movq %r15, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%r15), %rax movl $10, %esi movq %r15, %rdi call *48(%rax) movl %eax, %esi jmp .L40 .L49: addl $1, %r12d addq $1024, %r13 cmpl $128, %r12d je .L42 .L32: movl $0, %ebp jmp .L41 .L42: movq 16(%rsp), %rdi call _ZdaPv@PLT movq 24(%rsp), %rdi call _ZdaPv@PLT movq 8(%rsp), %rdi call _ZdaPv@PLT movq 48(%rsp), %rdi call cudaFree@PLT movq 56(%rsp), %rdi call cudaFree@PLT movq 64(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT movq 120(%rsp), %rax subq %fs:40, %rax jne .L51 movl $0, %eax addq $136, %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 .L51: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE3671: .size main, .-main .section .rodata.str1.1,"aMS",@progbits,1 .LC2: .string "_Z9matrixMulPfS_S_i" .LC3: .string "_Z15transposeMatrixPfS_ii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3701: .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 .LC2(%rip), %rdx movq %rdx, %rcx leaq _Z9matrixMulPfS_S_i(%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 .LC3(%rip), %rdx movq %rdx, %rcx leaq _Z15transposeMatrixPfS_ii(%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 .LFE3701: .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 1065353216 .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 "shared.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z11fillMatrixAPfii .LCPI0_0: .long 0x3f800000 # float 1 .text .globl _Z11fillMatrixAPfii .p2align 4, 0x90 .type _Z11fillMatrixAPfii,@function _Z11fillMatrixAPfii: # @_Z11fillMatrixAPfii .cfi_startproc # %bb.0: testl %esi, %esi jle .LBB0_8 # %bb.1: # %.preheader.lr.ph movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI0_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB0_2 .p2align 4, 0x90 .LBB0_7: # %._crit_edge # in Loop: Header=BB0_2 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB0_8 .LBB0_2: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB0_4 Depth 2 testl %edx, %edx jle .LBB0_7 # %bb.3: # %.lr.ph # in Loop: Header=BB0_2 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d jmp .LBB0_4 .p2align 4, 0x90 .LBB0_6: # in Loop: Header=BB0_4 Depth=2 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx je .LBB0_7 .LBB0_4: # Parent Loop BB0_2 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %r10, %r8 je .LBB0_6 # %bb.5: # in Loop: Header=BB0_4 Depth=2 xorps %xmm1, %xmm1 jmp .LBB0_6 .LBB0_8: # %._crit_edge15 retq .Lfunc_end0: .size _Z11fillMatrixAPfii, .Lfunc_end0-_Z11fillMatrixAPfii .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z11fillMatrixBPfii .LCPI1_0: .long 0x3f800000 # float 1 .text .globl _Z11fillMatrixBPfii .p2align 4, 0x90 .type _Z11fillMatrixBPfii,@function _Z11fillMatrixBPfii: # @_Z11fillMatrixBPfii .cfi_startproc # %bb.0: testl %esi, %esi jle .LBB1_8 # %bb.1: # %.preheader.lr.ph.i movl %esi, %eax movl %edx, %ecx xorl %esi, %esi movss .LCPI1_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %r8d, %r8d jmp .LBB1_2 .p2align 4, 0x90 .LBB1_7: # %._crit_edge.i # in Loop: Header=BB1_2 Depth=1 incq %r8 addl %edx, %esi cmpq %rax, %r8 je .LBB1_8 .LBB1_2: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 testl %edx, %edx jle .LBB1_7 # %bb.3: # %.lr.ph.i # in Loop: Header=BB1_2 Depth=1 movl %esi, %r9d leaq (%rdi,%r9,4), %r9 xorl %r10d, %r10d jmp .LBB1_4 .p2align 4, 0x90 .LBB1_6: # in Loop: Header=BB1_4 Depth=2 movss %xmm1, (%r9,%r10,4) incq %r10 cmpq %r10, %rcx je .LBB1_7 .LBB1_4: # Parent Loop BB1_2 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %r10, %r8 je .LBB1_6 # %bb.5: # in Loop: Header=BB1_4 Depth=2 xorps %xmm1, %xmm1 jmp .LBB1_6 .LBB1_8: # %_Z11fillMatrixAPfii.exit retq .Lfunc_end1: .size _Z11fillMatrixBPfii, .Lfunc_end1-_Z11fillMatrixBPfii .cfi_endproc # -- End function .globl _Z30__device_stub__transposeMatrixPfS_ii # -- Begin function _Z30__device_stub__transposeMatrixPfS_ii .p2align 4, 0x90 .type _Z30__device_stub__transposeMatrixPfS_ii,@function _Z30__device_stub__transposeMatrixPfS_ii: # @_Z30__device_stub__transposeMatrixPfS_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 $_Z15transposeMatrixPfS_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_end2: .size _Z30__device_stub__transposeMatrixPfS_ii, .Lfunc_end2-_Z30__device_stub__transposeMatrixPfS_ii .cfi_endproc # -- End function .globl _Z24__device_stub__matrixMulPfS_S_i # -- Begin function _Z24__device_stub__matrixMulPfS_S_i .p2align 4, 0x90 .type _Z24__device_stub__matrixMulPfS_S_i,@function _Z24__device_stub__matrixMulPfS_S_i: # @_Z24__device_stub__matrixMulPfS_S_i .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 $_Z9matrixMulPfS_S_i, %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_end3: .size _Z24__device_stub__matrixMulPfS_S_i, .Lfunc_end3-_Z24__device_stub__matrixMulPfS_S_i .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI4_0: .long 0x3f800000 # float 1 .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 $168, %rsp .cfi_def_cfa_offset 224 .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 $196608, %edi # imm = 0x30000 callq _Znam movq %rax, %rbx movl $393216, %edi # imm = 0x60000 callq _Znam movq %rax, %r14 movl $131072, %edi # imm = 0x20000 callq _Znam movq %rax, %r15 xorl %eax, %eax movss .LCPI4_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero movq %rbx, %rcx jmp .LBB4_1 .p2align 4, 0x90 .LBB4_5: # %._crit_edge.i # in Loop: Header=BB4_1 Depth=1 incq %rax addq $1536, %rcx # imm = 0x600 cmpq $128, %rax je .LBB4_6 .LBB4_1: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB4_2 Depth 2 xorl %edx, %edx jmp .LBB4_2 .p2align 4, 0x90 .LBB4_4: # in Loop: Header=BB4_2 Depth=2 movss %xmm1, (%rcx,%rdx,4) incq %rdx cmpq $384, %rdx # imm = 0x180 je .LBB4_5 .LBB4_2: # Parent Loop BB4_1 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %rdx, %rax je .LBB4_4 # %bb.3: # in Loop: Header=BB4_2 Depth=2 xorps %xmm1, %xmm1 jmp .LBB4_4 .LBB4_6: # %.preheader.i.i.preheader xorl %eax, %eax movss .LCPI4_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero movq %r14, %rcx jmp .LBB4_7 .p2align 4, 0x90 .LBB4_11: # %._crit_edge.i.i # in Loop: Header=BB4_7 Depth=1 incq %rax addq $1024, %rcx # imm = 0x400 cmpq $384, %rax # imm = 0x180 je .LBB4_12 .LBB4_7: # %.preheader.i.i # =>This Loop Header: Depth=1 # Child Loop BB4_8 Depth 2 xorl %edx, %edx jmp .LBB4_8 .p2align 4, 0x90 .LBB4_10: # in Loop: Header=BB4_8 Depth=2 movss %xmm1, (%rcx,%rdx,4) incq %rdx cmpq $256, %rdx # imm = 0x100 je .LBB4_11 .LBB4_8: # Parent Loop BB4_7 Depth=1 # => This Inner Loop Header: Depth=2 movaps %xmm0, %xmm1 cmpq %rdx, %rax je .LBB4_10 # %bb.9: # in Loop: Header=BB4_8 Depth=2 xorps %xmm1, %xmm1 jmp .LBB4_10 .LBB4_12: # %_Z11fillMatrixBPfii.exit movabsq $68719476752, %r12 # imm = 0x1000000010 leaq 32(%rsp), %rdi movl $196608, %esi # imm = 0x30000 callq hipMalloc leaq 24(%rsp), %rdi movl $393216, %esi # imm = 0x60000 callq hipMalloc leaq 16(%rsp), %rdi movl $393216, %esi # imm = 0x60000 callq hipMalloc leaq 8(%rsp), %rdi movl $131072, %esi # imm = 0x20000 callq hipMalloc movq 32(%rsp), %rdi movl $196608, %edx # imm = 0x30000 movq %rbx, %rsi movl $1, %ecx callq hipMemcpy movq 24(%rsp), %rdi movl $393216, %edx # imm = 0x60000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy leaq 8(%r12), %rdi movl $1, %esi movq %r12, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_14 # %bb.13: movq 24(%rsp), %rax movq 16(%rsp), %rcx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movl $384, 40(%rsp) # imm = 0x180 movl $256, 4(%rsp) # imm = 0x100 leaq 104(%rsp), %rax movq %rax, 112(%rsp) leaq 96(%rsp), %rax movq %rax, 120(%rsp) leaq 40(%rsp), %rax movq %rax, 128(%rsp) leaq 4(%rsp), %rax movq %rax, 136(%rsp) leaq 72(%rsp), %rdi leaq 56(%rsp), %rsi leaq 88(%rsp), %rdx leaq 48(%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 $_Z15transposeMatrixPfS_ii, %edi pushq 48(%rsp) .cfi_adjust_cfa_offset 8 pushq 96(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB4_14: movq %r14, 152(%rsp) # 8-byte Spill movq %rbx, 160(%rsp) # 8-byte Spill leaq -8(%r12), %rdi movl $2048, %r8d # imm = 0x800 movl $1, %esi movq %r12, %rdx movl $1, %ecx xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB4_16 # %bb.15: movq 32(%rsp), %rax movq 16(%rsp), %rcx movq 8(%rsp), %rdx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movq %rdx, 88(%rsp) movl $384, 4(%rsp) # imm = 0x180 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 4(%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 $_Z9matrixMulPfS_S_i, %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 .LBB4_16: movq 8(%rsp), %rsi movl $131072, %edx # imm = 0x20000 movq %r15, %rdi movl $2, %ecx callq hipMemcpy xorl %r12d, %r12d leaq 112(%rsp), %r13 movq %r15, 144(%rsp) # 8-byte Spill jmp .LBB4_17 .p2align 4, 0x90 .LBB4_29: # in Loop: Header=BB4_17 Depth=1 incq %r12 addq $1024, %r15 # imm = 0x400 cmpq $128, %r12 je .LBB4_30 .LBB4_17: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB4_18 Depth 2 xorl %ebp, %ebp jmp .LBB4_18 .p2align 4, 0x90 .LBB4_27: # in Loop: Header=BB4_18 Depth=2 movq %r14, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r14), %rax movq %r14, %rdi movl $10, %esi callq *48(%rax) .LBB4_28: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit # in Loop: Header=BB4_18 Depth=2 movsbl %al, %esi movq %rbx, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv incq %rbp cmpq $256, %rbp # imm = 0x100 je .LBB4_29 .LBB4_18: # Parent Loop BB4_17 Depth=1 # => This Inner Loop Header: Depth=2 movl $_ZSt4cout, %edi movl %r12d, %esi callq _ZNSolsEi movb $32, 112(%rsp) movq (%rax), %rcx movq -24(%rcx), %rcx cmpq $0, 16(%rax,%rcx) je .LBB4_20 # %bb.19: # in Loop: Header=BB4_18 Depth=2 movl $1, %edx movq %rax, %rdi movq %r13, %rsi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq %rax, %rdi jmp .LBB4_21 .p2align 4, 0x90 .LBB4_20: # in Loop: Header=BB4_18 Depth=2 movq %rax, %rbx movq %rax, %rdi movl $32, %esi callq _ZNSo3putEc movq %rbx, %rdi .LBB4_21: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c.exit # in Loop: Header=BB4_18 Depth=2 movl %ebp, %esi callq _ZNSolsEi movb $32, 112(%rsp) movq (%rax), %rcx movq -24(%rcx), %rcx cmpq $0, 16(%rax,%rcx) je .LBB4_23 # %bb.22: # in Loop: Header=BB4_18 Depth=2 movl $1, %edx movq %rax, %rdi movq %r13, %rsi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq %rax, %rdi jmp .LBB4_24 .p2align 4, 0x90 .LBB4_23: # in Loop: Header=BB4_18 Depth=2 movq %rax, %rbx movq %rax, %rdi movl $32, %esi callq _ZNSo3putEc movq %rbx, %rdi .LBB4_24: # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c.exit41 # in Loop: Header=BB4_18 Depth=2 movss (%r15,%rbp,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 callq _ZNSo9_M_insertIdEERSoT_ movq %rax, %rbx movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %r14 testq %r14, %r14 je .LBB4_31 # %bb.25: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i # in Loop: Header=BB4_18 Depth=2 cmpb $0, 56(%r14) je .LBB4_27 # %bb.26: # in Loop: Header=BB4_18 Depth=2 movzbl 67(%r14), %eax jmp .LBB4_28 .LBB4_30: movq 160(%rsp), %rdi # 8-byte Reload callq _ZdaPv movq 152(%rsp), %rdi # 8-byte Reload callq _ZdaPv movq 144(%rsp), %rdi # 8-byte Reload callq _ZdaPv movq 32(%rsp), %rdi callq hipFree movq 24(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree xorl %eax, %eax addq $168, %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_31: .cfi_def_cfa_offset 224 callq _ZSt16__throw_bad_castv .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 $_Z15transposeMatrixPfS_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 $_Z9matrixMulPfS_S_i, %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_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 _Z15transposeMatrixPfS_ii,@object # @_Z15transposeMatrixPfS_ii .section .rodata,"a",@progbits .globl _Z15transposeMatrixPfS_ii .p2align 3, 0x0 _Z15transposeMatrixPfS_ii: .quad _Z30__device_stub__transposeMatrixPfS_ii .size _Z15transposeMatrixPfS_ii, 8 .type _Z9matrixMulPfS_S_i,@object # @_Z9matrixMulPfS_S_i .globl _Z9matrixMulPfS_S_i .p2align 3, 0x0 _Z9matrixMulPfS_S_i: .quad _Z24__device_stub__matrixMulPfS_S_i .size _Z9matrixMulPfS_S_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z15transposeMatrixPfS_ii" .size .L__unnamed_1, 26 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z9matrixMulPfS_S_i" .size .L__unnamed_2, 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 _Z30__device_stub__transposeMatrixPfS_ii .addrsig_sym _Z24__device_stub__matrixMulPfS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15transposeMatrixPfS_ii .addrsig_sym _Z9matrixMulPfS_S_i .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_runtime.h" #include "device_launch_parameters.h" #include <time.h> /** * Using CPU to calculate pi * @param a Lower Integral Bounds * @param b Upper Integral Bounds * @param Integral Value */ const int N = 1024 * 1024 * 64; void pi_by_cpu(double a, double b, double *integral) { int i; double x, temp = 0; for (i = 0; i < N; i++) { x = a + (double)(b - a) / N * (i + 0.5); temp += 4 / (1 + x * x); } temp *= (double)(b - a) / N; *integral = temp; } // Using CUDA device to calculate pi #include <stdio.h> #include <cuda.h> #define NBIN N // Number of bins #define NUM_BLOCK 64 // Number of thread blocks #define NUM_THREAD 256 // Number of threads per block int tid; double pi = 0; // Kernel that executes on the CUDA device __global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) { int i; double x; int idx = blockIdx.x*blockDim.x + threadIdx.x; // Sequential thread index across the blocks for (i = idx; i < nbin; i += nthreads * nblocks) { x = (i + 0.5)*step; sum[idx] += 4.0 / (1.0 + x * x); } } // Main routine that executes on the host int main(void) { //Using CPU to calculate pi double a, b; double integral; clock_t clockBegin, clockEnd; double duration; a = 0; b = 1; clockBegin = clock(); pi_by_cpu(a, b, &integral); clockEnd = clock(); duration = (double)1000 * (clockEnd - clockBegin) / CLOCKS_PER_SEC; printf("CPU Result: %.11lf\n", integral); printf("CPU Elapsed time: %.6lfms\n\n", duration); // Using CUDA device to calculate pi cudaEvent_t start, stop; cudaEventCreate(&start); //event cudaEventCreate(&stop); //event cudaEventRecord(start, 0); //record time float tm; dim3 dimGrid(NUM_BLOCK, 1, 1); // Grid dimensions dim3 dimBlock(NUM_THREAD, 1, 1); // Block dimensions double *sumHost, *sumDev; // Pointer to host & device arrays double step = 1.0 / NBIN; // Step size size_t size = NUM_BLOCK * NUM_THREAD * sizeof(double); //Array memory size sumHost = (double *)malloc(size); // Allocate array on host cudaMalloc((void **)&sumDev, size); // Allocate array on device // Initialize array in device to 0 cudaMemset(sumDev, 0, size); // Do calculation on device cal_pi <<<dimGrid, dimBlock >>> (sumDev, NBIN, step, NUM_THREAD, NUM_BLOCK); // call CUDA kernel // Retrieve result from device and store it in host array cudaMemcpy(sumHost, sumDev, size, cudaMemcpyDeviceToHost); for (tid = 0; tid < NUM_THREAD*NUM_BLOCK; tid++) pi += sumHost[tid]; pi *= step; // Print results printf("GPU Result: %.11lf\n", pi); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&tm, start, stop); printf("GPU Elapsed time:%.6f ms.\n\n", tm); // Cleanup free(sumHost); cudaFree(sumDev); printf("Press to exit.\n"); getchar(); return 0; }
code for sm_80 Function : _Z6cal_piPdidii .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 R25, SR_CTAID.X ; /* 0x0000000000197919 */ /* 0x000e280000002500 */ /*0020*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R25, R25, c[0x0][0x0], R0 ; /* 0x0000000019197a24 */ /* 0x001fca00078e0200 */ /*0040*/ ISETP.GE.AND P0, PT, R25, c[0x0][0x168], PT ; /* 0x00005a0019007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ IMAD.MOV.U32 R6, RZ, RZ, 0x8 ; /* 0x00000008ff067424 */ /* 0x000fe200078e00ff */ /*0070*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*0080*/ ULDC.64 UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe20000000a00 */ /*0090*/ IMAD.WIDE R6, R25, R6, c[0x0][0x160] ; /* 0x0000580019067625 */ /* 0x000fca00078e0206 */ /*00a0*/ LDG.E.64 R22, [R6.64] ; /* 0x0000000606167981 */ /* 0x000162000c1e1b00 */ /*00b0*/ UIMAD UR4, UR5, UR4, URZ ; /* 0x00000004050472a4 */ /* 0x000fe2000f8e023f */ /*00c0*/ LOP3.LUT R0, RZ, R25, RZ, 0x33, !PT ; /* 0x00000019ff007212 */ /* 0x000fe200078e33ff */ /*00d0*/ BSSY B0, 0x430 ; /* 0x0000035000007945 */ /* 0x000fe60003800000 */ /*00e0*/ IADD3 R0, R0, c[0x0][0x168], RZ ; /* 0x00005a0000007a10 */ /* 0x000fe20007ffe0ff */ /*00f0*/ IMAD R5, RZ, RZ, -UR4 ; /* 0x80000004ff057e24 */ /* 0x000fe2000f8e02ff */ /*0100*/ ISETP.NE.U32.AND P2, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe4000bf45070 */ /*0110*/ I2F.U32.RP R4, UR4 ; /* 0x0000000400047d06 */ /* 0x000e700008209000 */ /*0120*/ MUFU.RCP R4, R4 ; /* 0x0000000400047308 */ /* 0x002e640000001000 */ /*0130*/ IADD3 R2, R4, 0xffffffe, RZ ; /* 0x0ffffffe04027810 */ /* 0x002fcc0007ffe0ff */ /*0140*/ F2I.FTZ.U32.TRUNC.NTZ R3, R2 ; /* 0x0000000200037305 */ /* 0x0002a4000021f000 */ /*0150*/ IMAD.MOV.U32 R2, RZ, RZ, RZ ; /* 0x000000ffff027224 */ /* 0x002fe400078e00ff */ /*0160*/ IMAD R5, R5, R3, RZ ; /* 0x0000000305057224 */ /* 0x004fc800078e02ff */ /*0170*/ IMAD.HI.U32 R3, R3, R5, R2 ; /* 0x0000000503037227 */ /* 0x000fcc00078e0002 */ /*0180*/ IMAD.HI.U32 R26, R3, R0, RZ ; /* 0x00000000031a7227 */ /* 0x000fc800078e00ff */ /*0190*/ IMAD.MOV R3, RZ, RZ, -R26 ; /* 0x000000ffff037224 */ /* 0x000fc800078e0a1a */ /*01a0*/ IMAD R0, R3, UR4, R0 ; /* 0x0000000403007c24 */ /* 0x000fca000f8e0200 */ /*01b0*/ ISETP.GE.U32.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf06070 */ /*01c0*/ @P0 IADD3 R0, R0, -UR4, RZ ; /* 0x8000000400000c10 */ /* 0x000fe4000fffe0ff */ /*01d0*/ @P0 IADD3 R26, R26, 0x1, RZ ; /* 0x000000011a1a0810 */ /* 0x000fe40007ffe0ff */ /*01e0*/ ISETP.GE.U32.AND P1, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf26070 */ /*01f0*/ @P1 IADD3 R26, R26, 0x1, RZ ; /* 0x000000011a1a1810 */ /* 0x000fe40007ffe0ff */ /*0200*/ @!P2 LOP3.LUT R26, RZ, UR4, RZ, 0x33, !PT ; /* 0x00000004ff1aac12 */ /* 0x000fc8000f8e33ff */ /*0210*/ IADD3 R0, R26, 0x1, RZ ; /* 0x000000011a007810 */ /* 0x000fc80007ffe0ff */ /*0220*/ LOP3.LUT P0, R27, R0, 0x3, RZ, 0xc0, !PT ; /* 0x00000003001b7812 */ /* 0x000fda000780c0ff */ /*0230*/ @!P0 BRA 0x420 ; /* 0x000001e000008947 */ /* 0x001fea0003800000 */ /*0240*/ I2F.F64 R2, R25 ; /* 0x0000001900027312 */ /* 0x000e220000201c00 */ /*0250*/ IADD3 R27, R27, -0x1, RZ ; /* 0xffffffff1b1b7810 */ /* 0x000fe20007ffe0ff */ /*0260*/ BSSY B1, 0x3f0 ; /* 0x0000018000017945 */ /* 0x000fe60003800000 */ /*0270*/ ISETP.NE.AND P1, PT, R27, RZ, PT ; /* 0x000000ff1b00720c */ /* 0x000fe20003f25270 */ /*0280*/ DADD R2, R2, 0.5 ; /* 0x3fe0000002027429 */ /* 0x001e0c0000000000 */ /*0290*/ DMUL R2, R2, c[0x0][0x170] ; /* 0x00005c0002027a28 */ /* 0x001e0c0000000000 */ /*02a0*/ DFMA R10, R2, R2, 1 ; /* 0x3ff00000020a742b */ /* 0x0010640000000002 */ /*02b0*/ IMAD.MOV.U32 R2, RZ, RZ, 0x1 ; /* 0x00000001ff027424 */ /* 0x001fc800078e00ff */ /*02c0*/ MUFU.RCP64H R3, R11 ; /* 0x0000000b00037308 */ /* 0x002e240000001800 */ /*02d0*/ DFMA R4, -R10, R2, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000102 */ /*02e0*/ DFMA R4, R4, R4, R4 ; /* 0x000000040404722b */ /* 0x001e0c0000000004 */ /*02f0*/ DFMA R4, R2, R4, R2 ; /* 0x000000040204722b */ /* 0x001e0c0000000002 */ /*0300*/ DFMA R2, -R10, R4, 1 ; /* 0x3ff000000a02742b */ /* 0x001e0c0000000104 */ /*0310*/ DFMA R2, R4, R2, R4 ; /* 0x000000020402722b */ /* 0x001e0c0000000004 */ /*0320*/ DMUL R4, R2, 4 ; /* 0x4010000002047828 */ /* 0x001e0c0000000000 */ /*0330*/ DFMA R8, -R10, R4, 4 ; /* 0x401000000a08742b */ /* 0x001e0c0000000104 */ /*0340*/ DFMA R2, R2, R8, R4 ; /* 0x000000080202722b */ /* 0x001e140000000004 */ /*0350*/ FFMA R0, RZ, R11, R3 ; /* 0x0000000bff007223 */ /* 0x001fca0000000003 */ /*0360*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0370*/ @P0 BRA 0x3e0 ; /* 0x0000006000000947 */ /* 0x000fea0003800000 */ /*0380*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0390*/ MOV R2, 0x3c0 ; /* 0x000003c000027802 */ /* 0x000fe20000000f00 */ /*03a0*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*03b0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000077000007944 */ /* 0x020fea0003c00000 */ /*03c0*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0004 */ /*03d0*/ IMAD.MOV.U32 R3, RZ, RZ, R5 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0005 */ /*03e0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*03f0*/ DADD R22, R2, R22 ; /* 0x0000000002167229 */ /* 0x0200620000000016 */ /*0400*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0410*/ @P1 BRA 0x240 ; /* 0xfffffe2000001947 */ /* 0x003fea000383ffff */ /*0420*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0430*/ ISETP.GE.U32.AND P0, PT, R26, 0x3, PT ; /* 0x000000031a00780c */ /* 0x000fe20003f06070 */ /*0440*/ BSSY B0, 0xb10 ; /* 0x000006c000007945 */ /* 0x000fd80003800000 */ /*0450*/ @!P0 BRA 0xb00 ; /* 0x000006a000008947 */ /* 0x000fea0003800000 */ /*0460*/ I2F.F64 R2, R25 ; /* 0x0000001900027312 */ /* 0x000e220000201c00 */ /*0470*/ BSSY B1, 0x5f0 ; /* 0x0000017000017945 */ /* 0x000fe20003800000 */ /*0480*/ DADD R2, R2, 0.5 ; /* 0x3fe0000002027429 */ /* 0x001e0c0000000000 */ /*0490*/ DMUL R2, R2, c[0x0][0x170] ; /* 0x00005c0002027a28 */ /* 0x001e0c0000000000 */ /*04a0*/ DFMA R10, R2, R2, 1 ; /* 0x3ff00000020a742b */ /* 0x0010640000000002 */ /*04b0*/ IMAD.MOV.U32 R2, RZ, RZ, 0x1 ; /* 0x00000001ff027424 */ /* 0x001fc800078e00ff */ /*04c0*/ MUFU.RCP64H R3, R11 ; /* 0x0000000b00037308 */ /* 0x002e240000001800 */ /*04d0*/ DFMA R4, -R10, R2, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000102 */ /*04e0*/ DFMA R4, R4, R4, R4 ; /* 0x000000040404722b */ /* 0x001e0c0000000004 */ /*04f0*/ DFMA R4, R2, R4, R2 ; /* 0x000000040204722b */ /* 0x001e0c0000000002 */ /*0500*/ DFMA R2, -R10, R4, 1 ; /* 0x3ff000000a02742b */ /* 0x001e0c0000000104 */ /*0510*/ DFMA R2, R4, R2, R4 ; /* 0x000000020402722b */ /* 0x001e0c0000000004 */ /*0520*/ DMUL R4, R2, 4 ; /* 0x4010000002047828 */ /* 0x001e0c0000000000 */ /*0530*/ DFMA R8, -R10, R4, 4 ; /* 0x401000000a08742b */ /* 0x001e0c0000000104 */ /*0540*/ DFMA R2, R2, R8, R4 ; /* 0x000000080202722b */ /* 0x001e140000000004 */ /*0550*/ FFMA R0, RZ, R11, R3 ; /* 0x0000000bff007223 */ /* 0x001fca0000000003 */ /*0560*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0570*/ @P0 BRA 0x5e0 ; /* 0x0000006000000947 */ /* 0x000fea0003800000 */ /*0580*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0590*/ MOV R2, 0x5c0 ; /* 0x000005c000027802 */ /* 0x000fe20000000f00 */ /*05a0*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*05b0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000057000007944 */ /* 0x020fea0003c00000 */ /*05c0*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0004 */ /*05d0*/ IMAD.MOV.U32 R3, RZ, RZ, R5 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0005 */ /*05e0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*05f0*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0600*/ BSSY B1, 0x780 ; /* 0x0000017000017945 */ /* 0x000fe20003800000 */ /*0610*/ DADD R22, R2, R22 ; /* 0x0000000002167229 */ /* 0x020fe40000000016 */ /*0620*/ I2F.F64 R4, R25 ; /* 0x0000001900047312 */ /* 0x000e240000201c00 */ /*0630*/ DADD R4, R4, 0.5 ; /* 0x3fe0000004047429 */ /* 0x001e0c0000000000 */ /*0640*/ DMUL R4, R4, c[0x0][0x170] ; /* 0x00005c0004047a28 */ /* 0x001e0c0000000000 */ /*0650*/ DFMA R10, R4, R4, 1 ; /* 0x3ff00000040a742b */ /* 0x0010640000000004 */ /*0660*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x001fc800078e00ff */ /*0670*/ MUFU.RCP64H R5, R11 ; /* 0x0000000b00057308 */ /* 0x002e240000001800 */ /*0680*/ DFMA R8, -R10, R4, 1 ; /* 0x3ff000000a08742b */ /* 0x001e0c0000000104 */ /*0690*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x001e0c0000000008 */ /*06a0*/ DFMA R8, R4, R8, R4 ; /* 0x000000080408722b */ /* 0x001e0c0000000004 */ /*06b0*/ DFMA R4, -R10, R8, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000108 */ /*06c0*/ DFMA R4, R8, R4, R8 ; /* 0x000000040804722b */ /* 0x001e0c0000000008 */ /*06d0*/ DMUL R8, R4, 4 ; /* 0x4010000004087828 */ /* 0x001e0c0000000000 */ /*06e0*/ DFMA R12, -R10, R8, 4 ; /* 0x401000000a0c742b */ /* 0x001e0c0000000108 */ /*06f0*/ DFMA R4, R4, R12, R8 ; /* 0x0000000c0404722b */ /* 0x001e140000000008 */ /*0700*/ FFMA R0, RZ, R11, R5 ; /* 0x0000000bff007223 */ /* 0x001fca0000000005 */ /*0710*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0720*/ @P0 BRA 0x770 ; /* 0x0000004000000947 */ /* 0x000fea0003800000 */ /*0730*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0740*/ MOV R2, 0x770 ; /* 0x0000077000027802 */ /* 0x000fe20000000f00 */ /*0750*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*0760*/ CALL.REL.NOINC 0xb30 ; /* 0x000003c000007944 */ /* 0x000fea0003c00000 */ /*0770*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0780*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0790*/ BSSY B1, 0x930 ; /* 0x0000019000017945 */ /* 0x000fe20003800000 */ /*07a0*/ DADD R22, R22, R4 ; /* 0x0000000016167229 */ /* 0x000fe40000000004 */ /*07b0*/ I2F.F64 R2, R25 ; /* 0x0000001900027312 */ /* 0x000e240000201c00 */ /*07c0*/ DADD R2, R2, 0.5 ; /* 0x3fe0000002027429 */ /* 0x001e0c0000000000 */ /*07d0*/ DMUL R2, R2, c[0x0][0x170] ; /* 0x00005c0002027a28 */ /* 0x001e0c0000000000 */ /*07e0*/ DFMA R10, R2, R2, 1 ; /* 0x3ff00000020a742b */ /* 0x0010640000000002 */ /*07f0*/ IMAD.MOV.U32 R2, RZ, RZ, 0x1 ; /* 0x00000001ff027424 */ /* 0x001fc800078e00ff */ /*0800*/ MUFU.RCP64H R3, R11 ; /* 0x0000000b00037308 */ /* 0x002e240000001800 */ /*0810*/ DFMA R8, -R10, R2, 1 ; /* 0x3ff000000a08742b */ /* 0x001e0c0000000102 */ /*0820*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x001e0c0000000008 */ /*0830*/ DFMA R8, R2, R8, R2 ; /* 0x000000080208722b */ /* 0x001e0c0000000002 */ /*0840*/ DFMA R2, -R10, R8, 1 ; /* 0x3ff000000a02742b */ /* 0x001e0c0000000108 */ /*0850*/ DFMA R2, R8, R2, R8 ; /* 0x000000020802722b */ /* 0x001e0c0000000008 */ /*0860*/ DMUL R8, R2, 4 ; /* 0x4010000002087828 */ /* 0x001e0c0000000000 */ /*0870*/ DFMA R12, -R10, R8, 4 ; /* 0x401000000a0c742b */ /* 0x001e0c0000000108 */ /*0880*/ DFMA R2, R2, R12, R8 ; /* 0x0000000c0202722b */ /* 0x001e140000000008 */ /*0890*/ FFMA R0, RZ, R11, R3 ; /* 0x0000000bff007223 */ /* 0x001fca0000000003 */ /*08a0*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*08b0*/ @P0 BRA 0x920 ; /* 0x0000006000000947 */ /* 0x000fea0003800000 */ /*08c0*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*08d0*/ MOV R2, 0x900 ; /* 0x0000090000027802 */ /* 0x000fe20000000f00 */ /*08e0*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*08f0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000023000007944 */ /* 0x000fea0003c00000 */ /*0900*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0004 */ /*0910*/ IMAD.MOV.U32 R3, RZ, RZ, R5 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0005 */ /*0920*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0930*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0940*/ BSSY B1, 0xac0 ; /* 0x0000017000017945 */ /* 0x000fe20003800000 */ /*0950*/ DADD R22, R22, R2 ; /* 0x0000000016167229 */ /* 0x000fe40000000002 */ /*0960*/ I2F.F64 R4, R25 ; /* 0x0000001900047312 */ /* 0x000e240000201c00 */ /*0970*/ DADD R4, R4, 0.5 ; /* 0x3fe0000004047429 */ /* 0x001e0c0000000000 */ /*0980*/ DMUL R4, R4, c[0x0][0x170] ; /* 0x00005c0004047a28 */ /* 0x001e0c0000000000 */ /*0990*/ DFMA R10, R4, R4, 1 ; /* 0x3ff00000040a742b */ /* 0x0010640000000004 */ /*09a0*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x001fc800078e00ff */ /*09b0*/ MUFU.RCP64H R5, R11 ; /* 0x0000000b00057308 */ /* 0x002e240000001800 */ /*09c0*/ DFMA R8, -R10, R4, 1 ; /* 0x3ff000000a08742b */ /* 0x001e0c0000000104 */ /*09d0*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x001e0c0000000008 */ /*09e0*/ DFMA R8, R4, R8, R4 ; /* 0x000000080408722b */ /* 0x001e0c0000000004 */ /*09f0*/ DFMA R4, -R10, R8, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000108 */ /*0a00*/ DFMA R4, R8, R4, R8 ; /* 0x000000040804722b */ /* 0x001e0c0000000008 */ /*0a10*/ DMUL R8, R4, 4 ; /* 0x4010000004087828 */ /* 0x001e0c0000000000 */ /*0a20*/ DFMA R12, -R10, R8, 4 ; /* 0x401000000a0c742b */ /* 0x001e0c0000000108 */ /*0a30*/ DFMA R4, R4, R12, R8 ; /* 0x0000000c0404722b */ /* 0x001e140000000008 */ /*0a40*/ FFMA R0, RZ, R11, R5 ; /* 0x0000000bff007223 */ /* 0x001fca0000000005 */ /*0a50*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0a60*/ @P0 BRA 0xab0 ; /* 0x0000004000000947 */ /* 0x000fea0003800000 */ /*0a70*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0a80*/ MOV R2, 0xab0 ; /* 0x00000ab000027802 */ /* 0x000fe20000000f00 */ /*0a90*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*0aa0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000008000007944 */ /* 0x000fea0003c00000 */ /*0ab0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0ac0*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0ad0*/ DADD R22, R22, R4 ; /* 0x0000000016167229 */ /* 0x0000460000000004 */ /*0ae0*/ ISETP.GE.AND P0, PT, R25, c[0x0][0x168], PT ; /* 0x00005a0019007a0c */ /* 0x000fda0003f06270 */ /*0af0*/ @!P0 BRA 0x460 ; /* 0xfffff96000008947 */ /* 0x003fea000383ffff */ /*0b00*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0b10*/ STG.E.64 [R6.64], R22 ; /* 0x0000001606007986 */ /* 0x020fe2000c101b06 */ /*0b20*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0b30*/ FSETP.GEU.AND P0, PT, |R11|.reuse, 1.469367938527859385e-39, PT ; /* 0x001000000b00780b */ /* 0x040fe20003f0e200 */ /*0b40*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x000fe200078e00ff */ /*0b50*/ LOP3.LUT R8, R11.reuse, 0x800fffff, RZ, 0xc0, !PT ; /* 0x800fffff0b087812 */ /* 0x040fe200078ec0ff */ /*0b60*/ IMAD.MOV.U32 R14, RZ, RZ, R12 ; /* 0x000000ffff0e7224 */ /* 0x000fe200078e000c */ /*0b70*/ LOP3.LUT R0, R11, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000b007812 */ /* 0x000fe400078ec0ff */ /*0b80*/ LOP3.LUT R9, R8, 0x3ff00000, RZ, 0xfc, !PT ; /* 0x3ff0000008097812 */ /* 0x000fe200078efcff */ /*0b90*/ IMAD.MOV.U32 R8, RZ, RZ, R10 ; /* 0x000000ffff087224 */ /* 0x000fe200078e000a */ /*0ba0*/ LOP3.LUT R3, R13, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000d037812 */ /* 0x000fc800078ec0ff */ /*0bb0*/ ISETP.GE.U32.AND P2, PT, R3, R0, PT ; /* 0x000000000300720c */ /* 0x000fe20003f46070 */ /*0bc0*/ @!P0 DMUL R8, R10, 8.98846567431157953865e+307 ; /* 0x7fe000000a088828 */ /* 0x000e0c0000000000 */ /*0bd0*/ MUFU.RCP64H R5, R9 ; /* 0x0000000900057308 */ /* 0x001e240000001800 */ /*0be0*/ DFMA R18, R4, -R8, 1 ; /* 0x3ff000000412742b */ /* 0x001e0c0000000808 */ /*0bf0*/ DFMA R18, R18, R18, R18 ; /* 0x000000121212722b */ /* 0x001e0c0000000012 */ /*0c00*/ DFMA R18, R4, R18, R4 ; /* 0x000000120412722b */ /* 0x0010640000000004 */ /*0c10*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1ca00000 ; /* 0x1ca00000ff047424 */ /* 0x001fe400078e00ff */ /*0c20*/ IMAD.MOV.U32 R5, RZ, RZ, R3 ; /* 0x000000ffff057224 */ /* 0x000fe400078e0003 */ /*0c30*/ DFMA R16, R18.reuse, -R8, 1 ; /* 0x3ff000001210742b */ /* 0x042e220000000808 */ /*0c40*/ SEL R15, R4, 0x63400000, !P2 ; /* 0x63400000040f7807 */ /* 0x000fe40005000000 */ /*0c50*/ FSETP.GEU.AND P2, PT, |R13|, 1.469367938527859385e-39, PT ; /* 0x001000000d00780b */ /* 0x000fe40003f4e200 */ /*0c60*/ LOP3.LUT R15, R15, 0x800fffff, R13, 0xf8, !PT ; /* 0x800fffff0f0f7812 */ /* 0x000fe200078ef80d */ /*0c70*/ DFMA R16, R18, R16, R18 ; /* 0x000000101210722b */ /* 0x0010540000000012 */ /*0c80*/ @P2 BRA 0xd10 ; /* 0x0000008000002947 */ /* 0x000fea0003800000 */ /*0c90*/ LOP3.LUT R18, R11, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000b127812 */ /* 0x003fc800078ec0ff */ /*0ca0*/ ISETP.GE.U32.AND P2, PT, R3, R18, PT ; /* 0x000000120300720c */ /* 0x000fe20003f46070 */ /*0cb0*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fc600078e00ff */ /*0cc0*/ SEL R5, R4, 0x63400000, !P2 ; /* 0x6340000004057807 */ /* 0x000fc80005000000 */ /*0cd0*/ LOP3.LUT R5, R5, 0x80000000, R13, 0xf8, !PT ; /* 0x8000000005057812 */ /* 0x000fc800078ef80d */ /*0ce0*/ LOP3.LUT R19, R5, 0x100000, RZ, 0xfc, !PT ; /* 0x0010000005137812 */ /* 0x000fcc00078efcff */ /*0cf0*/ DFMA R14, R14, 2, -R18 ; /* 0x400000000e0e782b */ /* 0x000e140000000812 */ /*0d00*/ LOP3.LUT R5, R15, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000f057812 */ /* 0x001fc800078ec0ff */ /*0d10*/ IADD3 R20, R5, -0x1, RZ ; /* 0xffffffff05147810 */ /* 0x003fe20007ffe0ff */ /*0d20*/ DMUL R18, R16, R14 ; /* 0x0000000e10127228 */ /* 0x000e220000000000 */ /*0d30*/ @!P0 LOP3.LUT R0, R9, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff0000009008812 */ /* 0x000fe200078ec0ff */ /*0d40*/ BSSY B2, 0x10d0 ; /* 0x0000038000027945 */ /* 0x000fe20003800000 */ /*0d50*/ ISETP.GT.U32.AND P0, PT, R20, 0x7feffffe, PT ; /* 0x7feffffe1400780c */ /* 0x000fe40003f04070 */ /*0d60*/ IADD3 R24, R0, -0x1, RZ ; /* 0xffffffff00187810 */ /* 0x000fe20007ffe0ff */ /*0d70*/ DFMA R20, R18, -R8, R14 ; /* 0x800000081214722b */ /* 0x001e06000000000e */ /*0d80*/ ISETP.GT.U32.OR P0, PT, R24, 0x7feffffe, P0 ; /* 0x7feffffe1800780c */ /* 0x000fc60000704470 */ /*0d90*/ DFMA R20, R16, R20, R18 ; /* 0x000000141014722b */ /* 0x0010540000000012 */ /*0da0*/ @P0 BRA 0xf70 ; /* 0x000001c000000947 */ /* 0x000fea0003800000 */ /*0db0*/ LOP3.LUT R12, R11, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000b0c7812 */ /* 0x003fc800078ec0ff */ /*0dc0*/ ISETP.GE.U32.AND P0, PT, R3.reuse, R12, PT ; /* 0x0000000c0300720c */ /* 0x040fe20003f06070 */ /*0dd0*/ IMAD.IADD R0, R3, 0x1, -R12 ; /* 0x0000000103007824 */ /* 0x000fc600078e0a0c */ /*0de0*/ SEL R3, R4, 0x63400000, !P0 ; /* 0x6340000004037807 */ /* 0x000fe20004000000 */ /*0df0*/ IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff047224 */ /* 0x000fe200078e00ff */ /*0e00*/ IMNMX R0, R0, -0x46a00000, !PT ; /* 0xb960000000007817 */ /* 0x000fc80007800200 */ /*0e10*/ IMNMX R0, R0, 0x46a00000, PT ; /* 0x46a0000000007817 */ /* 0x000fca0003800200 */ /*0e20*/ IMAD.IADD R0, R0, 0x1, -R3 ; /* 0x0000000100007824 */ /* 0x000fca00078e0a03 */ /*0e30*/ IADD3 R5, R0, 0x7fe00000, RZ ; /* 0x7fe0000000057810 */ /* 0x000fcc0007ffe0ff */ /*0e40*/ DMUL R16, R20, R4 ; /* 0x0000000414107228 */ /* 0x000e140000000000 */ /*0e50*/ FSETP.GTU.AND P0, PT, |R17|, 1.469367938527859385e-39, PT ; /* 0x001000001100780b */ /* 0x001fda0003f0c200 */ /*0e60*/ @P0 BRA 0x10c0 ; /* 0x0000025000000947 */ /* 0x000fea0003800000 */ /*0e70*/ DFMA R8, R20, -R8, R14 ; /* 0x800000081408722b */ /* 0x000e0c000000000e */ /*0e80*/ IMAD.MOV.U32 R8, RZ, RZ, RZ ; /* 0x000000ffff087224 */ /* 0x001fc800078e00ff */ /*0e90*/ FSETP.NEU.AND P0, PT, R9.reuse, RZ, PT ; /* 0x000000ff0900720b */ /* 0x040fe40003f0d000 */ /*0ea0*/ LOP3.LUT R11, R9, 0x80000000, R11, 0x48, !PT ; /* 0x80000000090b7812 */ /* 0x000fc800078e480b */ /*0eb0*/ LOP3.LUT R9, R11, R5, RZ, 0xfc, !PT ; /* 0x000000050b097212 */ /* 0x000fce00078efcff */ /*0ec0*/ @!P0 BRA 0x10c0 ; /* 0x000001f000008947 */ /* 0x000fea0003800000 */ /*0ed0*/ IMAD.MOV R5, RZ, RZ, -R0 ; /* 0x000000ffff057224 */ /* 0x000fe200078e0a00 */ /*0ee0*/ DMUL.RP R8, R20, R8 ; /* 0x0000000814087228 */ /* 0x000e220000008000 */ /*0ef0*/ IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff047224 */ /* 0x000fe200078e00ff */ /*0f00*/ IADD3 R3, -R0, -0x43300000, RZ ; /* 0xbcd0000000037810 */ /* 0x000fca0007ffe1ff */ /*0f10*/ DFMA R4, R16, -R4, R20 ; /* 0x800000041004722b */ /* 0x000e460000000014 */ /*0f20*/ LOP3.LUT R11, R9, R11, RZ, 0x3c, !PT ; /* 0x0000000b090b7212 */ /* 0x001fce00078e3cff */ /*0f30*/ FSETP.NEU.AND P0, PT, |R5|, R3, PT ; /* 0x000000030500720b */ /* 0x002fc80003f0d200 */ /*0f40*/ FSEL R16, R8, R16, !P0 ; /* 0x0000001008107208 */ /* 0x000fe40004000000 */ /*0f50*/ FSEL R17, R11, R17, !P0 ; /* 0x000000110b117208 */ /* 0x000fe20004000000 */ /*0f60*/ BRA 0x10c0 ; /* 0x0000015000007947 */ /* 0x000fea0003800000 */ /*0f70*/ DSETP.NAN.AND P0, PT, R12, R12, PT ; /* 0x0000000c0c00722a */ /* 0x003e1c0003f08000 */ /*0f80*/ @P0 BRA 0x10a0 ; /* 0x0000011000000947 */ /* 0x001fea0003800000 */ /*0f90*/ DSETP.NAN.AND P0, PT, R10, R10, PT ; /* 0x0000000a0a00722a */ /* 0x000e1c0003f08000 */ /*0fa0*/ @P0 BRA 0x1070 ; /* 0x000000c000000947 */ /* 0x001fea0003800000 */ /*0fb0*/ ISETP.NE.AND P0, PT, R5, R0, PT ; /* 0x000000000500720c */ /* 0x000fe20003f05270 */ /*0fc0*/ IMAD.MOV.U32 R16, RZ, RZ, 0x0 ; /* 0x00000000ff107424 */ /* 0x000fe400078e00ff */ /*0fd0*/ IMAD.MOV.U32 R17, RZ, RZ, -0x80000 ; /* 0xfff80000ff117424 */ /* 0x000fd400078e00ff */ /*0fe0*/ @!P0 BRA 0x10c0 ; /* 0x000000d000008947 */ /* 0x000fea0003800000 */ /*0ff0*/ ISETP.NE.AND P0, PT, R5, 0x7ff00000, PT ; /* 0x7ff000000500780c */ /* 0x000fe40003f05270 */ /*1000*/ LOP3.LUT R17, R13, 0x80000000, R11, 0x48, !PT ; /* 0x800000000d117812 */ /* 0x000fe400078e480b */ /*1010*/ ISETP.EQ.OR P0, PT, R0, RZ, !P0 ; /* 0x000000ff0000720c */ /* 0x000fda0004702670 */ /*1020*/ @P0 LOP3.LUT R0, R17, 0x7ff00000, RZ, 0xfc, !PT ; /* 0x7ff0000011000812 */ /* 0x000fe200078efcff */ /*1030*/ @!P0 IMAD.MOV.U32 R16, RZ, RZ, RZ ; /* 0x000000ffff108224 */ /* 0x000fe400078e00ff */ /*1040*/ @P0 IMAD.MOV.U32 R16, RZ, RZ, RZ ; /* 0x000000ffff100224 */ /* 0x000fe400078e00ff */ /*1050*/ @P0 IMAD.MOV.U32 R17, RZ, RZ, R0 ; /* 0x000000ffff110224 */ /* 0x000fe200078e0000 */ /*1060*/ BRA 0x10c0 ; /* 0x0000005000007947 */ /* 0x000fea0003800000 */ /*1070*/ LOP3.LUT R17, R11, 0x80000, RZ, 0xfc, !PT ; /* 0x000800000b117812 */ /* 0x000fe200078efcff */ /*1080*/ IMAD.MOV.U32 R16, RZ, RZ, R10 ; /* 0x000000ffff107224 */ /* 0x000fe200078e000a */ /*1090*/ BRA 0x10c0 ; /* 0x0000002000007947 */ /* 0x000fea0003800000 */ /*10a0*/ LOP3.LUT R17, R13, 0x80000, RZ, 0xfc, !PT ; /* 0x000800000d117812 */ /* 0x000fe200078efcff */ /*10b0*/ IMAD.MOV.U32 R16, RZ, RZ, R12 ; /* 0x000000ffff107224 */ /* 0x000fe400078e000c */ /*10c0*/ BSYNC B2 ; /* 0x0000000000027941 */ /* 0x000fea0003800000 */ /*10d0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x0 ; /* 0x00000000ff037424 */ /* 0x000fe400078e00ff */ /*10e0*/ IMAD.MOV.U32 R4, RZ, RZ, R16 ; /* 0x000000ffff047224 */ /* 0x000fc400078e0010 */ /*10f0*/ IMAD.MOV.U32 R5, RZ, RZ, R17 ; /* 0x000000ffff057224 */ /* 0x000fe200078e0011 */ /*1100*/ RET.REL.NODEC R2 0x0 ; /* 0xffffeef002007950 */ /* 0x000fec0003c3ffff */ /*1110*/ BRA 0x1110; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*1120*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1130*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1140*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11f0*/ 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 <time.h> /** * Using CPU to calculate pi * @param a Lower Integral Bounds * @param b Upper Integral Bounds * @param Integral Value */ const int N = 1024 * 1024 * 64; void pi_by_cpu(double a, double b, double *integral) { int i; double x, temp = 0; for (i = 0; i < N; i++) { x = a + (double)(b - a) / N * (i + 0.5); temp += 4 / (1 + x * x); } temp *= (double)(b - a) / N; *integral = temp; } // Using CUDA device to calculate pi #include <stdio.h> #include <cuda.h> #define NBIN N // Number of bins #define NUM_BLOCK 64 // Number of thread blocks #define NUM_THREAD 256 // Number of threads per block int tid; double pi = 0; // Kernel that executes on the CUDA device __global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) { int i; double x; int idx = blockIdx.x*blockDim.x + threadIdx.x; // Sequential thread index across the blocks for (i = idx; i < nbin; i += nthreads * nblocks) { x = (i + 0.5)*step; sum[idx] += 4.0 / (1.0 + x * x); } } // Main routine that executes on the host int main(void) { //Using CPU to calculate pi double a, b; double integral; clock_t clockBegin, clockEnd; double duration; a = 0; b = 1; clockBegin = clock(); pi_by_cpu(a, b, &integral); clockEnd = clock(); duration = (double)1000 * (clockEnd - clockBegin) / CLOCKS_PER_SEC; printf("CPU Result: %.11lf\n", integral); printf("CPU Elapsed time: %.6lfms\n\n", duration); // Using CUDA device to calculate pi cudaEvent_t start, stop; cudaEventCreate(&start); //event cudaEventCreate(&stop); //event cudaEventRecord(start, 0); //record time float tm; dim3 dimGrid(NUM_BLOCK, 1, 1); // Grid dimensions dim3 dimBlock(NUM_THREAD, 1, 1); // Block dimensions double *sumHost, *sumDev; // Pointer to host & device arrays double step = 1.0 / NBIN; // Step size size_t size = NUM_BLOCK * NUM_THREAD * sizeof(double); //Array memory size sumHost = (double *)malloc(size); // Allocate array on host cudaMalloc((void **)&sumDev, size); // Allocate array on device // Initialize array in device to 0 cudaMemset(sumDev, 0, size); // Do calculation on device cal_pi <<<dimGrid, dimBlock >>> (sumDev, NBIN, step, NUM_THREAD, NUM_BLOCK); // call CUDA kernel // Retrieve result from device and store it in host array cudaMemcpy(sumHost, sumDev, size, cudaMemcpyDeviceToHost); for (tid = 0; tid < NUM_THREAD*NUM_BLOCK; tid++) pi += sumHost[tid]; pi *= step; // Print results printf("GPU Result: %.11lf\n", pi); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&tm, start, stop); printf("GPU Elapsed time:%.6f ms.\n\n", tm); // Cleanup free(sumHost); cudaFree(sumDev); printf("Press to exit.\n"); getchar(); return 0; }
.file "tmpxft_0004ca04_00000000-6_kernel.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2061: .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 .LFE2061: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z9pi_by_cpuddPd .type _Z9pi_by_cpuddPd, @function _Z9pi_by_cpuddPd: .LFB2027: .cfi_startproc endbr64 subsd %xmm0, %xmm1 mulsd .LC1(%rip), %xmm1 pxor %xmm3, %xmm3 movl $0, %eax movsd .LC2(%rip), %xmm7 movsd .LC3(%rip), %xmm6 movsd .LC4(%rip), %xmm5 .L4: pxor %xmm2, %xmm2 cvtsi2sdl %eax, %xmm2 addsd %xmm7, %xmm2 mulsd %xmm1, %xmm2 addsd %xmm0, %xmm2 mulsd %xmm2, %xmm2 addsd %xmm6, %xmm2 movapd %xmm5, %xmm4 divsd %xmm2, %xmm4 addsd %xmm4, %xmm3 addl $1, %eax cmpl $67108864, %eax jne .L4 mulsd %xmm3, %xmm1 movsd %xmm1, (%rdi) ret .cfi_endproc .LFE2027: .size _Z9pi_by_cpuddPd, .-_Z9pi_by_cpuddPd .globl _Z29__device_stub__Z6cal_piPdidiiPdidii .type _Z29__device_stub__Z6cal_piPdidiiPdidii, @function _Z29__device_stub__Z6cal_piPdidiiPdidii: .LFB2083: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movsd %xmm0, 8(%rsp) movl %edx, 16(%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 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 16(%rsp), %rax movq %rax, 120(%rsp) leaq 4(%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 .L10 .L6: movq 136(%rsp), %rax subq %fs:40, %rax jne .L11 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L10: .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 _Z6cal_piPdidii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L6 .L11: call __stack_chk_fail@PLT .cfi_endproc .LFE2083: .size _Z29__device_stub__Z6cal_piPdidiiPdidii, .-_Z29__device_stub__Z6cal_piPdidiiPdidii .globl _Z6cal_piPdidii .type _Z6cal_piPdidii, @function _Z6cal_piPdidii: .LFB2084: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z29__device_stub__Z6cal_piPdidiiPdidii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2084: .size _Z6cal_piPdidii, .-_Z6cal_piPdidii .section .rodata.str1.1,"aMS",@progbits,1 .LC7: .string "CPU Result: %.11lf\n" .LC8: .string "CPU Elapsed time: %.6lfms\n\n" .LC9: .string "GPU Result: %.11lf\n" .LC10: .string "GPU Elapsed time:%.6f ms.\n\n" .LC11: .string "Press to exit.\n" .text .globl main .type main, @function main: .LFB2058: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $80, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax call clock@PLT movq %rax, %rbx leaq 16(%rsp), %rdi movsd .LC3(%rip), %xmm1 pxor %xmm0, %xmm0 call _Z9pi_by_cpuddPd call clock@PLT subq %rbx, %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 mulsd .LC5(%rip), %xmm0 divsd .LC6(%rip), %xmm0 movq %xmm0, %rbx movsd 16(%rsp), %xmm0 leaq .LC7(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq %rbx, %xmm0 leaq .LC8(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT leaq 24(%rsp), %rdi call cudaEventCreate@PLT leaq 32(%rsp), %rdi call cudaEventCreate@PLT movl $0, %esi movq 24(%rsp), %rdi call cudaEventRecord@PLT movl $64, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $256, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $131072, %edi call malloc@PLT movq %rax, %rbx leaq 40(%rsp), %rdi movl $131072, %esi call cudaMalloc@PLT movl $131072, %edx movl $0, %esi movq 40(%rsp), %rdi call cudaMemset@PLT movl 68(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 60(%rsp), %rdx movq 48(%rsp), %rdi movl 56(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L20 .L15: movl $2, %ecx movl $131072, %edx movq 40(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT movsd pi(%rip), %xmm0 movq %rbx, %rax leaq 131072(%rbx), %rdx .L16: addsd (%rax), %xmm0 addq $8, %rax cmpq %rdx, %rax jne .L16 movl $16384, tid(%rip) mulsd .LC1(%rip), %xmm0 movsd %xmm0, pi(%rip) leaq .LC9(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movq 32(%rsp), %rdi call cudaEventSynchronize@PLT leaq 12(%rsp), %rdi movq 32(%rsp), %rdx movq 24(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 12(%rsp), %xmm0 leaq .LC10(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq %rbx, %rdi call free@PLT movq 40(%rsp), %rdi call cudaFree@PLT leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq stdin(%rip), %rdi call getc@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L21 movl $0, %eax addq $80, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L20: .cfi_restore_state movl $64, %ecx movl $256, %edx movsd .LC1(%rip), %xmm0 movl $67108864, %esi movq 40(%rsp), %rdi call _Z29__device_stub__Z6cal_piPdidiiPdidii jmp .L15 .L21: call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size main, .-main .section .rodata.str1.1 .LC12: .string "_Z6cal_piPdidii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2086: .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 .LC12(%rip), %rdx movq %rdx, %rcx leaq _Z6cal_piPdidii(%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 .LFE2086: .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 pi .bss .align 8 .type pi, @object .size pi, 8 pi: .zero 8 .globl tid .align 4 .type tid, @object .size tid, 4 tid: .zero 4 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC1: .long 0 .long 1045430272 .align 8 .LC2: .long 0 .long 1071644672 .align 8 .LC3: .long 0 .long 1072693248 .align 8 .LC4: .long 0 .long 1074790400 .align 8 .LC5: .long 0 .long 1083129856 .align 8 .LC6: .long 0 .long 1093567616 .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 <time.h> /** * Using CPU to calculate pi * @param a Lower Integral Bounds * @param b Upper Integral Bounds * @param Integral Value */ const int N = 1024 * 1024 * 64; void pi_by_cpu(double a, double b, double *integral) { int i; double x, temp = 0; for (i = 0; i < N; i++) { x = a + (double)(b - a) / N * (i + 0.5); temp += 4 / (1 + x * x); } temp *= (double)(b - a) / N; *integral = temp; } // Using CUDA device to calculate pi #include <stdio.h> #include <cuda.h> #define NBIN N // Number of bins #define NUM_BLOCK 64 // Number of thread blocks #define NUM_THREAD 256 // Number of threads per block int tid; double pi = 0; // Kernel that executes on the CUDA device __global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) { int i; double x; int idx = blockIdx.x*blockDim.x + threadIdx.x; // Sequential thread index across the blocks for (i = idx; i < nbin; i += nthreads * nblocks) { x = (i + 0.5)*step; sum[idx] += 4.0 / (1.0 + x * x); } } // Main routine that executes on the host int main(void) { //Using CPU to calculate pi double a, b; double integral; clock_t clockBegin, clockEnd; double duration; a = 0; b = 1; clockBegin = clock(); pi_by_cpu(a, b, &integral); clockEnd = clock(); duration = (double)1000 * (clockEnd - clockBegin) / CLOCKS_PER_SEC; printf("CPU Result: %.11lf\n", integral); printf("CPU Elapsed time: %.6lfms\n\n", duration); // Using CUDA device to calculate pi cudaEvent_t start, stop; cudaEventCreate(&start); //event cudaEventCreate(&stop); //event cudaEventRecord(start, 0); //record time float tm; dim3 dimGrid(NUM_BLOCK, 1, 1); // Grid dimensions dim3 dimBlock(NUM_THREAD, 1, 1); // Block dimensions double *sumHost, *sumDev; // Pointer to host & device arrays double step = 1.0 / NBIN; // Step size size_t size = NUM_BLOCK * NUM_THREAD * sizeof(double); //Array memory size sumHost = (double *)malloc(size); // Allocate array on host cudaMalloc((void **)&sumDev, size); // Allocate array on device // Initialize array in device to 0 cudaMemset(sumDev, 0, size); // Do calculation on device cal_pi <<<dimGrid, dimBlock >>> (sumDev, NBIN, step, NUM_THREAD, NUM_BLOCK); // call CUDA kernel // Retrieve result from device and store it in host array cudaMemcpy(sumHost, sumDev, size, cudaMemcpyDeviceToHost); for (tid = 0; tid < NUM_THREAD*NUM_BLOCK; tid++) pi += sumHost[tid]; pi *= step; // Print results printf("GPU Result: %.11lf\n", pi); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&tm, start, stop); printf("GPU Elapsed time:%.6f ms.\n\n", tm); // Cleanup free(sumHost); cudaFree(sumDev); printf("Press to exit.\n"); getchar(); return 0; }
#include "hip/hip_runtime.h" #include <time.h> /** * Using CPU to calculate pi * @param a Lower Integral Bounds * @param b Upper Integral Bounds * @param Integral Value */ const int N = 1024 * 1024 * 64; void pi_by_cpu(double a, double b, double *integral) { int i; double x, temp = 0; for (i = 0; i < N; i++) { x = a + (double)(b - a) / N * (i + 0.5); temp += 4 / (1 + x * x); } temp *= (double)(b - a) / N; *integral = temp; } // Using CUDA device to calculate pi #include <stdio.h> #define NBIN N // Number of bins #define NUM_BLOCK 64 // Number of thread blocks #define NUM_THREAD 256 // Number of threads per block int tid; double pi = 0; // Kernel that executes on the CUDA device __global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) { int i; double x; int idx = blockIdx.x*blockDim.x + threadIdx.x; // Sequential thread index across the blocks for (i = idx; i < nbin; i += nthreads * nblocks) { x = (i + 0.5)*step; sum[idx] += 4.0 / (1.0 + x * x); } } // Main routine that executes on the host int main(void) { //Using CPU to calculate pi double a, b; double integral; clock_t clockBegin, clockEnd; double duration; a = 0; b = 1; clockBegin = clock(); pi_by_cpu(a, b, &integral); clockEnd = clock(); duration = (double)1000 * (clockEnd - clockBegin) / CLOCKS_PER_SEC; printf("CPU Result: %.11lf\n", integral); printf("CPU Elapsed time: %.6lfms\n\n", duration); // Using CUDA device to calculate pi hipEvent_t start, stop; hipEventCreate(&start); //event hipEventCreate(&stop); //event hipEventRecord(start, 0); //record time float tm; dim3 dimGrid(NUM_BLOCK, 1, 1); // Grid dimensions dim3 dimBlock(NUM_THREAD, 1, 1); // Block dimensions double *sumHost, *sumDev; // Pointer to host & device arrays double step = 1.0 / NBIN; // Step size size_t size = NUM_BLOCK * NUM_THREAD * sizeof(double); //Array memory size sumHost = (double *)malloc(size); // Allocate array on host hipMalloc((void **)&sumDev, size); // Allocate array on device // Initialize array in device to 0 hipMemset(sumDev, 0, size); // Do calculation on device cal_pi <<<dimGrid, dimBlock >>> (sumDev, NBIN, step, NUM_THREAD, NUM_BLOCK); // call CUDA kernel // Retrieve result from device and store it in host array hipMemcpy(sumHost, sumDev, size, hipMemcpyDeviceToHost); for (tid = 0; tid < NUM_THREAD*NUM_BLOCK; tid++) pi += sumHost[tid]; pi *= step; // Print results printf("GPU Result: %.11lf\n", pi); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&tm, start, stop); printf("GPU Elapsed time:%.6f ms.\n\n", tm); // Cleanup free(sumHost); hipFree(sumDev); printf("Press to exit.\n"); getchar(); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include "hip/hip_runtime.h" #include <time.h> /** * Using CPU to calculate pi * @param a Lower Integral Bounds * @param b Upper Integral Bounds * @param Integral Value */ const int N = 1024 * 1024 * 64; void pi_by_cpu(double a, double b, double *integral) { int i; double x, temp = 0; for (i = 0; i < N; i++) { x = a + (double)(b - a) / N * (i + 0.5); temp += 4 / (1 + x * x); } temp *= (double)(b - a) / N; *integral = temp; } // Using CUDA device to calculate pi #include <stdio.h> #define NBIN N // Number of bins #define NUM_BLOCK 64 // Number of thread blocks #define NUM_THREAD 256 // Number of threads per block int tid; double pi = 0; // Kernel that executes on the CUDA device __global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) { int i; double x; int idx = blockIdx.x*blockDim.x + threadIdx.x; // Sequential thread index across the blocks for (i = idx; i < nbin; i += nthreads * nblocks) { x = (i + 0.5)*step; sum[idx] += 4.0 / (1.0 + x * x); } } // Main routine that executes on the host int main(void) { //Using CPU to calculate pi double a, b; double integral; clock_t clockBegin, clockEnd; double duration; a = 0; b = 1; clockBegin = clock(); pi_by_cpu(a, b, &integral); clockEnd = clock(); duration = (double)1000 * (clockEnd - clockBegin) / CLOCKS_PER_SEC; printf("CPU Result: %.11lf\n", integral); printf("CPU Elapsed time: %.6lfms\n\n", duration); // Using CUDA device to calculate pi hipEvent_t start, stop; hipEventCreate(&start); //event hipEventCreate(&stop); //event hipEventRecord(start, 0); //record time float tm; dim3 dimGrid(NUM_BLOCK, 1, 1); // Grid dimensions dim3 dimBlock(NUM_THREAD, 1, 1); // Block dimensions double *sumHost, *sumDev; // Pointer to host & device arrays double step = 1.0 / NBIN; // Step size size_t size = NUM_BLOCK * NUM_THREAD * sizeof(double); //Array memory size sumHost = (double *)malloc(size); // Allocate array on host hipMalloc((void **)&sumDev, size); // Allocate array on device // Initialize array in device to 0 hipMemset(sumDev, 0, size); // Do calculation on device cal_pi <<<dimGrid, dimBlock >>> (sumDev, NBIN, step, NUM_THREAD, NUM_BLOCK); // call CUDA kernel // Retrieve result from device and store it in host array hipMemcpy(sumHost, sumDev, size, hipMemcpyDeviceToHost); for (tid = 0; tid < NUM_THREAD*NUM_BLOCK; tid++) pi += sumHost[tid]; pi *= step; // Print results printf("GPU Result: %.11lf\n", pi); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&tm, start, stop); printf("GPU Elapsed time:%.6f ms.\n\n", tm); // Cleanup free(sumHost); hipFree(sumDev); printf("Press to exit.\n"); getchar(); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6cal_piPdidii .globl _Z6cal_piPdidii .p2align 8 .type _Z6cal_piPdidii,@function _Z6cal_piPdidii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x8 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 s4, v1 s_cbranch_execz .LBB0_4 s_load_b64 s[6:7], s[0:1], 0x0 v_ashrrev_i32_e32 v2, 31, v1 s_load_b128 s[0:3], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 3, v[1:2] s_waitcnt lgkmcnt(0) v_add_co_u32 v2, vcc_lo, s6, v2 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo s_mul_i32 s3, s3, s2 s_mov_b32 s2, 0 global_load_b64 v[4:5], v[2:3], off s_set_inst_prefetch_distance 0x1 .p2align 6 .LBB0_2: v_cvt_f64_i32_e32 v[6:7], v1 v_add_nc_u32_e32 v1, s3, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_f64 v[6:7], v[6:7], 0.5 v_mul_f64 v[6:7], v[6:7], s[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[6:7], v[6:7], v[6:7], 1.0 v_div_scale_f64 v[8:9], null, v[6:7], v[6:7], 4.0 v_div_scale_f64 v[14:15], vcc_lo, 4.0, v[6:7], 4.0 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_rcp_f64_e32 v[10:11], v[8:9] s_waitcnt_depctr 0xfff v_fma_f64 v[12:13], -v[8:9], v[10:11], 1.0 v_fma_f64 v[10:11], v[10:11], v[12:13], v[10:11] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[12:13], -v[8:9], v[10:11], 1.0 v_fma_f64 v[10:11], v[10:11], v[12:13], v[10:11] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f64 v[12:13], v[14:15], v[10:11] v_fma_f64 v[8:9], -v[8:9], v[12:13], v[14:15] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_div_fmas_f64 v[8:9], v[8:9], v[10:11], v[12:13] v_cmp_le_i32_e32 vcc_lo, s4, v1 s_or_b32 s2, vcc_lo, s2 v_div_fixup_f64 v[6:7], v[8:9], v[6:7], 4.0 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) v_add_f64 v[4:5], v[6:7], v[4:5] s_and_not1_b32 exec_lo, exec_lo, s2 s_cbranch_execnz .LBB0_2 s_set_inst_prefetch_distance 0x2 s_or_b32 exec_lo, exec_lo, s2 global_store_b64 v[2:3], v[4:5], off .LBB0_4: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6cal_piPdidii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .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 16 .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 _Z6cal_piPdidii, .Lfunc_end0-_Z6cal_piPdidii .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: 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: _Z6cal_piPdidii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6cal_piPdidii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 16 .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 <time.h> /** * Using CPU to calculate pi * @param a Lower Integral Bounds * @param b Upper Integral Bounds * @param Integral Value */ const int N = 1024 * 1024 * 64; void pi_by_cpu(double a, double b, double *integral) { int i; double x, temp = 0; for (i = 0; i < N; i++) { x = a + (double)(b - a) / N * (i + 0.5); temp += 4 / (1 + x * x); } temp *= (double)(b - a) / N; *integral = temp; } // Using CUDA device to calculate pi #include <stdio.h> #define NBIN N // Number of bins #define NUM_BLOCK 64 // Number of thread blocks #define NUM_THREAD 256 // Number of threads per block int tid; double pi = 0; // Kernel that executes on the CUDA device __global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) { int i; double x; int idx = blockIdx.x*blockDim.x + threadIdx.x; // Sequential thread index across the blocks for (i = idx; i < nbin; i += nthreads * nblocks) { x = (i + 0.5)*step; sum[idx] += 4.0 / (1.0 + x * x); } } // Main routine that executes on the host int main(void) { //Using CPU to calculate pi double a, b; double integral; clock_t clockBegin, clockEnd; double duration; a = 0; b = 1; clockBegin = clock(); pi_by_cpu(a, b, &integral); clockEnd = clock(); duration = (double)1000 * (clockEnd - clockBegin) / CLOCKS_PER_SEC; printf("CPU Result: %.11lf\n", integral); printf("CPU Elapsed time: %.6lfms\n\n", duration); // Using CUDA device to calculate pi hipEvent_t start, stop; hipEventCreate(&start); //event hipEventCreate(&stop); //event hipEventRecord(start, 0); //record time float tm; dim3 dimGrid(NUM_BLOCK, 1, 1); // Grid dimensions dim3 dimBlock(NUM_THREAD, 1, 1); // Block dimensions double *sumHost, *sumDev; // Pointer to host & device arrays double step = 1.0 / NBIN; // Step size size_t size = NUM_BLOCK * NUM_THREAD * sizeof(double); //Array memory size sumHost = (double *)malloc(size); // Allocate array on host hipMalloc((void **)&sumDev, size); // Allocate array on device // Initialize array in device to 0 hipMemset(sumDev, 0, size); // Do calculation on device cal_pi <<<dimGrid, dimBlock >>> (sumDev, NBIN, step, NUM_THREAD, NUM_BLOCK); // call CUDA kernel // Retrieve result from device and store it in host array hipMemcpy(sumHost, sumDev, size, hipMemcpyDeviceToHost); for (tid = 0; tid < NUM_THREAD*NUM_BLOCK; tid++) pi += sumHost[tid]; pi *= step; // Print results printf("GPU Result: %.11lf\n", pi); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&tm, start, stop); printf("GPU Elapsed time:%.6f ms.\n\n", tm); // Cleanup free(sumHost); hipFree(sumDev); printf("Press to exit.\n"); getchar(); return 0; }
.text .file "kernel.hip" .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function _Z9pi_by_cpuddPd .LCPI0_0: .quad 0x3e50000000000000 # double 1.4901161193847656E-8 .LCPI0_1: .quad 0x3fe0000000000000 # double 0.5 .LCPI0_2: .quad 0x3ff0000000000000 # double 1 .LCPI0_3: .quad 0x4010000000000000 # double 4 .text .globl _Z9pi_by_cpuddPd .p2align 4, 0x90 .type _Z9pi_by_cpuddPd,@function _Z9pi_by_cpuddPd: # @_Z9pi_by_cpuddPd .cfi_startproc # %bb.0: subsd %xmm0, %xmm1 mulsd .LCPI0_0(%rip), %xmm1 xorpd %xmm2, %xmm2 movl $67108864, %eax # imm = 0x4000000 movsd .LCPI0_1(%rip), %xmm3 # xmm3 = mem[0],zero movsd .LCPI0_2(%rip), %xmm4 # xmm4 = mem[0],zero movsd .LCPI0_3(%rip), %xmm5 # xmm5 = mem[0],zero xorpd %xmm6, %xmm6 .p2align 4, 0x90 .LBB0_1: # =>This Inner Loop Header: Depth=1 movapd %xmm6, %xmm7 addsd %xmm3, %xmm7 mulsd %xmm1, %xmm7 addsd %xmm0, %xmm7 mulsd %xmm7, %xmm7 addsd %xmm4, %xmm7 movapd %xmm5, %xmm8 divsd %xmm7, %xmm8 addsd %xmm8, %xmm2 addsd %xmm4, %xmm6 decl %eax jne .LBB0_1 # %bb.2: mulsd %xmm2, %xmm1 movsd %xmm1, (%rdi) retq .Lfunc_end0: .size _Z9pi_by_cpuddPd, .Lfunc_end0-_Z9pi_by_cpuddPd .cfi_endproc # -- End function .globl _Z21__device_stub__cal_piPdidii # -- Begin function _Z21__device_stub__cal_piPdidii .p2align 4, 0x90 .type _Z21__device_stub__cal_piPdidii,@function _Z21__device_stub__cal_piPdidii: # @_Z21__device_stub__cal_piPdidii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 12(%rsp) movsd %xmm0, 64(%rsp) movl %edx, 8(%rsp) movl %ecx, 4(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%rsp), %rax movq %rax, 96(%rsp) leaq 8(%rsp), %rax movq %rax, 104(%rsp) leaq 4(%rsp), %rax movq %rax, 112(%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 $_Z6cal_piPdidii, %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 _Z21__device_stub__cal_piPdidii, .Lfunc_end1-_Z21__device_stub__cal_piPdidii .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI2_0: .quad 0x3fe0000000000000 # double 0.5 .LCPI2_1: .quad 0x3e50000000000000 # double 1.4901161193847656E-8 .LCPI2_2: .quad 0x3ff0000000000000 # double 1 .LCPI2_3: .quad 0x4010000000000000 # double 4 .LCPI2_4: .quad 0x408f400000000000 # double 1000 .LCPI2_5: .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 %rbx .cfi_def_cfa_offset 24 subq $168, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -24 .cfi_offset %rbp, -16 movl $67108864, %ebp # imm = 0x4000000 callq clock xorpd %xmm8, %xmm8 movq %rax, %rbx movsd .LCPI2_0(%rip), %xmm0 # xmm0 = mem[0],zero movsd .LCPI2_1(%rip), %xmm1 # xmm1 = mem[0],zero movsd .LCPI2_2(%rip), %xmm2 # xmm2 = mem[0],zero movsd .LCPI2_3(%rip), %xmm3 # xmm3 = mem[0],zero xorpd %xmm7, %xmm7 xorpd %xmm4, %xmm4 .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 movapd %xmm4, %xmm5 addsd %xmm0, %xmm5 mulsd %xmm1, %xmm5 addsd %xmm8, %xmm5 mulsd %xmm5, %xmm5 addsd %xmm2, %xmm5 movapd %xmm3, %xmm6 divsd %xmm5, %xmm6 addsd %xmm6, %xmm7 addsd %xmm2, %xmm4 decl %ebp jne .LBB2_1 # %bb.2: # %_Z9pi_by_cpuddPd.exit mulsd .LCPI2_1(%rip), %xmm7 movsd %xmm7, 56(%rsp) # 8-byte Spill callq clock subq %rbx, %rax xorps %xmm0, %xmm0 cvtsi2sd %rax, %xmm0 mulsd .LCPI2_4(%rip), %xmm0 divsd .LCPI2_5(%rip), %xmm0 movsd %xmm0, 48(%rsp) # 8-byte Spill movl $.L.str, %edi movsd 56(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero movb $1, %al callq printf movl $.L.str.1, %edi movsd 48(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero movb $1, %al callq printf leaq 40(%rsp), %rdi callq hipEventCreate leaq 16(%rsp), %rdi callq hipEventCreate movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movl $131072, %edi # imm = 0x20000 callq malloc movq %rax, %rbx leaq 8(%rsp), %rdi movl $131072, %esi # imm = 0x20000 callq hipMalloc movq 8(%rsp), %rdi movl $131072, %edx # imm = 0x20000 xorl %esi, %esi callq hipMemset movabsq $4294967360, %rdi # imm = 0x100000040 leaq 192(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_4 # %bb.3: movq 8(%rsp), %rax movq %rax, 120(%rsp) movl $67108864, 36(%rsp) # imm = 0x4000000 movabsq $4490088828488384512, %rax # imm = 0x3E50000000000000 movq %rax, 112(%rsp) movl $256, 32(%rsp) # imm = 0x100 movl $64, 28(%rsp) leaq 120(%rsp), %rax movq %rax, 128(%rsp) leaq 36(%rsp), %rax movq %rax, 136(%rsp) leaq 112(%rsp), %rax movq %rax, 144(%rsp) leaq 32(%rsp), %rax movq %rax, 152(%rsp) leaq 28(%rsp), %rax movq %rax, 160(%rsp) leaq 96(%rsp), %rdi leaq 80(%rsp), %rsi leaq 72(%rsp), %rdx leaq 64(%rsp), %rcx callq __hipPopCallConfiguration movq 96(%rsp), %rsi movl 104(%rsp), %edx movq 80(%rsp), %rcx movl 88(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z6cal_piPdidii, %edi pushq 64(%rsp) .cfi_adjust_cfa_offset 8 pushq 80(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_4: movq 8(%rsp), %rsi movl $131072, %edx # imm = 0x20000 movq %rbx, %rdi movl $2, %ecx callq hipMemcpy xorl %eax, %eax movsd pi(%rip), %xmm0 # xmm0 = mem[0],zero .p2align 4, 0x90 .LBB2_5: # =>This Inner Loop Header: Depth=1 addsd (%rbx,%rax,8), %xmm0 incq %rax cmpq $16384, %rax # imm = 0x4000 jne .LBB2_5 # %bb.6: movl $16384, tid(%rip) # imm = 0x4000 mulsd .LCPI2_1(%rip), %xmm0 movsd %xmm0, pi(%rip) movl $.L.str.2, %edi movb $1, %al callq printf movq 16(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 16(%rsp), %rdi callq hipEventSynchronize movq 40(%rsp), %rsi movq 16(%rsp), %rdx leaq 128(%rsp), %rdi callq hipEventElapsedTime movss 128(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.3, %edi movb $1, %al callq printf movq %rbx, %rdi callq free movq 8(%rsp), %rdi callq hipFree movl $.Lstr, %edi callq puts@PLT movq stdin(%rip), %rdi callq getc xorl %eax, %eax addq $168, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z6cal_piPdidii, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type tid,@object # @tid .bss .globl tid .p2align 2, 0x0 tid: .long 0 # 0x0 .size tid, 4 .type pi,@object # @pi .globl pi .p2align 3, 0x0 pi: .quad 0x0000000000000000 # double 0 .size pi, 8 .type _Z6cal_piPdidii,@object # @_Z6cal_piPdidii .section .rodata,"a",@progbits .globl _Z6cal_piPdidii .p2align 3, 0x0 _Z6cal_piPdidii: .quad _Z21__device_stub__cal_piPdidii .size _Z6cal_piPdidii, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "CPU Result: %.11lf\n" .size .L.str, 20 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "CPU Elapsed time: %.6lfms\n\n" .size .L.str.1, 28 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "GPU Result: %.11lf\n" .size .L.str.2, 20 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "GPU Elapsed time:%.6f ms.\n\n" .size .L.str.3, 28 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6cal_piPdidii" .size .L__unnamed_1, 16 .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 "Press to exit." .size .Lstr, 15 .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 _Z21__device_stub__cal_piPdidii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6cal_piPdidii .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 : _Z6cal_piPdidii .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 R25, SR_CTAID.X ; /* 0x0000000000197919 */ /* 0x000e280000002500 */ /*0020*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R25, R25, c[0x0][0x0], R0 ; /* 0x0000000019197a24 */ /* 0x001fca00078e0200 */ /*0040*/ ISETP.GE.AND P0, PT, R25, c[0x0][0x168], PT ; /* 0x00005a0019007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ IMAD.MOV.U32 R6, RZ, RZ, 0x8 ; /* 0x00000008ff067424 */ /* 0x000fe200078e00ff */ /*0070*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*0080*/ ULDC.64 UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe20000000a00 */ /*0090*/ IMAD.WIDE R6, R25, R6, c[0x0][0x160] ; /* 0x0000580019067625 */ /* 0x000fca00078e0206 */ /*00a0*/ LDG.E.64 R22, [R6.64] ; /* 0x0000000606167981 */ /* 0x000162000c1e1b00 */ /*00b0*/ UIMAD UR4, UR5, UR4, URZ ; /* 0x00000004050472a4 */ /* 0x000fe2000f8e023f */ /*00c0*/ LOP3.LUT R0, RZ, R25, RZ, 0x33, !PT ; /* 0x00000019ff007212 */ /* 0x000fe200078e33ff */ /*00d0*/ BSSY B0, 0x430 ; /* 0x0000035000007945 */ /* 0x000fe60003800000 */ /*00e0*/ IADD3 R0, R0, c[0x0][0x168], RZ ; /* 0x00005a0000007a10 */ /* 0x000fe20007ffe0ff */ /*00f0*/ IMAD R5, RZ, RZ, -UR4 ; /* 0x80000004ff057e24 */ /* 0x000fe2000f8e02ff */ /*0100*/ ISETP.NE.U32.AND P2, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe4000bf45070 */ /*0110*/ I2F.U32.RP R4, UR4 ; /* 0x0000000400047d06 */ /* 0x000e700008209000 */ /*0120*/ MUFU.RCP R4, R4 ; /* 0x0000000400047308 */ /* 0x002e640000001000 */ /*0130*/ IADD3 R2, R4, 0xffffffe, RZ ; /* 0x0ffffffe04027810 */ /* 0x002fcc0007ffe0ff */ /*0140*/ F2I.FTZ.U32.TRUNC.NTZ R3, R2 ; /* 0x0000000200037305 */ /* 0x0002a4000021f000 */ /*0150*/ IMAD.MOV.U32 R2, RZ, RZ, RZ ; /* 0x000000ffff027224 */ /* 0x002fe400078e00ff */ /*0160*/ IMAD R5, R5, R3, RZ ; /* 0x0000000305057224 */ /* 0x004fc800078e02ff */ /*0170*/ IMAD.HI.U32 R3, R3, R5, R2 ; /* 0x0000000503037227 */ /* 0x000fcc00078e0002 */ /*0180*/ IMAD.HI.U32 R26, R3, R0, RZ ; /* 0x00000000031a7227 */ /* 0x000fc800078e00ff */ /*0190*/ IMAD.MOV R3, RZ, RZ, -R26 ; /* 0x000000ffff037224 */ /* 0x000fc800078e0a1a */ /*01a0*/ IMAD R0, R3, UR4, R0 ; /* 0x0000000403007c24 */ /* 0x000fca000f8e0200 */ /*01b0*/ ISETP.GE.U32.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf06070 */ /*01c0*/ @P0 IADD3 R0, R0, -UR4, RZ ; /* 0x8000000400000c10 */ /* 0x000fe4000fffe0ff */ /*01d0*/ @P0 IADD3 R26, R26, 0x1, RZ ; /* 0x000000011a1a0810 */ /* 0x000fe40007ffe0ff */ /*01e0*/ ISETP.GE.U32.AND P1, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf26070 */ /*01f0*/ @P1 IADD3 R26, R26, 0x1, RZ ; /* 0x000000011a1a1810 */ /* 0x000fe40007ffe0ff */ /*0200*/ @!P2 LOP3.LUT R26, RZ, UR4, RZ, 0x33, !PT ; /* 0x00000004ff1aac12 */ /* 0x000fc8000f8e33ff */ /*0210*/ IADD3 R0, R26, 0x1, RZ ; /* 0x000000011a007810 */ /* 0x000fc80007ffe0ff */ /*0220*/ LOP3.LUT P0, R27, R0, 0x3, RZ, 0xc0, !PT ; /* 0x00000003001b7812 */ /* 0x000fda000780c0ff */ /*0230*/ @!P0 BRA 0x420 ; /* 0x000001e000008947 */ /* 0x001fea0003800000 */ /*0240*/ I2F.F64 R2, R25 ; /* 0x0000001900027312 */ /* 0x000e220000201c00 */ /*0250*/ IADD3 R27, R27, -0x1, RZ ; /* 0xffffffff1b1b7810 */ /* 0x000fe20007ffe0ff */ /*0260*/ BSSY B1, 0x3f0 ; /* 0x0000018000017945 */ /* 0x000fe60003800000 */ /*0270*/ ISETP.NE.AND P1, PT, R27, RZ, PT ; /* 0x000000ff1b00720c */ /* 0x000fe20003f25270 */ /*0280*/ DADD R2, R2, 0.5 ; /* 0x3fe0000002027429 */ /* 0x001e0c0000000000 */ /*0290*/ DMUL R2, R2, c[0x0][0x170] ; /* 0x00005c0002027a28 */ /* 0x001e0c0000000000 */ /*02a0*/ DFMA R10, R2, R2, 1 ; /* 0x3ff00000020a742b */ /* 0x0010640000000002 */ /*02b0*/ IMAD.MOV.U32 R2, RZ, RZ, 0x1 ; /* 0x00000001ff027424 */ /* 0x001fc800078e00ff */ /*02c0*/ MUFU.RCP64H R3, R11 ; /* 0x0000000b00037308 */ /* 0x002e240000001800 */ /*02d0*/ DFMA R4, -R10, R2, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000102 */ /*02e0*/ DFMA R4, R4, R4, R4 ; /* 0x000000040404722b */ /* 0x001e0c0000000004 */ /*02f0*/ DFMA R4, R2, R4, R2 ; /* 0x000000040204722b */ /* 0x001e0c0000000002 */ /*0300*/ DFMA R2, -R10, R4, 1 ; /* 0x3ff000000a02742b */ /* 0x001e0c0000000104 */ /*0310*/ DFMA R2, R4, R2, R4 ; /* 0x000000020402722b */ /* 0x001e0c0000000004 */ /*0320*/ DMUL R4, R2, 4 ; /* 0x4010000002047828 */ /* 0x001e0c0000000000 */ /*0330*/ DFMA R8, -R10, R4, 4 ; /* 0x401000000a08742b */ /* 0x001e0c0000000104 */ /*0340*/ DFMA R2, R2, R8, R4 ; /* 0x000000080202722b */ /* 0x001e140000000004 */ /*0350*/ FFMA R0, RZ, R11, R3 ; /* 0x0000000bff007223 */ /* 0x001fca0000000003 */ /*0360*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0370*/ @P0 BRA 0x3e0 ; /* 0x0000006000000947 */ /* 0x000fea0003800000 */ /*0380*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0390*/ MOV R2, 0x3c0 ; /* 0x000003c000027802 */ /* 0x000fe20000000f00 */ /*03a0*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*03b0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000077000007944 */ /* 0x020fea0003c00000 */ /*03c0*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0004 */ /*03d0*/ IMAD.MOV.U32 R3, RZ, RZ, R5 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0005 */ /*03e0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*03f0*/ DADD R22, R2, R22 ; /* 0x0000000002167229 */ /* 0x0200620000000016 */ /*0400*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0410*/ @P1 BRA 0x240 ; /* 0xfffffe2000001947 */ /* 0x003fea000383ffff */ /*0420*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0430*/ ISETP.GE.U32.AND P0, PT, R26, 0x3, PT ; /* 0x000000031a00780c */ /* 0x000fe20003f06070 */ /*0440*/ BSSY B0, 0xb10 ; /* 0x000006c000007945 */ /* 0x000fd80003800000 */ /*0450*/ @!P0 BRA 0xb00 ; /* 0x000006a000008947 */ /* 0x000fea0003800000 */ /*0460*/ I2F.F64 R2, R25 ; /* 0x0000001900027312 */ /* 0x000e220000201c00 */ /*0470*/ BSSY B1, 0x5f0 ; /* 0x0000017000017945 */ /* 0x000fe20003800000 */ /*0480*/ DADD R2, R2, 0.5 ; /* 0x3fe0000002027429 */ /* 0x001e0c0000000000 */ /*0490*/ DMUL R2, R2, c[0x0][0x170] ; /* 0x00005c0002027a28 */ /* 0x001e0c0000000000 */ /*04a0*/ DFMA R10, R2, R2, 1 ; /* 0x3ff00000020a742b */ /* 0x0010640000000002 */ /*04b0*/ IMAD.MOV.U32 R2, RZ, RZ, 0x1 ; /* 0x00000001ff027424 */ /* 0x001fc800078e00ff */ /*04c0*/ MUFU.RCP64H R3, R11 ; /* 0x0000000b00037308 */ /* 0x002e240000001800 */ /*04d0*/ DFMA R4, -R10, R2, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000102 */ /*04e0*/ DFMA R4, R4, R4, R4 ; /* 0x000000040404722b */ /* 0x001e0c0000000004 */ /*04f0*/ DFMA R4, R2, R4, R2 ; /* 0x000000040204722b */ /* 0x001e0c0000000002 */ /*0500*/ DFMA R2, -R10, R4, 1 ; /* 0x3ff000000a02742b */ /* 0x001e0c0000000104 */ /*0510*/ DFMA R2, R4, R2, R4 ; /* 0x000000020402722b */ /* 0x001e0c0000000004 */ /*0520*/ DMUL R4, R2, 4 ; /* 0x4010000002047828 */ /* 0x001e0c0000000000 */ /*0530*/ DFMA R8, -R10, R4, 4 ; /* 0x401000000a08742b */ /* 0x001e0c0000000104 */ /*0540*/ DFMA R2, R2, R8, R4 ; /* 0x000000080202722b */ /* 0x001e140000000004 */ /*0550*/ FFMA R0, RZ, R11, R3 ; /* 0x0000000bff007223 */ /* 0x001fca0000000003 */ /*0560*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0570*/ @P0 BRA 0x5e0 ; /* 0x0000006000000947 */ /* 0x000fea0003800000 */ /*0580*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0590*/ MOV R2, 0x5c0 ; /* 0x000005c000027802 */ /* 0x000fe20000000f00 */ /*05a0*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*05b0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000057000007944 */ /* 0x020fea0003c00000 */ /*05c0*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0004 */ /*05d0*/ IMAD.MOV.U32 R3, RZ, RZ, R5 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0005 */ /*05e0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*05f0*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0600*/ BSSY B1, 0x780 ; /* 0x0000017000017945 */ /* 0x000fe20003800000 */ /*0610*/ DADD R22, R2, R22 ; /* 0x0000000002167229 */ /* 0x020fe40000000016 */ /*0620*/ I2F.F64 R4, R25 ; /* 0x0000001900047312 */ /* 0x000e240000201c00 */ /*0630*/ DADD R4, R4, 0.5 ; /* 0x3fe0000004047429 */ /* 0x001e0c0000000000 */ /*0640*/ DMUL R4, R4, c[0x0][0x170] ; /* 0x00005c0004047a28 */ /* 0x001e0c0000000000 */ /*0650*/ DFMA R10, R4, R4, 1 ; /* 0x3ff00000040a742b */ /* 0x0010640000000004 */ /*0660*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x001fc800078e00ff */ /*0670*/ MUFU.RCP64H R5, R11 ; /* 0x0000000b00057308 */ /* 0x002e240000001800 */ /*0680*/ DFMA R8, -R10, R4, 1 ; /* 0x3ff000000a08742b */ /* 0x001e0c0000000104 */ /*0690*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x001e0c0000000008 */ /*06a0*/ DFMA R8, R4, R8, R4 ; /* 0x000000080408722b */ /* 0x001e0c0000000004 */ /*06b0*/ DFMA R4, -R10, R8, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000108 */ /*06c0*/ DFMA R4, R8, R4, R8 ; /* 0x000000040804722b */ /* 0x001e0c0000000008 */ /*06d0*/ DMUL R8, R4, 4 ; /* 0x4010000004087828 */ /* 0x001e0c0000000000 */ /*06e0*/ DFMA R12, -R10, R8, 4 ; /* 0x401000000a0c742b */ /* 0x001e0c0000000108 */ /*06f0*/ DFMA R4, R4, R12, R8 ; /* 0x0000000c0404722b */ /* 0x001e140000000008 */ /*0700*/ FFMA R0, RZ, R11, R5 ; /* 0x0000000bff007223 */ /* 0x001fca0000000005 */ /*0710*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0720*/ @P0 BRA 0x770 ; /* 0x0000004000000947 */ /* 0x000fea0003800000 */ /*0730*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0740*/ MOV R2, 0x770 ; /* 0x0000077000027802 */ /* 0x000fe20000000f00 */ /*0750*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*0760*/ CALL.REL.NOINC 0xb30 ; /* 0x000003c000007944 */ /* 0x000fea0003c00000 */ /*0770*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0780*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0790*/ BSSY B1, 0x930 ; /* 0x0000019000017945 */ /* 0x000fe20003800000 */ /*07a0*/ DADD R22, R22, R4 ; /* 0x0000000016167229 */ /* 0x000fe40000000004 */ /*07b0*/ I2F.F64 R2, R25 ; /* 0x0000001900027312 */ /* 0x000e240000201c00 */ /*07c0*/ DADD R2, R2, 0.5 ; /* 0x3fe0000002027429 */ /* 0x001e0c0000000000 */ /*07d0*/ DMUL R2, R2, c[0x0][0x170] ; /* 0x00005c0002027a28 */ /* 0x001e0c0000000000 */ /*07e0*/ DFMA R10, R2, R2, 1 ; /* 0x3ff00000020a742b */ /* 0x0010640000000002 */ /*07f0*/ IMAD.MOV.U32 R2, RZ, RZ, 0x1 ; /* 0x00000001ff027424 */ /* 0x001fc800078e00ff */ /*0800*/ MUFU.RCP64H R3, R11 ; /* 0x0000000b00037308 */ /* 0x002e240000001800 */ /*0810*/ DFMA R8, -R10, R2, 1 ; /* 0x3ff000000a08742b */ /* 0x001e0c0000000102 */ /*0820*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x001e0c0000000008 */ /*0830*/ DFMA R8, R2, R8, R2 ; /* 0x000000080208722b */ /* 0x001e0c0000000002 */ /*0840*/ DFMA R2, -R10, R8, 1 ; /* 0x3ff000000a02742b */ /* 0x001e0c0000000108 */ /*0850*/ DFMA R2, R8, R2, R8 ; /* 0x000000020802722b */ /* 0x001e0c0000000008 */ /*0860*/ DMUL R8, R2, 4 ; /* 0x4010000002087828 */ /* 0x001e0c0000000000 */ /*0870*/ DFMA R12, -R10, R8, 4 ; /* 0x401000000a0c742b */ /* 0x001e0c0000000108 */ /*0880*/ DFMA R2, R2, R12, R8 ; /* 0x0000000c0202722b */ /* 0x001e140000000008 */ /*0890*/ FFMA R0, RZ, R11, R3 ; /* 0x0000000bff007223 */ /* 0x001fca0000000003 */ /*08a0*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*08b0*/ @P0 BRA 0x920 ; /* 0x0000006000000947 */ /* 0x000fea0003800000 */ /*08c0*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*08d0*/ MOV R2, 0x900 ; /* 0x0000090000027802 */ /* 0x000fe20000000f00 */ /*08e0*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*08f0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000023000007944 */ /* 0x000fea0003c00000 */ /*0900*/ IMAD.MOV.U32 R2, RZ, RZ, R4 ; /* 0x000000ffff027224 */ /* 0x000fe400078e0004 */ /*0910*/ IMAD.MOV.U32 R3, RZ, RZ, R5 ; /* 0x000000ffff037224 */ /* 0x000fe400078e0005 */ /*0920*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0930*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0940*/ BSSY B1, 0xac0 ; /* 0x0000017000017945 */ /* 0x000fe20003800000 */ /*0950*/ DADD R22, R22, R2 ; /* 0x0000000016167229 */ /* 0x000fe40000000002 */ /*0960*/ I2F.F64 R4, R25 ; /* 0x0000001900047312 */ /* 0x000e240000201c00 */ /*0970*/ DADD R4, R4, 0.5 ; /* 0x3fe0000004047429 */ /* 0x001e0c0000000000 */ /*0980*/ DMUL R4, R4, c[0x0][0x170] ; /* 0x00005c0004047a28 */ /* 0x001e0c0000000000 */ /*0990*/ DFMA R10, R4, R4, 1 ; /* 0x3ff00000040a742b */ /* 0x0010640000000004 */ /*09a0*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x001fc800078e00ff */ /*09b0*/ MUFU.RCP64H R5, R11 ; /* 0x0000000b00057308 */ /* 0x002e240000001800 */ /*09c0*/ DFMA R8, -R10, R4, 1 ; /* 0x3ff000000a08742b */ /* 0x001e0c0000000104 */ /*09d0*/ DFMA R8, R8, R8, R8 ; /* 0x000000080808722b */ /* 0x001e0c0000000008 */ /*09e0*/ DFMA R8, R4, R8, R4 ; /* 0x000000080408722b */ /* 0x001e0c0000000004 */ /*09f0*/ DFMA R4, -R10, R8, 1 ; /* 0x3ff000000a04742b */ /* 0x001e0c0000000108 */ /*0a00*/ DFMA R4, R8, R4, R8 ; /* 0x000000040804722b */ /* 0x001e0c0000000008 */ /*0a10*/ DMUL R8, R4, 4 ; /* 0x4010000004087828 */ /* 0x001e0c0000000000 */ /*0a20*/ DFMA R12, -R10, R8, 4 ; /* 0x401000000a0c742b */ /* 0x001e0c0000000108 */ /*0a30*/ DFMA R4, R4, R12, R8 ; /* 0x0000000c0404722b */ /* 0x001e140000000008 */ /*0a40*/ FFMA R0, RZ, R11, R5 ; /* 0x0000000bff007223 */ /* 0x001fca0000000005 */ /*0a50*/ FSETP.GT.AND P0, PT, |R0|, 1.469367938527859385e-39, PT ; /* 0x001000000000780b */ /* 0x000fda0003f04200 */ /*0a60*/ @P0 BRA 0xab0 ; /* 0x0000004000000947 */ /* 0x000fea0003800000 */ /*0a70*/ IMAD.MOV.U32 R12, RZ, RZ, RZ ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e00ff */ /*0a80*/ MOV R2, 0xab0 ; /* 0x00000ab000027802 */ /* 0x000fe20000000f00 */ /*0a90*/ IMAD.MOV.U32 R13, RZ, RZ, 0x40100000 ; /* 0x40100000ff0d7424 */ /* 0x000fe400078e00ff */ /*0aa0*/ CALL.REL.NOINC 0xb30 ; /* 0x0000008000007944 */ /* 0x000fea0003c00000 */ /*0ab0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0ac0*/ IADD3 R25, R25, UR4, RZ ; /* 0x0000000419197c10 */ /* 0x000fe2000fffe0ff */ /*0ad0*/ DADD R22, R22, R4 ; /* 0x0000000016167229 */ /* 0x0000460000000004 */ /*0ae0*/ ISETP.GE.AND P0, PT, R25, c[0x0][0x168], PT ; /* 0x00005a0019007a0c */ /* 0x000fda0003f06270 */ /*0af0*/ @!P0 BRA 0x460 ; /* 0xfffff96000008947 */ /* 0x003fea000383ffff */ /*0b00*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0b10*/ STG.E.64 [R6.64], R22 ; /* 0x0000001606007986 */ /* 0x020fe2000c101b06 */ /*0b20*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0b30*/ FSETP.GEU.AND P0, PT, |R11|.reuse, 1.469367938527859385e-39, PT ; /* 0x001000000b00780b */ /* 0x040fe20003f0e200 */ /*0b40*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1 ; /* 0x00000001ff047424 */ /* 0x000fe200078e00ff */ /*0b50*/ LOP3.LUT R8, R11.reuse, 0x800fffff, RZ, 0xc0, !PT ; /* 0x800fffff0b087812 */ /* 0x040fe200078ec0ff */ /*0b60*/ IMAD.MOV.U32 R14, RZ, RZ, R12 ; /* 0x000000ffff0e7224 */ /* 0x000fe200078e000c */ /*0b70*/ LOP3.LUT R0, R11, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000b007812 */ /* 0x000fe400078ec0ff */ /*0b80*/ LOP3.LUT R9, R8, 0x3ff00000, RZ, 0xfc, !PT ; /* 0x3ff0000008097812 */ /* 0x000fe200078efcff */ /*0b90*/ IMAD.MOV.U32 R8, RZ, RZ, R10 ; /* 0x000000ffff087224 */ /* 0x000fe200078e000a */ /*0ba0*/ LOP3.LUT R3, R13, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000d037812 */ /* 0x000fc800078ec0ff */ /*0bb0*/ ISETP.GE.U32.AND P2, PT, R3, R0, PT ; /* 0x000000000300720c */ /* 0x000fe20003f46070 */ /*0bc0*/ @!P0 DMUL R8, R10, 8.98846567431157953865e+307 ; /* 0x7fe000000a088828 */ /* 0x000e0c0000000000 */ /*0bd0*/ MUFU.RCP64H R5, R9 ; /* 0x0000000900057308 */ /* 0x001e240000001800 */ /*0be0*/ DFMA R18, R4, -R8, 1 ; /* 0x3ff000000412742b */ /* 0x001e0c0000000808 */ /*0bf0*/ DFMA R18, R18, R18, R18 ; /* 0x000000121212722b */ /* 0x001e0c0000000012 */ /*0c00*/ DFMA R18, R4, R18, R4 ; /* 0x000000120412722b */ /* 0x0010640000000004 */ /*0c10*/ IMAD.MOV.U32 R4, RZ, RZ, 0x1ca00000 ; /* 0x1ca00000ff047424 */ /* 0x001fe400078e00ff */ /*0c20*/ IMAD.MOV.U32 R5, RZ, RZ, R3 ; /* 0x000000ffff057224 */ /* 0x000fe400078e0003 */ /*0c30*/ DFMA R16, R18.reuse, -R8, 1 ; /* 0x3ff000001210742b */ /* 0x042e220000000808 */ /*0c40*/ SEL R15, R4, 0x63400000, !P2 ; /* 0x63400000040f7807 */ /* 0x000fe40005000000 */ /*0c50*/ FSETP.GEU.AND P2, PT, |R13|, 1.469367938527859385e-39, PT ; /* 0x001000000d00780b */ /* 0x000fe40003f4e200 */ /*0c60*/ LOP3.LUT R15, R15, 0x800fffff, R13, 0xf8, !PT ; /* 0x800fffff0f0f7812 */ /* 0x000fe200078ef80d */ /*0c70*/ DFMA R16, R18, R16, R18 ; /* 0x000000101210722b */ /* 0x0010540000000012 */ /*0c80*/ @P2 BRA 0xd10 ; /* 0x0000008000002947 */ /* 0x000fea0003800000 */ /*0c90*/ LOP3.LUT R18, R11, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000b127812 */ /* 0x003fc800078ec0ff */ /*0ca0*/ ISETP.GE.U32.AND P2, PT, R3, R18, PT ; /* 0x000000120300720c */ /* 0x000fe20003f46070 */ /*0cb0*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fc600078e00ff */ /*0cc0*/ SEL R5, R4, 0x63400000, !P2 ; /* 0x6340000004057807 */ /* 0x000fc80005000000 */ /*0cd0*/ LOP3.LUT R5, R5, 0x80000000, R13, 0xf8, !PT ; /* 0x8000000005057812 */ /* 0x000fc800078ef80d */ /*0ce0*/ LOP3.LUT R19, R5, 0x100000, RZ, 0xfc, !PT ; /* 0x0010000005137812 */ /* 0x000fcc00078efcff */ /*0cf0*/ DFMA R14, R14, 2, -R18 ; /* 0x400000000e0e782b */ /* 0x000e140000000812 */ /*0d00*/ LOP3.LUT R5, R15, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000f057812 */ /* 0x001fc800078ec0ff */ /*0d10*/ IADD3 R20, R5, -0x1, RZ ; /* 0xffffffff05147810 */ /* 0x003fe20007ffe0ff */ /*0d20*/ DMUL R18, R16, R14 ; /* 0x0000000e10127228 */ /* 0x000e220000000000 */ /*0d30*/ @!P0 LOP3.LUT R0, R9, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff0000009008812 */ /* 0x000fe200078ec0ff */ /*0d40*/ BSSY B2, 0x10d0 ; /* 0x0000038000027945 */ /* 0x000fe20003800000 */ /*0d50*/ ISETP.GT.U32.AND P0, PT, R20, 0x7feffffe, PT ; /* 0x7feffffe1400780c */ /* 0x000fe40003f04070 */ /*0d60*/ IADD3 R24, R0, -0x1, RZ ; /* 0xffffffff00187810 */ /* 0x000fe20007ffe0ff */ /*0d70*/ DFMA R20, R18, -R8, R14 ; /* 0x800000081214722b */ /* 0x001e06000000000e */ /*0d80*/ ISETP.GT.U32.OR P0, PT, R24, 0x7feffffe, P0 ; /* 0x7feffffe1800780c */ /* 0x000fc60000704470 */ /*0d90*/ DFMA R20, R16, R20, R18 ; /* 0x000000141014722b */ /* 0x0010540000000012 */ /*0da0*/ @P0 BRA 0xf70 ; /* 0x000001c000000947 */ /* 0x000fea0003800000 */ /*0db0*/ LOP3.LUT R12, R11, 0x7ff00000, RZ, 0xc0, !PT ; /* 0x7ff000000b0c7812 */ /* 0x003fc800078ec0ff */ /*0dc0*/ ISETP.GE.U32.AND P0, PT, R3.reuse, R12, PT ; /* 0x0000000c0300720c */ /* 0x040fe20003f06070 */ /*0dd0*/ IMAD.IADD R0, R3, 0x1, -R12 ; /* 0x0000000103007824 */ /* 0x000fc600078e0a0c */ /*0de0*/ SEL R3, R4, 0x63400000, !P0 ; /* 0x6340000004037807 */ /* 0x000fe20004000000 */ /*0df0*/ IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff047224 */ /* 0x000fe200078e00ff */ /*0e00*/ IMNMX R0, R0, -0x46a00000, !PT ; /* 0xb960000000007817 */ /* 0x000fc80007800200 */ /*0e10*/ IMNMX R0, R0, 0x46a00000, PT ; /* 0x46a0000000007817 */ /* 0x000fca0003800200 */ /*0e20*/ IMAD.IADD R0, R0, 0x1, -R3 ; /* 0x0000000100007824 */ /* 0x000fca00078e0a03 */ /*0e30*/ IADD3 R5, R0, 0x7fe00000, RZ ; /* 0x7fe0000000057810 */ /* 0x000fcc0007ffe0ff */ /*0e40*/ DMUL R16, R20, R4 ; /* 0x0000000414107228 */ /* 0x000e140000000000 */ /*0e50*/ FSETP.GTU.AND P0, PT, |R17|, 1.469367938527859385e-39, PT ; /* 0x001000001100780b */ /* 0x001fda0003f0c200 */ /*0e60*/ @P0 BRA 0x10c0 ; /* 0x0000025000000947 */ /* 0x000fea0003800000 */ /*0e70*/ DFMA R8, R20, -R8, R14 ; /* 0x800000081408722b */ /* 0x000e0c000000000e */ /*0e80*/ IMAD.MOV.U32 R8, RZ, RZ, RZ ; /* 0x000000ffff087224 */ /* 0x001fc800078e00ff */ /*0e90*/ FSETP.NEU.AND P0, PT, R9.reuse, RZ, PT ; /* 0x000000ff0900720b */ /* 0x040fe40003f0d000 */ /*0ea0*/ LOP3.LUT R11, R9, 0x80000000, R11, 0x48, !PT ; /* 0x80000000090b7812 */ /* 0x000fc800078e480b */ /*0eb0*/ LOP3.LUT R9, R11, R5, RZ, 0xfc, !PT ; /* 0x000000050b097212 */ /* 0x000fce00078efcff */ /*0ec0*/ @!P0 BRA 0x10c0 ; /* 0x000001f000008947 */ /* 0x000fea0003800000 */ /*0ed0*/ IMAD.MOV R5, RZ, RZ, -R0 ; /* 0x000000ffff057224 */ /* 0x000fe200078e0a00 */ /*0ee0*/ DMUL.RP R8, R20, R8 ; /* 0x0000000814087228 */ /* 0x000e220000008000 */ /*0ef0*/ IMAD.MOV.U32 R4, RZ, RZ, RZ ; /* 0x000000ffff047224 */ /* 0x000fe200078e00ff */ /*0f00*/ IADD3 R3, -R0, -0x43300000, RZ ; /* 0xbcd0000000037810 */ /* 0x000fca0007ffe1ff */ /*0f10*/ DFMA R4, R16, -R4, R20 ; /* 0x800000041004722b */ /* 0x000e460000000014 */ /*0f20*/ LOP3.LUT R11, R9, R11, RZ, 0x3c, !PT ; /* 0x0000000b090b7212 */ /* 0x001fce00078e3cff */ /*0f30*/ FSETP.NEU.AND P0, PT, |R5|, R3, PT ; /* 0x000000030500720b */ /* 0x002fc80003f0d200 */ /*0f40*/ FSEL R16, R8, R16, !P0 ; /* 0x0000001008107208 */ /* 0x000fe40004000000 */ /*0f50*/ FSEL R17, R11, R17, !P0 ; /* 0x000000110b117208 */ /* 0x000fe20004000000 */ /*0f60*/ BRA 0x10c0 ; /* 0x0000015000007947 */ /* 0x000fea0003800000 */ /*0f70*/ DSETP.NAN.AND P0, PT, R12, R12, PT ; /* 0x0000000c0c00722a */ /* 0x003e1c0003f08000 */ /*0f80*/ @P0 BRA 0x10a0 ; /* 0x0000011000000947 */ /* 0x001fea0003800000 */ /*0f90*/ DSETP.NAN.AND P0, PT, R10, R10, PT ; /* 0x0000000a0a00722a */ /* 0x000e1c0003f08000 */ /*0fa0*/ @P0 BRA 0x1070 ; /* 0x000000c000000947 */ /* 0x001fea0003800000 */ /*0fb0*/ ISETP.NE.AND P0, PT, R5, R0, PT ; /* 0x000000000500720c */ /* 0x000fe20003f05270 */ /*0fc0*/ IMAD.MOV.U32 R16, RZ, RZ, 0x0 ; /* 0x00000000ff107424 */ /* 0x000fe400078e00ff */ /*0fd0*/ IMAD.MOV.U32 R17, RZ, RZ, -0x80000 ; /* 0xfff80000ff117424 */ /* 0x000fd400078e00ff */ /*0fe0*/ @!P0 BRA 0x10c0 ; /* 0x000000d000008947 */ /* 0x000fea0003800000 */ /*0ff0*/ ISETP.NE.AND P0, PT, R5, 0x7ff00000, PT ; /* 0x7ff000000500780c */ /* 0x000fe40003f05270 */ /*1000*/ LOP3.LUT R17, R13, 0x80000000, R11, 0x48, !PT ; /* 0x800000000d117812 */ /* 0x000fe400078e480b */ /*1010*/ ISETP.EQ.OR P0, PT, R0, RZ, !P0 ; /* 0x000000ff0000720c */ /* 0x000fda0004702670 */ /*1020*/ @P0 LOP3.LUT R0, R17, 0x7ff00000, RZ, 0xfc, !PT ; /* 0x7ff0000011000812 */ /* 0x000fe200078efcff */ /*1030*/ @!P0 IMAD.MOV.U32 R16, RZ, RZ, RZ ; /* 0x000000ffff108224 */ /* 0x000fe400078e00ff */ /*1040*/ @P0 IMAD.MOV.U32 R16, RZ, RZ, RZ ; /* 0x000000ffff100224 */ /* 0x000fe400078e00ff */ /*1050*/ @P0 IMAD.MOV.U32 R17, RZ, RZ, R0 ; /* 0x000000ffff110224 */ /* 0x000fe200078e0000 */ /*1060*/ BRA 0x10c0 ; /* 0x0000005000007947 */ /* 0x000fea0003800000 */ /*1070*/ LOP3.LUT R17, R11, 0x80000, RZ, 0xfc, !PT ; /* 0x000800000b117812 */ /* 0x000fe200078efcff */ /*1080*/ IMAD.MOV.U32 R16, RZ, RZ, R10 ; /* 0x000000ffff107224 */ /* 0x000fe200078e000a */ /*1090*/ BRA 0x10c0 ; /* 0x0000002000007947 */ /* 0x000fea0003800000 */ /*10a0*/ LOP3.LUT R17, R13, 0x80000, RZ, 0xfc, !PT ; /* 0x000800000d117812 */ /* 0x000fe200078efcff */ /*10b0*/ IMAD.MOV.U32 R16, RZ, RZ, R12 ; /* 0x000000ffff107224 */ /* 0x000fe400078e000c */ /*10c0*/ BSYNC B2 ; /* 0x0000000000027941 */ /* 0x000fea0003800000 */ /*10d0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x0 ; /* 0x00000000ff037424 */ /* 0x000fe400078e00ff */ /*10e0*/ IMAD.MOV.U32 R4, RZ, RZ, R16 ; /* 0x000000ffff047224 */ /* 0x000fc400078e0010 */ /*10f0*/ IMAD.MOV.U32 R5, RZ, RZ, R17 ; /* 0x000000ffff057224 */ /* 0x000fe200078e0011 */ /*1100*/ RET.REL.NODEC R2 0x0 ; /* 0xffffeef002007950 */ /* 0x000fec0003c3ffff */ /*1110*/ BRA 0x1110; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*1120*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1130*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1140*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1150*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*11f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6cal_piPdidii .globl _Z6cal_piPdidii .p2align 8 .type _Z6cal_piPdidii,@function _Z6cal_piPdidii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x8 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 s4, v1 s_cbranch_execz .LBB0_4 s_load_b64 s[6:7], s[0:1], 0x0 v_ashrrev_i32_e32 v2, 31, v1 s_load_b128 s[0:3], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 3, v[1:2] s_waitcnt lgkmcnt(0) v_add_co_u32 v2, vcc_lo, s6, v2 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo s_mul_i32 s3, s3, s2 s_mov_b32 s2, 0 global_load_b64 v[4:5], v[2:3], off s_set_inst_prefetch_distance 0x1 .p2align 6 .LBB0_2: v_cvt_f64_i32_e32 v[6:7], v1 v_add_nc_u32_e32 v1, s3, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_f64 v[6:7], v[6:7], 0.5 v_mul_f64 v[6:7], v[6:7], s[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[6:7], v[6:7], v[6:7], 1.0 v_div_scale_f64 v[8:9], null, v[6:7], v[6:7], 4.0 v_div_scale_f64 v[14:15], vcc_lo, 4.0, v[6:7], 4.0 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_rcp_f64_e32 v[10:11], v[8:9] s_waitcnt_depctr 0xfff v_fma_f64 v[12:13], -v[8:9], v[10:11], 1.0 v_fma_f64 v[10:11], v[10:11], v[12:13], v[10:11] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_fma_f64 v[12:13], -v[8:9], v[10:11], 1.0 v_fma_f64 v[10:11], v[10:11], v[12:13], v[10:11] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f64 v[12:13], v[14:15], v[10:11] v_fma_f64 v[8:9], -v[8:9], v[12:13], v[14:15] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_div_fmas_f64 v[8:9], v[8:9], v[10:11], v[12:13] v_cmp_le_i32_e32 vcc_lo, s4, v1 s_or_b32 s2, vcc_lo, s2 v_div_fixup_f64 v[6:7], v[8:9], v[6:7], 4.0 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) v_add_f64 v[4:5], v[6:7], v[4:5] s_and_not1_b32 exec_lo, exec_lo, s2 s_cbranch_execnz .LBB0_2 s_set_inst_prefetch_distance 0x2 s_or_b32 exec_lo, exec_lo, s2 global_store_b64 v[2:3], v[4:5], off .LBB0_4: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6cal_piPdidii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .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 16 .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 _Z6cal_piPdidii, .Lfunc_end0-_Z6cal_piPdidii .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: 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: _Z6cal_piPdidii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6cal_piPdidii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 16 .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_0004ca04_00000000-6_kernel.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2061: .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 .LFE2061: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z9pi_by_cpuddPd .type _Z9pi_by_cpuddPd, @function _Z9pi_by_cpuddPd: .LFB2027: .cfi_startproc endbr64 subsd %xmm0, %xmm1 mulsd .LC1(%rip), %xmm1 pxor %xmm3, %xmm3 movl $0, %eax movsd .LC2(%rip), %xmm7 movsd .LC3(%rip), %xmm6 movsd .LC4(%rip), %xmm5 .L4: pxor %xmm2, %xmm2 cvtsi2sdl %eax, %xmm2 addsd %xmm7, %xmm2 mulsd %xmm1, %xmm2 addsd %xmm0, %xmm2 mulsd %xmm2, %xmm2 addsd %xmm6, %xmm2 movapd %xmm5, %xmm4 divsd %xmm2, %xmm4 addsd %xmm4, %xmm3 addl $1, %eax cmpl $67108864, %eax jne .L4 mulsd %xmm3, %xmm1 movsd %xmm1, (%rdi) ret .cfi_endproc .LFE2027: .size _Z9pi_by_cpuddPd, .-_Z9pi_by_cpuddPd .globl _Z29__device_stub__Z6cal_piPdidiiPdidii .type _Z29__device_stub__Z6cal_piPdidiiPdidii, @function _Z29__device_stub__Z6cal_piPdidiiPdidii: .LFB2083: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movsd %xmm0, 8(%rsp) movl %edx, 16(%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 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 16(%rsp), %rax movq %rax, 120(%rsp) leaq 4(%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 .L10 .L6: movq 136(%rsp), %rax subq %fs:40, %rax jne .L11 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L10: .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 _Z6cal_piPdidii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L6 .L11: call __stack_chk_fail@PLT .cfi_endproc .LFE2083: .size _Z29__device_stub__Z6cal_piPdidiiPdidii, .-_Z29__device_stub__Z6cal_piPdidiiPdidii .globl _Z6cal_piPdidii .type _Z6cal_piPdidii, @function _Z6cal_piPdidii: .LFB2084: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z29__device_stub__Z6cal_piPdidiiPdidii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2084: .size _Z6cal_piPdidii, .-_Z6cal_piPdidii .section .rodata.str1.1,"aMS",@progbits,1 .LC7: .string "CPU Result: %.11lf\n" .LC8: .string "CPU Elapsed time: %.6lfms\n\n" .LC9: .string "GPU Result: %.11lf\n" .LC10: .string "GPU Elapsed time:%.6f ms.\n\n" .LC11: .string "Press to exit.\n" .text .globl main .type main, @function main: .LFB2058: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $80, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax call clock@PLT movq %rax, %rbx leaq 16(%rsp), %rdi movsd .LC3(%rip), %xmm1 pxor %xmm0, %xmm0 call _Z9pi_by_cpuddPd call clock@PLT subq %rbx, %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 mulsd .LC5(%rip), %xmm0 divsd .LC6(%rip), %xmm0 movq %xmm0, %rbx movsd 16(%rsp), %xmm0 leaq .LC7(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq %rbx, %xmm0 leaq .LC8(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT leaq 24(%rsp), %rdi call cudaEventCreate@PLT leaq 32(%rsp), %rdi call cudaEventCreate@PLT movl $0, %esi movq 24(%rsp), %rdi call cudaEventRecord@PLT movl $64, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $256, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $131072, %edi call malloc@PLT movq %rax, %rbx leaq 40(%rsp), %rdi movl $131072, %esi call cudaMalloc@PLT movl $131072, %edx movl $0, %esi movq 40(%rsp), %rdi call cudaMemset@PLT movl 68(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 60(%rsp), %rdx movq 48(%rsp), %rdi movl 56(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L20 .L15: movl $2, %ecx movl $131072, %edx movq 40(%rsp), %rsi movq %rbx, %rdi call cudaMemcpy@PLT movsd pi(%rip), %xmm0 movq %rbx, %rax leaq 131072(%rbx), %rdx .L16: addsd (%rax), %xmm0 addq $8, %rax cmpq %rdx, %rax jne .L16 movl $16384, tid(%rip) mulsd .LC1(%rip), %xmm0 movsd %xmm0, pi(%rip) leaq .LC9(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movq 32(%rsp), %rdi call cudaEventSynchronize@PLT leaq 12(%rsp), %rdi movq 32(%rsp), %rdx movq 24(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 12(%rsp), %xmm0 leaq .LC10(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq %rbx, %rdi call free@PLT movq 40(%rsp), %rdi call cudaFree@PLT leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq stdin(%rip), %rdi call getc@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L21 movl $0, %eax addq $80, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L20: .cfi_restore_state movl $64, %ecx movl $256, %edx movsd .LC1(%rip), %xmm0 movl $67108864, %esi movq 40(%rsp), %rdi call _Z29__device_stub__Z6cal_piPdidiiPdidii jmp .L15 .L21: call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size main, .-main .section .rodata.str1.1 .LC12: .string "_Z6cal_piPdidii" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2086: .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 .LC12(%rip), %rdx movq %rdx, %rcx leaq _Z6cal_piPdidii(%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 .LFE2086: .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 pi .bss .align 8 .type pi, @object .size pi, 8 pi: .zero 8 .globl tid .align 4 .type tid, @object .size tid, 4 tid: .zero 4 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC1: .long 0 .long 1045430272 .align 8 .LC2: .long 0 .long 1071644672 .align 8 .LC3: .long 0 .long 1072693248 .align 8 .LC4: .long 0 .long 1074790400 .align 8 .LC5: .long 0 .long 1083129856 .align 8 .LC6: .long 0 .long 1093567616 .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.hip" .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function _Z9pi_by_cpuddPd .LCPI0_0: .quad 0x3e50000000000000 # double 1.4901161193847656E-8 .LCPI0_1: .quad 0x3fe0000000000000 # double 0.5 .LCPI0_2: .quad 0x3ff0000000000000 # double 1 .LCPI0_3: .quad 0x4010000000000000 # double 4 .text .globl _Z9pi_by_cpuddPd .p2align 4, 0x90 .type _Z9pi_by_cpuddPd,@function _Z9pi_by_cpuddPd: # @_Z9pi_by_cpuddPd .cfi_startproc # %bb.0: subsd %xmm0, %xmm1 mulsd .LCPI0_0(%rip), %xmm1 xorpd %xmm2, %xmm2 movl $67108864, %eax # imm = 0x4000000 movsd .LCPI0_1(%rip), %xmm3 # xmm3 = mem[0],zero movsd .LCPI0_2(%rip), %xmm4 # xmm4 = mem[0],zero movsd .LCPI0_3(%rip), %xmm5 # xmm5 = mem[0],zero xorpd %xmm6, %xmm6 .p2align 4, 0x90 .LBB0_1: # =>This Inner Loop Header: Depth=1 movapd %xmm6, %xmm7 addsd %xmm3, %xmm7 mulsd %xmm1, %xmm7 addsd %xmm0, %xmm7 mulsd %xmm7, %xmm7 addsd %xmm4, %xmm7 movapd %xmm5, %xmm8 divsd %xmm7, %xmm8 addsd %xmm8, %xmm2 addsd %xmm4, %xmm6 decl %eax jne .LBB0_1 # %bb.2: mulsd %xmm2, %xmm1 movsd %xmm1, (%rdi) retq .Lfunc_end0: .size _Z9pi_by_cpuddPd, .Lfunc_end0-_Z9pi_by_cpuddPd .cfi_endproc # -- End function .globl _Z21__device_stub__cal_piPdidii # -- Begin function _Z21__device_stub__cal_piPdidii .p2align 4, 0x90 .type _Z21__device_stub__cal_piPdidii,@function _Z21__device_stub__cal_piPdidii: # @_Z21__device_stub__cal_piPdidii .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 12(%rsp) movsd %xmm0, 64(%rsp) movl %edx, 8(%rsp) movl %ecx, 4(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%rsp), %rax movq %rax, 96(%rsp) leaq 8(%rsp), %rax movq %rax, 104(%rsp) leaq 4(%rsp), %rax movq %rax, 112(%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 $_Z6cal_piPdidii, %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 _Z21__device_stub__cal_piPdidii, .Lfunc_end1-_Z21__device_stub__cal_piPdidii .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI2_0: .quad 0x3fe0000000000000 # double 0.5 .LCPI2_1: .quad 0x3e50000000000000 # double 1.4901161193847656E-8 .LCPI2_2: .quad 0x3ff0000000000000 # double 1 .LCPI2_3: .quad 0x4010000000000000 # double 4 .LCPI2_4: .quad 0x408f400000000000 # double 1000 .LCPI2_5: .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 %rbx .cfi_def_cfa_offset 24 subq $168, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -24 .cfi_offset %rbp, -16 movl $67108864, %ebp # imm = 0x4000000 callq clock xorpd %xmm8, %xmm8 movq %rax, %rbx movsd .LCPI2_0(%rip), %xmm0 # xmm0 = mem[0],zero movsd .LCPI2_1(%rip), %xmm1 # xmm1 = mem[0],zero movsd .LCPI2_2(%rip), %xmm2 # xmm2 = mem[0],zero movsd .LCPI2_3(%rip), %xmm3 # xmm3 = mem[0],zero xorpd %xmm7, %xmm7 xorpd %xmm4, %xmm4 .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 movapd %xmm4, %xmm5 addsd %xmm0, %xmm5 mulsd %xmm1, %xmm5 addsd %xmm8, %xmm5 mulsd %xmm5, %xmm5 addsd %xmm2, %xmm5 movapd %xmm3, %xmm6 divsd %xmm5, %xmm6 addsd %xmm6, %xmm7 addsd %xmm2, %xmm4 decl %ebp jne .LBB2_1 # %bb.2: # %_Z9pi_by_cpuddPd.exit mulsd .LCPI2_1(%rip), %xmm7 movsd %xmm7, 56(%rsp) # 8-byte Spill callq clock subq %rbx, %rax xorps %xmm0, %xmm0 cvtsi2sd %rax, %xmm0 mulsd .LCPI2_4(%rip), %xmm0 divsd .LCPI2_5(%rip), %xmm0 movsd %xmm0, 48(%rsp) # 8-byte Spill movl $.L.str, %edi movsd 56(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero movb $1, %al callq printf movl $.L.str.1, %edi movsd 48(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero movb $1, %al callq printf leaq 40(%rsp), %rdi callq hipEventCreate leaq 16(%rsp), %rdi callq hipEventCreate movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movl $131072, %edi # imm = 0x20000 callq malloc movq %rax, %rbx leaq 8(%rsp), %rdi movl $131072, %esi # imm = 0x20000 callq hipMalloc movq 8(%rsp), %rdi movl $131072, %edx # imm = 0x20000 xorl %esi, %esi callq hipMemset movabsq $4294967360, %rdi # imm = 0x100000040 leaq 192(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_4 # %bb.3: movq 8(%rsp), %rax movq %rax, 120(%rsp) movl $67108864, 36(%rsp) # imm = 0x4000000 movabsq $4490088828488384512, %rax # imm = 0x3E50000000000000 movq %rax, 112(%rsp) movl $256, 32(%rsp) # imm = 0x100 movl $64, 28(%rsp) leaq 120(%rsp), %rax movq %rax, 128(%rsp) leaq 36(%rsp), %rax movq %rax, 136(%rsp) leaq 112(%rsp), %rax movq %rax, 144(%rsp) leaq 32(%rsp), %rax movq %rax, 152(%rsp) leaq 28(%rsp), %rax movq %rax, 160(%rsp) leaq 96(%rsp), %rdi leaq 80(%rsp), %rsi leaq 72(%rsp), %rdx leaq 64(%rsp), %rcx callq __hipPopCallConfiguration movq 96(%rsp), %rsi movl 104(%rsp), %edx movq 80(%rsp), %rcx movl 88(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z6cal_piPdidii, %edi pushq 64(%rsp) .cfi_adjust_cfa_offset 8 pushq 80(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_4: movq 8(%rsp), %rsi movl $131072, %edx # imm = 0x20000 movq %rbx, %rdi movl $2, %ecx callq hipMemcpy xorl %eax, %eax movsd pi(%rip), %xmm0 # xmm0 = mem[0],zero .p2align 4, 0x90 .LBB2_5: # =>This Inner Loop Header: Depth=1 addsd (%rbx,%rax,8), %xmm0 incq %rax cmpq $16384, %rax # imm = 0x4000 jne .LBB2_5 # %bb.6: movl $16384, tid(%rip) # imm = 0x4000 mulsd .LCPI2_1(%rip), %xmm0 movsd %xmm0, pi(%rip) movl $.L.str.2, %edi movb $1, %al callq printf movq 16(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 16(%rsp), %rdi callq hipEventSynchronize movq 40(%rsp), %rsi movq 16(%rsp), %rdx leaq 128(%rsp), %rdi callq hipEventElapsedTime movss 128(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.3, %edi movb $1, %al callq printf movq %rbx, %rdi callq free movq 8(%rsp), %rdi callq hipFree movl $.Lstr, %edi callq puts@PLT movq stdin(%rip), %rdi callq getc xorl %eax, %eax addq $168, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z6cal_piPdidii, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type tid,@object # @tid .bss .globl tid .p2align 2, 0x0 tid: .long 0 # 0x0 .size tid, 4 .type pi,@object # @pi .globl pi .p2align 3, 0x0 pi: .quad 0x0000000000000000 # double 0 .size pi, 8 .type _Z6cal_piPdidii,@object # @_Z6cal_piPdidii .section .rodata,"a",@progbits .globl _Z6cal_piPdidii .p2align 3, 0x0 _Z6cal_piPdidii: .quad _Z21__device_stub__cal_piPdidii .size _Z6cal_piPdidii, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "CPU Result: %.11lf\n" .size .L.str, 20 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "CPU Elapsed time: %.6lfms\n\n" .size .L.str.1, 28 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "GPU Result: %.11lf\n" .size .L.str.2, 20 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "GPU Elapsed time:%.6f ms.\n\n" .size .L.str.3, 28 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6cal_piPdidii" .size .L__unnamed_1, 16 .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 "Press to exit." .size .Lstr, 15 .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 _Z21__device_stub__cal_piPdidii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6cal_piPdidii .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" __global__ void KerFtCalcForcesRes(unsigned ftcount,bool simulate2d,double dt ,const float3 *ftoomega,const float3 *ftovel,const double3 *ftocenter,const float3 *ftoforces ,float3 *ftoforcesres,double3 *ftocenterres) { const unsigned cf=blockIdx.x*blockDim.x + threadIdx.x; //-Floating number. if(cf<ftcount){ //-Compute fomega. float3 fomega=ftoomega[cf]; { const float3 omegaace=ftoforces[cf*2+1]; fomega.x=float(dt*omegaace.x+fomega.x); fomega.y=float(dt*omegaace.y+fomega.y); fomega.z=float(dt*omegaace.z+fomega.z); } float3 fvel=ftovel[cf]; //-Zero components for 2-D simulation. | Anula componentes para 2D. float3 face=ftoforces[cf*2]; if(simulate2d){ face.y=0; fomega.x=0; fomega.z=0; fvel.y=0; } //-Compute fcenter. double3 fcenter=ftocenter[cf]; fcenter.x+=dt*fvel.x; fcenter.y+=dt*fvel.y; fcenter.z+=dt*fvel.z; //-Compute fvel. fvel.x=float(dt*face.x+fvel.x); fvel.y=float(dt*face.y+fvel.y); fvel.z=float(dt*face.z+fvel.z); //-Store data to update floating. | Guarda datos para actualizar floatings. ftoforcesres[cf*2]=fomega; ftoforcesres[cf*2+1]=fvel; ftocenterres[cf]=fcenter; } }
code for sm_80 Function : _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_ .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 R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e280000002500 */ /*0020*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R5, R5, c[0x0][0x0], R0 ; /* 0x0000000005057a24 */ /* 0x001fca00078e0200 */ /*0040*/ ISETP.GE.U32.AND P0, PT, R5, c[0x0][0x160], PT ; /* 0x0000580005007a0c */ /* 0x000fda0003f06070 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ SHF.L.U32 R25, R5, 0x1, RZ ; /* 0x0000000105197819 */ /* 0x000fe200000006ff */ /*0070*/ IMAD.MOV.U32 R2, RZ, RZ, 0xc ; /* 0x0000000cff027424 */ /* 0x000fe200078e00ff */ /*0080*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fc60000000a00 */ /*0090*/ IMAD.WIDE.U32 R8, R5, R2, c[0x0][0x170] ; /* 0x00005c0005087625 */ /* 0x000fc800078e0002 */ /*00a0*/ IMAD.WIDE.U32 R22, R25, R2.reuse, c[0x0][0x188] ; /* 0x0000620019167625 */ /* 0x080fe200078e0002 */ /*00b0*/ LDG.E R36, [R8.64] ; /* 0x0000000608247981 */ /* 0x0000a8000c1e1900 */ /*00c0*/ LDG.E R31, [R22.64+0xc] ; /* 0x00000c06161f7981 */ /* 0x000ee8000c1e1900 */ /*00d0*/ LDG.E R27, [R8.64+0x4] ; /* 0x00000406081b7981 */ /* 0x000128000c1e1900 */ /*00e0*/ LDG.E R28, [R22.64+0x10] ; /* 0x00001006161c7981 */ /* 0x000f68000c1e1900 */ /*00f0*/ LDG.E R29, [R8.64+0x8] ; /* 0x00000806081d7981 */ /* 0x000128000c1e1900 */ /*0100*/ LDG.E R30, [R22.64+0x14] ; /* 0x00001406161e7981 */ /* 0x000f62000c1e1900 */ /*0110*/ IMAD.WIDE.U32 R16, R5, R2, c[0x0][0x178] ; /* 0x00005e0005107625 */ /* 0x000fc600078e0002 */ /*0120*/ LDG.E R24, [R22.64] ; /* 0x0000000616187981 */ /* 0x000368000c1e1900 */ /*0130*/ LDG.E R26, [R16.64] ; /* 0x00000006101a7981 */ /* 0x000168000c1e1900 */ /*0140*/ LDG.E R4, [R16.64+0x4] ; /* 0x0000040610047981 */ /* 0x000168000c1e1900 */ /*0150*/ LDG.E R3, [R22.64+0x4] ; /* 0x0000040616037981 */ /* 0x000368000c1e1900 */ /*0160*/ LDG.E R0, [R16.64+0x8] ; /* 0x0000080610007981 */ /* 0x000168000c1e1900 */ /*0170*/ LDG.E R7, [R22.64+0x8] ; /* 0x0000080616077981 */ /* 0x000362000c1e1900 */ /*0180*/ HFMA2.MMA R6, -RZ, RZ, 0, 1.430511474609375e-06 ; /* 0x00000018ff067435 */ /* 0x000fd400000001ff */ /*0190*/ IMAD.WIDE.U32 R32, R5, R6, c[0x0][0x180] ; /* 0x0000600005207625 */ /* 0x000fca00078e0006 */ /*01a0*/ LDG.E.64 R8, [R32.64+0x8] ; /* 0x0000080620087981 */ /* 0x001168000c1e1b00 */ /*01b0*/ LDG.E.64 R10, [R32.64] ; /* 0x00000006200a7981 */ /* 0x000168000c1e1b00 */ /*01c0*/ LDG.E.64 R12, [R32.64+0x10] ; /* 0x00001006200c7981 */ /* 0x000162000c1e1b00 */ /*01d0*/ ULDC.S8 UR4, c[0x0][0x164] ; /* 0x0000590000047ab9 */ /* 0x000fe40000000200 */ /*01e0*/ ISETP.NE.AND P0, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf05270 */ /*01f0*/ F2F.F64.F32 R18, R36 ; /* 0x0000002400127310 */ /* 0x004ff00000201800 */ /*0200*/ F2F.F64.F32 R20, R31 ; /* 0x0000001f00147310 */ /* 0x008eb00000201800 */ /*0210*/ F2F.F64.F32 R14, R27 ; /* 0x0000001b000e7310 */ /* 0x010fe20000201800 */ /*0220*/ DFMA R18, R20, c[0x0][0x168], R18 ; /* 0x00005a0014127a2b */ /* 0x004bce0000000012 */ /*0230*/ F2F.F64.F32 R16, R29 ; /* 0x0000001d00107310 */ /* 0x000ff00000201800 */ /*0240*/ F2F.F64.F32 R20, R28 ; /* 0x0000001c00147310 */ /* 0x020eb00000201800 */ /*0250*/ F2F.F64.F32 R22, R30 ; /* 0x0000001e00167310 */ /* 0x002e620000201800 */ /*0260*/ DFMA R14, R20, c[0x0][0x168], R14 ; /* 0x00005a00140e7a2b */ /* 0x0044ce000000000e */ /*0270*/ F2F.F64.F32 R26, R26 ; /* 0x0000001a001a7310 */ /* 0x000fe20000201800 */ /*0280*/ DFMA R34, R22, c[0x0][0x168], R16 ; /* 0x00005a0016227a2b */ /* 0x00230e0000000010 */ /*0290*/ F2F.F64.F32 R20, R24 ; /* 0x0000001800147310 */ /* 0x004e300000201800 */ /*02a0*/ F2F.F64.F32 R16, R4 ; /* 0x0000000400107310 */ /* 0x002e700000201800 */ /*02b0*/ F2F.F64.F32 R30, R3 ; /* 0x00000003001e7310 */ /* 0x000eb00000201800 */ /*02c0*/ F2F.F64.F32 R22, R0 ; /* 0x0000000000167310 */ /* 0x000ff00000201800 */ /*02d0*/ F2F.F64.F32 R28, R7 ; /* 0x00000007001c7310 */ /* 0x000f620000201800 */ /*02e0*/ DFMA R32, R20, c[0x0][0x168], R26 ; /* 0x00005a0014207a2b */ /* 0x001422000000001a */ /*02f0*/ FSEL R16, R16, RZ, !P0 ; /* 0x000000ff10107208 */ /* 0x002fc40004000000 */ /*0300*/ FSEL R17, R17, RZ, !P0 ; /* 0x000000ff11117208 */ /* 0x000fe40004000000 */ /*0310*/ FSEL R20, R30, RZ, !P0 ; /* 0x000000ff1e147208 */ /* 0x004fe40004000000 */ /*0320*/ FSEL R21, R31, RZ, !P0 ; /* 0x000000ff1f157208 */ /* 0x000fe20004000000 */ /*0330*/ F2F.F32.F64 R14, R14 ; /* 0x0000000e000e7310 */ /* 0x008fea0000301000 */ /*0340*/ DFMA R20, R20, c[0x0][0x168], R16 ; /* 0x00005a0014147a2b */ /* 0x000fc80000000010 */ /*0350*/ DFMA R28, R28, c[0x0][0x168], R22 ; /* 0x00005a001c1c7a2b */ /* 0x020e620000000016 */ /*0360*/ F2F.F32.F64 R18, R18 ; /* 0x0000001200127310 */ /* 0x000eb00000301000 */ /*0370*/ F2F.F32.F64 R15, R34 ; /* 0x00000022000f7310 */ /* 0x010ef00000301000 */ /*0380*/ F2F.F32.F64 R19, R32 ; /* 0x0000002000137310 */ /* 0x001e300000301000 */ /*0390*/ F2F.F32.F64 R28, R28 ; /* 0x0000001c001c7310 */ /* 0x002e700000301000 */ /*03a0*/ F2F.F32.F64 R21, R20 ; /* 0x0000001400157310 */ /* 0x000f220000301000 */ /*03b0*/ DFMA R8, R16, c[0x0][0x168], R8 ; /* 0x00005a0010087a2b */ /* 0x0005e20000000008 */ /*03c0*/ IMAD.WIDE.U32 R2, R25, R2, c[0x0][0x190] ; /* 0x0000640019027625 */ /* 0x000fe200078e0002 */ /*03d0*/ FSEL R17, R18, RZ, !P0 ; /* 0x000000ff12117208 */ /* 0x004fc40004000000 */ /*03e0*/ DFMA R10, R26, c[0x0][0x168], R10 ; /* 0x00005a001a0a7a2b */ /* 0x000ea2000000000a */ /*03f0*/ FSEL R15, R15, RZ, !P0 ; /* 0x000000ff0f0f7208 */ /* 0x008fe20004000000 */ /*0400*/ IMAD.WIDE.U32 R6, R5, R6, c[0x0][0x198] ; /* 0x0000660005067625 */ /* 0x000fe400078e0006 */ /*0410*/ DFMA R12, R22, c[0x0][0x168], R12 ; /* 0x00005a00160c7a2b */ /* 0x000ee2000000000c */ /*0420*/ STG.E [R2.64+0x4], R14 ; /* 0x0000040e02007986 */ /* 0x000fe8000c101906 */ /*0430*/ STG.E [R2.64+0xc], R19 ; /* 0x00000c1302007986 */ /* 0x001fe8000c101906 */ /*0440*/ STG.E [R2.64+0x14], R28 ; /* 0x0000141c02007986 */ /* 0x002fe8000c101906 */ /*0450*/ STG.E [R2.64], R17 ; /* 0x0000001102007986 */ /* 0x000fe8000c101906 */ /*0460*/ STG.E [R2.64+0x8], R15 ; /* 0x0000080f02007986 */ /* 0x000fe8000c101906 */ /*0470*/ STG.E [R2.64+0x10], R21 ; /* 0x0000101502007986 */ /* 0x010fe8000c101906 */ /*0480*/ STG.E.64 [R6.64], R10 ; /* 0x0000000a06007986 */ /* 0x004fe8000c101b06 */ /*0490*/ STG.E.64 [R6.64+0x8], R8 ; /* 0x0000080806007986 */ /* 0x000fe8000c101b06 */ /*04a0*/ STG.E.64 [R6.64+0x10], R12 ; /* 0x0000100c06007986 */ /* 0x008fe2000c101b06 */ /*04b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*04c0*/ BRA 0x4c0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*04d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*04e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*04f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0500*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0510*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0520*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0530*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0540*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0550*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0560*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0570*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __global__ void KerFtCalcForcesRes(unsigned ftcount,bool simulate2d,double dt ,const float3 *ftoomega,const float3 *ftovel,const double3 *ftocenter,const float3 *ftoforces ,float3 *ftoforcesres,double3 *ftocenterres) { const unsigned cf=blockIdx.x*blockDim.x + threadIdx.x; //-Floating number. if(cf<ftcount){ //-Compute fomega. float3 fomega=ftoomega[cf]; { const float3 omegaace=ftoforces[cf*2+1]; fomega.x=float(dt*omegaace.x+fomega.x); fomega.y=float(dt*omegaace.y+fomega.y); fomega.z=float(dt*omegaace.z+fomega.z); } float3 fvel=ftovel[cf]; //-Zero components for 2-D simulation. | Anula componentes para 2D. float3 face=ftoforces[cf*2]; if(simulate2d){ face.y=0; fomega.x=0; fomega.z=0; fvel.y=0; } //-Compute fcenter. double3 fcenter=ftocenter[cf]; fcenter.x+=dt*fvel.x; fcenter.y+=dt*fvel.y; fcenter.z+=dt*fvel.z; //-Compute fvel. fvel.x=float(dt*face.x+fvel.x); fvel.y=float(dt*face.y+fvel.y); fvel.z=float(dt*face.z+fvel.z); //-Store data to update floating. | Guarda datos para actualizar floatings. ftoforcesres[cf*2]=fomega; ftoforcesres[cf*2+1]=fvel; ftocenterres[cf]=fcenter; } }
.file "tmpxft_0006f697_00000000-6_KerFtCalcForcesRes.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 _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_ .type _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_, @function _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_: .LFB2051: .cfi_startproc endbr64 subq $216, %rsp .cfi_def_cfa_offset 224 movl %edi, 60(%rsp) movsd %xmm0, 48(%rsp) movq %rdx, 40(%rsp) movq %rcx, 32(%rsp) movq %r8, 24(%rsp) movq %r9, 16(%rsp) movb %sil, 56(%rsp) movq 224(%rsp), %rax movq %rax, 8(%rsp) movq 232(%rsp), %rax movq %rax, (%rsp) movq %fs:40, %rax movq %rax, 200(%rsp) xorl %eax, %eax leaq 60(%rsp), %rax movq %rax, 128(%rsp) leaq 56(%rsp), %rax movq %rax, 136(%rsp) leaq 48(%rsp), %rax movq %rax, 144(%rsp) leaq 40(%rsp), %rax movq %rax, 152(%rsp) leaq 32(%rsp), %rax movq %rax, 160(%rsp) leaq 24(%rsp), %rax movq %rax, 168(%rsp) leaq 16(%rsp), %rax movq %rax, 176(%rsp) leaq 8(%rsp), %rax movq %rax, 184(%rsp) movq %rsp, %rax movq %rax, 192(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl $1, 88(%rsp) movl $1, 92(%rsp) movl $1, 96(%rsp) movl $1, 100(%rsp) leaq 72(%rsp), %rcx leaq 64(%rsp), %rdx leaq 92(%rsp), %rsi leaq 80(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 200(%rsp), %rax subq %fs:40, %rax jne .L8 addq $216, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 72(%rsp) .cfi_def_cfa_offset 232 pushq 72(%rsp) .cfi_def_cfa_offset 240 leaq 144(%rsp), %r9 movq 108(%rsp), %rcx movl 116(%rsp), %r8d movq 96(%rsp), %rsi movl 104(%rsp), %edx leaq _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 224 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_, .-_Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_ .globl _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_ .type _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_, @function _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movzbl %sil, %esi pushq 24(%rsp) .cfi_def_cfa_offset 24 pushq 24(%rsp) .cfi_def_cfa_offset 32 call _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_ addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_, .-_Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_ .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_" .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 _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_(%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 KerFtCalcForcesRes(unsigned ftcount,bool simulate2d,double dt ,const float3 *ftoomega,const float3 *ftovel,const double3 *ftocenter,const float3 *ftoforces ,float3 *ftoforcesres,double3 *ftocenterres) { const unsigned cf=blockIdx.x*blockDim.x + threadIdx.x; //-Floating number. if(cf<ftcount){ //-Compute fomega. float3 fomega=ftoomega[cf]; { const float3 omegaace=ftoforces[cf*2+1]; fomega.x=float(dt*omegaace.x+fomega.x); fomega.y=float(dt*omegaace.y+fomega.y); fomega.z=float(dt*omegaace.z+fomega.z); } float3 fvel=ftovel[cf]; //-Zero components for 2-D simulation. | Anula componentes para 2D. float3 face=ftoforces[cf*2]; if(simulate2d){ face.y=0; fomega.x=0; fomega.z=0; fvel.y=0; } //-Compute fcenter. double3 fcenter=ftocenter[cf]; fcenter.x+=dt*fvel.x; fcenter.y+=dt*fvel.y; fcenter.z+=dt*fvel.z; //-Compute fvel. fvel.x=float(dt*face.x+fvel.x); fvel.y=float(dt*face.y+fvel.y); fvel.z=float(dt*face.z+fvel.z); //-Store data to update floating. | Guarda datos para actualizar floatings. ftoforcesres[cf*2]=fomega; ftoforcesres[cf*2+1]=fvel; ftocenterres[cf]=fcenter; } }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void KerFtCalcForcesRes(unsigned ftcount,bool simulate2d,double dt ,const float3 *ftoomega,const float3 *ftovel,const double3 *ftocenter,const float3 *ftoforces ,float3 *ftoforcesres,double3 *ftocenterres) { const unsigned cf=blockIdx.x*blockDim.x + threadIdx.x; //-Floating number. if(cf<ftcount){ //-Compute fomega. float3 fomega=ftoomega[cf]; { const float3 omegaace=ftoforces[cf*2+1]; fomega.x=float(dt*omegaace.x+fomega.x); fomega.y=float(dt*omegaace.y+fomega.y); fomega.z=float(dt*omegaace.z+fomega.z); } float3 fvel=ftovel[cf]; //-Zero components for 2-D simulation. | Anula componentes para 2D. float3 face=ftoforces[cf*2]; if(simulate2d){ face.y=0; fomega.x=0; fomega.z=0; fvel.y=0; } //-Compute fcenter. double3 fcenter=ftocenter[cf]; fcenter.x+=dt*fvel.x; fcenter.y+=dt*fvel.y; fcenter.z+=dt*fvel.z; //-Compute fvel. fvel.x=float(dt*face.x+fvel.x); fvel.y=float(dt*face.y+fvel.y); fvel.z=float(dt*face.z+fvel.z); //-Store data to update floating. | Guarda datos para actualizar floatings. ftoforcesres[cf*2]=fomega; ftoforcesres[cf*2+1]=fvel; ftocenterres[cf]=fcenter; } }
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 KerFtCalcForcesRes(unsigned ftcount,bool simulate2d,double dt ,const float3 *ftoomega,const float3 *ftovel,const double3 *ftocenter,const float3 *ftoforces ,float3 *ftoforcesres,double3 *ftocenterres) { const unsigned cf=blockIdx.x*blockDim.x + threadIdx.x; //-Floating number. if(cf<ftcount){ //-Compute fomega. float3 fomega=ftoomega[cf]; { const float3 omegaace=ftoforces[cf*2+1]; fomega.x=float(dt*omegaace.x+fomega.x); fomega.y=float(dt*omegaace.y+fomega.y); fomega.z=float(dt*omegaace.z+fomega.z); } float3 fvel=ftovel[cf]; //-Zero components for 2-D simulation. | Anula componentes para 2D. float3 face=ftoforces[cf*2]; if(simulate2d){ face.y=0; fomega.x=0; fomega.z=0; fvel.y=0; } //-Compute fcenter. double3 fcenter=ftocenter[cf]; fcenter.x+=dt*fvel.x; fcenter.y+=dt*fvel.y; fcenter.z+=dt*fvel.z; //-Compute fvel. fvel.x=float(dt*face.x+fvel.x); fvel.y=float(dt*face.y+fvel.y); fvel.z=float(dt*face.z+fvel.z); //-Store data to update floating. | Guarda datos para actualizar floatings. ftoforcesres[cf*2]=fomega; ftoforcesres[cf*2+1]=fvel; ftocenterres[cf]=fcenter; } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .globl _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .p2align 8 .type _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_,@function _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x4c s_load_b32 s3, s[0:1], 0x0 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[12:13], null, s15, s2, v[0:1] s_mov_b32 s2, exec_lo v_cmpx_gt_u32_e64 s3, v12 s_cbranch_execz .LBB0_5 s_clause 0x2 s_load_b128 s[4:7], s[0:1], 0x8 s_load_b64 s[2:3], s[0:1], 0x28 s_load_b64 s[8:9], s[0:1], 0x18 v_lshlrev_b32_e32 v14, 1, v12 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_or_b32_e32 v13, 1, v14 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[0:1], null, v12, 12, s[6:7] v_mad_u64_u32 v[3:4], null, v13, 12, s[2:3] v_mad_u64_u32 v[5:6], null, v12, 12, s[8:9] v_mad_u64_u32 v[15:16], null, v14, 12, s[2:3] global_load_b96 v[0:2], v[0:1], off global_load_b96 v[9:11], v[3:4], off global_load_b96 v[6:8], v[5:6], off global_load_b96 v[3:5], v[15:16], off s_load_b32 s2, s[0:1], 0x4 s_waitcnt lgkmcnt(0) s_bitcmp0_b32 s2, 0 s_cbranch_scc1 .LBB0_3 s_waitcnt vmcnt(1) v_mov_b32_e32 v7, 0 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) v_mov_b32_e32 v4, v7 v_mov_b32_e32 v0, v7 v_mov_b32_e32 v2, v7 s_branch .LBB0_4 .LBB0_3: s_waitcnt vmcnt(2) v_cvt_f64_f32_e32 v[15:16], v9 v_cvt_f64_f32_e32 v[17:18], v0 v_cvt_f64_f32_e32 v[19:20], v11 v_cvt_f64_f32_e32 v[21:22], v2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2) v_fma_f64 v[15:16], v[15:16], s[4:5], v[17:18] v_fma_f64 v[17:18], v[19:20], s[4:5], v[21:22] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_cvt_f32_f64_e32 v0, v[15:16] v_cvt_f32_f64_e32 v2, v[17:18] .LBB0_4: s_clause 0x1 s_load_b64 s[6:7], s[0:1], 0x20 s_load_b128 s[0:3], s[0:1], 0x30 v_cvt_f64_f32_e32 v[9:10], v10 v_cvt_f64_f32_e32 v[21:22], v1 s_waitcnt vmcnt(1) v_cvt_f64_f32_e32 v[23:24], v6 v_cvt_f64_f32_e32 v[25:26], v7 v_cvt_f64_f32_e32 v[27:28], v8 s_waitcnt vmcnt(0) v_cvt_f64_f32_e32 v[6:7], v3 v_cvt_f64_f32_e32 v[3:4], v4 v_cvt_f64_f32_e32 v[29:30], v5 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[19:20], null, v12, 24, s[6:7] s_clause 0x1 global_load_b128 v[15:18], v[19:20], off global_load_b64 v[19:20], v[19:20], off offset:16 v_fma_f64 v[8:9], v[9:10], s[4:5], v[21:22] v_fma_f64 v[5:6], v[6:7], s[4:5], v[23:24] v_fma_f64 v[3:4], v[3:4], s[4:5], v[25:26] v_fma_f64 v[10:11], v[29:30], s[4:5], v[27:28] s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_cvt_f32_f64_e32 v1, v[8:9] v_cvt_f32_f64_e32 v7, v[5:6] s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_cvt_f32_f64_e32 v8, v[3:4] v_cvt_f32_f64_e32 v9, v[10:11] s_waitcnt vmcnt(1) v_fma_f64 v[3:4], v[23:24], s[4:5], v[15:16] v_fma_f64 v[5:6], v[25:26], s[4:5], v[17:18] s_waitcnt vmcnt(0) v_fma_f64 v[10:11], v[27:28], s[4:5], v[19:20] v_mad_u64_u32 v[15:16], null, v14, 12, s[0:1] v_mad_u64_u32 v[17:18], null, v13, 12, s[0:1] v_mad_u64_u32 v[13:14], null, v12, 24, s[2:3] s_clause 0x1 global_store_b96 v[15:16], v[0:2], off global_store_b96 v[17:18], v[7:9], off s_clause 0x1 global_store_b128 v[13:14], v[3:6], off global_store_b64 v[13:14], v[10:11], off offset:16 .LBB0_5: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 320 .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 31 .amdhsa_next_free_sgpr 16 .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 _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, .Lfunc_end0-_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .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: 1 .value_kind: by_value - .offset: 8 .size: 8 .value_kind: by_value - .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 - .address_space: global .offset: 40 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 48 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 56 .size: 8 .value_kind: global_buffer - .offset: 64 .size: 4 .value_kind: hidden_block_count_x - .offset: 68 .size: 4 .value_kind: hidden_block_count_y - .offset: 72 .size: 4 .value_kind: hidden_block_count_z - .offset: 76 .size: 2 .value_kind: hidden_group_size_x - .offset: 78 .size: 2 .value_kind: hidden_group_size_y - .offset: 80 .size: 2 .value_kind: hidden_group_size_z - .offset: 82 .size: 2 .value_kind: hidden_remainder_x - .offset: 84 .size: 2 .value_kind: hidden_remainder_y - .offset: 86 .size: 2 .value_kind: hidden_remainder_z - .offset: 104 .size: 8 .value_kind: hidden_global_offset_x - .offset: 112 .size: 8 .value_kind: hidden_global_offset_y - .offset: 120 .size: 8 .value_kind: hidden_global_offset_z - .offset: 128 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 320 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .private_segment_fixed_size: 0 .sgpr_count: 16 .sgpr_spill_count: 0 .symbol: _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 31 .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 KerFtCalcForcesRes(unsigned ftcount,bool simulate2d,double dt ,const float3 *ftoomega,const float3 *ftovel,const double3 *ftocenter,const float3 *ftoforces ,float3 *ftoforcesres,double3 *ftocenterres) { const unsigned cf=blockIdx.x*blockDim.x + threadIdx.x; //-Floating number. if(cf<ftcount){ //-Compute fomega. float3 fomega=ftoomega[cf]; { const float3 omegaace=ftoforces[cf*2+1]; fomega.x=float(dt*omegaace.x+fomega.x); fomega.y=float(dt*omegaace.y+fomega.y); fomega.z=float(dt*omegaace.z+fomega.z); } float3 fvel=ftovel[cf]; //-Zero components for 2-D simulation. | Anula componentes para 2D. float3 face=ftoforces[cf*2]; if(simulate2d){ face.y=0; fomega.x=0; fomega.z=0; fvel.y=0; } //-Compute fcenter. double3 fcenter=ftocenter[cf]; fcenter.x+=dt*fvel.x; fcenter.y+=dt*fvel.y; fcenter.z+=dt*fvel.z; //-Compute fvel. fvel.x=float(dt*face.x+fvel.x); fvel.y=float(dt*face.y+fvel.y); fvel.z=float(dt*face.z+fvel.z); //-Store data to update floating. | Guarda datos para actualizar floatings. ftoforcesres[cf*2]=fomega; ftoforcesres[cf*2+1]=fvel; ftocenterres[cf]=fcenter; } }
.text .file "KerFtCalcForcesRes.hip" .globl _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ # -- Begin function _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .p2align 4, 0x90 .type _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_,@function _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_: # @_Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .cfi_startproc # %bb.0: subq $168, %rsp .cfi_def_cfa_offset 176 movl %edi, 4(%rsp) movb %sil, 3(%rsp) movsd %xmm0, 88(%rsp) movq %rdx, 80(%rsp) movq %rcx, 72(%rsp) movq %r8, 64(%rsp) movq %r9, 56(%rsp) leaq 4(%rsp), %rax movq %rax, 96(%rsp) leaq 3(%rsp), %rax movq %rax, 104(%rsp) leaq 88(%rsp), %rax movq %rax, 112(%rsp) leaq 80(%rsp), %rax movq %rax, 120(%rsp) leaq 72(%rsp), %rax movq %rax, 128(%rsp) leaq 64(%rsp), %rax movq %rax, 136(%rsp) leaq 56(%rsp), %rax movq %rax, 144(%rsp) leaq 176(%rsp), %rax movq %rax, 152(%rsp) leaq 184(%rsp), %rax movq %rax, 160(%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 $_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $184, %rsp .cfi_adjust_cfa_offset -184 retq .Lfunc_end0: .size _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, .Lfunc_end0-_Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .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 $_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, %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 _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_,@object # @_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .section .rodata,"a",@progbits .globl _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .p2align 3, 0x0 _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_: .quad _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .size _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_" .size .L__unnamed_1, 77 .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__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .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 : _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_ .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 R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e280000002500 */ /*0020*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R5, R5, c[0x0][0x0], R0 ; /* 0x0000000005057a24 */ /* 0x001fca00078e0200 */ /*0040*/ ISETP.GE.U32.AND P0, PT, R5, c[0x0][0x160], PT ; /* 0x0000580005007a0c */ /* 0x000fda0003f06070 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ SHF.L.U32 R25, R5, 0x1, RZ ; /* 0x0000000105197819 */ /* 0x000fe200000006ff */ /*0070*/ IMAD.MOV.U32 R2, RZ, RZ, 0xc ; /* 0x0000000cff027424 */ /* 0x000fe200078e00ff */ /*0080*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fc60000000a00 */ /*0090*/ IMAD.WIDE.U32 R8, R5, R2, c[0x0][0x170] ; /* 0x00005c0005087625 */ /* 0x000fc800078e0002 */ /*00a0*/ IMAD.WIDE.U32 R22, R25, R2.reuse, c[0x0][0x188] ; /* 0x0000620019167625 */ /* 0x080fe200078e0002 */ /*00b0*/ LDG.E R36, [R8.64] ; /* 0x0000000608247981 */ /* 0x0000a8000c1e1900 */ /*00c0*/ LDG.E R31, [R22.64+0xc] ; /* 0x00000c06161f7981 */ /* 0x000ee8000c1e1900 */ /*00d0*/ LDG.E R27, [R8.64+0x4] ; /* 0x00000406081b7981 */ /* 0x000128000c1e1900 */ /*00e0*/ LDG.E R28, [R22.64+0x10] ; /* 0x00001006161c7981 */ /* 0x000f68000c1e1900 */ /*00f0*/ LDG.E R29, [R8.64+0x8] ; /* 0x00000806081d7981 */ /* 0x000128000c1e1900 */ /*0100*/ LDG.E R30, [R22.64+0x14] ; /* 0x00001406161e7981 */ /* 0x000f62000c1e1900 */ /*0110*/ IMAD.WIDE.U32 R16, R5, R2, c[0x0][0x178] ; /* 0x00005e0005107625 */ /* 0x000fc600078e0002 */ /*0120*/ LDG.E R24, [R22.64] ; /* 0x0000000616187981 */ /* 0x000368000c1e1900 */ /*0130*/ LDG.E R26, [R16.64] ; /* 0x00000006101a7981 */ /* 0x000168000c1e1900 */ /*0140*/ LDG.E R4, [R16.64+0x4] ; /* 0x0000040610047981 */ /* 0x000168000c1e1900 */ /*0150*/ LDG.E R3, [R22.64+0x4] ; /* 0x0000040616037981 */ /* 0x000368000c1e1900 */ /*0160*/ LDG.E R0, [R16.64+0x8] ; /* 0x0000080610007981 */ /* 0x000168000c1e1900 */ /*0170*/ LDG.E R7, [R22.64+0x8] ; /* 0x0000080616077981 */ /* 0x000362000c1e1900 */ /*0180*/ HFMA2.MMA R6, -RZ, RZ, 0, 1.430511474609375e-06 ; /* 0x00000018ff067435 */ /* 0x000fd400000001ff */ /*0190*/ IMAD.WIDE.U32 R32, R5, R6, c[0x0][0x180] ; /* 0x0000600005207625 */ /* 0x000fca00078e0006 */ /*01a0*/ LDG.E.64 R8, [R32.64+0x8] ; /* 0x0000080620087981 */ /* 0x001168000c1e1b00 */ /*01b0*/ LDG.E.64 R10, [R32.64] ; /* 0x00000006200a7981 */ /* 0x000168000c1e1b00 */ /*01c0*/ LDG.E.64 R12, [R32.64+0x10] ; /* 0x00001006200c7981 */ /* 0x000162000c1e1b00 */ /*01d0*/ ULDC.S8 UR4, c[0x0][0x164] ; /* 0x0000590000047ab9 */ /* 0x000fe40000000200 */ /*01e0*/ ISETP.NE.AND P0, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf05270 */ /*01f0*/ F2F.F64.F32 R18, R36 ; /* 0x0000002400127310 */ /* 0x004ff00000201800 */ /*0200*/ F2F.F64.F32 R20, R31 ; /* 0x0000001f00147310 */ /* 0x008eb00000201800 */ /*0210*/ F2F.F64.F32 R14, R27 ; /* 0x0000001b000e7310 */ /* 0x010fe20000201800 */ /*0220*/ DFMA R18, R20, c[0x0][0x168], R18 ; /* 0x00005a0014127a2b */ /* 0x004bce0000000012 */ /*0230*/ F2F.F64.F32 R16, R29 ; /* 0x0000001d00107310 */ /* 0x000ff00000201800 */ /*0240*/ F2F.F64.F32 R20, R28 ; /* 0x0000001c00147310 */ /* 0x020eb00000201800 */ /*0250*/ F2F.F64.F32 R22, R30 ; /* 0x0000001e00167310 */ /* 0x002e620000201800 */ /*0260*/ DFMA R14, R20, c[0x0][0x168], R14 ; /* 0x00005a00140e7a2b */ /* 0x0044ce000000000e */ /*0270*/ F2F.F64.F32 R26, R26 ; /* 0x0000001a001a7310 */ /* 0x000fe20000201800 */ /*0280*/ DFMA R34, R22, c[0x0][0x168], R16 ; /* 0x00005a0016227a2b */ /* 0x00230e0000000010 */ /*0290*/ F2F.F64.F32 R20, R24 ; /* 0x0000001800147310 */ /* 0x004e300000201800 */ /*02a0*/ F2F.F64.F32 R16, R4 ; /* 0x0000000400107310 */ /* 0x002e700000201800 */ /*02b0*/ F2F.F64.F32 R30, R3 ; /* 0x00000003001e7310 */ /* 0x000eb00000201800 */ /*02c0*/ F2F.F64.F32 R22, R0 ; /* 0x0000000000167310 */ /* 0x000ff00000201800 */ /*02d0*/ F2F.F64.F32 R28, R7 ; /* 0x00000007001c7310 */ /* 0x000f620000201800 */ /*02e0*/ DFMA R32, R20, c[0x0][0x168], R26 ; /* 0x00005a0014207a2b */ /* 0x001422000000001a */ /*02f0*/ FSEL R16, R16, RZ, !P0 ; /* 0x000000ff10107208 */ /* 0x002fc40004000000 */ /*0300*/ FSEL R17, R17, RZ, !P0 ; /* 0x000000ff11117208 */ /* 0x000fe40004000000 */ /*0310*/ FSEL R20, R30, RZ, !P0 ; /* 0x000000ff1e147208 */ /* 0x004fe40004000000 */ /*0320*/ FSEL R21, R31, RZ, !P0 ; /* 0x000000ff1f157208 */ /* 0x000fe20004000000 */ /*0330*/ F2F.F32.F64 R14, R14 ; /* 0x0000000e000e7310 */ /* 0x008fea0000301000 */ /*0340*/ DFMA R20, R20, c[0x0][0x168], R16 ; /* 0x00005a0014147a2b */ /* 0x000fc80000000010 */ /*0350*/ DFMA R28, R28, c[0x0][0x168], R22 ; /* 0x00005a001c1c7a2b */ /* 0x020e620000000016 */ /*0360*/ F2F.F32.F64 R18, R18 ; /* 0x0000001200127310 */ /* 0x000eb00000301000 */ /*0370*/ F2F.F32.F64 R15, R34 ; /* 0x00000022000f7310 */ /* 0x010ef00000301000 */ /*0380*/ F2F.F32.F64 R19, R32 ; /* 0x0000002000137310 */ /* 0x001e300000301000 */ /*0390*/ F2F.F32.F64 R28, R28 ; /* 0x0000001c001c7310 */ /* 0x002e700000301000 */ /*03a0*/ F2F.F32.F64 R21, R20 ; /* 0x0000001400157310 */ /* 0x000f220000301000 */ /*03b0*/ DFMA R8, R16, c[0x0][0x168], R8 ; /* 0x00005a0010087a2b */ /* 0x0005e20000000008 */ /*03c0*/ IMAD.WIDE.U32 R2, R25, R2, c[0x0][0x190] ; /* 0x0000640019027625 */ /* 0x000fe200078e0002 */ /*03d0*/ FSEL R17, R18, RZ, !P0 ; /* 0x000000ff12117208 */ /* 0x004fc40004000000 */ /*03e0*/ DFMA R10, R26, c[0x0][0x168], R10 ; /* 0x00005a001a0a7a2b */ /* 0x000ea2000000000a */ /*03f0*/ FSEL R15, R15, RZ, !P0 ; /* 0x000000ff0f0f7208 */ /* 0x008fe20004000000 */ /*0400*/ IMAD.WIDE.U32 R6, R5, R6, c[0x0][0x198] ; /* 0x0000660005067625 */ /* 0x000fe400078e0006 */ /*0410*/ DFMA R12, R22, c[0x0][0x168], R12 ; /* 0x00005a00160c7a2b */ /* 0x000ee2000000000c */ /*0420*/ STG.E [R2.64+0x4], R14 ; /* 0x0000040e02007986 */ /* 0x000fe8000c101906 */ /*0430*/ STG.E [R2.64+0xc], R19 ; /* 0x00000c1302007986 */ /* 0x001fe8000c101906 */ /*0440*/ STG.E [R2.64+0x14], R28 ; /* 0x0000141c02007986 */ /* 0x002fe8000c101906 */ /*0450*/ STG.E [R2.64], R17 ; /* 0x0000001102007986 */ /* 0x000fe8000c101906 */ /*0460*/ STG.E [R2.64+0x8], R15 ; /* 0x0000080f02007986 */ /* 0x000fe8000c101906 */ /*0470*/ STG.E [R2.64+0x10], R21 ; /* 0x0000101502007986 */ /* 0x010fe8000c101906 */ /*0480*/ STG.E.64 [R6.64], R10 ; /* 0x0000000a06007986 */ /* 0x004fe8000c101b06 */ /*0490*/ STG.E.64 [R6.64+0x8], R8 ; /* 0x0000080806007986 */ /* 0x000fe8000c101b06 */ /*04a0*/ STG.E.64 [R6.64+0x10], R12 ; /* 0x0000100c06007986 */ /* 0x008fe2000c101b06 */ /*04b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*04c0*/ BRA 0x4c0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*04d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*04e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*04f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0500*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0510*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0520*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0530*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0540*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0550*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0560*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0570*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .globl _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .p2align 8 .type _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_,@function _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x4c s_load_b32 s3, s[0:1], 0x0 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[12:13], null, s15, s2, v[0:1] s_mov_b32 s2, exec_lo v_cmpx_gt_u32_e64 s3, v12 s_cbranch_execz .LBB0_5 s_clause 0x2 s_load_b128 s[4:7], s[0:1], 0x8 s_load_b64 s[2:3], s[0:1], 0x28 s_load_b64 s[8:9], s[0:1], 0x18 v_lshlrev_b32_e32 v14, 1, v12 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_or_b32_e32 v13, 1, v14 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[0:1], null, v12, 12, s[6:7] v_mad_u64_u32 v[3:4], null, v13, 12, s[2:3] v_mad_u64_u32 v[5:6], null, v12, 12, s[8:9] v_mad_u64_u32 v[15:16], null, v14, 12, s[2:3] global_load_b96 v[0:2], v[0:1], off global_load_b96 v[9:11], v[3:4], off global_load_b96 v[6:8], v[5:6], off global_load_b96 v[3:5], v[15:16], off s_load_b32 s2, s[0:1], 0x4 s_waitcnt lgkmcnt(0) s_bitcmp0_b32 s2, 0 s_cbranch_scc1 .LBB0_3 s_waitcnt vmcnt(1) v_mov_b32_e32 v7, 0 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) v_mov_b32_e32 v4, v7 v_mov_b32_e32 v0, v7 v_mov_b32_e32 v2, v7 s_branch .LBB0_4 .LBB0_3: s_waitcnt vmcnt(2) v_cvt_f64_f32_e32 v[15:16], v9 v_cvt_f64_f32_e32 v[17:18], v0 v_cvt_f64_f32_e32 v[19:20], v11 v_cvt_f64_f32_e32 v[21:22], v2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2) v_fma_f64 v[15:16], v[15:16], s[4:5], v[17:18] v_fma_f64 v[17:18], v[19:20], s[4:5], v[21:22] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_cvt_f32_f64_e32 v0, v[15:16] v_cvt_f32_f64_e32 v2, v[17:18] .LBB0_4: s_clause 0x1 s_load_b64 s[6:7], s[0:1], 0x20 s_load_b128 s[0:3], s[0:1], 0x30 v_cvt_f64_f32_e32 v[9:10], v10 v_cvt_f64_f32_e32 v[21:22], v1 s_waitcnt vmcnt(1) v_cvt_f64_f32_e32 v[23:24], v6 v_cvt_f64_f32_e32 v[25:26], v7 v_cvt_f64_f32_e32 v[27:28], v8 s_waitcnt vmcnt(0) v_cvt_f64_f32_e32 v[6:7], v3 v_cvt_f64_f32_e32 v[3:4], v4 v_cvt_f64_f32_e32 v[29:30], v5 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[19:20], null, v12, 24, s[6:7] s_clause 0x1 global_load_b128 v[15:18], v[19:20], off global_load_b64 v[19:20], v[19:20], off offset:16 v_fma_f64 v[8:9], v[9:10], s[4:5], v[21:22] v_fma_f64 v[5:6], v[6:7], s[4:5], v[23:24] v_fma_f64 v[3:4], v[3:4], s[4:5], v[25:26] v_fma_f64 v[10:11], v[29:30], s[4:5], v[27:28] s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_cvt_f32_f64_e32 v1, v[8:9] v_cvt_f32_f64_e32 v7, v[5:6] s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_cvt_f32_f64_e32 v8, v[3:4] v_cvt_f32_f64_e32 v9, v[10:11] s_waitcnt vmcnt(1) v_fma_f64 v[3:4], v[23:24], s[4:5], v[15:16] v_fma_f64 v[5:6], v[25:26], s[4:5], v[17:18] s_waitcnt vmcnt(0) v_fma_f64 v[10:11], v[27:28], s[4:5], v[19:20] v_mad_u64_u32 v[15:16], null, v14, 12, s[0:1] v_mad_u64_u32 v[17:18], null, v13, 12, s[0:1] v_mad_u64_u32 v[13:14], null, v12, 24, s[2:3] s_clause 0x1 global_store_b96 v[15:16], v[0:2], off global_store_b96 v[17:18], v[7:9], off s_clause 0x1 global_store_b128 v[13:14], v[3:6], off global_store_b64 v[13:14], v[10:11], off offset:16 .LBB0_5: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 320 .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 31 .amdhsa_next_free_sgpr 16 .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 _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, .Lfunc_end0-_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .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: 1 .value_kind: by_value - .offset: 8 .size: 8 .value_kind: by_value - .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 - .address_space: global .offset: 40 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 48 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 56 .size: 8 .value_kind: global_buffer - .offset: 64 .size: 4 .value_kind: hidden_block_count_x - .offset: 68 .size: 4 .value_kind: hidden_block_count_y - .offset: 72 .size: 4 .value_kind: hidden_block_count_z - .offset: 76 .size: 2 .value_kind: hidden_group_size_x - .offset: 78 .size: 2 .value_kind: hidden_group_size_y - .offset: 80 .size: 2 .value_kind: hidden_group_size_z - .offset: 82 .size: 2 .value_kind: hidden_remainder_x - .offset: 84 .size: 2 .value_kind: hidden_remainder_y - .offset: 86 .size: 2 .value_kind: hidden_remainder_z - .offset: 104 .size: 8 .value_kind: hidden_global_offset_x - .offset: 112 .size: 8 .value_kind: hidden_global_offset_y - .offset: 120 .size: 8 .value_kind: hidden_global_offset_z - .offset: 128 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 320 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .private_segment_fixed_size: 0 .sgpr_count: 16 .sgpr_spill_count: 0 .symbol: _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 31 .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_0006f697_00000000-6_KerFtCalcForcesRes.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 _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_ .type _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_, @function _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_: .LFB2051: .cfi_startproc endbr64 subq $216, %rsp .cfi_def_cfa_offset 224 movl %edi, 60(%rsp) movsd %xmm0, 48(%rsp) movq %rdx, 40(%rsp) movq %rcx, 32(%rsp) movq %r8, 24(%rsp) movq %r9, 16(%rsp) movb %sil, 56(%rsp) movq 224(%rsp), %rax movq %rax, 8(%rsp) movq 232(%rsp), %rax movq %rax, (%rsp) movq %fs:40, %rax movq %rax, 200(%rsp) xorl %eax, %eax leaq 60(%rsp), %rax movq %rax, 128(%rsp) leaq 56(%rsp), %rax movq %rax, 136(%rsp) leaq 48(%rsp), %rax movq %rax, 144(%rsp) leaq 40(%rsp), %rax movq %rax, 152(%rsp) leaq 32(%rsp), %rax movq %rax, 160(%rsp) leaq 24(%rsp), %rax movq %rax, 168(%rsp) leaq 16(%rsp), %rax movq %rax, 176(%rsp) leaq 8(%rsp), %rax movq %rax, 184(%rsp) movq %rsp, %rax movq %rax, 192(%rsp) movl $1, 80(%rsp) movl $1, 84(%rsp) movl $1, 88(%rsp) movl $1, 92(%rsp) movl $1, 96(%rsp) movl $1, 100(%rsp) leaq 72(%rsp), %rcx leaq 64(%rsp), %rdx leaq 92(%rsp), %rsi leaq 80(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 200(%rsp), %rax subq %fs:40, %rax jne .L8 addq $216, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 72(%rsp) .cfi_def_cfa_offset 232 pushq 72(%rsp) .cfi_def_cfa_offset 240 leaq 144(%rsp), %r9 movq 108(%rsp), %rcx movl 116(%rsp), %r8d movq 96(%rsp), %rsi movl 104(%rsp), %edx leaq _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 224 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_, .-_Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_ .globl _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_ .type _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_, @function _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movzbl %sil, %esi pushq 24(%rsp) .cfi_def_cfa_offset 24 pushq 24(%rsp) .cfi_def_cfa_offset 32 call _Z71__device_stub__Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_jbdPK6float3S1_PK7double3S1_PS_PS2_ addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_, .-_Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_ .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_" .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 _Z18KerFtCalcForcesResjbdPK6float3S1_PK7double3S1_PS_PS2_(%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 "KerFtCalcForcesRes.hip" .globl _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ # -- Begin function _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .p2align 4, 0x90 .type _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_,@function _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_: # @_Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .cfi_startproc # %bb.0: subq $168, %rsp .cfi_def_cfa_offset 176 movl %edi, 4(%rsp) movb %sil, 3(%rsp) movsd %xmm0, 88(%rsp) movq %rdx, 80(%rsp) movq %rcx, 72(%rsp) movq %r8, 64(%rsp) movq %r9, 56(%rsp) leaq 4(%rsp), %rax movq %rax, 96(%rsp) leaq 3(%rsp), %rax movq %rax, 104(%rsp) leaq 88(%rsp), %rax movq %rax, 112(%rsp) leaq 80(%rsp), %rax movq %rax, 120(%rsp) leaq 72(%rsp), %rax movq %rax, 128(%rsp) leaq 64(%rsp), %rax movq %rax, 136(%rsp) leaq 56(%rsp), %rax movq %rax, 144(%rsp) leaq 176(%rsp), %rax movq %rax, 152(%rsp) leaq 184(%rsp), %rax movq %rax, 160(%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 $_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, %edi pushq 8(%rsp) .cfi_adjust_cfa_offset 8 pushq 24(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $184, %rsp .cfi_adjust_cfa_offset -184 retq .Lfunc_end0: .size _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, .Lfunc_end0-_Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .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 $_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, %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 _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_,@object # @_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .section .rodata,"a",@progbits .globl _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .p2align 3, 0x0 _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_: .quad _Z33__device_stub__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .size _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_" .size .L__unnamed_1, 77 .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__KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z18KerFtCalcForcesResjbdPK15HIP_vector_typeIfLj3EES2_PKS_IdLj3EES2_PS0_PS3_ .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" __global__ void naiveHistKernel(int* bins, int nbins, int* in, int nrows) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; auto offset = blockIdx.y * nrows; auto binOffset = blockIdx.y * nbins; for (; tid < nrows; tid += stride) { int id = in[offset + tid]; if (id < 0) id = 0; else if (id >= nbins) id = nbins - 1; in[offset + tid] = id; atomicAdd(bins + binOffset + id, 1); } }
code for sm_80 Function : _Z15naiveHistKernelPiiS_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*/ 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][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ S2R R9, SR_CTAID.Y ; /* 0x0000000000097919 */ /* 0x000e220000002600 */ /*0070*/ ULDC UR4, c[0x0][0x168] ; /* 0x00005a0000047ab9 */ /* 0x000fe40000000800 */ /*0080*/ UIADD3 UR4, UR4, -0x1, URZ ; /* 0xffffffff04047890 */ /* 0x000fe4000fffe03f */ /*0090*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*00a0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x001fe400078e00ff */ /*00b0*/ IMAD R2, R9, c[0x0][0x178], R0 ; /* 0x00005e0009027a24 */ /* 0x001fc800078e0200 */ /*00c0*/ IMAD.WIDE.U32 R2, R2, R3, c[0x0][0x170] ; /* 0x00005c0002027625 */ /* 0x000fca00078e0003 */ /*00d0*/ LDG.E R4, [R2.64] ; /* 0x0000000602047981 */ /* 0x000ea2000c1e1900 */ /*00e0*/ IMAD R6, R9, c[0x0][0x168], RZ ; /* 0x00005a0009067a24 */ /* 0x000fe200078e02ff */ /*00f0*/ YIELD ; /* 0x0000000000007946 */ /* 0x000fe20003800000 */ /*0100*/ IMAD.MOV.U32 R13, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff0d7624 */ /* 0x000fe400078e00ff */ /*0110*/ IMAD.MOV.U32 R11, RZ, RZ, 0x1 ; /* 0x00000001ff0b7424 */ /* 0x000fe400078e00ff */ /*0120*/ IMAD R0, R13, c[0x0][0xc], R0 ; /* 0x000003000d007a24 */ /* 0x000fe200078e0200 */ /*0130*/ ISETP.GE.AND P1, PT, R4.reuse, c[0x0][0x168], PT ; /* 0x00005a0004007a0c */ /* 0x044fe40003f26270 */ /*0140*/ ISETP.GE.AND P0, PT, R4, RZ, PT ; /* 0x000000ff0400720c */ /* 0x000fc40003f06270 */ /*0150*/ SEL R4, R4, UR4, !P1 ; /* 0x0000000404047c07 */ /* 0x000fc8000c800000 */ /*0160*/ SEL R7, R4, RZ, P0 ; /* 0x000000ff04077207 */ /* 0x000fc80000000000 */ /*0170*/ IADD3 R5, P0, R6, R7, RZ ; /* 0x0000000706057210 */ /* 0x000fe20007f1e0ff */ /*0180*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e6000c101906 */ /*0190*/ LEA.HI.X.SX32 R6, R7, RZ, 0x1, P0 ; /* 0x000000ff07067211 */ /* 0x000fe400000f0eff */ /*01a0*/ LEA R4, P0, R5, c[0x0][0x160], 0x2 ; /* 0x0000580005047a11 */ /* 0x000fc800078010ff */ /*01b0*/ LEA.HI.X R5, R5, c[0x0][0x164], R6, 0x2, P0 ; /* 0x0000590005057a11 */ /* 0x000fe400000f1406 */ /*01c0*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x000fc60003f06270 */ /*01d0*/ RED.E.ADD.STRONG.GPU [R4.64], R11 ; /* 0x0000000b0400798e */ /* 0x0001f4000c10e186 */ /*01e0*/ @!P0 BRA 0xa0 ; /* 0xfffffeb000008947 */ /* 0x000fea000383ffff */ /*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 "includes.h" __global__ void naiveHistKernel(int* bins, int nbins, int* in, int nrows) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; auto offset = blockIdx.y * nrows; auto binOffset = blockIdx.y * nbins; for (; tid < nrows; tid += stride) { int id = in[offset + tid]; if (id < 0) id = 0; else if (id >= nbins) id = nbins - 1; in[offset + tid] = id; atomicAdd(bins + binOffset + id, 1); } }
.file "tmpxft_0005b2c4_00000000-6_naiveHistKernel.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 _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i .type _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i, @function _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i: .LFB2051: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movq %rdx, 8(%rsp) movl %ecx, 16(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 16(%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 _Z15naiveHistKernelPiiS_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i, .-_Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i .globl _Z15naiveHistKernelPiiS_i .type _Z15naiveHistKernelPiiS_i, @function _Z15naiveHistKernelPiiS_i: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z15naiveHistKernelPiiS_i, .-_Z15naiveHistKernelPiiS_i .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z15naiveHistKernelPiiS_i" .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 _Z15naiveHistKernelPiiS_i(%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 naiveHistKernel(int* bins, int nbins, int* in, int nrows) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; auto offset = blockIdx.y * nrows; auto binOffset = blockIdx.y * nbins; for (; tid < nrows; tid += stride) { int id = in[offset + tid]; if (id < 0) id = 0; else if (id >= nbins) id = nbins - 1; in[offset + tid] = id; atomicAdd(bins + binOffset + id, 1); } }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void naiveHistKernel(int* bins, int nbins, int* in, int nrows) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; auto offset = blockIdx.y * nrows; auto binOffset = blockIdx.y * nbins; for (; tid < nrows; tid += stride) { int id = in[offset + tid]; if (id < 0) id = 0; else if (id >= nbins) id = nbins - 1; in[offset + tid] = id; atomicAdd(bins + binOffset + id, 1); } }
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 naiveHistKernel(int* bins, int nbins, int* in, int nrows) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; auto offset = blockIdx.y * nrows; auto binOffset = blockIdx.y * nbins; for (; tid < nrows; tid += stride) { int id = in[offset + tid]; if (id < 0) id = 0; else if (id >= nbins) id = nbins - 1; in[offset + tid] = id; atomicAdd(bins + binOffset + id, 1); } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15naiveHistKernelPiiS_i .globl _Z15naiveHistKernelPiiS_i .p2align 8 .type _Z15naiveHistKernelPiiS_i,@function _Z15naiveHistKernelPiiS_i: s_clause 0x1 s_load_b32 s5, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x18 s_add_u32 s2, s0, 32 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s7, s5, 0xffff s_mov_b32 s5, exec_lo v_mad_u64_u32 v[1:2], null, s14, s7, v[0:1] s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e64 s4, v1 s_cbranch_execz .LBB0_3 s_load_b32 s5, s[0:1], 0x8 s_load_b32 s10, s[2:3], 0x0 s_clause 0x1 s_load_b64 s[8:9], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 s_mov_b32 s3, 0 v_dual_mov_b32 v3, 0 :: v_dual_mov_b32 v0, 1 s_mul_i32 s6, s15, s4 s_waitcnt lgkmcnt(0) s_mul_i32 s2, s15, s5 s_mul_i32 s7, s10, s7 s_lshl_b64 s[10:11], s[2:3], 2 s_add_i32 s2, s5, -1 s_add_u32 s8, s8, s10 s_addc_u32 s9, s9, s11 .p2align 6 .LBB0_2: v_add_nc_u32_e32 v2, s6, v1 v_add_nc_u32_e32 v1, s7, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[4:5], 2, v[2:3] v_add_co_u32 v4, vcc_lo, s0, v4 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo global_load_b32 v2, v[4:5], off s_waitcnt vmcnt(0) v_cmp_gt_i32_e32 vcc_lo, s5, v2 v_cndmask_b32_e32 v6, s2, v2, vcc_lo v_cmp_lt_i32_e32 vcc_lo, -1, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_cndmask_b32_e32 v6, 0, v6, vcc_lo v_ashrrev_i32_e32 v7, 31, v6 global_store_b32 v[4:5], v6, off v_lshlrev_b64 v[7:8], 2, v[6:7] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v7, vcc_lo, s8, v7 v_add_co_ci_u32_e32 v8, vcc_lo, s9, v8, vcc_lo v_cmp_le_i32_e32 vcc_lo, s4, v1 global_atomic_add_u32 v[7:8], v0, off s_or_b32 s3, vcc_lo, s3 s_delay_alu instid0(SALU_CYCLE_1) s_and_not1_b32 exec_lo, exec_lo, s3 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 _Z15naiveHistKernelPiiS_i .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 0 .amdhsa_next_free_vgpr 9 .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 _Z15naiveHistKernelPiiS_i, .Lfunc_end0-_Z15naiveHistKernelPiiS_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 - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .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: _Z15naiveHistKernelPiiS_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15naiveHistKernelPiiS_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 9 .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 naiveHistKernel(int* bins, int nbins, int* in, int nrows) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; auto offset = blockIdx.y * nrows; auto binOffset = blockIdx.y * nbins; for (; tid < nrows; tid += stride) { int id = in[offset + tid]; if (id < 0) id = 0; else if (id >= nbins) id = nbins - 1; in[offset + tid] = id; atomicAdd(bins + binOffset + id, 1); } }
.text .file "naiveHistKernel.hip" .globl _Z30__device_stub__naiveHistKernelPiiS_i # -- Begin function _Z30__device_stub__naiveHistKernelPiiS_i .p2align 4, 0x90 .type _Z30__device_stub__naiveHistKernelPiiS_i,@function _Z30__device_stub__naiveHistKernelPiiS_i: # @_Z30__device_stub__naiveHistKernelPiiS_i .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 12(%rsp) movq %rdx, 64(%rsp) movl %ecx, 8(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%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 $_Z15naiveHistKernelPiiS_i, %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__naiveHistKernelPiiS_i, .Lfunc_end0-_Z30__device_stub__naiveHistKernelPiiS_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: 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 $_Z15naiveHistKernelPiiS_i, %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 _Z15naiveHistKernelPiiS_i,@object # @_Z15naiveHistKernelPiiS_i .section .rodata,"a",@progbits .globl _Z15naiveHistKernelPiiS_i .p2align 3, 0x0 _Z15naiveHistKernelPiiS_i: .quad _Z30__device_stub__naiveHistKernelPiiS_i .size _Z15naiveHistKernelPiiS_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z15naiveHistKernelPiiS_i" .size .L__unnamed_1, 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 _Z30__device_stub__naiveHistKernelPiiS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15naiveHistKernelPiiS_i .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 : _Z15naiveHistKernelPiiS_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*/ 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][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ S2R R9, SR_CTAID.Y ; /* 0x0000000000097919 */ /* 0x000e220000002600 */ /*0070*/ ULDC UR4, c[0x0][0x168] ; /* 0x00005a0000047ab9 */ /* 0x000fe40000000800 */ /*0080*/ UIADD3 UR4, UR4, -0x1, URZ ; /* 0xffffffff04047890 */ /* 0x000fe4000fffe03f */ /*0090*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe40000000a00 */ /*00a0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x001fe400078e00ff */ /*00b0*/ IMAD R2, R9, c[0x0][0x178], R0 ; /* 0x00005e0009027a24 */ /* 0x001fc800078e0200 */ /*00c0*/ IMAD.WIDE.U32 R2, R2, R3, c[0x0][0x170] ; /* 0x00005c0002027625 */ /* 0x000fca00078e0003 */ /*00d0*/ LDG.E R4, [R2.64] ; /* 0x0000000602047981 */ /* 0x000ea2000c1e1900 */ /*00e0*/ IMAD R6, R9, c[0x0][0x168], RZ ; /* 0x00005a0009067a24 */ /* 0x000fe200078e02ff */ /*00f0*/ YIELD ; /* 0x0000000000007946 */ /* 0x000fe20003800000 */ /*0100*/ IMAD.MOV.U32 R13, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff0d7624 */ /* 0x000fe400078e00ff */ /*0110*/ IMAD.MOV.U32 R11, RZ, RZ, 0x1 ; /* 0x00000001ff0b7424 */ /* 0x000fe400078e00ff */ /*0120*/ IMAD R0, R13, c[0x0][0xc], R0 ; /* 0x000003000d007a24 */ /* 0x000fe200078e0200 */ /*0130*/ ISETP.GE.AND P1, PT, R4.reuse, c[0x0][0x168], PT ; /* 0x00005a0004007a0c */ /* 0x044fe40003f26270 */ /*0140*/ ISETP.GE.AND P0, PT, R4, RZ, PT ; /* 0x000000ff0400720c */ /* 0x000fc40003f06270 */ /*0150*/ SEL R4, R4, UR4, !P1 ; /* 0x0000000404047c07 */ /* 0x000fc8000c800000 */ /*0160*/ SEL R7, R4, RZ, P0 ; /* 0x000000ff04077207 */ /* 0x000fc80000000000 */ /*0170*/ IADD3 R5, P0, R6, R7, RZ ; /* 0x0000000706057210 */ /* 0x000fe20007f1e0ff */ /*0180*/ STG.E [R2.64], R7 ; /* 0x0000000702007986 */ /* 0x0001e6000c101906 */ /*0190*/ LEA.HI.X.SX32 R6, R7, RZ, 0x1, P0 ; /* 0x000000ff07067211 */ /* 0x000fe400000f0eff */ /*01a0*/ LEA R4, P0, R5, c[0x0][0x160], 0x2 ; /* 0x0000580005047a11 */ /* 0x000fc800078010ff */ /*01b0*/ LEA.HI.X R5, R5, c[0x0][0x164], R6, 0x2, P0 ; /* 0x0000590005057a11 */ /* 0x000fe400000f1406 */ /*01c0*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x000fc60003f06270 */ /*01d0*/ RED.E.ADD.STRONG.GPU [R4.64], R11 ; /* 0x0000000b0400798e */ /* 0x0001f4000c10e186 */ /*01e0*/ @!P0 BRA 0xa0 ; /* 0xfffffeb000008947 */ /* 0x000fea000383ffff */ /*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 _Z15naiveHistKernelPiiS_i .globl _Z15naiveHistKernelPiiS_i .p2align 8 .type _Z15naiveHistKernelPiiS_i,@function _Z15naiveHistKernelPiiS_i: s_clause 0x1 s_load_b32 s5, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x18 s_add_u32 s2, s0, 32 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s7, s5, 0xffff s_mov_b32 s5, exec_lo v_mad_u64_u32 v[1:2], null, s14, s7, v[0:1] s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e64 s4, v1 s_cbranch_execz .LBB0_3 s_load_b32 s5, s[0:1], 0x8 s_load_b32 s10, s[2:3], 0x0 s_clause 0x1 s_load_b64 s[8:9], s[0:1], 0x0 s_load_b64 s[0:1], s[0:1], 0x10 s_mov_b32 s3, 0 v_dual_mov_b32 v3, 0 :: v_dual_mov_b32 v0, 1 s_mul_i32 s6, s15, s4 s_waitcnt lgkmcnt(0) s_mul_i32 s2, s15, s5 s_mul_i32 s7, s10, s7 s_lshl_b64 s[10:11], s[2:3], 2 s_add_i32 s2, s5, -1 s_add_u32 s8, s8, s10 s_addc_u32 s9, s9, s11 .p2align 6 .LBB0_2: v_add_nc_u32_e32 v2, s6, v1 v_add_nc_u32_e32 v1, s7, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[4:5], 2, v[2:3] v_add_co_u32 v4, vcc_lo, s0, v4 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo global_load_b32 v2, v[4:5], off s_waitcnt vmcnt(0) v_cmp_gt_i32_e32 vcc_lo, s5, v2 v_cndmask_b32_e32 v6, s2, v2, vcc_lo v_cmp_lt_i32_e32 vcc_lo, -1, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_cndmask_b32_e32 v6, 0, v6, vcc_lo v_ashrrev_i32_e32 v7, 31, v6 global_store_b32 v[4:5], v6, off v_lshlrev_b64 v[7:8], 2, v[6:7] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v7, vcc_lo, s8, v7 v_add_co_ci_u32_e32 v8, vcc_lo, s9, v8, vcc_lo v_cmp_le_i32_e32 vcc_lo, s4, v1 global_atomic_add_u32 v[7:8], v0, off s_or_b32 s3, vcc_lo, s3 s_delay_alu instid0(SALU_CYCLE_1) s_and_not1_b32 exec_lo, exec_lo, s3 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 _Z15naiveHistKernelPiiS_i .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 0 .amdhsa_next_free_vgpr 9 .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 _Z15naiveHistKernelPiiS_i, .Lfunc_end0-_Z15naiveHistKernelPiiS_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 - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .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: _Z15naiveHistKernelPiiS_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15naiveHistKernelPiiS_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 9 .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_0005b2c4_00000000-6_naiveHistKernel.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 _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i .type _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i, @function _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i: .LFB2051: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movl %esi, 20(%rsp) movq %rdx, 8(%rsp) movl %ecx, 16(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 20(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 16(%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 _Z15naiveHistKernelPiiS_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i, .-_Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i .globl _Z15naiveHistKernelPiiS_i .type _Z15naiveHistKernelPiiS_i, @function _Z15naiveHistKernelPiiS_i: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z15naiveHistKernelPiiS_iPiiS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z15naiveHistKernelPiiS_i, .-_Z15naiveHistKernelPiiS_i .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z15naiveHistKernelPiiS_i" .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 _Z15naiveHistKernelPiiS_i(%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 "naiveHistKernel.hip" .globl _Z30__device_stub__naiveHistKernelPiiS_i # -- Begin function _Z30__device_stub__naiveHistKernelPiiS_i .p2align 4, 0x90 .type _Z30__device_stub__naiveHistKernelPiiS_i,@function _Z30__device_stub__naiveHistKernelPiiS_i: # @_Z30__device_stub__naiveHistKernelPiiS_i .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movl %esi, 12(%rsp) movq %rdx, 64(%rsp) movl %ecx, 8(%rsp) leaq 72(%rsp), %rax movq %rax, 80(%rsp) leaq 12(%rsp), %rax movq %rax, 88(%rsp) leaq 64(%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 $_Z15naiveHistKernelPiiS_i, %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__naiveHistKernelPiiS_i, .Lfunc_end0-_Z30__device_stub__naiveHistKernelPiiS_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: 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 $_Z15naiveHistKernelPiiS_i, %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 _Z15naiveHistKernelPiiS_i,@object # @_Z15naiveHistKernelPiiS_i .section .rodata,"a",@progbits .globl _Z15naiveHistKernelPiiS_i .p2align 3, 0x0 _Z15naiveHistKernelPiiS_i: .quad _Z30__device_stub__naiveHistKernelPiiS_i .size _Z15naiveHistKernelPiiS_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z15naiveHistKernelPiiS_i" .size .L__unnamed_1, 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 _Z30__device_stub__naiveHistKernelPiiS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15naiveHistKernelPiiS_i .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.
/* file name: matrix_mul.cu * * matrix.cu contains two implemention of matrix multiplication in class * Each matrix size is 1024*1024 * In this program, the elapesed time is only calculating kernel time. Time periods of allocating cuda memory, data transfer and freeing cuda memory are not included. However, in your homework, you should include these overheads. * */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #define BLOCK_SIZE 16 #define TILE_WIDTH 16 /* ********************************************************************* function name: gpu_matrix_mult description: simple impliementation ********************************************************************* */ __global__ void gpu_matrix_mult(float *A, float *B, float *C, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < n && col < n) { for (int i = 0; i < n; ++i) { C[row * n + col] += A[row * n + i] * B[i * n + col]; } } } /* ********************************************************************* function name: MatrixMul_tileKernel description: Using tiling stratagy for matrix multiplication in GPU ********************************************************************* */ __global__ void MatrixMul_tileKernel(float* Md, float* Nd, float* Pd, int Width){ int Row = blockIdx.y*TILE_WIDTH + threadIdx.y; int Col = blockIdx.x*TILE_WIDTH + threadIdx.x; int tx = threadIdx.x, ty = threadIdx.y; __shared__ float a[TILE_WIDTH][TILE_WIDTH], b[TILE_WIDTH][TILE_WIDTH]; float Pvalue = 0; //Each thread computes one element of the block sub-matrix for(int k=0; k< Width/TILE_WIDTH; k++){ a[ty][tx] = Md[Row*Width+k*TILE_WIDTH+tx]; b[ty][tx] = Nd[Col+Width*(k*TILE_WIDTH + ty)]; __syncthreads(); //sync all threads in a block; for(int kk=0; kk<TILE_WIDTH; kk++) Pvalue += a[ty][kk]*b[kk][tx]; __syncthreads(); //avoid memory hazards; } Pd[Row*Width+Col] = Pvalue; } /* ********************************************************************* function name: main description: test and compare parameters: none return: none ********************************************************************* */ int main(int argc, char const *argv[]) { int n=1024; /* Fixed seed for illustration */ srand(3333); // allocate memory in host RAM float *h_a, *h_b, *h_c; cudaMallocHost((void **) &h_a, sizeof(float)*n*n); cudaMallocHost((void **) &h_b, sizeof(float)*n*n); cudaMallocHost((void **) &h_c, sizeof(float)*n*n); //generate matrix A and B for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { h_a[i * n + j] = rand() % 1024/2.3; h_b[i * n + j] = rand() % 24/3.3; } } float gpu_elapsed_time_ms; // some events to count the execution time cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); // Allocate memory space on the device float *d_a, *d_b, *d_c; cudaMalloc((void **) &d_a, sizeof(float)*n*n); cudaMalloc((void **) &d_b, sizeof(float)*n*n); cudaMalloc((void **) &d_c, sizeof(float)*n*n); // copy matrix A and B from host to device memory cudaMemcpy(d_a, h_a, sizeof(float)*n*n, cudaMemcpyHostToDevice); cudaMemcpy(d_b, h_b, sizeof(float)*n*n, cudaMemcpyHostToDevice); unsigned int grid_rows = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; unsigned int grid_cols = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; dim3 dimGrid(grid_cols, grid_rows); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE); // start to count execution time of GPU Kernel cudaEventRecord(start, 0); // Launch simple matrix multiplication kernel gpu_matrix_mult<<<dimGrid, dimBlock>>>(d_a, d_b, d_c, n); // time counting terminate cudaEventRecord(stop, 0); cudaEventSynchronize(stop); // Transefr results from device to host cudaMemcpy(h_c, d_c, sizeof(float)*n*n, cudaMemcpyDeviceToHost); // compute time elapse on GPU computing cudaEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n", gpu_elapsed_time_ms); cudaEventRecord(start, 0); // Launch tile matrix multiplication kernel MatrixMul_tileKernel<<<dimGrid, dimBlock>>>( d_a, d_b, d_c, n); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); // Transefr results from device to host cudaMemcpy(h_c, d_c, sizeof(float)*n*n, cudaMemcpyDeviceToHost); // compute time elapse on GPU kernel cudaEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n", gpu_elapsed_time_ms); // free memory cudaFree(d_a); cudaFree(d_b); cudaFree(d_c); cudaFreeHost(h_a); cudaFreeHost(h_b); cudaFreeHost(h_c); return 0; }
code for sm_80 Function : _Z20MatrixMul_tileKernelPfS_S_i .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 R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000e220000002600 */ /*0020*/ MOV R19, c[0x0][0x178] ; /* 0x00005e0000137a02 */ /* 0x000fe20000000f00 */ /*0030*/ HFMA2.MMA R3, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff037435 */ /* 0x000fe200000001ff */ /*0040*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0050*/ S2R R17, SR_TID.Y ; /* 0x0000000000117919 */ /* 0x000e220000002200 */ /*0060*/ ISETP.GE.AND P0, PT, R19, 0x10, PT ; /* 0x000000101300780c */ /* 0x000fe20003f06270 */ /*0070*/ HFMA2.MMA R23, -RZ, RZ, 0, 0 ; /* 0x00000000ff177435 */ /* 0x000fe400000001ff */ /*0080*/ S2R R7, SR_CTAID.X ; /* 0x0000000000077919 */ /* 0x000e680000002500 */ /*0090*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e620000002100 */ /*00a0*/ LEA R5, R5, R17, 0x4 ; /* 0x0000001105057211 */ /* 0x001fc400078e20ff */ /*00b0*/ LEA R2, R7, R0, 0x4 ; /* 0x0000000007027211 */ /* 0x002fca00078e20ff */ /*00c0*/ IMAD R2, R5, c[0x0][0x178], R2 ; /* 0x00005e0005027a24 */ /* 0x000fc800078e0202 */ /*00d0*/ IMAD.WIDE R2, R2, R3, c[0x0][0x170] ; /* 0x00005c0002027625 */ /* 0x000fe200078e0203 */ /*00e0*/ @!P0 BRA 0x4f0 ; /* 0x0000040000008947 */ /* 0x000fea0003800000 */ /*00f0*/ MOV R13, 0x4 ; /* 0x00000004000d7802 */ /* 0x000fe20000000f00 */ /*0100*/ IMAD R14, R5, c[0x0][0x178], R0.reuse ; /* 0x00005e00050e7a24 */ /* 0x100fe200078e0200 */ /*0110*/ SHF.R.S32.HI R5, RZ, 0x1f, R19 ; /* 0x0000001fff057819 */ /* 0x000fe20000011413 */ /*0120*/ IMAD R4, R17.reuse, c[0x0][0x178], R0 ; /* 0x00005e0011047a24 */ /* 0x040fe200078e0200 */ /*0130*/ SHF.L.U32 R17, R17, 0x6, RZ ; /* 0x0000000611117819 */ /* 0x000fe200000006ff */ /*0140*/ IMAD.WIDE R14, R14, R13, c[0x0][0x160] ; /* 0x000058000e0e7625 */ /* 0x000fe200078e020d */ /*0150*/ LEA.HI R5, R5, c[0x0][0x178], RZ, 0x4 ; /* 0x00005e0005057a11 */ /* 0x000fe200078f20ff */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ LEA R4, R7, R4, 0x4 ; /* 0x0000000407047211 */ /* 0x000fe400078e20ff */ /*0180*/ MOV R21, R15 ; /* 0x0000000f00157202 */ /* 0x000fc40000000f00 */ /*0190*/ SHF.L.U32 R19, R19, 0x4, RZ ; /* 0x0000000413137819 */ /* 0x000fe200000006ff */ /*01a0*/ IMAD.WIDE R12, R4, R13, c[0x0][0x168] ; /* 0x00005a00040c7625 */ /* 0x000fe200078e020d */ /*01b0*/ MOV R23, RZ ; /* 0x000000ff00177202 */ /* 0x000fe40000000f00 */ /*01c0*/ LEA R16, R0, R17, 0x2 ; /* 0x0000001100107211 */ /* 0x000fe400078e10ff */ /*01d0*/ SHF.R.S32.HI R15, RZ, 0x4, R5 ; /* 0x00000004ff0f7819 */ /* 0x000fe40000011405 */ /*01e0*/ MOV R20, R14 ; /* 0x0000000e00147202 */ /* 0x000fe20000000f00 */ /*01f0*/ LDG.E R24, [R12.64] ; /* 0x000000060c187981 */ /* 0x0000a8000c1e1900 */ /*0200*/ LDG.E R27, [R20.64] ; /* 0x00000006141b7981 */ /* 0x0002e2000c1e1900 */ /*0210*/ UIADD3 UR4, UR4, 0x1, URZ ; /* 0x0000000104047890 */ /* 0x000fe2000fffe03f */ /*0220*/ IADD3 R14, P1, R14, 0x40, RZ ; /* 0x000000400e0e7810 */ /* 0x000fe20007f3e0ff */ /*0230*/ IMAD.WIDE R12, R19, 0x4, R12 ; /* 0x00000004130c7825 */ /* 0x001fc800078e020c */ /*0240*/ ISETP.LE.AND P0, PT, R15, UR4, PT ; /* 0x000000040f007c0c */ /* 0x000fe4000bf03270 */ /*0250*/ IADD3.X R21, RZ, R21, RZ, P1, !PT ; /* 0x00000015ff157210 */ /* 0x002fe20000ffe4ff */ /*0260*/ STS [R16+0x400], R24 ; /* 0x0004001810007388 */ /* 0x004fe80000000800 */ /*0270*/ STS [R16], R27 ; /* 0x0000001b10007388 */ /* 0x008fe80000000800 */ /*0280*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0290*/ LDS R26, [R0.X4+0x400] ; /* 0x00040000001a7984 */ /* 0x000fe80000004800 */ /*02a0*/ LDS.128 R8, [R17] ; /* 0x0000000011087984 */ /* 0x000e280000000c00 */ /*02b0*/ LDS R28, [R0.X4+0x440] ; /* 0x00044000001c7984 */ /* 0x000e680000004800 */ /*02c0*/ LDS R29, [R0.X4+0x480] ; /* 0x00048000001d7984 */ /* 0x000ea80000004800 */ /*02d0*/ LDS R22, [R0.X4+0x4c0] ; /* 0x0004c00000167984 */ /* 0x000ee80000004800 */ /*02e0*/ LDS R25, [R0.X4+0x500] ; /* 0x0005000000197984 */ /* 0x000fe80000004800 */ /*02f0*/ LDS.128 R4, [R17+0x10] ; /* 0x0000100011047984 */ /* 0x000f280000000c00 */ /*0300*/ LDS R18, [R0.X4+0x540] ; /* 0x0005400000127984 */ /* 0x000f680000004800 */ /*0310*/ LDS R27, [R0.X4+0x580] ; /* 0x00058000001b7984 */ /* 0x000f680000004800 */ /*0320*/ LDS R20, [R0.X4+0x5c0] ; /* 0x0005c00000147984 */ /* 0x000f620000004800 */ /*0330*/ FFMA R8, R26, R8, R23 ; /* 0x000000081a087223 */ /* 0x001fc60000000017 */ /*0340*/ LDS R23, [R0.X4+0x600] ; /* 0x0006000000177984 */ /* 0x000fe20000004800 */ /*0350*/ FFMA R8, R28, R9, R8 ; /* 0x000000091c087223 */ /* 0x002fc80000000008 */ /*0360*/ FFMA R8, R29, R10, R8 ; /* 0x0000000a1d087223 */ /* 0x004fc80000000008 */ /*0370*/ FFMA R22, R22, R11, R8 ; /* 0x0000000b16167223 */ /* 0x008fe40000000008 */ /*0380*/ LDS.128 R8, [R17+0x20] ; /* 0x0000200011087984 */ /* 0x000e240000000c00 */ /*0390*/ FFMA R4, R25, R4, R22 ; /* 0x0000000419047223 */ /* 0x010fe40000000016 */ /*03a0*/ LDS R22, [R0.X4+0x640] ; /* 0x0006400000167984 */ /* 0x000e640000004800 */ /*03b0*/ FFMA R4, R18, R5, R4 ; /* 0x0000000512047223 */ /* 0x020fe40000000004 */ /*03c0*/ LDS R25, [R0.X4+0x680] ; /* 0x0006800000197984 */ /* 0x000ea40000004800 */ /*03d0*/ FFMA R4, R27, R6, R4 ; /* 0x000000061b047223 */ /* 0x000fc40000000004 */ /*03e0*/ LDS R18, [R0.X4+0x6c0] ; /* 0x0006c00000127984 */ /* 0x000ee40000004800 */ /*03f0*/ FFMA R24, R20, R7, R4 ; /* 0x0000000714187223 */ /* 0x000fe40000000004 */ /*0400*/ LDS R27, [R0.X4+0x700] ; /* 0x00070000001b7984 */ /* 0x000fe80000004800 */ /*0410*/ LDS.128 R4, [R17+0x30] ; /* 0x0000300011047984 */ /* 0x000f280000000c00 */ /*0420*/ LDS R20, [R0.X4+0x740] ; /* 0x0007400000147984 */ /* 0x000f620000004800 */ /*0430*/ FFMA R24, R23, R8, R24 ; /* 0x0000000817187223 */ /* 0x001fc60000000018 */ /*0440*/ LDS R23, [R0.X4+0x780] ; /* 0x0007800000177984 */ /* 0x000e280000004800 */ /*0450*/ LDS R8, [R0.X4+0x7c0] ; /* 0x0007c00000087984 */ /* 0x000e220000004800 */ /*0460*/ FFMA R9, R22, R9, R24 ; /* 0x0000000916097223 */ /* 0x002fc80000000018 */ /*0470*/ FFMA R9, R25, R10, R9 ; /* 0x0000000a19097223 */ /* 0x004fc80000000009 */ /*0480*/ FFMA R9, R18, R11, R9 ; /* 0x0000000b12097223 */ /* 0x008fc80000000009 */ /*0490*/ FFMA R4, R27, R4, R9 ; /* 0x000000041b047223 */ /* 0x010fc80000000009 */ /*04a0*/ FFMA R4, R20, R5, R4 ; /* 0x0000000514047223 */ /* 0x020fc80000000004 */ /*04b0*/ FFMA R23, R23, R6, R4 ; /* 0x0000000617177223 */ /* 0x001fc80000000004 */ /*04c0*/ FFMA R23, R8, R7, R23 ; /* 0x0000000708177223 */ /* 0x000fe20000000017 */ /*04d0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*04e0*/ @!P0 BRA 0x1e0 ; /* 0xfffffcf000008947 */ /* 0x000fea000383ffff */ /*04f0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x000fe2000c101906 */ /*0500*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0510*/ BRA 0x510; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0520*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0530*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0540*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0550*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0560*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0570*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0580*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0590*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*05f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : _Z15gpu_matrix_multPfS_S_i .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 R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e280000002500 */ /*0020*/ S2R R2, SR_TID.X ; /* 0x0000000000027919 */ /* 0x000e280000002100 */ /*0030*/ S2R R9, SR_CTAID.Y ; /* 0x0000000000097919 */ /* 0x000e680000002600 */ /*0040*/ S2R R0, SR_TID.Y ; /* 0x0000000000007919 */ /* 0x000e620000002200 */ /*0050*/ IMAD R5, R5, c[0x0][0x0], R2 ; /* 0x0000000005057a24 */ /* 0x001fca00078e0202 */ /*0060*/ ISETP.GE.AND P0, PT, R5, c[0x0][0x178], PT ; /* 0x00005e0005007a0c */ /* 0x000fe20003f06270 */ /*0070*/ IMAD R9, R9, c[0x0][0x4], R0 ; /* 0x0000010009097a24 */ /* 0x002fe200078e0200 */ /*0080*/ MOV R0, c[0x0][0x178] ; /* 0x00005e0000007a02 */ /* 0x000fc80000000f00 */ /*0090*/ ISETP.GE.OR P0, PT, R9, c[0x0][0x178], P0 ; /* 0x00005e0009007a0c */ /* 0x000fc80000706670 */ /*00a0*/ ISETP.LT.OR P0, PT, R0, 0x1, P0 ; /* 0x000000010000780c */ /* 0x000fda0000701670 */ /*00b0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00c0*/ IADD3 R2, R0, -0x1, RZ ; /* 0xffffffff00027810 */ /* 0x000fe20007ffe0ff */ /*00d0*/ IMAD R9, R9, c[0x0][0x178], RZ ; /* 0x00005e0009097a24 */ /* 0x000fe200078e02ff */ /*00e0*/ HFMA2.MMA R8, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff087435 */ /* 0x000fe200000001ff */ /*00f0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0100*/ ISETP.GE.U32.AND P0, PT, R2, 0x3, PT ; /* 0x000000030200780c */ /* 0x000fe40003f06070 */ /*0110*/ IADD3 R3, R5, R9, RZ ; /* 0x0000000905037210 */ /* 0x000fe40007ffe0ff */ /*0120*/ LOP3.LUT R4, R0, 0x3, RZ, 0xc0, !PT ; /* 0x0000000300047812 */ /* 0x000fe400078ec0ff */ /*0130*/ MOV R10, RZ ; /* 0x000000ff000a7202 */ /* 0x000fc40000000f00 */ /*0140*/ IMAD.WIDE R2, R3, R8, c[0x0][0x170] ; /* 0x00005c0003027625 */ /* 0x000fca00078e0208 */ /*0150*/ @!P0 BRA 0xcb0 ; /* 0x00000b5000008947 */ /* 0x000fea0003800000 */ /*0160*/ IADD3 R11, -R4, c[0x0][0x178], RZ ; /* 0x00005e00040b7a10 */ /* 0x000fe20007ffe1ff */ /*0170*/ LDG.E R15, [R2.64] ; /* 0x00000004020f7981 */ /* 0x000162000c1e1900 */ /*0180*/ ULDC.64 UR6, c[0x0][0x160] ; /* 0x0000580000067ab9 */ /* 0x000fe20000000a00 */ /*0190*/ MOV R10, RZ ; /* 0x000000ff000a7202 */ /* 0x000fe20000000f00 */ /*01a0*/ IMAD.WIDE R12, R5, R8, c[0x0][0x168] ; /* 0x00005a00050c7625 */ /* 0x000fe200078e0208 */ /*01b0*/ ISETP.GT.AND P0, PT, R11, RZ, PT ; /* 0x000000ff0b00720c */ /* 0x000fda0003f04270 */ /*01c0*/ @!P0 BRA 0xae0 ; /* 0x0000091000008947 */ /* 0x001fea0003800000 */ /*01d0*/ ISETP.GT.AND P1, PT, R11, 0xc, PT ; /* 0x0000000c0b00780c */ /* 0x000fe40003f24270 */ /*01e0*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x80, 0x0 ; /* 0x000000000000781c */ /* 0x000fd60003f0f070 */ /*01f0*/ @!P1 BRA 0x7a0 ; /* 0x000005a000009947 */ /* 0x000fea0003800000 */ /*0200*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe40003f0e170 */ /*0210*/ MOV R6, UR6 ; /* 0x0000000600067c02 */ /* 0x000fe20008000f00 */ /*0220*/ LDG.E R14, [R12.64] ; /* 0x000000040c0e7981 */ /* 0x004ea2000c1e1900 */ /*0230*/ MOV R7, UR7 ; /* 0x0000000700077c02 */ /* 0x000fca0008000f00 */ /*0240*/ IMAD.WIDE R6, R9, 0x4, R6 ; /* 0x0000000409067825 */ /* 0x000fca00078e0206 */ /*0250*/ LDG.E R16, [R6.64] ; /* 0x0000000406107981 */ /* 0x000ea4000c1e1900 */ /*0260*/ FFMA R19, R14, R16, R15 ; /* 0x000000100e137223 */ /* 0x024fe4000000000f */ /*0270*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0280*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0001e8000c101904 */ /*0290*/ LDG.E R16, [R14.64] ; /* 0x000000040e107981 */ /* 0x000ea8000c1e1900 */ /*02a0*/ LDG.E R17, [R6.64+0x4] ; /* 0x0000040406117981 */ /* 0x000ea4000c1e1900 */ /*02b0*/ FFMA R21, R16, R17, R19 ; /* 0x0000001110157223 */ /* 0x004fc40000000013 */ /*02c0*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*02d0*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0003e8000c101904 */ /*02e0*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*02f0*/ LDG.E R12, [R6.64+0x8] ; /* 0x00000804060c7981 */ /* 0x000ea4000c1e1900 */ /*0300*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x004fc40000000015 */ /*0310*/ IMAD.WIDE R12, R0, 0x4, R16 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0210 */ /*0320*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0005e8000c101904 */ /*0330*/ LDG.E R18, [R12.64] ; /* 0x000000040c127981 */ /* 0x000e28000c1e1900 */ /*0340*/ LDG.E R14, [R6.64+0xc] ; /* 0x00000c04060e7981 */ /* 0x000e24000c1e1900 */ /*0350*/ FFMA R19, R18, R14, R23 ; /* 0x0000000e12137223 */ /* 0x001fc40000000017 */ /*0360*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0370*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0001e8000c101904 */ /*0380*/ LDG.E R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000e68000c1e1900 */ /*0390*/ LDG.E R16, [R6.64+0x10] ; /* 0x0000100406107981 */ /* 0x000e64000c1e1900 */ /*03a0*/ FFMA R21, R18, R16, R19 ; /* 0x0000001012157223 */ /* 0x002fc40000000013 */ /*03b0*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*03c0*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0003e8000c101904 */ /*03d0*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*03e0*/ LDG.E R12, [R6.64+0x14] ; /* 0x00001404060c7981 */ /* 0x000ea4000c1e1900 */ /*03f0*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x004fc40000000015 */ /*0400*/ IMAD.WIDE R12, R0, 0x4, R16 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0210 */ /*0410*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0005e8000c101904 */ /*0420*/ LDG.E R18, [R12.64] ; /* 0x000000040c127981 */ /* 0x000e28000c1e1900 */ /*0430*/ LDG.E R14, [R6.64+0x18] ; /* 0x00001804060e7981 */ /* 0x000e24000c1e1900 */ /*0440*/ FFMA R19, R18, R14, R23 ; /* 0x0000000e12137223 */ /* 0x001fc40000000017 */ /*0450*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0460*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0001e8000c101904 */ /*0470*/ LDG.E R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000e68000c1e1900 */ /*0480*/ LDG.E R16, [R6.64+0x1c] ; /* 0x00001c0406107981 */ /* 0x000e64000c1e1900 */ /*0490*/ FFMA R21, R18, R16, R19 ; /* 0x0000001012157223 */ /* 0x002fc40000000013 */ /*04a0*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*04b0*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0003e8000c101904 */ /*04c0*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*04d0*/ LDG.E R12, [R6.64+0x20] ; /* 0x00002004060c7981 */ /* 0x000ea4000c1e1900 */ /*04e0*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x004fc40000000015 */ /*04f0*/ IMAD.WIDE R12, R0, 0x4, R16 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0210 */ /*0500*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0005e8000c101904 */ /*0510*/ LDG.E R18, [R12.64] ; /* 0x000000040c127981 */ /* 0x000e28000c1e1900 */ /*0520*/ LDG.E R14, [R6.64+0x24] ; /* 0x00002404060e7981 */ /* 0x000e24000c1e1900 */ /*0530*/ FFMA R19, R18, R14, R23 ; /* 0x0000000e12137223 */ /* 0x001fc40000000017 */ /*0540*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0550*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x000fe8000c101904 */ /*0560*/ LDG.E R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000e68000c1e1900 */ /*0570*/ LDG.E R16, [R6.64+0x28] ; /* 0x0000280406107981 */ /* 0x000e64000c1e1900 */ /*0580*/ FFMA R21, R18, R16, R19 ; /* 0x0000001012157223 */ /* 0x002fc40000000013 */ /*0590*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*05a0*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0001e8000c101904 */ /*05b0*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*05c0*/ LDG.E R12, [R6.64+0x2c] ; /* 0x00002c04060c7981 */ /* 0x000ea4000c1e1900 */ /*05d0*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x004fc40000000015 */ /*05e0*/ IMAD.WIDE R12, R0, 0x4, R16 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0210 */ /*05f0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0003e8000c101904 */ /*0600*/ LDG.E R18, [R12.64] ; /* 0x000000040c127981 */ /* 0x000ea8000c1e1900 */ /*0610*/ LDG.E R14, [R6.64+0x30] ; /* 0x00003004060e7981 */ /* 0x000ea4000c1e1900 */ /*0620*/ FFMA R25, R18, R14, R23 ; /* 0x0000000e12197223 */ /* 0x004fc40000000017 */ /*0630*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0640*/ STG.E [R2.64], R25 ; /* 0x0000001902007986 */ /* 0x0005e8000c101904 */ /*0650*/ LDG.E R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000e28000c1e1900 */ /*0660*/ LDG.E R16, [R6.64+0x34] ; /* 0x0000340406107981 */ /* 0x000e24000c1e1900 */ /*0670*/ FFMA R21, R18, R16, R25 ; /* 0x0000001012157223 */ /* 0x001fc40000000019 */ /*0680*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*0690*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0005e8000c101904 */ /*06a0*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000e68000c1e1900 */ /*06b0*/ LDG.E R12, [R6.64+0x38] ; /* 0x00003804060c7981 */ /* 0x000e62000c1e1900 */ /*06c0*/ IADD3 R11, R11, -0x10, RZ ; /* 0xfffffff00b0b7810 */ /* 0x000fe20007ffe0ff */ /*06d0*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x002fc40000000015 */ /*06e0*/ IMAD.WIDE R18, R0, 0x4, R16 ; /* 0x0000000400127825 */ /* 0x000fc600078e0210 */ /*06f0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0005e8000c101904 */ /*0700*/ LDG.E R13, [R6.64+0x3c] ; /* 0x00003c04060d7981 */ /* 0x000ee8000c1e1900 */ /*0710*/ LDG.E R12, [R18.64] ; /* 0x00000004120c7981 */ /* 0x000ee2000c1e1900 */ /*0720*/ ISETP.GT.AND P1, PT, R11, 0xc, PT ; /* 0x0000000c0b00780c */ /* 0x000fe20003f24270 */ /*0730*/ UIADD3 UR6, UP0, UR6, 0x40, URZ ; /* 0x0000004006067890 */ /* 0x000fe2000ff1e03f */ /*0740*/ IADD3 R10, R10, 0x10, RZ ; /* 0x000000100a0a7810 */ /* 0x000fc60007ffe0ff */ /*0750*/ UIADD3.X UR7, URZ, UR7, URZ, UP0, !UPT ; /* 0x000000073f077290 */ /* 0x000fe200087fe43f */ /*0760*/ FFMA R15, R12, R13, R23 ; /* 0x0000000d0c0f7223 */ /* 0x008fe40000000017 */ /*0770*/ IMAD.WIDE R12, R0, 0x4, R18 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0212 */ /*0780*/ STG.E [R2.64], R15 ; /* 0x0000000f02007986 */ /* 0x0005e4000c101904 */ /*0790*/ @P1 BRA 0x210 ; /* 0xfffffa7000001947 */ /* 0x000fea000383ffff */ /*07a0*/ ISETP.GT.AND P1, PT, R11, 0x4, PT ; /* 0x000000040b00780c */ /* 0x000fda0003f24270 */ /*07b0*/ @!P1 BRA 0xac0 ; /* 0x0000030000009947 */ /* 0x000fea0003800000 */ /*07c0*/ MOV R6, UR6 ; /* 0x0000000600067c02 */ /* 0x000fe20008000f00 */ /*07d0*/ LDG.E R14, [R12.64] ; /* 0x000000040c0e7981 */ /* 0x000ee2000c1e1900 */ /*07e0*/ MOV R7, UR7 ; /* 0x0000000700077c02 */ /* 0x000fca0008000f00 */ /*07f0*/ IMAD.WIDE R6, R9, 0x4, R6 ; /* 0x0000000409067825 */ /* 0x000fca00078e0206 */ /*0800*/ LDG.E R16, [R6.64] ; /* 0x0000000406107981 */ /* 0x000ee4000c1e1900 */ /*0810*/ FFMA R19, R14, R16, R15 ; /* 0x000000100e137223 */ /* 0x028fe4000000000f */ /*0820*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x004fc600078e020c */ /*0830*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0001e8000c101904 */ /*0840*/ LDG.E R16, [R14.64] ; /* 0x000000040e107981 */ /* 0x000ea8000c1e1900 */ /*0850*/ LDG.E R17, [R6.64+0x4] ; /* 0x0000040406117981 */ /* 0x000ea4000c1e1900 */ /*0860*/ FFMA R21, R16, R17, R19 ; /* 0x0000001110157223 */ /* 0x004fc40000000013 */ /*0870*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*0880*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0003e8000c101904 */ /*0890*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*08a0*/ LDG.E R12, [R6.64+0x8] ; /* 0x00000804060c7981 */ /* 0x000ea4000c1e1900 */ /*08b0*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x004fc40000000015 */ /*08c0*/ IMAD.WIDE R12, R0, 0x4, R16 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0210 */ /*08d0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0005e8000c101904 */ /*08e0*/ LDG.E R18, [R12.64] ; /* 0x000000040c127981 */ /* 0x000e28000c1e1900 */ /*08f0*/ LDG.E R14, [R6.64+0xc] ; /* 0x00000c04060e7981 */ /* 0x000e24000c1e1900 */ /*0900*/ FFMA R19, R18, R14, R23 ; /* 0x0000000e12137223 */ /* 0x001fc40000000017 */ /*0910*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0920*/ STG.E [R2.64], R19 ; /* 0x0000001302007986 */ /* 0x0001e8000c101904 */ /*0930*/ LDG.E R18, [R14.64] ; /* 0x000000040e127981 */ /* 0x000e68000c1e1900 */ /*0940*/ LDG.E R16, [R6.64+0x10] ; /* 0x0000100406107981 */ /* 0x000e64000c1e1900 */ /*0950*/ FFMA R21, R18, R16, R19 ; /* 0x0000001012157223 */ /* 0x002fc40000000013 */ /*0960*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*0970*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0003e8000c101904 */ /*0980*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*0990*/ LDG.E R12, [R6.64+0x14] ; /* 0x00001404060c7981 */ /* 0x000ea4000c1e1900 */ /*09a0*/ FFMA R23, R18, R12, R21 ; /* 0x0000000c12177223 */ /* 0x004fc40000000015 */ /*09b0*/ IMAD.WIDE R12, R0, 0x4, R16 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0210 */ /*09c0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0003e8000c101904 */ /*09d0*/ LDG.E R18, [R12.64] ; /* 0x000000040c127981 */ /* 0x000ea8000c1e1900 */ /*09e0*/ LDG.E R14, [R6.64+0x18] ; /* 0x00001804060e7981 */ /* 0x000ea4000c1e1900 */ /*09f0*/ FFMA R25, R18, R14, R23 ; /* 0x0000000e12197223 */ /* 0x004fc40000000017 */ /*0a00*/ IMAD.WIDE R18, R0, 0x4, R12 ; /* 0x0000000400127825 */ /* 0x001fc600078e020c */ /*0a10*/ STG.E [R2.64], R25 ; /* 0x0000001902007986 */ /* 0x0003e8000c101904 */ /*0a20*/ LDG.E R15, [R6.64+0x1c] ; /* 0x00001c04060f7981 */ /* 0x000ea8000c1e1900 */ /*0a30*/ LDG.E R14, [R18.64] ; /* 0x00000004120e7981 */ /* 0x000ea2000c1e1900 */ /*0a40*/ UIADD3 UR6, UP0, UR6, 0x20, URZ ; /* 0x0000002006067890 */ /* 0x000fe2000ff1e03f */ /*0a50*/ PLOP3.LUT P0, PT, PT, PT, PT, 0x8, 0x0 ; /* 0x000000000000781c */ /* 0x000fe20003f0e170 */ /*0a60*/ IMAD.WIDE R12, R0, 0x4, R18 ; /* 0x00000004000c7825 */ /* 0x000fe200078e0212 */ /*0a70*/ IADD3 R10, R10, 0x8, RZ ; /* 0x000000080a0a7810 */ /* 0x000fc40007ffe0ff */ /*0a80*/ IADD3 R11, R11, -0x8, RZ ; /* 0xfffffff80b0b7810 */ /* 0x000fe20007ffe0ff */ /*0a90*/ UIADD3.X UR7, URZ, UR7, URZ, UP0, !UPT ; /* 0x000000073f077290 */ /* 0x000fe200087fe43f */ /*0aa0*/ FFMA R15, R14, R15, R25 ; /* 0x0000000f0e0f7223 */ /* 0x004fca0000000019 */ /*0ab0*/ STG.E [R2.64], R15 ; /* 0x0000000f02007986 */ /* 0x0003e8000c101904 */ /*0ac0*/ ISETP.NE.OR P0, PT, R11, RZ, P0 ; /* 0x000000ff0b00720c */ /* 0x000fda0000705670 */ /*0ad0*/ @!P0 BRA 0xcb0 ; /* 0x000001d000008947 */ /* 0x000fea0003800000 */ /*0ae0*/ MOV R6, UR6 ; /* 0x0000000600067c02 */ /* 0x000fe20008000f00 */ /*0af0*/ LDG.E R14, [R12.64] ; /* 0x000000040c0e7981 */ /* 0x000ee2000c1e1900 */ /*0b00*/ MOV R7, UR7 ; /* 0x0000000700077c02 */ /* 0x000fca0008000f00 */ /*0b10*/ IMAD.WIDE R6, R9, 0x4, R6 ; /* 0x0000000409067825 */ /* 0x000fca00078e0206 */ /*0b20*/ LDG.E R16, [R6.64] ; /* 0x0000000406107981 */ /* 0x000ee4000c1e1900 */ /*0b30*/ FFMA R21, R14, R16, R15 ; /* 0x000000100e157223 */ /* 0x02efe4000000000f */ /*0b40*/ IMAD.WIDE R14, R0, 0x4, R12 ; /* 0x00000004000e7825 */ /* 0x000fc600078e020c */ /*0b50*/ STG.E [R2.64], R21 ; /* 0x0000001502007986 */ /* 0x0001e8000c101904 */ /*0b60*/ LDG.E R16, [R14.64] ; /* 0x000000040e107981 */ /* 0x000ea8000c1e1900 */ /*0b70*/ LDG.E R17, [R6.64+0x4] ; /* 0x0000040406117981 */ /* 0x000ea4000c1e1900 */ /*0b80*/ FFMA R23, R16, R17, R21 ; /* 0x0000001110177223 */ /* 0x004fc40000000015 */ /*0b90*/ IMAD.WIDE R16, R0, 0x4, R14 ; /* 0x0000000400107825 */ /* 0x000fc600078e020e */ /*0ba0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x0001e8000c101904 */ /*0bb0*/ LDG.E R18, [R16.64] ; /* 0x0000000410127981 */ /* 0x000ea8000c1e1900 */ /*0bc0*/ LDG.E R12, [R6.64+0x8] ; /* 0x00000804060c7981 */ /* 0x000ea2000c1e1900 */ /*0bd0*/ IADD3 R11, R11, -0x4, RZ ; /* 0xfffffffc0b0b7810 */ /* 0x000fe20007ffe0ff */ /*0be0*/ FFMA R25, R18, R12, R23 ; /* 0x0000000c12197223 */ /* 0x004fc40000000017 */ /*0bf0*/ IMAD.WIDE R18, R0, 0x4, R16 ; /* 0x0000000400127825 */ /* 0x000fc600078e0210 */ /*0c00*/ STG.E [R2.64], R25 ; /* 0x0000001902007986 */ /* 0x0001e8000c101904 */ /*0c10*/ LDG.E R13, [R6.64+0xc] ; /* 0x00000c04060d7981 */ /* 0x000ea8000c1e1900 */ /*0c20*/ LDG.E R12, [R18.64] ; /* 0x00000004120c7981 */ /* 0x000ea2000c1e1900 */ /*0c30*/ ISETP.NE.AND P0, PT, R11, RZ, PT ; /* 0x000000ff0b00720c */ /* 0x000fe20003f05270 */ /*0c40*/ UIADD3 UR6, UP0, UR6, 0x10, URZ ; /* 0x0000001006067890 */ /* 0x000fe2000ff1e03f */ /*0c50*/ IADD3 R10, R10, 0x4, RZ ; /* 0x000000040a0a7810 */ /* 0x000fc60007ffe0ff */ /*0c60*/ UIADD3.X UR7, URZ, UR7, URZ, UP0, !UPT ; /* 0x000000073f077290 */ /* 0x000fe200087fe43f */ /*0c70*/ FFMA R15, R12, R13, R25 ; /* 0x0000000d0c0f7223 */ /* 0x004fe40000000019 */ /*0c80*/ IMAD.WIDE R12, R0, 0x4, R18 ; /* 0x00000004000c7825 */ /* 0x000fc600078e0212 */ /*0c90*/ STG.E [R2.64], R15 ; /* 0x0000000f02007986 */ /* 0x0001e4000c101904 */ /*0ca0*/ @P0 BRA 0xae0 ; /* 0xfffffe3000000947 */ /* 0x001fea000383ffff */ /*0cb0*/ ISETP.NE.AND P0, PT, R4, RZ, PT ; /* 0x000000ff0400720c */ /* 0x000fda0003f05270 */ /*0cc0*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*0cd0*/ LDG.E R11, [R2.64] ; /* 0x00000004020b7981 */ /* 0x000162000c1e1900 */ /*0ce0*/ IADD3 R7, R9, R10, RZ ; /* 0x0000000a09077210 */ /* 0x000fe20007ffe0ff */ /*0cf0*/ IMAD R5, R10, c[0x0][0x178], R5 ; /* 0x00005e000a057a24 */ /* 0x000fc800078e0205 */ /*0d00*/ IMAD.WIDE R6, R7, R8, c[0x0][0x160] ; /* 0x0000580007067625 */ /* 0x000fc800078e0208 */ /*0d10*/ IMAD.WIDE R8, R5, R8, c[0x0][0x168] ; /* 0x00005a0005087625 */ /* 0x001fca00078e0208 */ /*0d20*/ LDG.E R10, [R8.64] ; /* 0x00000004080a7981 */ /* 0x0010e8000c1e1900 */ /*0d30*/ LDG.E R5, [R6.64] ; /* 0x0000000406057981 */ /* 0x0008e2000c1e1900 */ /*0d40*/ IADD3 R4, R4, -0x1, RZ ; /* 0xffffffff04047810 */ /* 0x000fc80007ffe0ff */ /*0d50*/ ISETP.NE.AND P0, PT, R4, RZ, PT ; /* 0x000000ff0400720c */ /* 0x000fe20003f05270 */ /*0d60*/ IMAD.WIDE R8, R0, 0x4, R8 ; /* 0x0000000400087825 */ /* 0x001fe200078e0208 */ /*0d70*/ IADD3 R6, P1, R6, 0x4, RZ ; /* 0x0000000406067810 */ /* 0x010fc80007f3e0ff */ /*0d80*/ IADD3.X R7, RZ, R7, RZ, P1, !PT ; /* 0x00000007ff077210 */ /* 0x000fe20000ffe4ff */ /*0d90*/ FFMA R11, R10, R5, R11 ; /* 0x000000050a0b7223 */ /* 0x028fca000000000b */ /*0da0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x0001e2000c101904 */ /*0db0*/ @P0 BRA 0xd20 ; /* 0xffffff6000000947 */ /* 0x000fea000383ffff */ /*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.
/* file name: matrix_mul.cu * * matrix.cu contains two implemention of matrix multiplication in class * Each matrix size is 1024*1024 * In this program, the elapesed time is only calculating kernel time. Time periods of allocating cuda memory, data transfer and freeing cuda memory are not included. However, in your homework, you should include these overheads. * */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #define BLOCK_SIZE 16 #define TILE_WIDTH 16 /* ********************************************************************* function name: gpu_matrix_mult description: simple impliementation ********************************************************************* */ __global__ void gpu_matrix_mult(float *A, float *B, float *C, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < n && col < n) { for (int i = 0; i < n; ++i) { C[row * n + col] += A[row * n + i] * B[i * n + col]; } } } /* ********************************************************************* function name: MatrixMul_tileKernel description: Using tiling stratagy for matrix multiplication in GPU ********************************************************************* */ __global__ void MatrixMul_tileKernel(float* Md, float* Nd, float* Pd, int Width){ int Row = blockIdx.y*TILE_WIDTH + threadIdx.y; int Col = blockIdx.x*TILE_WIDTH + threadIdx.x; int tx = threadIdx.x, ty = threadIdx.y; __shared__ float a[TILE_WIDTH][TILE_WIDTH], b[TILE_WIDTH][TILE_WIDTH]; float Pvalue = 0; //Each thread computes one element of the block sub-matrix for(int k=0; k< Width/TILE_WIDTH; k++){ a[ty][tx] = Md[Row*Width+k*TILE_WIDTH+tx]; b[ty][tx] = Nd[Col+Width*(k*TILE_WIDTH + ty)]; __syncthreads(); //sync all threads in a block; for(int kk=0; kk<TILE_WIDTH; kk++) Pvalue += a[ty][kk]*b[kk][tx]; __syncthreads(); //avoid memory hazards; } Pd[Row*Width+Col] = Pvalue; } /* ********************************************************************* function name: main description: test and compare parameters: none return: none ********************************************************************* */ int main(int argc, char const *argv[]) { int n=1024; /* Fixed seed for illustration */ srand(3333); // allocate memory in host RAM float *h_a, *h_b, *h_c; cudaMallocHost((void **) &h_a, sizeof(float)*n*n); cudaMallocHost((void **) &h_b, sizeof(float)*n*n); cudaMallocHost((void **) &h_c, sizeof(float)*n*n); //generate matrix A and B for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { h_a[i * n + j] = rand() % 1024/2.3; h_b[i * n + j] = rand() % 24/3.3; } } float gpu_elapsed_time_ms; // some events to count the execution time cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); // Allocate memory space on the device float *d_a, *d_b, *d_c; cudaMalloc((void **) &d_a, sizeof(float)*n*n); cudaMalloc((void **) &d_b, sizeof(float)*n*n); cudaMalloc((void **) &d_c, sizeof(float)*n*n); // copy matrix A and B from host to device memory cudaMemcpy(d_a, h_a, sizeof(float)*n*n, cudaMemcpyHostToDevice); cudaMemcpy(d_b, h_b, sizeof(float)*n*n, cudaMemcpyHostToDevice); unsigned int grid_rows = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; unsigned int grid_cols = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; dim3 dimGrid(grid_cols, grid_rows); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE); // start to count execution time of GPU Kernel cudaEventRecord(start, 0); // Launch simple matrix multiplication kernel gpu_matrix_mult<<<dimGrid, dimBlock>>>(d_a, d_b, d_c, n); // time counting terminate cudaEventRecord(stop, 0); cudaEventSynchronize(stop); // Transefr results from device to host cudaMemcpy(h_c, d_c, sizeof(float)*n*n, cudaMemcpyDeviceToHost); // compute time elapse on GPU computing cudaEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n", gpu_elapsed_time_ms); cudaEventRecord(start, 0); // Launch tile matrix multiplication kernel MatrixMul_tileKernel<<<dimGrid, dimBlock>>>( d_a, d_b, d_c, n); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); // Transefr results from device to host cudaMemcpy(h_c, d_c, sizeof(float)*n*n, cudaMemcpyDeviceToHost); // compute time elapse on GPU kernel cudaEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n", gpu_elapsed_time_ms); // free memory cudaFree(d_a); cudaFree(d_b); cudaFree(d_c); cudaFreeHost(h_a); cudaFreeHost(h_b); cudaFreeHost(h_c); return 0; }
.file "tmpxft_00149ffc_00000000-6_test.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 _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i .type _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i, @function _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i: .LFB2082: .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 _Z15gpu_matrix_multPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i, .-_Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i .globl _Z15gpu_matrix_multPfS_S_i .type _Z15gpu_matrix_multPfS_S_i, @function _Z15gpu_matrix_multPfS_S_i: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z15gpu_matrix_multPfS_S_i, .-_Z15gpu_matrix_multPfS_S_i .globl _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i .type _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i, @function _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i: .LFB2084: .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 .L15 .L11: movq 136(%rsp), %rax subq %fs:40, %rax jne .L16 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .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 _Z20MatrixMul_tileKernelPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L11 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i, .-_Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i .globl _Z20MatrixMul_tileKernelPfS_S_i .type _Z20MatrixMul_tileKernelPfS_S_i, @function _Z20MatrixMul_tileKernelPfS_S_i: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z20MatrixMul_tileKernelPfS_S_i, .-_Z20MatrixMul_tileKernelPfS_S_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC2: .string "Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n" .align 8 .LC3: .string "Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\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 subq $120, %rsp .cfi_def_cfa_offset 144 movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax movl $3333, %edi call srand@PLT leaq 16(%rsp), %rdi movl $4194304, %esi call cudaMallocHost@PLT leaq 24(%rsp), %rdi movl $4194304, %esi call cudaMallocHost@PLT leaq 32(%rsp), %rdi movl $4194304, %esi call cudaMallocHost@PLT movl $4096, %ebp .L20: leaq -4096(%rbp), %rbx .L21: call rand@PLT cltd shrl $22, %edx addl %edx, %eax andl $1023, %eax subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2sdl %eax, %xmm0 divsd .LC0(%rip), %xmm0 cvtsd2ss %xmm0, %xmm0 movq 16(%rsp), %rax movss %xmm0, (%rax,%rbx) call rand@PLT movslq %eax, %rdx imulq $715827883, %rdx, %rdx sarq $34, %rdx movl %eax, %ecx sarl $31, %ecx subl %ecx, %edx leal (%rdx,%rdx,2), %edx sall $3, %edx subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2sdl %eax, %xmm0 divsd .LC1(%rip), %xmm0 cvtsd2ss %xmm0, %xmm0 movq 24(%rsp), %rax movss %xmm0, (%rax,%rbx) addq $4, %rbx cmpq %rbp, %rbx jne .L21 addq $4096, %rbp cmpq $4198400, %rbp jne .L20 leaq 40(%rsp), %rdi call cudaEventCreate@PLT leaq 48(%rsp), %rdi call cudaEventCreate@PLT leaq 56(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 64(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 72(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT movl $1, %ecx movl $4194304, %edx movq 16(%rsp), %rsi movq 56(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $4194304, %edx movq 24(%rsp), %rsi movq 64(%rsp), %rdi call cudaMemcpy@PLT movl $64, 80(%rsp) movl $64, 84(%rsp) movl $1, 88(%rsp) movl $16, 92(%rsp) movl $16, 96(%rsp) movl $1, 100(%rsp) movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movl 100(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 92(%rsp), %rdx movq 80(%rsp), %rdi movl 88(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L28 .L23: movl $0, %esi movq 48(%rsp), %rdi call cudaEventRecord@PLT movq 48(%rsp), %rdi call cudaEventSynchronize@PLT movl $2, %ecx movl $4194304, %edx movq 72(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT leaq 12(%rsp), %rdi movq 48(%rsp), %rdx movq 40(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 12(%rsp), %xmm0 leaq .LC2(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movl 100(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 92(%rsp), %rdx movq 80(%rsp), %rdi movl 88(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L29 .L24: movl $0, %esi movq 48(%rsp), %rdi call cudaEventRecord@PLT movq 48(%rsp), %rdi call cudaEventSynchronize@PLT movl $2, %ecx movl $4194304, %edx movq 72(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT leaq 12(%rsp), %rdi movq 48(%rsp), %rdx movq 40(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 12(%rsp), %xmm0 leaq .LC3(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 56(%rsp), %rdi call cudaFree@PLT movq 64(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFreeHost@PLT movq 24(%rsp), %rdi call cudaFreeHost@PLT movq 32(%rsp), %rdi call cudaFreeHost@PLT movq 104(%rsp), %rax subq %fs:40, %rax jne .L30 movl $0, %eax addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L28: .cfi_restore_state movl $1024, %ecx movq 72(%rsp), %rdx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i jmp .L23 .L29: movl $1024, %ecx movq 72(%rsp), %rdx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i jmp .L24 .L30: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.8 .align 8 .LC4: .string "_Z20MatrixMul_tileKernelPfS_S_i" .section .rodata.str1.1,"aMS",@progbits,1 .LC5: .string "_Z15gpu_matrix_multPfS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2087: .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 .LC4(%rip), %rdx movq %rdx, %rcx leaq _Z20MatrixMul_tileKernelPfS_S_i(%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 .LC5(%rip), %rdx movq %rdx, %rcx leaq _Z15gpu_matrix_multPfS_S_i(%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 .LFE2087: .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 .LC0: .long 1717986918 .long 1073899110 .align 8 .LC1: .long 1717986918 .long 1074423398 .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.
/* file name: matrix_mul.cu * * matrix.cu contains two implemention of matrix multiplication in class * Each matrix size is 1024*1024 * In this program, the elapesed time is only calculating kernel time. Time periods of allocating cuda memory, data transfer and freeing cuda memory are not included. However, in your homework, you should include these overheads. * */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #define BLOCK_SIZE 16 #define TILE_WIDTH 16 /* ********************************************************************* function name: gpu_matrix_mult description: simple impliementation ********************************************************************* */ __global__ void gpu_matrix_mult(float *A, float *B, float *C, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < n && col < n) { for (int i = 0; i < n; ++i) { C[row * n + col] += A[row * n + i] * B[i * n + col]; } } } /* ********************************************************************* function name: MatrixMul_tileKernel description: Using tiling stratagy for matrix multiplication in GPU ********************************************************************* */ __global__ void MatrixMul_tileKernel(float* Md, float* Nd, float* Pd, int Width){ int Row = blockIdx.y*TILE_WIDTH + threadIdx.y; int Col = blockIdx.x*TILE_WIDTH + threadIdx.x; int tx = threadIdx.x, ty = threadIdx.y; __shared__ float a[TILE_WIDTH][TILE_WIDTH], b[TILE_WIDTH][TILE_WIDTH]; float Pvalue = 0; //Each thread computes one element of the block sub-matrix for(int k=0; k< Width/TILE_WIDTH; k++){ a[ty][tx] = Md[Row*Width+k*TILE_WIDTH+tx]; b[ty][tx] = Nd[Col+Width*(k*TILE_WIDTH + ty)]; __syncthreads(); //sync all threads in a block; for(int kk=0; kk<TILE_WIDTH; kk++) Pvalue += a[ty][kk]*b[kk][tx]; __syncthreads(); //avoid memory hazards; } Pd[Row*Width+Col] = Pvalue; } /* ********************************************************************* function name: main description: test and compare parameters: none return: none ********************************************************************* */ int main(int argc, char const *argv[]) { int n=1024; /* Fixed seed for illustration */ srand(3333); // allocate memory in host RAM float *h_a, *h_b, *h_c; cudaMallocHost((void **) &h_a, sizeof(float)*n*n); cudaMallocHost((void **) &h_b, sizeof(float)*n*n); cudaMallocHost((void **) &h_c, sizeof(float)*n*n); //generate matrix A and B for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { h_a[i * n + j] = rand() % 1024/2.3; h_b[i * n + j] = rand() % 24/3.3; } } float gpu_elapsed_time_ms; // some events to count the execution time cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); // Allocate memory space on the device float *d_a, *d_b, *d_c; cudaMalloc((void **) &d_a, sizeof(float)*n*n); cudaMalloc((void **) &d_b, sizeof(float)*n*n); cudaMalloc((void **) &d_c, sizeof(float)*n*n); // copy matrix A and B from host to device memory cudaMemcpy(d_a, h_a, sizeof(float)*n*n, cudaMemcpyHostToDevice); cudaMemcpy(d_b, h_b, sizeof(float)*n*n, cudaMemcpyHostToDevice); unsigned int grid_rows = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; unsigned int grid_cols = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; dim3 dimGrid(grid_cols, grid_rows); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE); // start to count execution time of GPU Kernel cudaEventRecord(start, 0); // Launch simple matrix multiplication kernel gpu_matrix_mult<<<dimGrid, dimBlock>>>(d_a, d_b, d_c, n); // time counting terminate cudaEventRecord(stop, 0); cudaEventSynchronize(stop); // Transefr results from device to host cudaMemcpy(h_c, d_c, sizeof(float)*n*n, cudaMemcpyDeviceToHost); // compute time elapse on GPU computing cudaEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n", gpu_elapsed_time_ms); cudaEventRecord(start, 0); // Launch tile matrix multiplication kernel MatrixMul_tileKernel<<<dimGrid, dimBlock>>>( d_a, d_b, d_c, n); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); // Transefr results from device to host cudaMemcpy(h_c, d_c, sizeof(float)*n*n, cudaMemcpyDeviceToHost); // compute time elapse on GPU kernel cudaEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n", gpu_elapsed_time_ms); // free memory cudaFree(d_a); cudaFree(d_b); cudaFree(d_c); cudaFreeHost(h_a); cudaFreeHost(h_b); cudaFreeHost(h_c); return 0; }
/* file name: matrix_mul.cu * * matrix.cu contains two implemention of matrix multiplication in class * Each matrix size is 1024*1024 * In this program, the elapesed time is only calculating kernel time. Time periods of allocating cuda memory, data transfer and freeing cuda memory are not included. However, in your homework, you should include these overheads. * */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #define BLOCK_SIZE 16 #define TILE_WIDTH 16 /* ********************************************************************* function name: gpu_matrix_mult description: simple impliementation ********************************************************************* */ __global__ void gpu_matrix_mult(float *A, float *B, float *C, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < n && col < n) { for (int i = 0; i < n; ++i) { C[row * n + col] += A[row * n + i] * B[i * n + col]; } } } /* ********************************************************************* function name: MatrixMul_tileKernel description: Using tiling stratagy for matrix multiplication in GPU ********************************************************************* */ __global__ void MatrixMul_tileKernel(float* Md, float* Nd, float* Pd, int Width){ int Row = blockIdx.y*TILE_WIDTH + threadIdx.y; int Col = blockIdx.x*TILE_WIDTH + threadIdx.x; int tx = threadIdx.x, ty = threadIdx.y; __shared__ float a[TILE_WIDTH][TILE_WIDTH], b[TILE_WIDTH][TILE_WIDTH]; float Pvalue = 0; //Each thread computes one element of the block sub-matrix for(int k=0; k< Width/TILE_WIDTH; k++){ a[ty][tx] = Md[Row*Width+k*TILE_WIDTH+tx]; b[ty][tx] = Nd[Col+Width*(k*TILE_WIDTH + ty)]; __syncthreads(); //sync all threads in a block; for(int kk=0; kk<TILE_WIDTH; kk++) Pvalue += a[ty][kk]*b[kk][tx]; __syncthreads(); //avoid memory hazards; } Pd[Row*Width+Col] = Pvalue; } /* ********************************************************************* function name: main description: test and compare parameters: none return: none ********************************************************************* */ int main(int argc, char const *argv[]) { int n=1024; /* Fixed seed for illustration */ srand(3333); // allocate memory in host RAM float *h_a, *h_b, *h_c; hipHostMalloc((void **) &h_a, sizeof(float)*n*n, hipHostMallocDefault); hipHostMalloc((void **) &h_b, sizeof(float)*n*n, hipHostMallocDefault); hipHostMalloc((void **) &h_c, sizeof(float)*n*n, hipHostMallocDefault); //generate matrix A and B for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { h_a[i * n + j] = rand() % 1024/2.3; h_b[i * n + j] = rand() % 24/3.3; } } float gpu_elapsed_time_ms; // some events to count the execution time hipEvent_t start, stop; hipEventCreate(&start); hipEventCreate(&stop); // Allocate memory space on the device float *d_a, *d_b, *d_c; hipMalloc((void **) &d_a, sizeof(float)*n*n); hipMalloc((void **) &d_b, sizeof(float)*n*n); hipMalloc((void **) &d_c, sizeof(float)*n*n); // copy matrix A and B from host to device memory hipMemcpy(d_a, h_a, sizeof(float)*n*n, hipMemcpyHostToDevice); hipMemcpy(d_b, h_b, sizeof(float)*n*n, hipMemcpyHostToDevice); unsigned int grid_rows = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; unsigned int grid_cols = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; dim3 dimGrid(grid_cols, grid_rows); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE); // start to count execution time of GPU Kernel hipEventRecord(start, 0); // Launch simple matrix multiplication kernel gpu_matrix_mult<<<dimGrid, dimBlock>>>(d_a, d_b, d_c, n); // time counting terminate hipEventRecord(stop, 0); hipEventSynchronize(stop); // Transefr results from device to host hipMemcpy(h_c, d_c, sizeof(float)*n*n, hipMemcpyDeviceToHost); // compute time elapse on GPU computing hipEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n", gpu_elapsed_time_ms); hipEventRecord(start, 0); // Launch tile matrix multiplication kernel MatrixMul_tileKernel<<<dimGrid, dimBlock>>>( d_a, d_b, d_c, n); hipEventRecord(stop, 0); hipEventSynchronize(stop); // Transefr results from device to host hipMemcpy(h_c, d_c, sizeof(float)*n*n, hipMemcpyDeviceToHost); // compute time elapse on GPU kernel hipEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n", gpu_elapsed_time_ms); // free memory hipFree(d_a); hipFree(d_b); hipFree(d_c); hipHostFree(h_a); hipHostFree(h_b); hipHostFree(h_c); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/* file name: matrix_mul.cu * * matrix.cu contains two implemention of matrix multiplication in class * Each matrix size is 1024*1024 * In this program, the elapesed time is only calculating kernel time. Time periods of allocating cuda memory, data transfer and freeing cuda memory are not included. However, in your homework, you should include these overheads. * */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #define BLOCK_SIZE 16 #define TILE_WIDTH 16 /* ********************************************************************* function name: gpu_matrix_mult description: simple impliementation ********************************************************************* */ __global__ void gpu_matrix_mult(float *A, float *B, float *C, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < n && col < n) { for (int i = 0; i < n; ++i) { C[row * n + col] += A[row * n + i] * B[i * n + col]; } } } /* ********************************************************************* function name: MatrixMul_tileKernel description: Using tiling stratagy for matrix multiplication in GPU ********************************************************************* */ __global__ void MatrixMul_tileKernel(float* Md, float* Nd, float* Pd, int Width){ int Row = blockIdx.y*TILE_WIDTH + threadIdx.y; int Col = blockIdx.x*TILE_WIDTH + threadIdx.x; int tx = threadIdx.x, ty = threadIdx.y; __shared__ float a[TILE_WIDTH][TILE_WIDTH], b[TILE_WIDTH][TILE_WIDTH]; float Pvalue = 0; //Each thread computes one element of the block sub-matrix for(int k=0; k< Width/TILE_WIDTH; k++){ a[ty][tx] = Md[Row*Width+k*TILE_WIDTH+tx]; b[ty][tx] = Nd[Col+Width*(k*TILE_WIDTH + ty)]; __syncthreads(); //sync all threads in a block; for(int kk=0; kk<TILE_WIDTH; kk++) Pvalue += a[ty][kk]*b[kk][tx]; __syncthreads(); //avoid memory hazards; } Pd[Row*Width+Col] = Pvalue; } /* ********************************************************************* function name: main description: test and compare parameters: none return: none ********************************************************************* */ int main(int argc, char const *argv[]) { int n=1024; /* Fixed seed for illustration */ srand(3333); // allocate memory in host RAM float *h_a, *h_b, *h_c; hipHostMalloc((void **) &h_a, sizeof(float)*n*n, hipHostMallocDefault); hipHostMalloc((void **) &h_b, sizeof(float)*n*n, hipHostMallocDefault); hipHostMalloc((void **) &h_c, sizeof(float)*n*n, hipHostMallocDefault); //generate matrix A and B for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { h_a[i * n + j] = rand() % 1024/2.3; h_b[i * n + j] = rand() % 24/3.3; } } float gpu_elapsed_time_ms; // some events to count the execution time hipEvent_t start, stop; hipEventCreate(&start); hipEventCreate(&stop); // Allocate memory space on the device float *d_a, *d_b, *d_c; hipMalloc((void **) &d_a, sizeof(float)*n*n); hipMalloc((void **) &d_b, sizeof(float)*n*n); hipMalloc((void **) &d_c, sizeof(float)*n*n); // copy matrix A and B from host to device memory hipMemcpy(d_a, h_a, sizeof(float)*n*n, hipMemcpyHostToDevice); hipMemcpy(d_b, h_b, sizeof(float)*n*n, hipMemcpyHostToDevice); unsigned int grid_rows = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; unsigned int grid_cols = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; dim3 dimGrid(grid_cols, grid_rows); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE); // start to count execution time of GPU Kernel hipEventRecord(start, 0); // Launch simple matrix multiplication kernel gpu_matrix_mult<<<dimGrid, dimBlock>>>(d_a, d_b, d_c, n); // time counting terminate hipEventRecord(stop, 0); hipEventSynchronize(stop); // Transefr results from device to host hipMemcpy(h_c, d_c, sizeof(float)*n*n, hipMemcpyDeviceToHost); // compute time elapse on GPU computing hipEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n", gpu_elapsed_time_ms); hipEventRecord(start, 0); // Launch tile matrix multiplication kernel MatrixMul_tileKernel<<<dimGrid, dimBlock>>>( d_a, d_b, d_c, n); hipEventRecord(stop, 0); hipEventSynchronize(stop); // Transefr results from device to host hipMemcpy(h_c, d_c, sizeof(float)*n*n, hipMemcpyDeviceToHost); // compute time elapse on GPU kernel hipEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n", gpu_elapsed_time_ms); // free memory hipFree(d_a); hipFree(d_b); hipFree(d_c); hipHostFree(h_a); hipHostFree(h_b); hipHostFree(h_c); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15gpu_matrix_multPfS_S_i .globl _Z15gpu_matrix_multPfS_S_i .p2align 8 .type _Z15gpu_matrix_multPfS_S_i,@function _Z15gpu_matrix_multPfS_S_i: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v4, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s3, s2, 16 s_and_b32 s2, s2, 0xffff v_mad_u64_u32 v[2:3], null, s15, s3, v[1:2] v_mad_u64_u32 v[0:1], null, s14, s2, v[4:5] s_mov_b32 s2, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_max3_i32 v1, v2, v0, 0 v_cmpx_gt_i32_e64 s4, v1 s_cbranch_execz .LBB0_3 v_mul_lo_u32 v4, v2, s4 s_load_b64 s[2:3], s[0:1], 0x10 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v1, v4, v0 v_ashrrev_i32_e32 v5, 31, v4 v_ashrrev_i32_e32 v2, 31, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[4:5], 2, v[4:5] v_lshlrev_b64 v[2:3], 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 v2, vcc_lo, s2, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo s_load_b128 s[0:3], s[0:1], 0x0 global_load_b32 v6, v[2:3], off s_waitcnt lgkmcnt(0) v_add_co_u32 v4, vcc_lo, s0, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo s_mov_b32 s0, s4 .p2align 6 .LBB0_2: v_ashrrev_i32_e32 v1, 31, v0 s_add_i32 s0, s0, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_cmp_lg_u32 s0, 0 v_lshlrev_b64 v[7:8], 2, v[0:1] v_add_nc_u32_e32 v0, s4, v0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v7, vcc_lo, s2, v7 v_add_co_ci_u32_e32 v8, vcc_lo, s3, v8, vcc_lo global_load_b32 v1, v[4:5], off global_load_b32 v7, v[7:8], off v_add_co_u32 v4, vcc_lo, v4, 4 v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo s_waitcnt vmcnt(0) v_fmac_f32_e32 v6, v1, v7 global_store_b32 v[2:3], v6, off s_cbranch_scc1 .LBB0_2 .LBB0_3: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15gpu_matrix_multPfS_S_i .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 9 .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 _Z15gpu_matrix_multPfS_S_i, .Lfunc_end0-_Z15gpu_matrix_multPfS_S_i .section .AMDGPU.csdata,"",@progbits .text .protected _Z20MatrixMul_tileKernelPfS_S_i .globl _Z20MatrixMul_tileKernelPfS_S_i .p2align 8 .type _Z20MatrixMul_tileKernelPfS_S_i,@function _Z20MatrixMul_tileKernelPfS_S_i: s_load_b32 s2, s[0:1], 0x18 v_bfe_u32 v5, v0, 10, 10 v_dual_mov_b32 v2, 0 :: v_dual_and_b32 v3, 0x3ff, v0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshl_add_u32 v4, s15, 4, v5 v_lshl_add_u32 v0, s14, 4, v3 s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s2, 16 s_cbranch_scc1 .LBB1_5 s_load_b128 s[4:7], s[0:1], 0x0 v_lshlrev_b32_e32 v8, 2, v3 v_lshlrev_b32_e32 v6, 6, v5 s_ashr_i32 s3, s2, 31 v_mad_u64_u32 v[1:2], null, v4, s2, v[3:4] s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_3) | instid1(VALU_DEP_2) v_dual_mov_b32 v2, 0 :: v_dual_add_nc_u32 v7, 0x400, v8 s_lshr_b32 s3, s3, 28 v_add_nc_u32_e32 v3, v6, v8 s_add_i32 s3, s2, s3 v_add_nc_u32_e32 v8, v7, v6 s_ashr_i32 s3, s3, 4 s_mov_b32 s8, 0 s_set_inst_prefetch_distance 0x1 .p2align 6 .LBB1_2: s_lshl_b32 s9, s8, 4 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v10, s9, v5 v_add_nc_u32_e32 v9, s9, v1 s_mov_b32 s9, 0 v_mad_u64_u32 v[11:12], null, v10, s2, v[0:1] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v10, 31, v9 v_lshlrev_b64 v[9:10], 2, v[9:10] s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v12, 31, v11 s_waitcnt lgkmcnt(0) v_add_co_u32 v9, vcc_lo, s4, v9 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4) v_lshlrev_b64 v[11:12], 2, v[11:12] v_add_co_ci_u32_e32 v10, vcc_lo, s5, v10, vcc_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v11, vcc_lo, s6, v11 v_add_co_ci_u32_e32 v12, vcc_lo, s7, v12, vcc_lo global_load_b32 v10, v[9:10], off global_load_b32 v11, v[11:12], off v_mov_b32_e32 v9, v7 s_waitcnt vmcnt(1) ds_store_b32 v3, v10 s_waitcnt vmcnt(0) ds_store_b32 v8, v11 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB1_3: v_add_nc_u32_e32 v10, s9, v6 s_add_i32 s9, s9, 4 ds_load_b32 v11, v9 ds_load_b32 v10, v10 v_add_nc_u32_e32 v9, 64, v9 s_cmp_eq_u32 s9, 64 s_waitcnt lgkmcnt(0) v_fmac_f32_e32 v2, v10, v11 s_cbranch_scc0 .LBB1_3 s_add_i32 s8, s8, 1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_eq_u32 s8, s3 s_barrier buffer_gl0_inv s_cbranch_scc0 .LBB1_2 .LBB1_5: s_set_inst_prefetch_distance 0x2 s_load_b64 s[0:1], s[0:1], 0x10 v_mad_u64_u32 v[5:6], null, v4, s2, v[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v6, 31, v5 v_lshlrev_b64 v[0:1], 2, v[5:6] 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], v2, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z20MatrixMul_tileKernelPfS_S_i .amdhsa_group_segment_fixed_size 2048 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 28 .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 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_end1: .size _Z20MatrixMul_tileKernelPfS_S_i, .Lfunc_end1-_Z20MatrixMul_tileKernelPfS_S_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 - .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: 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: _Z15gpu_matrix_multPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z15gpu_matrix_multPfS_S_i.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: - .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: 2048 .kernarg_segment_align: 8 .kernarg_segment_size: 28 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z20MatrixMul_tileKernelPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z20MatrixMul_tileKernelPfS_S_i.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 HIP source code to AMD host assembly.
/* file name: matrix_mul.cu * * matrix.cu contains two implemention of matrix multiplication in class * Each matrix size is 1024*1024 * In this program, the elapesed time is only calculating kernel time. Time periods of allocating cuda memory, data transfer and freeing cuda memory are not included. However, in your homework, you should include these overheads. * */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #define BLOCK_SIZE 16 #define TILE_WIDTH 16 /* ********************************************************************* function name: gpu_matrix_mult description: simple impliementation ********************************************************************* */ __global__ void gpu_matrix_mult(float *A, float *B, float *C, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < n && col < n) { for (int i = 0; i < n; ++i) { C[row * n + col] += A[row * n + i] * B[i * n + col]; } } } /* ********************************************************************* function name: MatrixMul_tileKernel description: Using tiling stratagy for matrix multiplication in GPU ********************************************************************* */ __global__ void MatrixMul_tileKernel(float* Md, float* Nd, float* Pd, int Width){ int Row = blockIdx.y*TILE_WIDTH + threadIdx.y; int Col = blockIdx.x*TILE_WIDTH + threadIdx.x; int tx = threadIdx.x, ty = threadIdx.y; __shared__ float a[TILE_WIDTH][TILE_WIDTH], b[TILE_WIDTH][TILE_WIDTH]; float Pvalue = 0; //Each thread computes one element of the block sub-matrix for(int k=0; k< Width/TILE_WIDTH; k++){ a[ty][tx] = Md[Row*Width+k*TILE_WIDTH+tx]; b[ty][tx] = Nd[Col+Width*(k*TILE_WIDTH + ty)]; __syncthreads(); //sync all threads in a block; for(int kk=0; kk<TILE_WIDTH; kk++) Pvalue += a[ty][kk]*b[kk][tx]; __syncthreads(); //avoid memory hazards; } Pd[Row*Width+Col] = Pvalue; } /* ********************************************************************* function name: main description: test and compare parameters: none return: none ********************************************************************* */ int main(int argc, char const *argv[]) { int n=1024; /* Fixed seed for illustration */ srand(3333); // allocate memory in host RAM float *h_a, *h_b, *h_c; hipHostMalloc((void **) &h_a, sizeof(float)*n*n, hipHostMallocDefault); hipHostMalloc((void **) &h_b, sizeof(float)*n*n, hipHostMallocDefault); hipHostMalloc((void **) &h_c, sizeof(float)*n*n, hipHostMallocDefault); //generate matrix A and B for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { h_a[i * n + j] = rand() % 1024/2.3; h_b[i * n + j] = rand() % 24/3.3; } } float gpu_elapsed_time_ms; // some events to count the execution time hipEvent_t start, stop; hipEventCreate(&start); hipEventCreate(&stop); // Allocate memory space on the device float *d_a, *d_b, *d_c; hipMalloc((void **) &d_a, sizeof(float)*n*n); hipMalloc((void **) &d_b, sizeof(float)*n*n); hipMalloc((void **) &d_c, sizeof(float)*n*n); // copy matrix A and B from host to device memory hipMemcpy(d_a, h_a, sizeof(float)*n*n, hipMemcpyHostToDevice); hipMemcpy(d_b, h_b, sizeof(float)*n*n, hipMemcpyHostToDevice); unsigned int grid_rows = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; unsigned int grid_cols = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; dim3 dimGrid(grid_cols, grid_rows); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE); // start to count execution time of GPU Kernel hipEventRecord(start, 0); // Launch simple matrix multiplication kernel gpu_matrix_mult<<<dimGrid, dimBlock>>>(d_a, d_b, d_c, n); // time counting terminate hipEventRecord(stop, 0); hipEventSynchronize(stop); // Transefr results from device to host hipMemcpy(h_c, d_c, sizeof(float)*n*n, hipMemcpyDeviceToHost); // compute time elapse on GPU computing hipEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n", gpu_elapsed_time_ms); hipEventRecord(start, 0); // Launch tile matrix multiplication kernel MatrixMul_tileKernel<<<dimGrid, dimBlock>>>( d_a, d_b, d_c, n); hipEventRecord(stop, 0); hipEventSynchronize(stop); // Transefr results from device to host hipMemcpy(h_c, d_c, sizeof(float)*n*n, hipMemcpyDeviceToHost); // compute time elapse on GPU kernel hipEventElapsedTime(&gpu_elapsed_time_ms, start, stop); printf("Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n", gpu_elapsed_time_ms); // free memory hipFree(d_a); hipFree(d_b); hipFree(d_c); hipHostFree(h_a); hipHostFree(h_b); hipHostFree(h_c); return 0; }
.text .file "test.hip" .globl _Z30__device_stub__gpu_matrix_multPfS_S_i # -- Begin function _Z30__device_stub__gpu_matrix_multPfS_S_i .p2align 4, 0x90 .type _Z30__device_stub__gpu_matrix_multPfS_S_i,@function _Z30__device_stub__gpu_matrix_multPfS_S_i: # @_Z30__device_stub__gpu_matrix_multPfS_S_i .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 $_Z15gpu_matrix_multPfS_S_i, %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 _Z30__device_stub__gpu_matrix_multPfS_S_i, .Lfunc_end0-_Z30__device_stub__gpu_matrix_multPfS_S_i .cfi_endproc # -- End function .globl _Z35__device_stub__MatrixMul_tileKernelPfS_S_i # -- Begin function _Z35__device_stub__MatrixMul_tileKernelPfS_S_i .p2align 4, 0x90 .type _Z35__device_stub__MatrixMul_tileKernelPfS_S_i,@function _Z35__device_stub__MatrixMul_tileKernelPfS_S_i: # @_Z35__device_stub__MatrixMul_tileKernelPfS_S_i .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 $_Z20MatrixMul_tileKernelPfS_S_i, %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_end1: .size _Z35__device_stub__MatrixMul_tileKernelPfS_S_i, .Lfunc_end1-_Z35__device_stub__MatrixMul_tileKernelPfS_S_i .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI2_0: .quad 0x4002666666666666 # double 2.2999999999999998 .LCPI2_1: .quad 0x400a666666666666 # double 3.2999999999999998 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $184, %rsp .cfi_def_cfa_offset 224 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $3333, %edi # imm = 0xD05 callq srand leaq 64(%rsp), %rdi xorl %ebx, %ebx movl $4194304, %esi # imm = 0x400000 xorl %edx, %edx callq hipHostMalloc leaq 56(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 xorl %edx, %edx callq hipHostMalloc leaq 48(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 xorl %edx, %edx callq hipHostMalloc xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_1: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_2 Depth 2 movl $1024, %r15d # imm = 0x400 movq %rbx, %r12 .p2align 4, 0x90 .LBB2_2: # Parent Loop BB2_1 Depth=1 # => This Inner Loop Header: Depth=2 callq rand # kill: def $eax killed $eax def $rax leal 1023(%rax), %ecx testl %eax, %eax cmovnsl %eax, %ecx andl $-1024, %ecx # imm = 0xFC00 subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2sd %eax, %xmm0 divsd .LCPI2_0(%rip), %xmm0 cvtsd2ss %xmm0, %xmm0 movq 64(%rsp), %rax movss %xmm0, (%rax,%r12) callq rand movsd .LCPI2_1(%rip), %xmm1 # xmm1 = mem[0],zero cltq imulq $715827883, %rax, %rcx # imm = 0x2AAAAAAB movq %rcx, %rdx shrq $63, %rdx shrq $34, %rcx addl %edx, %ecx shll $3, %ecx leal (%rcx,%rcx,2), %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2sd %eax, %xmm0 divsd %xmm1, %xmm0 cvtsd2ss %xmm0, %xmm0 movq 56(%rsp), %rax movss %xmm0, (%rax,%r12) addq $4, %r12 decq %r15 jne .LBB2_2 # %bb.3: # in Loop: Header=BB2_1 Depth=1 incq %r14 addq $4096, %rbx # imm = 0x1000 cmpq $1024, %r14 # imm = 0x400 jne .LBB2_1 # %bb.4: movabsq $274877907008, %r14 # imm = 0x4000000040 movabsq $68719476752, %rbx # imm = 0x1000000010 leaq 40(%rsp), %rdi callq hipEventCreate leaq 8(%rsp), %rdi callq hipEventCreate leaq 32(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 24(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 16(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc movq 32(%rsp), %rdi movq 64(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $1, %ecx callq hipMemcpy movq 24(%rsp), %rdi movq 56(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $1, %ecx callq hipMemcpy movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq %r14, %rdi movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_6 # %bb.5: movq 32(%rsp), %rax movq 24(%rsp), %rcx movq 16(%rsp), %rdx movq %rax, 136(%rsp) movq %rcx, 128(%rsp) movq %rdx, 120(%rsp) movl $1024, 4(%rsp) # imm = 0x400 leaq 136(%rsp), %rax movq %rax, 144(%rsp) leaq 128(%rsp), %rax movq %rax, 152(%rsp) leaq 120(%rsp), %rax movq %rax, 160(%rsp) leaq 4(%rsp), %rax movq %rax, 168(%rsp) leaq 104(%rsp), %rdi leaq 88(%rsp), %rsi leaq 80(%rsp), %rdx leaq 72(%rsp), %rcx callq __hipPopCallConfiguration movq 104(%rsp), %rsi movl 112(%rsp), %edx movq 88(%rsp), %rcx movl 96(%rsp), %r8d leaq 144(%rsp), %r9 movl $_Z15gpu_matrix_multPfS_S_i, %edi pushq 72(%rsp) .cfi_adjust_cfa_offset 8 pushq 88(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_6: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 48(%rsp), %rdi movq 16(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $2, %ecx callq hipMemcpy movq 40(%rsp), %rsi movq 8(%rsp), %rdx movq %rsp, %rdi callq hipEventElapsedTime movss (%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str, %edi movb $1, %al callq printf movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq %r14, %rdi movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_8 # %bb.7: movq 32(%rsp), %rax movq 24(%rsp), %rcx movq 16(%rsp), %rdx movq %rax, 136(%rsp) movq %rcx, 128(%rsp) movq %rdx, 120(%rsp) movl $1024, 4(%rsp) # imm = 0x400 leaq 136(%rsp), %rax movq %rax, 144(%rsp) leaq 128(%rsp), %rax movq %rax, 152(%rsp) leaq 120(%rsp), %rax movq %rax, 160(%rsp) leaq 4(%rsp), %rax movq %rax, 168(%rsp) leaq 104(%rsp), %rdi leaq 88(%rsp), %rsi leaq 80(%rsp), %rdx leaq 72(%rsp), %rcx callq __hipPopCallConfiguration movq 104(%rsp), %rsi movl 112(%rsp), %edx movq 88(%rsp), %rcx movl 96(%rsp), %r8d leaq 144(%rsp), %r9 movl $_Z20MatrixMul_tileKernelPfS_S_i, %edi pushq 72(%rsp) .cfi_adjust_cfa_offset 8 pushq 88(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_8: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 48(%rsp), %rdi movq 16(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $2, %ecx callq hipMemcpy movq 40(%rsp), %rsi movq 8(%rsp), %rdx movq %rsp, %rdi callq hipEventElapsedTime movss (%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.1, %edi movb $1, %al callq printf movq 32(%rsp), %rdi callq hipFree movq 24(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree movq 64(%rsp), %rdi callq hipHostFree movq 56(%rsp), %rdi callq hipHostFree movq 48(%rsp), %rdi callq hipHostFree xorl %eax, %eax addq $184, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z15gpu_matrix_multPfS_S_i, %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 $_Z20MatrixMul_tileKernelPfS_S_i, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type _Z15gpu_matrix_multPfS_S_i,@object # @_Z15gpu_matrix_multPfS_S_i .section .rodata,"a",@progbits .globl _Z15gpu_matrix_multPfS_S_i .p2align 3, 0x0 _Z15gpu_matrix_multPfS_S_i: .quad _Z30__device_stub__gpu_matrix_multPfS_S_i .size _Z15gpu_matrix_multPfS_S_i, 8 .type _Z20MatrixMul_tileKernelPfS_S_i,@object # @_Z20MatrixMul_tileKernelPfS_S_i .globl _Z20MatrixMul_tileKernelPfS_S_i .p2align 3, 0x0 _Z20MatrixMul_tileKernelPfS_S_i: .quad _Z35__device_stub__MatrixMul_tileKernelPfS_S_i .size _Z20MatrixMul_tileKernelPfS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n" .size .L.str, 62 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n" .size .L.str.1, 77 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z15gpu_matrix_multPfS_S_i" .size .L__unnamed_1, 27 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z20MatrixMul_tileKernelPfS_S_i" .size .L__unnamed_2, 32 .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 _Z30__device_stub__gpu_matrix_multPfS_S_i .addrsig_sym _Z35__device_stub__MatrixMul_tileKernelPfS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15gpu_matrix_multPfS_S_i .addrsig_sym _Z20MatrixMul_tileKernelPfS_S_i .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_00149ffc_00000000-6_test.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 _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i .type _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i, @function _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i: .LFB2082: .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 _Z15gpu_matrix_multPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i, .-_Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i .globl _Z15gpu_matrix_multPfS_S_i .type _Z15gpu_matrix_multPfS_S_i, @function _Z15gpu_matrix_multPfS_S_i: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z15gpu_matrix_multPfS_S_i, .-_Z15gpu_matrix_multPfS_S_i .globl _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i .type _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i, @function _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i: .LFB2084: .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 .L15 .L11: movq 136(%rsp), %rax subq %fs:40, %rax jne .L16 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .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 _Z20MatrixMul_tileKernelPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L11 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i, .-_Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i .globl _Z20MatrixMul_tileKernelPfS_S_i .type _Z20MatrixMul_tileKernelPfS_S_i, @function _Z20MatrixMul_tileKernelPfS_S_i: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z20MatrixMul_tileKernelPfS_S_i, .-_Z20MatrixMul_tileKernelPfS_S_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC2: .string "Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n" .align 8 .LC3: .string "Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\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 subq $120, %rsp .cfi_def_cfa_offset 144 movq %fs:40, %rax movq %rax, 104(%rsp) xorl %eax, %eax movl $3333, %edi call srand@PLT leaq 16(%rsp), %rdi movl $4194304, %esi call cudaMallocHost@PLT leaq 24(%rsp), %rdi movl $4194304, %esi call cudaMallocHost@PLT leaq 32(%rsp), %rdi movl $4194304, %esi call cudaMallocHost@PLT movl $4096, %ebp .L20: leaq -4096(%rbp), %rbx .L21: call rand@PLT cltd shrl $22, %edx addl %edx, %eax andl $1023, %eax subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2sdl %eax, %xmm0 divsd .LC0(%rip), %xmm0 cvtsd2ss %xmm0, %xmm0 movq 16(%rsp), %rax movss %xmm0, (%rax,%rbx) call rand@PLT movslq %eax, %rdx imulq $715827883, %rdx, %rdx sarq $34, %rdx movl %eax, %ecx sarl $31, %ecx subl %ecx, %edx leal (%rdx,%rdx,2), %edx sall $3, %edx subl %edx, %eax pxor %xmm0, %xmm0 cvtsi2sdl %eax, %xmm0 divsd .LC1(%rip), %xmm0 cvtsd2ss %xmm0, %xmm0 movq 24(%rsp), %rax movss %xmm0, (%rax,%rbx) addq $4, %rbx cmpq %rbp, %rbx jne .L21 addq $4096, %rbp cmpq $4198400, %rbp jne .L20 leaq 40(%rsp), %rdi call cudaEventCreate@PLT leaq 48(%rsp), %rdi call cudaEventCreate@PLT leaq 56(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 64(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 72(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT movl $1, %ecx movl $4194304, %edx movq 16(%rsp), %rsi movq 56(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $4194304, %edx movq 24(%rsp), %rsi movq 64(%rsp), %rdi call cudaMemcpy@PLT movl $64, 80(%rsp) movl $64, 84(%rsp) movl $1, 88(%rsp) movl $16, 92(%rsp) movl $16, 96(%rsp) movl $1, 100(%rsp) movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movl 100(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 92(%rsp), %rdx movq 80(%rsp), %rdi movl 88(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L28 .L23: movl $0, %esi movq 48(%rsp), %rdi call cudaEventRecord@PLT movq 48(%rsp), %rdi call cudaEventSynchronize@PLT movl $2, %ecx movl $4194304, %edx movq 72(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT leaq 12(%rsp), %rdi movq 48(%rsp), %rdx movq 40(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 12(%rsp), %xmm0 leaq .LC2(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movl 100(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 92(%rsp), %rdx movq 80(%rsp), %rdi movl 88(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L29 .L24: movl $0, %esi movq 48(%rsp), %rdi call cudaEventRecord@PLT movq 48(%rsp), %rdi call cudaEventSynchronize@PLT movl $2, %ecx movl $4194304, %edx movq 72(%rsp), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT leaq 12(%rsp), %rdi movq 48(%rsp), %rdx movq 40(%rsp), %rsi call cudaEventElapsedTime@PLT pxor %xmm0, %xmm0 cvtss2sd 12(%rsp), %xmm0 leaq .LC3(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 56(%rsp), %rdi call cudaFree@PLT movq 64(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFreeHost@PLT movq 24(%rsp), %rdi call cudaFreeHost@PLT movq 32(%rsp), %rdi call cudaFreeHost@PLT movq 104(%rsp), %rax subq %fs:40, %rax jne .L30 movl $0, %eax addq $120, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L28: .cfi_restore_state movl $1024, %ecx movq 72(%rsp), %rdx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z40__device_stub__Z15gpu_matrix_multPfS_S_iPfS_S_i jmp .L23 .L29: movl $1024, %ecx movq 72(%rsp), %rdx movq 64(%rsp), %rsi movq 56(%rsp), %rdi call _Z45__device_stub__Z20MatrixMul_tileKernelPfS_S_iPfS_S_i jmp .L24 .L30: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.8 .align 8 .LC4: .string "_Z20MatrixMul_tileKernelPfS_S_i" .section .rodata.str1.1,"aMS",@progbits,1 .LC5: .string "_Z15gpu_matrix_multPfS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2087: .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 .LC4(%rip), %rdx movq %rdx, %rcx leaq _Z20MatrixMul_tileKernelPfS_S_i(%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 .LC5(%rip), %rdx movq %rdx, %rcx leaq _Z15gpu_matrix_multPfS_S_i(%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 .LFE2087: .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 .LC0: .long 1717986918 .long 1073899110 .align 8 .LC1: .long 1717986918 .long 1074423398 .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 "test.hip" .globl _Z30__device_stub__gpu_matrix_multPfS_S_i # -- Begin function _Z30__device_stub__gpu_matrix_multPfS_S_i .p2align 4, 0x90 .type _Z30__device_stub__gpu_matrix_multPfS_S_i,@function _Z30__device_stub__gpu_matrix_multPfS_S_i: # @_Z30__device_stub__gpu_matrix_multPfS_S_i .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 $_Z15gpu_matrix_multPfS_S_i, %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 _Z30__device_stub__gpu_matrix_multPfS_S_i, .Lfunc_end0-_Z30__device_stub__gpu_matrix_multPfS_S_i .cfi_endproc # -- End function .globl _Z35__device_stub__MatrixMul_tileKernelPfS_S_i # -- Begin function _Z35__device_stub__MatrixMul_tileKernelPfS_S_i .p2align 4, 0x90 .type _Z35__device_stub__MatrixMul_tileKernelPfS_S_i,@function _Z35__device_stub__MatrixMul_tileKernelPfS_S_i: # @_Z35__device_stub__MatrixMul_tileKernelPfS_S_i .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 $_Z20MatrixMul_tileKernelPfS_S_i, %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_end1: .size _Z35__device_stub__MatrixMul_tileKernelPfS_S_i, .Lfunc_end1-_Z35__device_stub__MatrixMul_tileKernelPfS_S_i .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI2_0: .quad 0x4002666666666666 # double 2.2999999999999998 .LCPI2_1: .quad 0x400a666666666666 # double 3.2999999999999998 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $184, %rsp .cfi_def_cfa_offset 224 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $3333, %edi # imm = 0xD05 callq srand leaq 64(%rsp), %rdi xorl %ebx, %ebx movl $4194304, %esi # imm = 0x400000 xorl %edx, %edx callq hipHostMalloc leaq 56(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 xorl %edx, %edx callq hipHostMalloc leaq 48(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 xorl %edx, %edx callq hipHostMalloc xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_1: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_2 Depth 2 movl $1024, %r15d # imm = 0x400 movq %rbx, %r12 .p2align 4, 0x90 .LBB2_2: # Parent Loop BB2_1 Depth=1 # => This Inner Loop Header: Depth=2 callq rand # kill: def $eax killed $eax def $rax leal 1023(%rax), %ecx testl %eax, %eax cmovnsl %eax, %ecx andl $-1024, %ecx # imm = 0xFC00 subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2sd %eax, %xmm0 divsd .LCPI2_0(%rip), %xmm0 cvtsd2ss %xmm0, %xmm0 movq 64(%rsp), %rax movss %xmm0, (%rax,%r12) callq rand movsd .LCPI2_1(%rip), %xmm1 # xmm1 = mem[0],zero cltq imulq $715827883, %rax, %rcx # imm = 0x2AAAAAAB movq %rcx, %rdx shrq $63, %rdx shrq $34, %rcx addl %edx, %ecx shll $3, %ecx leal (%rcx,%rcx,2), %ecx subl %ecx, %eax xorps %xmm0, %xmm0 cvtsi2sd %eax, %xmm0 divsd %xmm1, %xmm0 cvtsd2ss %xmm0, %xmm0 movq 56(%rsp), %rax movss %xmm0, (%rax,%r12) addq $4, %r12 decq %r15 jne .LBB2_2 # %bb.3: # in Loop: Header=BB2_1 Depth=1 incq %r14 addq $4096, %rbx # imm = 0x1000 cmpq $1024, %r14 # imm = 0x400 jne .LBB2_1 # %bb.4: movabsq $274877907008, %r14 # imm = 0x4000000040 movabsq $68719476752, %rbx # imm = 0x1000000010 leaq 40(%rsp), %rdi callq hipEventCreate leaq 8(%rsp), %rdi callq hipEventCreate leaq 32(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 24(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 16(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc movq 32(%rsp), %rdi movq 64(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $1, %ecx callq hipMemcpy movq 24(%rsp), %rdi movq 56(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $1, %ecx callq hipMemcpy movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq %r14, %rdi movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_6 # %bb.5: movq 32(%rsp), %rax movq 24(%rsp), %rcx movq 16(%rsp), %rdx movq %rax, 136(%rsp) movq %rcx, 128(%rsp) movq %rdx, 120(%rsp) movl $1024, 4(%rsp) # imm = 0x400 leaq 136(%rsp), %rax movq %rax, 144(%rsp) leaq 128(%rsp), %rax movq %rax, 152(%rsp) leaq 120(%rsp), %rax movq %rax, 160(%rsp) leaq 4(%rsp), %rax movq %rax, 168(%rsp) leaq 104(%rsp), %rdi leaq 88(%rsp), %rsi leaq 80(%rsp), %rdx leaq 72(%rsp), %rcx callq __hipPopCallConfiguration movq 104(%rsp), %rsi movl 112(%rsp), %edx movq 88(%rsp), %rcx movl 96(%rsp), %r8d leaq 144(%rsp), %r9 movl $_Z15gpu_matrix_multPfS_S_i, %edi pushq 72(%rsp) .cfi_adjust_cfa_offset 8 pushq 88(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_6: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 48(%rsp), %rdi movq 16(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $2, %ecx callq hipMemcpy movq 40(%rsp), %rsi movq 8(%rsp), %rdx movq %rsp, %rdi callq hipEventElapsedTime movss (%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str, %edi movb $1, %al callq printf movq 40(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq %r14, %rdi movl $1, %esi movq %rbx, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_8 # %bb.7: movq 32(%rsp), %rax movq 24(%rsp), %rcx movq 16(%rsp), %rdx movq %rax, 136(%rsp) movq %rcx, 128(%rsp) movq %rdx, 120(%rsp) movl $1024, 4(%rsp) # imm = 0x400 leaq 136(%rsp), %rax movq %rax, 144(%rsp) leaq 128(%rsp), %rax movq %rax, 152(%rsp) leaq 120(%rsp), %rax movq %rax, 160(%rsp) leaq 4(%rsp), %rax movq %rax, 168(%rsp) leaq 104(%rsp), %rdi leaq 88(%rsp), %rsi leaq 80(%rsp), %rdx leaq 72(%rsp), %rcx callq __hipPopCallConfiguration movq 104(%rsp), %rsi movl 112(%rsp), %edx movq 88(%rsp), %rcx movl 96(%rsp), %r8d leaq 144(%rsp), %r9 movl $_Z20MatrixMul_tileKernelPfS_S_i, %edi pushq 72(%rsp) .cfi_adjust_cfa_offset 8 pushq 88(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_8: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 8(%rsp), %rdi callq hipEventSynchronize movq 48(%rsp), %rdi movq 16(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movl $2, %ecx callq hipMemcpy movq 40(%rsp), %rsi movq 8(%rsp), %rdx movq %rsp, %rdi callq hipEventElapsedTime movss (%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.1, %edi movb $1, %al callq printf movq 32(%rsp), %rdi callq hipFree movq 24(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree movq 64(%rsp), %rdi callq hipHostFree movq 56(%rsp), %rdi callq hipHostFree movq 48(%rsp), %rdi callq hipHostFree xorl %eax, %eax addq $184, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z15gpu_matrix_multPfS_S_i, %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 $_Z20MatrixMul_tileKernelPfS_S_i, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type _Z15gpu_matrix_multPfS_S_i,@object # @_Z15gpu_matrix_multPfS_S_i .section .rodata,"a",@progbits .globl _Z15gpu_matrix_multPfS_S_i .p2align 3, 0x0 _Z15gpu_matrix_multPfS_S_i: .quad _Z30__device_stub__gpu_matrix_multPfS_S_i .size _Z15gpu_matrix_multPfS_S_i, 8 .type _Z20MatrixMul_tileKernelPfS_S_i,@object # @_Z20MatrixMul_tileKernelPfS_S_i .globl _Z20MatrixMul_tileKernelPfS_S_i .p2align 3, 0x0 _Z20MatrixMul_tileKernelPfS_S_i: .quad _Z35__device_stub__MatrixMul_tileKernelPfS_S_i .size _Z20MatrixMul_tileKernelPfS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "Time elapsed on simple matrix multiplication on GPU: %f ms.\n\n" .size .L.str, 62 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz "Time elapsed on matrix multiplication with tiling strategy on GPU: %f ms.\n\n" .size .L.str.1, 77 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z15gpu_matrix_multPfS_S_i" .size .L__unnamed_1, 27 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "_Z20MatrixMul_tileKernelPfS_S_i" .size .L__unnamed_2, 32 .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 _Z30__device_stub__gpu_matrix_multPfS_S_i .addrsig_sym _Z35__device_stub__MatrixMul_tileKernelPfS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15gpu_matrix_multPfS_S_i .addrsig_sym _Z20MatrixMul_tileKernelPfS_S_i .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.
// Matrix addition, CPU version // gcc matrix_cpu.c -o matrix_cpu -std=c99 /* answers N = 2**6 = 64 is the turning point in gpu v cpu block size 16*16 gave the best performance for us coalescing on N=2**10 Time 0.4686 Time 0.1143 */ #include <stdio.h> __global__ void add_matrix(float *a, float *b, float *c, int N) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int index = x + y*N; if (index < N*N) // allow allocating more threads than elements c[index] = a[index] + b[index]; } void add_matrix_cpu(float *a, float *b, float *c, int N) { for (int y=0; y < N; y++) for (int x=0; y < N; x++){ int index = x + y*N; c[index] = a[index] + b[index]; } } int main() { const int N = 1<<10; const int blockSize = 16; const int size = N*N*sizeof(float); float t; float *a, *ad; float *b, *bd; float *c, *cd; a = new float[N*N]; b = new float[N*N]; c = new float[N*N]; cudaMalloc( (void**)&ad, size ); cudaMalloc( (void**)&bd, size ); cudaMalloc( (void**)&cd, size ); cudaEvent_t event0, event1; cudaEventCreate(&event0); cudaEventCreate(&event1); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { a[i+j*N] = 10 + i; b[i+j*N] = (float)j / N; } cudaMemcpy( ad, a, size, cudaMemcpyHostToDevice ); cudaMemcpy( bd, b, size, cudaMemcpyHostToDevice ); dim3 dimBlock( blockSize, blockSize ); dim3 dimGrid( N/blockSize, N/blockSize ); cudaEventRecord(event0, 0); add_matrix<<< dimGrid, dimBlock >>>(ad, bd, cd, N); cudaEventRecord(event1, 0); cudaMemcpy( c, cd, size, cudaMemcpyDeviceToHost ); cudaEventSynchronize(event0); cudaEventSynchronize(event1); cudaEventElapsedTime(&t, event0, event1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i==N-1 && N-32 < j)printf("%0.2f ", c[i+j*N]); } //printf("\n"); } printf("\n"); printf("Time %0.4f\n", t); }
code for sm_80 Function : _Z10add_matrixPfS_S_i .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 */ /* 0x000e220000002500 */ /*0020*/ ULDC UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe40000000800 */ /*0030*/ UIMAD UR4, UR4, UR4, URZ ; /* 0x00000004040472a4 */ /* 0x000fe2000f8e023f */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e280000002100 */ /*0050*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e680000002600 */ /*0060*/ S2R R5, SR_TID.Y ; /* 0x0000000000057919 */ /* 0x000e620000002200 */ /*0070*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fc400078e0203 */ /*0080*/ IMAD R3, R2, c[0x0][0x4], R5 ; /* 0x0000010002037a24 */ /* 0x002fc800078e0205 */ /*0090*/ IMAD R0, R3, c[0x0][0x178], R0 ; /* 0x00005e0003007a24 */ /* 0x000fca00078e0200 */ /*00a0*/ ISETP.GE.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf06270 */ /*00b0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00c0*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*00d0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*00e0*/ IMAD.WIDE R4, R0, R7, c[0x0][0x168] ; /* 0x00005a0000047625 */ /* 0x000fc800078e0207 */ /*00f0*/ IMAD.WIDE R2, R0.reuse, R7.reuse, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x0c0fe400078e0207 */ /*0100*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea8000c1e1900 */ /*0110*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*0120*/ IMAD.WIDE R6, R0, R7, c[0x0][0x170] ; /* 0x00005c0000067625 */ /* 0x000fc800078e0207 */ /*0130*/ FADD R9, R4, R3 ; /* 0x0000000304097221 */ /* 0x004fca0000000000 */ /*0140*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*0150*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0160*/ BRA 0x160; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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.
// Matrix addition, CPU version // gcc matrix_cpu.c -o matrix_cpu -std=c99 /* answers N = 2**6 = 64 is the turning point in gpu v cpu block size 16*16 gave the best performance for us coalescing on N=2**10 Time 0.4686 Time 0.1143 */ #include <stdio.h> __global__ void add_matrix(float *a, float *b, float *c, int N) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int index = x + y*N; if (index < N*N) // allow allocating more threads than elements c[index] = a[index] + b[index]; } void add_matrix_cpu(float *a, float *b, float *c, int N) { for (int y=0; y < N; y++) for (int x=0; y < N; x++){ int index = x + y*N; c[index] = a[index] + b[index]; } } int main() { const int N = 1<<10; const int blockSize = 16; const int size = N*N*sizeof(float); float t; float *a, *ad; float *b, *bd; float *c, *cd; a = new float[N*N]; b = new float[N*N]; c = new float[N*N]; cudaMalloc( (void**)&ad, size ); cudaMalloc( (void**)&bd, size ); cudaMalloc( (void**)&cd, size ); cudaEvent_t event0, event1; cudaEventCreate(&event0); cudaEventCreate(&event1); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { a[i+j*N] = 10 + i; b[i+j*N] = (float)j / N; } cudaMemcpy( ad, a, size, cudaMemcpyHostToDevice ); cudaMemcpy( bd, b, size, cudaMemcpyHostToDevice ); dim3 dimBlock( blockSize, blockSize ); dim3 dimGrid( N/blockSize, N/blockSize ); cudaEventRecord(event0, 0); add_matrix<<< dimGrid, dimBlock >>>(ad, bd, cd, N); cudaEventRecord(event1, 0); cudaMemcpy( c, cd, size, cudaMemcpyDeviceToHost ); cudaEventSynchronize(event0); cudaEventSynchronize(event1); cudaEventElapsedTime(&t, event0, event1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i==N-1 && N-32 < j)printf("%0.2f ", c[i+j*N]); } //printf("\n"); } printf("\n"); printf("Time %0.4f\n", t); }
.file "tmpxft_000dc165_00000000-6_matrix_gpu.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2061: .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 .LFE2061: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z14add_matrix_cpuPfS_S_i .type _Z14add_matrix_cpuPfS_S_i, @function _Z14add_matrix_cpuPfS_S_i: .LFB2057: .cfi_startproc endbr64 testl %ecx, %ecx jle .L3 movl $0, %eax .L5: movss (%rdi,%rax), %xmm0 addss (%rsi,%rax), %xmm0 movss %xmm0, (%rdx,%rax) addq $4, %rax jmp .L5 .L3: ret .cfi_endproc .LFE2057: .size _Z14add_matrix_cpuPfS_S_i, .-_Z14add_matrix_cpuPfS_S_i .globl _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i .type _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i, @function _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i: .LFB2083: .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 .L10 .L6: movq 136(%rsp), %rax subq %fs:40, %rax jne .L11 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L10: .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 _Z10add_matrixPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L6 .L11: call __stack_chk_fail@PLT .cfi_endproc .LFE2083: .size _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i, .-_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i .globl _Z10add_matrixPfS_S_i .type _Z10add_matrixPfS_S_i, @function _Z10add_matrixPfS_S_i: .LFB2084: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2084: .size _Z10add_matrixPfS_S_i, .-_Z10add_matrixPfS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "%0.2f " .LC2: .string "\n" .LC3: .string "Time %0.4f\n" .text .globl main .type main, @function main: .LFB2058: .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 $80, %rsp .cfi_def_cfa_offset 128 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax movl $4194304, %edi call _Znam@PLT movq %rax, %rbp movl $4194304, %edi call _Znam@PLT movq %rax, %rbx movl $4194304, %edi call _Znam@PLT movq %rax, %r12 leaq 8(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 24(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 32(%rsp), %rdi call cudaEventCreate@PLT leaq 40(%rsp), %rdi call cudaEventCreate@PLT movl $10, %esi movl $0, %ecx movss .LC0(%rip), %xmm2 .L15: leaq 0(,%rcx,4), %rdx movl $0, %eax pxor %xmm1, %xmm1 cvtsi2ssl %esi, %xmm1 .L16: movss %xmm1, 0(%rbp,%rdx) pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss %xmm2, %xmm0 movss %xmm0, (%rbx,%rdx) addl $1, %eax addq $4096, %rdx cmpl $1024, %eax jne .L16 addq $1, %rcx addl $1, %esi cmpq $1024, %rcx jne .L15 movl $1, %ecx movl $4194304, %edx movq %rbp, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $4194304, %edx movq %rbx, %rsi movq 16(%rsp), %rdi call cudaMemcpy@PLT movl $16, 48(%rsp) movl $16, 52(%rsp) movl $1, 56(%rsp) movl $64, 60(%rsp) movl $64, 64(%rsp) movl $1, 68(%rsp) movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movl 56(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 48(%rsp), %rdx movq 60(%rsp), %rdi movl 68(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L27 .L18: movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movl $2, %ecx movl $4194304, %edx movq 24(%rsp), %rsi movq %r12, %rdi call cudaMemcpy@PLT movq 32(%rsp), %rdi call cudaEventSynchronize@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 4(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT movl $0, %r13d leaq .LC1(%rip), %r14 jmp .L19 .L27: movl $1024, %ecx movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i jmp .L18 .L20: addl $1, %ebx addq $4096, %rbp cmpl $1024, %ebx je .L28 .L23: cmpl $1023, %r13d jne .L20 cmpl $992, %ebx jle .L20 pxor %xmm0, %xmm0 cvtss2sd 0(%rbp), %xmm0 movq %r14, %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT addl $1, %ebx addq $4096, %rbp cmpl $1024, %ebx jne .L23 .L22: leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT pxor %xmm0, %xmm0 cvtss2sd 4(%rsp), %xmm0 leaq .LC3(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L29 movl $0, %eax addq $80, %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 .L28: .cfi_restore_state addl $1, %r13d cmpl $1024, %r13d je .L22 .L19: leaq 4092(%r12), %rbp movl $0, %ebx jmp .L23 .L29: call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size main, .-main .section .rodata.str1.1 .LC4: .string "_Z10add_matrixPfS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2086: .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 _Z10add_matrixPfS_S_i(%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 .LFE2086: .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 981467136 .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.
// Matrix addition, CPU version // gcc matrix_cpu.c -o matrix_cpu -std=c99 /* answers N = 2**6 = 64 is the turning point in gpu v cpu block size 16*16 gave the best performance for us coalescing on N=2**10 Time 0.4686 Time 0.1143 */ #include <stdio.h> __global__ void add_matrix(float *a, float *b, float *c, int N) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int index = x + y*N; if (index < N*N) // allow allocating more threads than elements c[index] = a[index] + b[index]; } void add_matrix_cpu(float *a, float *b, float *c, int N) { for (int y=0; y < N; y++) for (int x=0; y < N; x++){ int index = x + y*N; c[index] = a[index] + b[index]; } } int main() { const int N = 1<<10; const int blockSize = 16; const int size = N*N*sizeof(float); float t; float *a, *ad; float *b, *bd; float *c, *cd; a = new float[N*N]; b = new float[N*N]; c = new float[N*N]; cudaMalloc( (void**)&ad, size ); cudaMalloc( (void**)&bd, size ); cudaMalloc( (void**)&cd, size ); cudaEvent_t event0, event1; cudaEventCreate(&event0); cudaEventCreate(&event1); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { a[i+j*N] = 10 + i; b[i+j*N] = (float)j / N; } cudaMemcpy( ad, a, size, cudaMemcpyHostToDevice ); cudaMemcpy( bd, b, size, cudaMemcpyHostToDevice ); dim3 dimBlock( blockSize, blockSize ); dim3 dimGrid( N/blockSize, N/blockSize ); cudaEventRecord(event0, 0); add_matrix<<< dimGrid, dimBlock >>>(ad, bd, cd, N); cudaEventRecord(event1, 0); cudaMemcpy( c, cd, size, cudaMemcpyDeviceToHost ); cudaEventSynchronize(event0); cudaEventSynchronize(event1); cudaEventElapsedTime(&t, event0, event1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i==N-1 && N-32 < j)printf("%0.2f ", c[i+j*N]); } //printf("\n"); } printf("\n"); printf("Time %0.4f\n", t); }
// Matrix addition, CPU version // gcc matrix_cpu.c -o matrix_cpu -std=c99 /* answers N = 2**6 = 64 is the turning point in gpu v cpu block size 16*16 gave the best performance for us coalescing on N=2**10 Time 0.4686 Time 0.1143 */ #include <hip/hip_runtime.h> #include <stdio.h> __global__ void add_matrix(float *a, float *b, float *c, int N) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int index = x + y*N; if (index < N*N) // allow allocating more threads than elements c[index] = a[index] + b[index]; } void add_matrix_cpu(float *a, float *b, float *c, int N) { for (int y=0; y < N; y++) for (int x=0; y < N; x++){ int index = x + y*N; c[index] = a[index] + b[index]; } } int main() { const int N = 1<<10; const int blockSize = 16; const int size = N*N*sizeof(float); float t; float *a, *ad; float *b, *bd; float *c, *cd; a = new float[N*N]; b = new float[N*N]; c = new float[N*N]; hipMalloc( (void**)&ad, size ); hipMalloc( (void**)&bd, size ); hipMalloc( (void**)&cd, size ); hipEvent_t event0, event1; hipEventCreate(&event0); hipEventCreate(&event1); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { a[i+j*N] = 10 + i; b[i+j*N] = (float)j / N; } hipMemcpy( ad, a, size, hipMemcpyHostToDevice ); hipMemcpy( bd, b, size, hipMemcpyHostToDevice ); dim3 dimBlock( blockSize, blockSize ); dim3 dimGrid( N/blockSize, N/blockSize ); hipEventRecord(event0, 0); add_matrix<<< dimGrid, dimBlock >>>(ad, bd, cd, N); hipEventRecord(event1, 0); hipMemcpy( c, cd, size, hipMemcpyDeviceToHost ); hipEventSynchronize(event0); hipEventSynchronize(event1); hipEventElapsedTime(&t, event0, event1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i==N-1 && N-32 < j)printf("%0.2f ", c[i+j*N]); } //printf("\n"); } printf("\n"); printf("Time %0.4f\n", t); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
// Matrix addition, CPU version // gcc matrix_cpu.c -o matrix_cpu -std=c99 /* answers N = 2**6 = 64 is the turning point in gpu v cpu block size 16*16 gave the best performance for us coalescing on N=2**10 Time 0.4686 Time 0.1143 */ #include <hip/hip_runtime.h> #include <stdio.h> __global__ void add_matrix(float *a, float *b, float *c, int N) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int index = x + y*N; if (index < N*N) // allow allocating more threads than elements c[index] = a[index] + b[index]; } void add_matrix_cpu(float *a, float *b, float *c, int N) { for (int y=0; y < N; y++) for (int x=0; y < N; x++){ int index = x + y*N; c[index] = a[index] + b[index]; } } int main() { const int N = 1<<10; const int blockSize = 16; const int size = N*N*sizeof(float); float t; float *a, *ad; float *b, *bd; float *c, *cd; a = new float[N*N]; b = new float[N*N]; c = new float[N*N]; hipMalloc( (void**)&ad, size ); hipMalloc( (void**)&bd, size ); hipMalloc( (void**)&cd, size ); hipEvent_t event0, event1; hipEventCreate(&event0); hipEventCreate(&event1); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { a[i+j*N] = 10 + i; b[i+j*N] = (float)j / N; } hipMemcpy( ad, a, size, hipMemcpyHostToDevice ); hipMemcpy( bd, b, size, hipMemcpyHostToDevice ); dim3 dimBlock( blockSize, blockSize ); dim3 dimGrid( N/blockSize, N/blockSize ); hipEventRecord(event0, 0); add_matrix<<< dimGrid, dimBlock >>>(ad, bd, cd, N); hipEventRecord(event1, 0); hipMemcpy( c, cd, size, hipMemcpyDeviceToHost ); hipEventSynchronize(event0); hipEventSynchronize(event1); hipEventElapsedTime(&t, event0, event1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i==N-1 && N-32 < j)printf("%0.2f ", c[i+j*N]); } //printf("\n"); } printf("\n"); printf("Time %0.4f\n", t); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z10add_matrixPfS_S_i .globl _Z10add_matrixPfS_S_i .p2align 8 .type _Z10add_matrixPfS_S_i,@function _Z10add_matrixPfS_S_i: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s3, s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s4, s2, 16 s_and_b32 s2, s2, 0xffff v_mad_u64_u32 v[2:3], null, s15, s4, v[1:2] s_mul_i32 s14, s14, s2 s_mov_b32 s2, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mul_lo_u32 v1, v2, s3 s_mul_i32 s3, s3, s3 v_add3_u32 v0, s14, v0, v1 s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e64 s3, v0 s_cbranch_execz .LBB0_2 s_load_b128 s[4:7], s[0:1], 0x0 v_ashrrev_i32_e32 v1, 31, v0 s_load_b64 s[0:1], s[0:1], 0x10 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 v2, vcc_lo, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 global_load_b32 v2, v[2:3], off global_load_b32 v3, v[4:5], off v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v2, v2, v3 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 _Z10add_matrixPfS_S_i .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 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 _Z10add_matrixPfS_S_i, .Lfunc_end0-_Z10add_matrixPfS_S_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 - .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: 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: _Z10add_matrixPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z10add_matrixPfS_S_i.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.
// Matrix addition, CPU version // gcc matrix_cpu.c -o matrix_cpu -std=c99 /* answers N = 2**6 = 64 is the turning point in gpu v cpu block size 16*16 gave the best performance for us coalescing on N=2**10 Time 0.4686 Time 0.1143 */ #include <hip/hip_runtime.h> #include <stdio.h> __global__ void add_matrix(float *a, float *b, float *c, int N) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int index = x + y*N; if (index < N*N) // allow allocating more threads than elements c[index] = a[index] + b[index]; } void add_matrix_cpu(float *a, float *b, float *c, int N) { for (int y=0; y < N; y++) for (int x=0; y < N; x++){ int index = x + y*N; c[index] = a[index] + b[index]; } } int main() { const int N = 1<<10; const int blockSize = 16; const int size = N*N*sizeof(float); float t; float *a, *ad; float *b, *bd; float *c, *cd; a = new float[N*N]; b = new float[N*N]; c = new float[N*N]; hipMalloc( (void**)&ad, size ); hipMalloc( (void**)&bd, size ); hipMalloc( (void**)&cd, size ); hipEvent_t event0, event1; hipEventCreate(&event0); hipEventCreate(&event1); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { a[i+j*N] = 10 + i; b[i+j*N] = (float)j / N; } hipMemcpy( ad, a, size, hipMemcpyHostToDevice ); hipMemcpy( bd, b, size, hipMemcpyHostToDevice ); dim3 dimBlock( blockSize, blockSize ); dim3 dimGrid( N/blockSize, N/blockSize ); hipEventRecord(event0, 0); add_matrix<<< dimGrid, dimBlock >>>(ad, bd, cd, N); hipEventRecord(event1, 0); hipMemcpy( c, cd, size, hipMemcpyDeviceToHost ); hipEventSynchronize(event0); hipEventSynchronize(event1); hipEventElapsedTime(&t, event0, event1); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i==N-1 && N-32 < j)printf("%0.2f ", c[i+j*N]); } //printf("\n"); } printf("\n"); printf("Time %0.4f\n", t); }
.text .file "matrix_gpu.hip" .globl _Z25__device_stub__add_matrixPfS_S_i # -- Begin function _Z25__device_stub__add_matrixPfS_S_i .p2align 4, 0x90 .type _Z25__device_stub__add_matrixPfS_S_i,@function _Z25__device_stub__add_matrixPfS_S_i: # @_Z25__device_stub__add_matrixPfS_S_i .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 $_Z10add_matrixPfS_S_i, %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 _Z25__device_stub__add_matrixPfS_S_i, .Lfunc_end0-_Z25__device_stub__add_matrixPfS_S_i .cfi_endproc # -- End function .globl _Z14add_matrix_cpuPfS_S_i # -- Begin function _Z14add_matrix_cpuPfS_S_i .p2align 4, 0x90 .type _Z14add_matrix_cpuPfS_S_i,@function _Z14add_matrix_cpuPfS_S_i: # @_Z14add_matrix_cpuPfS_S_i .cfi_startproc # %bb.0: testl %ecx, %ecx jle .LBB1_3 # %bb.1: # %.preheader.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_2: # %.preheader # =>This Inner Loop Header: Depth=1 movss (%rdi,%rax), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rsi,%rax), %xmm0 movss %xmm0, (%rdx,%rax) addq $4, %rax jmp .LBB1_2 .LBB1_3: retq .Lfunc_end1: .size _Z14add_matrix_cpuPfS_S_i, .Lfunc_end1-_Z14add_matrix_cpuPfS_S_i .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI2_0: .long 0x3a800000 # float 9.765625E-4 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $168, %rsp .cfi_def_cfa_offset 208 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $4194304, %edi # imm = 0x400000 callq _Znam movq %rax, %r15 movl $4194304, %edi # imm = 0x400000 callq _Znam movq %rax, %r14 movl $4194304, %edi # imm = 0x400000 callq _Znam movq %rax, %rbx leaq 48(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 40(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 32(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 16(%rsp), %rdi callq hipEventCreate leaq 8(%rsp), %rdi callq hipEventCreate xorl %eax, %eax movss .LCPI2_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %ecx, %ecx .p2align 4, 0x90 .LBB2_1: # %.preheader36 # =>This Loop Header: Depth=1 # Child Loop BB2_2 Depth 2 leal 10(%rcx), %edx xorps %xmm1, %xmm1 cvtsi2ss %edx, %xmm1 movq %rax, %rdx xorl %esi, %esi .p2align 4, 0x90 .LBB2_2: # Parent Loop BB2_1 Depth=1 # => This Inner Loop Header: Depth=2 movss %xmm1, (%r15,%rdx) xorps %xmm2, %xmm2 cvtsi2ss %esi, %xmm2 mulss %xmm0, %xmm2 movss %xmm2, (%r14,%rdx) incq %rsi addq $4096, %rdx # imm = 0x1000 cmpq $1024, %rsi # imm = 0x400 jne .LBB2_2 # %bb.3: # in Loop: Header=BB2_1 Depth=1 incq %rcx addq $4, %rax cmpq $1024, %rcx # imm = 0x400 jne .LBB2_1 # %bb.4: movq 48(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r15, %rsi movl $1, %ecx callq hipMemcpy movq 40(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy movq 16(%rsp), %rdi xorl %r14d, %r14d xorl %esi, %esi callq hipEventRecord movabsq $274877907008, %rdi # imm = 0x4000000040 movabsq $68719476752, %rdx # imm = 0x1000000010 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_6 # %bb.5: movq 48(%rsp), %rax movq 40(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 120(%rsp) movq %rcx, 112(%rsp) movq %rdx, 104(%rsp) movl $1024, 28(%rsp) # imm = 0x400 leaq 120(%rsp), %rax movq %rax, 128(%rsp) leaq 112(%rsp), %rax movq %rax, 136(%rsp) leaq 104(%rsp), %rax movq %rax, 144(%rsp) leaq 28(%rsp), %rax movq %rax, 152(%rsp) leaq 88(%rsp), %rdi leaq 72(%rsp), %rsi leaq 64(%rsp), %rdx leaq 56(%rsp), %rcx callq __hipPopCallConfiguration movq 88(%rsp), %rsi movl 96(%rsp), %edx movq 72(%rsp), %rcx movl 80(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z10add_matrixPfS_S_i, %edi pushq 56(%rsp) .cfi_adjust_cfa_offset 8 pushq 72(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_6: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 32(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movq %rbx, %rdi movl $2, %ecx callq hipMemcpy movq 16(%rsp), %rdi callq hipEventSynchronize movq 8(%rsp), %rdi callq hipEventSynchronize movq 16(%rsp), %rsi movq 8(%rsp), %rdx leaq 128(%rsp), %rdi callq hipEventElapsedTime addq $4092, %rbx # imm = 0xFFC jmp .LBB2_7 .p2align 4, 0x90 .LBB2_12: # in Loop: Header=BB2_7 Depth=1 incl %r14d cmpl $1024, %r14d # imm = 0x400 je .LBB2_13 .LBB2_7: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_8 Depth 2 movq %rbx, %r15 xorl %r12d, %r12d jmp .LBB2_8 .p2align 4, 0x90 .LBB2_11: # in Loop: Header=BB2_8 Depth=2 incq %r12 addq $4096, %r15 # imm = 0x1000 cmpq $1024, %r12 # imm = 0x400 je .LBB2_12 .LBB2_8: # Parent Loop BB2_7 Depth=1 # => This Inner Loop Header: Depth=2 cmpl $1023, %r14d # imm = 0x3FF jne .LBB2_11 # %bb.9: # in Loop: Header=BB2_8 Depth=2 cmpq $993, %r12 # imm = 0x3E1 jb .LBB2_11 # %bb.10: # in Loop: Header=BB2_8 Depth=2 movss (%r15), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str, %edi movb $1, %al callq printf jmp .LBB2_11 .LBB2_13: movl $10, %edi callq putchar@PLT movss 128(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf xorl %eax, %eax addq $168, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z10add_matrixPfS_S_i, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type _Z10add_matrixPfS_S_i,@object # @_Z10add_matrixPfS_S_i .section .rodata,"a",@progbits .globl _Z10add_matrixPfS_S_i .p2align 3, 0x0 _Z10add_matrixPfS_S_i: .quad _Z25__device_stub__add_matrixPfS_S_i .size _Z10add_matrixPfS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%0.2f " .size .L.str, 7 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Time %0.4f\n" .size .L.str.2, 12 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z10add_matrixPfS_S_i" .size .L__unnamed_1, 22 .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 _Z25__device_stub__add_matrixPfS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z10add_matrixPfS_S_i .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 : _Z10add_matrixPfS_S_i .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 */ /* 0x000e220000002500 */ /*0020*/ ULDC UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe40000000800 */ /*0030*/ UIMAD UR4, UR4, UR4, URZ ; /* 0x00000004040472a4 */ /* 0x000fe2000f8e023f */ /*0040*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e280000002100 */ /*0050*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e680000002600 */ /*0060*/ S2R R5, SR_TID.Y ; /* 0x0000000000057919 */ /* 0x000e620000002200 */ /*0070*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fc400078e0203 */ /*0080*/ IMAD R3, R2, c[0x0][0x4], R5 ; /* 0x0000010002037a24 */ /* 0x002fc800078e0205 */ /*0090*/ IMAD R0, R3, c[0x0][0x178], R0 ; /* 0x00005e0003007a24 */ /* 0x000fca00078e0200 */ /*00a0*/ ISETP.GE.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x000fda000bf06270 */ /*00b0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00c0*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*00d0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*00e0*/ IMAD.WIDE R4, R0, R7, c[0x0][0x168] ; /* 0x00005a0000047625 */ /* 0x000fc800078e0207 */ /*00f0*/ IMAD.WIDE R2, R0.reuse, R7.reuse, c[0x0][0x160] ; /* 0x0000580000027625 */ /* 0x0c0fe400078e0207 */ /*0100*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea8000c1e1900 */ /*0110*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*0120*/ IMAD.WIDE R6, R0, R7, c[0x0][0x170] ; /* 0x00005c0000067625 */ /* 0x000fc800078e0207 */ /*0130*/ FADD R9, R4, R3 ; /* 0x0000000304097221 */ /* 0x004fca0000000000 */ /*0140*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*0150*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0160*/ BRA 0x160; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 _Z10add_matrixPfS_S_i .globl _Z10add_matrixPfS_S_i .p2align 8 .type _Z10add_matrixPfS_S_i,@function _Z10add_matrixPfS_S_i: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s3, s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s4, s2, 16 s_and_b32 s2, s2, 0xffff v_mad_u64_u32 v[2:3], null, s15, s4, v[1:2] s_mul_i32 s14, s14, s2 s_mov_b32 s2, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mul_lo_u32 v1, v2, s3 s_mul_i32 s3, s3, s3 v_add3_u32 v0, s14, v0, v1 s_delay_alu instid0(VALU_DEP_1) v_cmpx_gt_i32_e64 s3, v0 s_cbranch_execz .LBB0_2 s_load_b128 s[4:7], s[0:1], 0x0 v_ashrrev_i32_e32 v1, 31, v0 s_load_b64 s[0:1], s[0:1], 0x10 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 v2, vcc_lo, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 global_load_b32 v2, v[2:3], off global_load_b32 v3, v[4:5], off v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) v_add_f32_e32 v2, v2, v3 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 _Z10add_matrixPfS_S_i .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 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 _Z10add_matrixPfS_S_i, .Lfunc_end0-_Z10add_matrixPfS_S_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 - .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: 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: _Z10add_matrixPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z10add_matrixPfS_S_i.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_000dc165_00000000-6_matrix_gpu.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2061: .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 .LFE2061: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z14add_matrix_cpuPfS_S_i .type _Z14add_matrix_cpuPfS_S_i, @function _Z14add_matrix_cpuPfS_S_i: .LFB2057: .cfi_startproc endbr64 testl %ecx, %ecx jle .L3 movl $0, %eax .L5: movss (%rdi,%rax), %xmm0 addss (%rsi,%rax), %xmm0 movss %xmm0, (%rdx,%rax) addq $4, %rax jmp .L5 .L3: ret .cfi_endproc .LFE2057: .size _Z14add_matrix_cpuPfS_S_i, .-_Z14add_matrix_cpuPfS_S_i .globl _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i .type _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i, @function _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i: .LFB2083: .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 .L10 .L6: movq 136(%rsp), %rax subq %fs:40, %rax jne .L11 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L10: .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 _Z10add_matrixPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L6 .L11: call __stack_chk_fail@PLT .cfi_endproc .LFE2083: .size _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i, .-_Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i .globl _Z10add_matrixPfS_S_i .type _Z10add_matrixPfS_S_i, @function _Z10add_matrixPfS_S_i: .LFB2084: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2084: .size _Z10add_matrixPfS_S_i, .-_Z10add_matrixPfS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "%0.2f " .LC2: .string "\n" .LC3: .string "Time %0.4f\n" .text .globl main .type main, @function main: .LFB2058: .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 $80, %rsp .cfi_def_cfa_offset 128 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax movl $4194304, %edi call _Znam@PLT movq %rax, %rbp movl $4194304, %edi call _Znam@PLT movq %rax, %rbx movl $4194304, %edi call _Znam@PLT movq %rax, %r12 leaq 8(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 16(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 24(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT leaq 32(%rsp), %rdi call cudaEventCreate@PLT leaq 40(%rsp), %rdi call cudaEventCreate@PLT movl $10, %esi movl $0, %ecx movss .LC0(%rip), %xmm2 .L15: leaq 0(,%rcx,4), %rdx movl $0, %eax pxor %xmm1, %xmm1 cvtsi2ssl %esi, %xmm1 .L16: movss %xmm1, 0(%rbp,%rdx) pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 mulss %xmm2, %xmm0 movss %xmm0, (%rbx,%rdx) addl $1, %eax addq $4096, %rdx cmpl $1024, %eax jne .L16 addq $1, %rcx addl $1, %esi cmpq $1024, %rcx jne .L15 movl $1, %ecx movl $4194304, %edx movq %rbp, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $4194304, %edx movq %rbx, %rsi movq 16(%rsp), %rdi call cudaMemcpy@PLT movl $16, 48(%rsp) movl $16, 52(%rsp) movl $1, 56(%rsp) movl $64, 60(%rsp) movl $64, 64(%rsp) movl $1, 68(%rsp) movl $0, %esi movq 32(%rsp), %rdi call cudaEventRecord@PLT movl 56(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 48(%rsp), %rdx movq 60(%rsp), %rdi movl 68(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L27 .L18: movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movl $2, %ecx movl $4194304, %edx movq 24(%rsp), %rsi movq %r12, %rdi call cudaMemcpy@PLT movq 32(%rsp), %rdi call cudaEventSynchronize@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 4(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT movl $0, %r13d leaq .LC1(%rip), %r14 jmp .L19 .L27: movl $1024, %ecx movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z35__device_stub__Z10add_matrixPfS_S_iPfS_S_i jmp .L18 .L20: addl $1, %ebx addq $4096, %rbp cmpl $1024, %ebx je .L28 .L23: cmpl $1023, %r13d jne .L20 cmpl $992, %ebx jle .L20 pxor %xmm0, %xmm0 cvtss2sd 0(%rbp), %xmm0 movq %r14, %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT addl $1, %ebx addq $4096, %rbp cmpl $1024, %ebx jne .L23 .L22: leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT pxor %xmm0, %xmm0 cvtss2sd 4(%rsp), %xmm0 leaq .LC3(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L29 movl $0, %eax addq $80, %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 .L28: .cfi_restore_state addl $1, %r13d cmpl $1024, %r13d je .L22 .L19: leaq 4092(%r12), %rbp movl $0, %ebx jmp .L23 .L29: call __stack_chk_fail@PLT .cfi_endproc .LFE2058: .size main, .-main .section .rodata.str1.1 .LC4: .string "_Z10add_matrixPfS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2086: .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 _Z10add_matrixPfS_S_i(%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 .LFE2086: .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 981467136 .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 "matrix_gpu.hip" .globl _Z25__device_stub__add_matrixPfS_S_i # -- Begin function _Z25__device_stub__add_matrixPfS_S_i .p2align 4, 0x90 .type _Z25__device_stub__add_matrixPfS_S_i,@function _Z25__device_stub__add_matrixPfS_S_i: # @_Z25__device_stub__add_matrixPfS_S_i .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 $_Z10add_matrixPfS_S_i, %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 _Z25__device_stub__add_matrixPfS_S_i, .Lfunc_end0-_Z25__device_stub__add_matrixPfS_S_i .cfi_endproc # -- End function .globl _Z14add_matrix_cpuPfS_S_i # -- Begin function _Z14add_matrix_cpuPfS_S_i .p2align 4, 0x90 .type _Z14add_matrix_cpuPfS_S_i,@function _Z14add_matrix_cpuPfS_S_i: # @_Z14add_matrix_cpuPfS_S_i .cfi_startproc # %bb.0: testl %ecx, %ecx jle .LBB1_3 # %bb.1: # %.preheader.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_2: # %.preheader # =>This Inner Loop Header: Depth=1 movss (%rdi,%rax), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rsi,%rax), %xmm0 movss %xmm0, (%rdx,%rax) addq $4, %rax jmp .LBB1_2 .LBB1_3: retq .Lfunc_end1: .size _Z14add_matrix_cpuPfS_S_i, .Lfunc_end1-_Z14add_matrix_cpuPfS_S_i .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI2_0: .long 0x3a800000 # float 9.765625E-4 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %r12 .cfi_def_cfa_offset 32 pushq %rbx .cfi_def_cfa_offset 40 subq $168, %rsp .cfi_def_cfa_offset 208 .cfi_offset %rbx, -40 .cfi_offset %r12, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $4194304, %edi # imm = 0x400000 callq _Znam movq %rax, %r15 movl $4194304, %edi # imm = 0x400000 callq _Znam movq %rax, %r14 movl $4194304, %edi # imm = 0x400000 callq _Znam movq %rax, %rbx leaq 48(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 40(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 32(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc leaq 16(%rsp), %rdi callq hipEventCreate leaq 8(%rsp), %rdi callq hipEventCreate xorl %eax, %eax movss .LCPI2_0(%rip), %xmm0 # xmm0 = mem[0],zero,zero,zero xorl %ecx, %ecx .p2align 4, 0x90 .LBB2_1: # %.preheader36 # =>This Loop Header: Depth=1 # Child Loop BB2_2 Depth 2 leal 10(%rcx), %edx xorps %xmm1, %xmm1 cvtsi2ss %edx, %xmm1 movq %rax, %rdx xorl %esi, %esi .p2align 4, 0x90 .LBB2_2: # Parent Loop BB2_1 Depth=1 # => This Inner Loop Header: Depth=2 movss %xmm1, (%r15,%rdx) xorps %xmm2, %xmm2 cvtsi2ss %esi, %xmm2 mulss %xmm0, %xmm2 movss %xmm2, (%r14,%rdx) incq %rsi addq $4096, %rdx # imm = 0x1000 cmpq $1024, %rsi # imm = 0x400 jne .LBB2_2 # %bb.3: # in Loop: Header=BB2_1 Depth=1 incq %rcx addq $4, %rax cmpq $1024, %rcx # imm = 0x400 jne .LBB2_1 # %bb.4: movq 48(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r15, %rsi movl $1, %ecx callq hipMemcpy movq 40(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy movq 16(%rsp), %rdi xorl %r14d, %r14d xorl %esi, %esi callq hipEventRecord movabsq $274877907008, %rdi # imm = 0x4000000040 movabsq $68719476752, %rdx # imm = 0x1000000010 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_6 # %bb.5: movq 48(%rsp), %rax movq 40(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 120(%rsp) movq %rcx, 112(%rsp) movq %rdx, 104(%rsp) movl $1024, 28(%rsp) # imm = 0x400 leaq 120(%rsp), %rax movq %rax, 128(%rsp) leaq 112(%rsp), %rax movq %rax, 136(%rsp) leaq 104(%rsp), %rax movq %rax, 144(%rsp) leaq 28(%rsp), %rax movq %rax, 152(%rsp) leaq 88(%rsp), %rdi leaq 72(%rsp), %rsi leaq 64(%rsp), %rdx leaq 56(%rsp), %rcx callq __hipPopCallConfiguration movq 88(%rsp), %rsi movl 96(%rsp), %edx movq 72(%rsp), %rcx movl 80(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z10add_matrixPfS_S_i, %edi pushq 56(%rsp) .cfi_adjust_cfa_offset 8 pushq 72(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB2_6: movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq 32(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movq %rbx, %rdi movl $2, %ecx callq hipMemcpy movq 16(%rsp), %rdi callq hipEventSynchronize movq 8(%rsp), %rdi callq hipEventSynchronize movq 16(%rsp), %rsi movq 8(%rsp), %rdx leaq 128(%rsp), %rdi callq hipEventElapsedTime addq $4092, %rbx # imm = 0xFFC jmp .LBB2_7 .p2align 4, 0x90 .LBB2_12: # in Loop: Header=BB2_7 Depth=1 incl %r14d cmpl $1024, %r14d # imm = 0x400 je .LBB2_13 .LBB2_7: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_8 Depth 2 movq %rbx, %r15 xorl %r12d, %r12d jmp .LBB2_8 .p2align 4, 0x90 .LBB2_11: # in Loop: Header=BB2_8 Depth=2 incq %r12 addq $4096, %r15 # imm = 0x1000 cmpq $1024, %r12 # imm = 0x400 je .LBB2_12 .LBB2_8: # Parent Loop BB2_7 Depth=1 # => This Inner Loop Header: Depth=2 cmpl $1023, %r14d # imm = 0x3FF jne .LBB2_11 # %bb.9: # in Loop: Header=BB2_8 Depth=2 cmpq $993, %r12 # imm = 0x3E1 jb .LBB2_11 # %bb.10: # in Loop: Header=BB2_8 Depth=2 movss (%r15), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str, %edi movb $1, %al callq printf jmp .LBB2_11 .LBB2_13: movl $10, %edi callq putchar@PLT movss 128(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf xorl %eax, %eax addq $168, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size main, .Lfunc_end2-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 .LBB3_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB3_2: movq __hip_gpubin_handle(%rip), %rdi xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z10add_matrixPfS_S_i, %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_end3: .size __hip_module_ctor, .Lfunc_end3-__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 .LBB4_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 .LBB4_2: retq .Lfunc_end4: .size __hip_module_dtor, .Lfunc_end4-__hip_module_dtor .cfi_endproc # -- End function .type _Z10add_matrixPfS_S_i,@object # @_Z10add_matrixPfS_S_i .section .rodata,"a",@progbits .globl _Z10add_matrixPfS_S_i .p2align 3, 0x0 _Z10add_matrixPfS_S_i: .quad _Z25__device_stub__add_matrixPfS_S_i .size _Z10add_matrixPfS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%0.2f " .size .L.str, 7 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "Time %0.4f\n" .size .L.str.2, 12 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z10add_matrixPfS_S_i" .size .L__unnamed_1, 22 .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 _Z25__device_stub__add_matrixPfS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z10add_matrixPfS_S_i .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" // this is how cuda knows that this code is a kernel by calling __global__ __global__ void cube(float * d_out, float * d_in) { int idx = threadIdx.x ; float f = d_in[idx]; d_out[idx] = f * f * f; }
code for sm_80 Function : _Z4cubePfS_ .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 R4, SR_TID.X ; /* 0x0000000000047919 */ /* 0x000e220000002100 */ /*0020*/ HFMA2.MMA R5, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff057435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0040*/ IMAD.WIDE R2, R4, R5, c[0x0][0x168] ; /* 0x00005a0004027625 */ /* 0x001fcc00078e0205 */ /*0050*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea2000c1e1900 */ /*0060*/ IMAD.WIDE R4, R4, R5, c[0x0][0x160] ; /* 0x0000580004047625 */ /* 0x000fc800078e0205 */ /*0070*/ FMUL R7, R2, R2 ; /* 0x0000000202077220 */ /* 0x004fc80000400000 */ /*0080*/ FMUL R7, R2, R7 ; /* 0x0000000702077220 */ /* 0x000fca0000400000 */ /*0090*/ STG.E [R4.64], R7 ; /* 0x0000000704007986 */ /* 0x000fe2000c101904 */ /*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 CUDA host assembly.
#include "includes.h" // this is how cuda knows that this code is a kernel by calling __global__ __global__ void cube(float * d_out, float * d_in) { int idx = threadIdx.x ; float f = d_in[idx]; d_out[idx] = f * f * f; }
.file "tmpxft_000d44b8_00000000-6_cube.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 _Z25__device_stub__Z4cubePfS_PfS_ .type _Z25__device_stub__Z4cubePfS_PfS_, @function _Z25__device_stub__Z4cubePfS_PfS_: .LFB2051: .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 _Z4cubePfS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z25__device_stub__Z4cubePfS_PfS_, .-_Z25__device_stub__Z4cubePfS_PfS_ .globl _Z4cubePfS_ .type _Z4cubePfS_, @function _Z4cubePfS_: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z25__device_stub__Z4cubePfS_PfS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z4cubePfS_, .-_Z4cubePfS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z4cubePfS_" .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 _Z4cubePfS_(%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" // this is how cuda knows that this code is a kernel by calling __global__ __global__ void cube(float * d_out, float * d_in) { int idx = threadIdx.x ; float f = d_in[idx]; d_out[idx] = f * f * f; }
#include <hip/hip_runtime.h> #include "includes.h" // this is how cuda knows that this code is a kernel by calling __global__ __global__ void cube(float * d_out, float * d_in) { int idx = threadIdx.x ; float f = d_in[idx]; d_out[idx] = f * f * f; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include "includes.h" // this is how cuda knows that this code is a kernel by calling __global__ __global__ void cube(float * d_out, float * d_in) { int idx = threadIdx.x ; float f = d_in[idx]; d_out[idx] = f * f * f; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z4cubePfS_ .globl _Z4cubePfS_ .p2align 8 .type _Z4cubePfS_,@function _Z4cubePfS_: s_load_b128 s[0:3], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 2, v0 s_waitcnt lgkmcnt(0) global_load_b32 v1, v0, s[2:3] s_waitcnt vmcnt(0) v_mul_f32_e32 v2, v1, v1 s_delay_alu instid0(VALU_DEP_1) v_mul_f32_e32 v1, v1, v2 global_store_b32 v0, v1, s[0:1] s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z4cubePfS_ .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 4 .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 _Z4cubePfS_, .Lfunc_end0-_Z4cubePfS_ .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: _Z4cubePfS_ .private_segment_fixed_size: 0 .sgpr_count: 4 .sgpr_spill_count: 0 .symbol: _Z4cubePfS_.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 <hip/hip_runtime.h> #include "includes.h" // this is how cuda knows that this code is a kernel by calling __global__ __global__ void cube(float * d_out, float * d_in) { int idx = threadIdx.x ; float f = d_in[idx]; d_out[idx] = f * f * f; }
.text .file "cube.hip" .globl _Z19__device_stub__cubePfS_ # -- Begin function _Z19__device_stub__cubePfS_ .p2align 4, 0x90 .type _Z19__device_stub__cubePfS_,@function _Z19__device_stub__cubePfS_: # @_Z19__device_stub__cubePfS_ .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 $_Z4cubePfS_, %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 _Z19__device_stub__cubePfS_, .Lfunc_end0-_Z19__device_stub__cubePfS_ .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 $_Z4cubePfS_, %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 _Z4cubePfS_,@object # @_Z4cubePfS_ .section .rodata,"a",@progbits .globl _Z4cubePfS_ .p2align 3, 0x0 _Z4cubePfS_: .quad _Z19__device_stub__cubePfS_ .size _Z4cubePfS_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z4cubePfS_" .size .L__unnamed_1, 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 _Z19__device_stub__cubePfS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4cubePfS_ .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 : _Z4cubePfS_ .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 R4, SR_TID.X ; /* 0x0000000000047919 */ /* 0x000e220000002100 */ /*0020*/ HFMA2.MMA R5, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff057435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0040*/ IMAD.WIDE R2, R4, R5, c[0x0][0x168] ; /* 0x00005a0004027625 */ /* 0x001fcc00078e0205 */ /*0050*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea2000c1e1900 */ /*0060*/ IMAD.WIDE R4, R4, R5, c[0x0][0x160] ; /* 0x0000580004047625 */ /* 0x000fc800078e0205 */ /*0070*/ FMUL R7, R2, R2 ; /* 0x0000000202077220 */ /* 0x004fc80000400000 */ /*0080*/ FMUL R7, R2, R7 ; /* 0x0000000702077220 */ /* 0x000fca0000400000 */ /*0090*/ STG.E [R4.64], R7 ; /* 0x0000000704007986 */ /* 0x000fe2000c101904 */ /*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 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z4cubePfS_ .globl _Z4cubePfS_ .p2align 8 .type _Z4cubePfS_,@function _Z4cubePfS_: s_load_b128 s[0:3], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 2, v0 s_waitcnt lgkmcnt(0) global_load_b32 v1, v0, s[2:3] s_waitcnt vmcnt(0) v_mul_f32_e32 v2, v1, v1 s_delay_alu instid0(VALU_DEP_1) v_mul_f32_e32 v1, v1, v2 global_store_b32 v0, v1, s[0:1] s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z4cubePfS_ .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 4 .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 _Z4cubePfS_, .Lfunc_end0-_Z4cubePfS_ .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: _Z4cubePfS_ .private_segment_fixed_size: 0 .sgpr_count: 4 .sgpr_spill_count: 0 .symbol: _Z4cubePfS_.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_000d44b8_00000000-6_cube.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 _Z25__device_stub__Z4cubePfS_PfS_ .type _Z25__device_stub__Z4cubePfS_PfS_, @function _Z25__device_stub__Z4cubePfS_PfS_: .LFB2051: .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 _Z4cubePfS_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 128 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z25__device_stub__Z4cubePfS_PfS_, .-_Z25__device_stub__Z4cubePfS_PfS_ .globl _Z4cubePfS_ .type _Z4cubePfS_, @function _Z4cubePfS_: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z25__device_stub__Z4cubePfS_PfS_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z4cubePfS_, .-_Z4cubePfS_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z4cubePfS_" .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 _Z4cubePfS_(%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 "cube.hip" .globl _Z19__device_stub__cubePfS_ # -- Begin function _Z19__device_stub__cubePfS_ .p2align 4, 0x90 .type _Z19__device_stub__cubePfS_,@function _Z19__device_stub__cubePfS_: # @_Z19__device_stub__cubePfS_ .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 $_Z4cubePfS_, %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 _Z19__device_stub__cubePfS_, .Lfunc_end0-_Z19__device_stub__cubePfS_ .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 $_Z4cubePfS_, %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 _Z4cubePfS_,@object # @_Z4cubePfS_ .section .rodata,"a",@progbits .globl _Z4cubePfS_ .p2align 3, 0x0 _Z4cubePfS_: .quad _Z19__device_stub__cubePfS_ .size _Z4cubePfS_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z4cubePfS_" .size .L__unnamed_1, 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 _Z19__device_stub__cubePfS_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4cubePfS_ .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.
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de memoria mapeada com cudaHostAlloc() usando o parametro cudaHostAllocMapped para alocar memoria tanto no host quanto no device. Copias entre host e device sao implicitas, igual aa memoria unificada. cudaDeviceSynchronize() antes da impressao do resultado se faz necessaria, caso contrário o resultado deve sair errado. Para compilar: nvcc 02-soma-vet-mapped.cu -o 02-soma-vet-mapped Para executar: ./02-soma-vet-mapped OBS: os valores de tamanho do vetor e o conteudo do vetor estao fixos no codigo */ #include <stdio.h> #include <stdlib.h> #include <cuda.h> __global__ void soma(int *vetorA, int *vetorB,int *vetorC,int tam) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < tam) { vetorC[idx]=vetorA[idx]+vetorB[idx]; } } int main(int argc,char **argv) { int i,*vetorA,*vetorB,*vetorC,threadsPerBlock,blocksPerGrid; int tam = 16; //5000; //Define a quantidade de threads por bloco threadsPerBlock = 256; //Aloca os vetores no host e no device (memória mapeada em endereço virtual unificado) cudaHostAlloc((void**)&vetorA,tam*(sizeof(int)),cudaHostAllocMapped); cudaHostAlloc((void**)&vetorB,tam*(sizeof(int)),cudaHostAllocMapped); cudaHostAlloc((void**)&vetorC,tam*(sizeof(int)),cudaHostAllocMapped); //Preenche os vetores no host for(i=0;i<tam;i++) { vetorA[i]=i; vetorB[i]=0; //-i; } //Define a quantidade de blocos por grade blocksPerGrid=(tam+threadsPerBlock-1)/threadsPerBlock; //Invoca o kernel com blocksPerGrid blocos e threadsPerBlock threads soma <<<blocksPerGrid,threadsPerBlock>>> (vetorA,vetorB,vetorC,tam); cudaDeviceSynchronize(); //Imprime o resultado no host for(i=0;i<tam;i++) { printf("%d ",vetorC[i]); } printf("\n"); //Desaloca os vetores no host e no device cudaFreeHost(vetorA); cudaFreeHost(vetorB); cudaFreeHost(vetorC); }
code for sm_80 Function : _Z4somaPiS_S_i .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 R6, SR_CTAID.X ; /* 0x0000000000067919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R6, R6, c[0x0][0x0], R3 ; /* 0x0000000006067a24 */ /* 0x001fca00078e0203 */ /*0040*/ ISETP.GE.AND P0, PT, R6, c[0x0][0x178], PT ; /* 0x00005e0006007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0070*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0080*/ IMAD.WIDE R4, R6, R7, c[0x0][0x168] ; /* 0x00005a0006047625 */ /* 0x000fc800078e0207 */ /*0090*/ IMAD.WIDE R2, R6.reuse, R7.reuse, c[0x0][0x160] ; /* 0x0000580006027625 */ /* 0x0c0fe400078e0207 */ /*00a0*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea8000c1e1900 */ /*00b0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x170] ; /* 0x00005c0006067625 */ /* 0x000fe200078e0207 */ /*00d0*/ IADD3 R9, R4, R3, RZ ; /* 0x0000000304097210 */ /* 0x004fca0007ffe0ff */ /*00e0*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*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.
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de memoria mapeada com cudaHostAlloc() usando o parametro cudaHostAllocMapped para alocar memoria tanto no host quanto no device. Copias entre host e device sao implicitas, igual aa memoria unificada. cudaDeviceSynchronize() antes da impressao do resultado se faz necessaria, caso contrário o resultado deve sair errado. Para compilar: nvcc 02-soma-vet-mapped.cu -o 02-soma-vet-mapped Para executar: ./02-soma-vet-mapped OBS: os valores de tamanho do vetor e o conteudo do vetor estao fixos no codigo */ #include <stdio.h> #include <stdlib.h> #include <cuda.h> __global__ void soma(int *vetorA, int *vetorB,int *vetorC,int tam) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < tam) { vetorC[idx]=vetorA[idx]+vetorB[idx]; } } int main(int argc,char **argv) { int i,*vetorA,*vetorB,*vetorC,threadsPerBlock,blocksPerGrid; int tam = 16; //5000; //Define a quantidade de threads por bloco threadsPerBlock = 256; //Aloca os vetores no host e no device (memória mapeada em endereço virtual unificado) cudaHostAlloc((void**)&vetorA,tam*(sizeof(int)),cudaHostAllocMapped); cudaHostAlloc((void**)&vetorB,tam*(sizeof(int)),cudaHostAllocMapped); cudaHostAlloc((void**)&vetorC,tam*(sizeof(int)),cudaHostAllocMapped); //Preenche os vetores no host for(i=0;i<tam;i++) { vetorA[i]=i; vetorB[i]=0; //-i; } //Define a quantidade de blocos por grade blocksPerGrid=(tam+threadsPerBlock-1)/threadsPerBlock; //Invoca o kernel com blocksPerGrid blocos e threadsPerBlock threads soma <<<blocksPerGrid,threadsPerBlock>>> (vetorA,vetorB,vetorC,tam); cudaDeviceSynchronize(); //Imprime o resultado no host for(i=0;i<tam;i++) { printf("%d ",vetorC[i]); } printf("\n"); //Desaloca os vetores no host e no device cudaFreeHost(vetorA); cudaFreeHost(vetorB); cudaFreeHost(vetorC); }
.file "tmpxft_001025a9_00000000-6_02-soma-vet-mapped.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 _Z28__device_stub__Z4somaPiS_S_iPiS_S_i .type _Z28__device_stub__Z4somaPiS_S_iPiS_S_i, @function _Z28__device_stub__Z4somaPiS_S_iPiS_S_i: .LFB2082: .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 _Z4somaPiS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z28__device_stub__Z4somaPiS_S_iPiS_S_i, .-_Z28__device_stub__Z4somaPiS_S_iPiS_S_i .globl _Z4somaPiS_S_i .type _Z4somaPiS_S_i, @function _Z4somaPiS_S_i: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z28__device_stub__Z4somaPiS_S_iPiS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z4somaPiS_S_i, .-_Z4somaPiS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d " .LC1: .string "\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 subq $72, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax leaq 8(%rsp), %rdi movl $2, %edx movl $64, %esi call cudaHostAlloc@PLT leaq 16(%rsp), %rdi movl $2, %edx movl $64, %esi call cudaHostAlloc@PLT leaq 24(%rsp), %rdi movl $2, %edx movl $64, %esi call cudaHostAlloc@PLT movl $0, %eax .L12: movq 8(%rsp), %rdx movl %eax, (%rdx,%rax,4) movq 16(%rsp), %rdx movl $0, (%rdx,%rax,4) addq $1, %rax cmpq $16, %rax jne .L12 movl $256, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%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 .L19 .L13: call cudaDeviceSynchronize@PLT movl $0, %ebx leaq .LC0(%rip), %rbp .L14: movq 24(%rsp), %rax movl (%rax,%rbx), %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT addq $4, %rbx cmpq $64, %rbx jne .L14 leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq 8(%rsp), %rdi call cudaFreeHost@PLT movq 16(%rsp), %rdi call cudaFreeHost@PLT movq 24(%rsp), %rdi call cudaFreeHost@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L20 movl $0, %eax addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L19: .cfi_restore_state movl $16, %ecx movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z28__device_stub__Z4somaPiS_S_iPiS_S_i jmp .L13 .L20: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC2: .string "_Z4somaPiS_S_i" .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 _Z4somaPiS_S_i(%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.
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de memoria mapeada com cudaHostAlloc() usando o parametro cudaHostAllocMapped para alocar memoria tanto no host quanto no device. Copias entre host e device sao implicitas, igual aa memoria unificada. cudaDeviceSynchronize() antes da impressao do resultado se faz necessaria, caso contrário o resultado deve sair errado. Para compilar: nvcc 02-soma-vet-mapped.cu -o 02-soma-vet-mapped Para executar: ./02-soma-vet-mapped OBS: os valores de tamanho do vetor e o conteudo do vetor estao fixos no codigo */ #include <stdio.h> #include <stdlib.h> #include <cuda.h> __global__ void soma(int *vetorA, int *vetorB,int *vetorC,int tam) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < tam) { vetorC[idx]=vetorA[idx]+vetorB[idx]; } } int main(int argc,char **argv) { int i,*vetorA,*vetorB,*vetorC,threadsPerBlock,blocksPerGrid; int tam = 16; //5000; //Define a quantidade de threads por bloco threadsPerBlock = 256; //Aloca os vetores no host e no device (memória mapeada em endereço virtual unificado) cudaHostAlloc((void**)&vetorA,tam*(sizeof(int)),cudaHostAllocMapped); cudaHostAlloc((void**)&vetorB,tam*(sizeof(int)),cudaHostAllocMapped); cudaHostAlloc((void**)&vetorC,tam*(sizeof(int)),cudaHostAllocMapped); //Preenche os vetores no host for(i=0;i<tam;i++) { vetorA[i]=i; vetorB[i]=0; //-i; } //Define a quantidade de blocos por grade blocksPerGrid=(tam+threadsPerBlock-1)/threadsPerBlock; //Invoca o kernel com blocksPerGrid blocos e threadsPerBlock threads soma <<<blocksPerGrid,threadsPerBlock>>> (vetorA,vetorB,vetorC,tam); cudaDeviceSynchronize(); //Imprime o resultado no host for(i=0;i<tam;i++) { printf("%d ",vetorC[i]); } printf("\n"); //Desaloca os vetores no host e no device cudaFreeHost(vetorA); cudaFreeHost(vetorB); cudaFreeHost(vetorC); }
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de memoria mapeada com cudaHostAlloc() usando o parametro cudaHostAllocMapped para alocar memoria tanto no host quanto no device. Copias entre host e device sao implicitas, igual aa memoria unificada. cudaDeviceSynchronize() antes da impressao do resultado se faz necessaria, caso contrário o resultado deve sair errado. Para compilar: nvcc 02-soma-vet-mapped.cu -o 02-soma-vet-mapped Para executar: ./02-soma-vet-mapped OBS: os valores de tamanho do vetor e o conteudo do vetor estao fixos no codigo */ #include <stdio.h> #include <stdlib.h> #include <hip/hip_runtime.h> __global__ void soma(int *vetorA, int *vetorB,int *vetorC,int tam) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < tam) { vetorC[idx]=vetorA[idx]+vetorB[idx]; } } int main(int argc,char **argv) { int i,*vetorA,*vetorB,*vetorC,threadsPerBlock,blocksPerGrid; int tam = 16; //5000; //Define a quantidade de threads por bloco threadsPerBlock = 256; //Aloca os vetores no host e no device (memória mapeada em endereço virtual unificado) hipHostAlloc((void**)&vetorA,tam*(sizeof(int)),hipHostMallocMapped); hipHostAlloc((void**)&vetorB,tam*(sizeof(int)),hipHostMallocMapped); hipHostAlloc((void**)&vetorC,tam*(sizeof(int)),hipHostMallocMapped); //Preenche os vetores no host for(i=0;i<tam;i++) { vetorA[i]=i; vetorB[i]=0; //-i; } //Define a quantidade de blocos por grade blocksPerGrid=(tam+threadsPerBlock-1)/threadsPerBlock; //Invoca o kernel com blocksPerGrid blocos e threadsPerBlock threads soma <<<blocksPerGrid,threadsPerBlock>>> (vetorA,vetorB,vetorC,tam); hipDeviceSynchronize(); //Imprime o resultado no host for(i=0;i<tam;i++) { printf("%d ",vetorC[i]); } printf("\n"); //Desaloca os vetores no host e no device hipHostFree(vetorA); hipHostFree(vetorB); hipHostFree(vetorC); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de memoria mapeada com cudaHostAlloc() usando o parametro cudaHostAllocMapped para alocar memoria tanto no host quanto no device. Copias entre host e device sao implicitas, igual aa memoria unificada. cudaDeviceSynchronize() antes da impressao do resultado se faz necessaria, caso contrário o resultado deve sair errado. Para compilar: nvcc 02-soma-vet-mapped.cu -o 02-soma-vet-mapped Para executar: ./02-soma-vet-mapped OBS: os valores de tamanho do vetor e o conteudo do vetor estao fixos no codigo */ #include <stdio.h> #include <stdlib.h> #include <hip/hip_runtime.h> __global__ void soma(int *vetorA, int *vetorB,int *vetorC,int tam) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < tam) { vetorC[idx]=vetorA[idx]+vetorB[idx]; } } int main(int argc,char **argv) { int i,*vetorA,*vetorB,*vetorC,threadsPerBlock,blocksPerGrid; int tam = 16; //5000; //Define a quantidade de threads por bloco threadsPerBlock = 256; //Aloca os vetores no host e no device (memória mapeada em endereço virtual unificado) hipHostAlloc((void**)&vetorA,tam*(sizeof(int)),hipHostMallocMapped); hipHostAlloc((void**)&vetorB,tam*(sizeof(int)),hipHostMallocMapped); hipHostAlloc((void**)&vetorC,tam*(sizeof(int)),hipHostMallocMapped); //Preenche os vetores no host for(i=0;i<tam;i++) { vetorA[i]=i; vetorB[i]=0; //-i; } //Define a quantidade de blocos por grade blocksPerGrid=(tam+threadsPerBlock-1)/threadsPerBlock; //Invoca o kernel com blocksPerGrid blocos e threadsPerBlock threads soma <<<blocksPerGrid,threadsPerBlock>>> (vetorA,vetorB,vetorC,tam); hipDeviceSynchronize(); //Imprime o resultado no host for(i=0;i<tam;i++) { printf("%d ",vetorC[i]); } printf("\n"); //Desaloca os vetores no host e no device hipHostFree(vetorA); hipHostFree(vetorB); hipHostFree(vetorC); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z4somaPiS_S_i .globl _Z4somaPiS_S_i .p2align 8 .type _Z4somaPiS_S_i,@function _Z4somaPiS_S_i: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s3, s[0:1], 0x18 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_2 s_load_b128 s[4:7], s[0:1], 0x0 v_ashrrev_i32_e32 v2, 31, v1 s_load_b64 s[0:1], s[0:1], 0x10 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, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 global_load_b32 v2, v[2:3], off global_load_b32 v3, v[4:5], off v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) v_add_nc_u32_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 _Z4somaPiS_S_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .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 _Z4somaPiS_S_i, .Lfunc_end0-_Z4somaPiS_S_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 - .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: 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: _Z4somaPiS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z4somaPiS_S_i.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.
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de memoria mapeada com cudaHostAlloc() usando o parametro cudaHostAllocMapped para alocar memoria tanto no host quanto no device. Copias entre host e device sao implicitas, igual aa memoria unificada. cudaDeviceSynchronize() antes da impressao do resultado se faz necessaria, caso contrário o resultado deve sair errado. Para compilar: nvcc 02-soma-vet-mapped.cu -o 02-soma-vet-mapped Para executar: ./02-soma-vet-mapped OBS: os valores de tamanho do vetor e o conteudo do vetor estao fixos no codigo */ #include <stdio.h> #include <stdlib.h> #include <hip/hip_runtime.h> __global__ void soma(int *vetorA, int *vetorB,int *vetorC,int tam) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < tam) { vetorC[idx]=vetorA[idx]+vetorB[idx]; } } int main(int argc,char **argv) { int i,*vetorA,*vetorB,*vetorC,threadsPerBlock,blocksPerGrid; int tam = 16; //5000; //Define a quantidade de threads por bloco threadsPerBlock = 256; //Aloca os vetores no host e no device (memória mapeada em endereço virtual unificado) hipHostAlloc((void**)&vetorA,tam*(sizeof(int)),hipHostMallocMapped); hipHostAlloc((void**)&vetorB,tam*(sizeof(int)),hipHostMallocMapped); hipHostAlloc((void**)&vetorC,tam*(sizeof(int)),hipHostMallocMapped); //Preenche os vetores no host for(i=0;i<tam;i++) { vetorA[i]=i; vetorB[i]=0; //-i; } //Define a quantidade de blocos por grade blocksPerGrid=(tam+threadsPerBlock-1)/threadsPerBlock; //Invoca o kernel com blocksPerGrid blocos e threadsPerBlock threads soma <<<blocksPerGrid,threadsPerBlock>>> (vetorA,vetorB,vetorC,tam); hipDeviceSynchronize(); //Imprime o resultado no host for(i=0;i<tam;i++) { printf("%d ",vetorC[i]); } printf("\n"); //Desaloca os vetores no host e no device hipHostFree(vetorA); hipHostFree(vetorB); hipHostFree(vetorC); }
.text .file "02-soma-vet-mapped.hip" .globl _Z19__device_stub__somaPiS_S_i # -- Begin function _Z19__device_stub__somaPiS_S_i .p2align 4, 0x90 .type _Z19__device_stub__somaPiS_S_i,@function _Z19__device_stub__somaPiS_S_i: # @_Z19__device_stub__somaPiS_S_i .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 $_Z4somaPiS_S_i, %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 _Z19__device_stub__somaPiS_S_i, .Lfunc_end0-_Z19__device_stub__somaPiS_S_i .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 $144, %rsp .cfi_def_cfa_offset 160 .cfi_offset %rbx, -16 leaq 24(%rsp), %rdi movl $64, %esi movl $2, %edx callq hipHostAlloc leaq 16(%rsp), %rdi movl $64, %esi movl $2, %edx callq hipHostAlloc leaq 8(%rsp), %rdi movl $64, %esi movl $2, %edx callq hipHostAlloc movq 24(%rsp), %rax xorl %ecx, %ecx movq 16(%rsp), %rdx .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 movl %ecx, (%rax,%rcx,4) movl $0, (%rdx,%rcx,4) incq %rcx cmpq $16, %rcx jne .LBB1_1 # %bb.2: movabsq $4294967297, %rdi # imm = 0x100000001 leaq 255(%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 24(%rsp), %rax movq 16(%rsp), %rcx movq 8(%rsp), %rdx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movq %rdx, 88(%rsp) movl $16, 36(%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 36(%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 $_Z4somaPiS_S_i, %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 .LBB1_4: callq hipDeviceSynchronize xorl %ebx, %ebx .p2align 4, 0x90 .LBB1_5: # =>This Inner Loop Header: Depth=1 movq 8(%rsp), %rax movl (%rax,%rbx,4), %esi movl $.L.str, %edi xorl %eax, %eax callq printf incq %rbx cmpq $16, %rbx jne .LBB1_5 # %bb.6: movl $10, %edi callq putchar@PLT movq 24(%rsp), %rdi callq hipHostFree movq 16(%rsp), %rdi callq hipHostFree movq 8(%rsp), %rdi callq hipHostFree xorl %eax, %eax addq $144, %rsp .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: 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 $_Z4somaPiS_S_i, %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 _Z4somaPiS_S_i,@object # @_Z4somaPiS_S_i .section .rodata,"a",@progbits .globl _Z4somaPiS_S_i .p2align 3, 0x0 _Z4somaPiS_S_i: .quad _Z19__device_stub__somaPiS_S_i .size _Z4somaPiS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d " .size .L.str, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z4somaPiS_S_i" .size .L__unnamed_1, 15 .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 _Z19__device_stub__somaPiS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4somaPiS_S_i .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 : _Z4somaPiS_S_i .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 R6, SR_CTAID.X ; /* 0x0000000000067919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e240000002100 */ /*0030*/ IMAD R6, R6, c[0x0][0x0], R3 ; /* 0x0000000006067a24 */ /* 0x001fca00078e0203 */ /*0040*/ ISETP.GE.AND P0, PT, R6, c[0x0][0x178], PT ; /* 0x00005e0006007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0070*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0080*/ IMAD.WIDE R4, R6, R7, c[0x0][0x168] ; /* 0x00005a0006047625 */ /* 0x000fc800078e0207 */ /*0090*/ IMAD.WIDE R2, R6.reuse, R7.reuse, c[0x0][0x160] ; /* 0x0000580006027625 */ /* 0x0c0fe400078e0207 */ /*00a0*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea8000c1e1900 */ /*00b0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x170] ; /* 0x00005c0006067625 */ /* 0x000fe200078e0207 */ /*00d0*/ IADD3 R9, R4, R3, RZ ; /* 0x0000000304097210 */ /* 0x004fca0007ffe0ff */ /*00e0*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*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 _Z4somaPiS_S_i .globl _Z4somaPiS_S_i .p2align 8 .type _Z4somaPiS_S_i,@function _Z4somaPiS_S_i: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s3, s[0:1], 0x18 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_2 s_load_b128 s[4:7], s[0:1], 0x0 v_ashrrev_i32_e32 v2, 31, v1 s_load_b64 s[0:1], s[0:1], 0x10 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, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s6, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v1, vcc_lo v_add_co_u32 v0, vcc_lo, s0, v0 global_load_b32 v2, v[2:3], off global_load_b32 v3, v[4:5], off v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_waitcnt vmcnt(0) v_add_nc_u32_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 _Z4somaPiS_S_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .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 _Z4somaPiS_S_i, .Lfunc_end0-_Z4somaPiS_S_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 - .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: 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: _Z4somaPiS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z4somaPiS_S_i.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_001025a9_00000000-6_02-soma-vet-mapped.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 _Z28__device_stub__Z4somaPiS_S_iPiS_S_i .type _Z28__device_stub__Z4somaPiS_S_iPiS_S_i, @function _Z28__device_stub__Z4somaPiS_S_iPiS_S_i: .LFB2082: .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 _Z4somaPiS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z28__device_stub__Z4somaPiS_S_iPiS_S_i, .-_Z28__device_stub__Z4somaPiS_S_iPiS_S_i .globl _Z4somaPiS_S_i .type _Z4somaPiS_S_i, @function _Z4somaPiS_S_i: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z28__device_stub__Z4somaPiS_S_iPiS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z4somaPiS_S_i, .-_Z4somaPiS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d " .LC1: .string "\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 subq $72, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax leaq 8(%rsp), %rdi movl $2, %edx movl $64, %esi call cudaHostAlloc@PLT leaq 16(%rsp), %rdi movl $2, %edx movl $64, %esi call cudaHostAlloc@PLT leaq 24(%rsp), %rdi movl $2, %edx movl $64, %esi call cudaHostAlloc@PLT movl $0, %eax .L12: movq 8(%rsp), %rdx movl %eax, (%rdx,%rax,4) movq 16(%rsp), %rdx movl $0, (%rdx,%rax,4) addq $1, %rax cmpq $16, %rax jne .L12 movl $256, 44(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) movl $1, 40(%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 .L19 .L13: call cudaDeviceSynchronize@PLT movl $0, %ebx leaq .LC0(%rip), %rbp .L14: movq 24(%rsp), %rax movl (%rax,%rbx), %edx movq %rbp, %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT addq $4, %rbx cmpq $64, %rbx jne .L14 leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq 8(%rsp), %rdi call cudaFreeHost@PLT movq 16(%rsp), %rdi call cudaFreeHost@PLT movq 24(%rsp), %rdi call cudaFreeHost@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L20 movl $0, %eax addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .L19: .cfi_restore_state movl $16, %ecx movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z28__device_stub__Z4somaPiS_S_iPiS_S_i jmp .L13 .L20: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC2: .string "_Z4somaPiS_S_i" .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 _Z4somaPiS_S_i(%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 "02-soma-vet-mapped.hip" .globl _Z19__device_stub__somaPiS_S_i # -- Begin function _Z19__device_stub__somaPiS_S_i .p2align 4, 0x90 .type _Z19__device_stub__somaPiS_S_i,@function _Z19__device_stub__somaPiS_S_i: # @_Z19__device_stub__somaPiS_S_i .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 $_Z4somaPiS_S_i, %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 _Z19__device_stub__somaPiS_S_i, .Lfunc_end0-_Z19__device_stub__somaPiS_S_i .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 $144, %rsp .cfi_def_cfa_offset 160 .cfi_offset %rbx, -16 leaq 24(%rsp), %rdi movl $64, %esi movl $2, %edx callq hipHostAlloc leaq 16(%rsp), %rdi movl $64, %esi movl $2, %edx callq hipHostAlloc leaq 8(%rsp), %rdi movl $64, %esi movl $2, %edx callq hipHostAlloc movq 24(%rsp), %rax xorl %ecx, %ecx movq 16(%rsp), %rdx .p2align 4, 0x90 .LBB1_1: # =>This Inner Loop Header: Depth=1 movl %ecx, (%rax,%rcx,4) movl $0, (%rdx,%rcx,4) incq %rcx cmpq $16, %rcx jne .LBB1_1 # %bb.2: movabsq $4294967297, %rdi # imm = 0x100000001 leaq 255(%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 24(%rsp), %rax movq 16(%rsp), %rcx movq 8(%rsp), %rdx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movq %rdx, 88(%rsp) movl $16, 36(%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 36(%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 $_Z4somaPiS_S_i, %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 .LBB1_4: callq hipDeviceSynchronize xorl %ebx, %ebx .p2align 4, 0x90 .LBB1_5: # =>This Inner Loop Header: Depth=1 movq 8(%rsp), %rax movl (%rax,%rbx,4), %esi movl $.L.str, %edi xorl %eax, %eax callq printf incq %rbx cmpq $16, %rbx jne .LBB1_5 # %bb.6: movl $10, %edi callq putchar@PLT movq 24(%rsp), %rdi callq hipHostFree movq 16(%rsp), %rdi callq hipHostFree movq 8(%rsp), %rdi callq hipHostFree xorl %eax, %eax addq $144, %rsp .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: 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 $_Z4somaPiS_S_i, %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 _Z4somaPiS_S_i,@object # @_Z4somaPiS_S_i .section .rodata,"a",@progbits .globl _Z4somaPiS_S_i .p2align 3, 0x0 _Z4somaPiS_S_i: .quad _Z19__device_stub__somaPiS_S_i .size _Z4somaPiS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "%d " .size .L.str, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z4somaPiS_S_i" .size .L__unnamed_1, 15 .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 _Z19__device_stub__somaPiS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4somaPiS_S_i .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__ int position; //index of the largest value __device__ int largest; //value of the largest value int lenString = 593; int maxNumStrings = 1000000; int threshold = 2; __global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) { int my_id = blockDim.x * blockIdx.x + threadIdx.x; if (my_id == position) d_c[my_id] = 2; if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) { int x, diffs = 0; for (x = 0; x < lenString; x++) { diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]); if (diffs > threshold) break; } if (diffs <= threshold) { d_b[position] += d_b[my_id]; d_c[my_id] = 1; } } }
code for sm_80 Function : _Z7comparePcPiS0_iii .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[0x4][0x0] ; /* 0x01000000ff047624 */ /* 0x000fe200078e00ff */ /*0020*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0030*/ IMAD.MOV.U32 R5, RZ, RZ, c[0x4][0x4] ; /* 0x01000100ff057624 */ /* 0x000fca00078e00ff */ /*0040*/ LDG.E R3, [R4.64] ; /* 0x0000000404037981 */ /* 0x000ea8000c1e1900 */ /*0050*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0060*/ S2R R7, SR_TID.X ; /* 0x0000000000077919 */ /* 0x000e240000002100 */ /*0070*/ IMAD R0, R0, c[0x0][0x0], R7 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0207 */ /*0080*/ ISETP.GE.AND P1, PT, R0.reuse, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x040fe40003f26270 */ /*0090*/ ISETP.NE.AND P0, PT, R0, R3, PT ; /* 0x000000030000720c */ /* 0x004fe20003f05270 */ /*00a0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fc800078e00ff */ /*00b0*/ IMAD.WIDE R2, R0, R3, c[0x0][0x170] ; /* 0x00005c0000027625 */ /* 0x000fd000078e0203 */ /*00c0*/ @!P0 IMAD.MOV.U32 R7, RZ, RZ, 0x2 ; /* 0x00000002ff078424 */ /* 0x000fca00078e00ff */ /*00d0*/ @!P0 STG.E [R2.64], R7 ; /* 0x0000000702008986 */ /* 0x0001e2000c101904 */ /*00e0*/ @P1 EXIT ; /* 0x000000000000194d */ /* 0x000fea0003800000 */ /*00f0*/ LDG.E R9, [R4.64] ; /* 0x0000000404097981 */ /* 0x000ea8000c1e1900 */ /*0100*/ LDG.E R6, [R2.64] ; /* 0x0000000402067981 */ /* 0x000ee2000c1e1900 */ /*0110*/ ISETP.NE.AND P0, PT, R0, R9, PT ; /* 0x000000090000720c */ /* 0x004fc80003f05270 */ /*0120*/ ISETP.NE.OR P0, PT, R6, RZ, !P0 ; /* 0x000000ff0600720c */ /* 0x008fda0004705670 */ /*0130*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0140*/ IMAD.MOV.U32 R4, RZ, RZ, c[0x0][0x17c] ; /* 0x00005f00ff047624 */ /* 0x000fe400078e00ff */ /*0150*/ IMAD.MOV.U32 R8, RZ, RZ, RZ ; /* 0x000000ffff087224 */ /* 0x000fc600078e00ff */ /*0160*/ ISETP.GE.AND P0, PT, R4, 0x1, PT ; /* 0x000000010400780c */ /* 0x000fda0003f06270 */ /*0170*/ @!P0 BRA 0x2c0 ; /* 0x0000014000008947 */ /* 0x000fea0003800000 */ /*0180*/ BSSY B0, 0x2c0 ; /* 0x0000013000007945 */ /* 0x000fe20003800000 */ /*0190*/ IMAD.MOV.U32 R8, RZ, RZ, RZ ; /* 0x000000ffff087224 */ /* 0x000fe400078e00ff */ /*01a0*/ IMAD.MOV.U32 R10, RZ, RZ, RZ ; /* 0x000000ffff0a7224 */ /* 0x000fc800078e00ff */ /*01b0*/ IMAD R5, R9, c[0x0][0x17c], R10.reuse ; /* 0x00005f0009057a24 */ /* 0x100fe400078e020a */ /*01c0*/ IMAD R11, R0, c[0x0][0x17c], R10 ; /* 0x00005f00000b7a24 */ /* 0x000fc600078e020a */ /*01d0*/ IADD3 R6, P0, R5, c[0x0][0x160], RZ ; /* 0x0000580005067a10 */ /* 0x000fe40007f1e0ff */ /*01e0*/ IADD3 R4, P1, R11, c[0x0][0x160], RZ ; /* 0x000058000b047a10 */ /* 0x000fe40007f3e0ff */ /*01f0*/ LEA.HI.X.SX32 R7, R5, c[0x0][0x164], 0x1, P0 ; /* 0x0000590005077a11 */ /* 0x001fe400000f0eff */ /*0200*/ LEA.HI.X.SX32 R5, R11, c[0x0][0x164], 0x1, P1 ; /* 0x000059000b057a11 */ /* 0x000fc800008f0eff */ /*0210*/ LDG.E.U8 R7, [R6.64] ; /* 0x0000000406077981 */ /* 0x000ea8000c1e1100 */ /*0220*/ LDG.E.U8 R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea2000c1e1100 */ /*0230*/ IADD3 R11, R8, 0x1, RZ ; /* 0x00000001080b7810 */ /* 0x000fe40007ffe0ff */ /*0240*/ IADD3 R10, R10, 0x1, RZ ; /* 0x000000010a0a7810 */ /* 0x000fe40007ffe0ff */ /*0250*/ ISETP.NE.AND P0, PT, R7, R4, PT ; /* 0x000000040700720c */ /* 0x004fda0003f05270 */ /*0260*/ @!P0 IMAD.MOV R11, RZ, RZ, R8 ; /* 0x000000ffff0b8224 */ /* 0x000fe200078e0208 */ /*0270*/ ISETP.GE.AND P0, PT, R10, c[0x0][0x17c], PT ; /* 0x00005f000a007a0c */ /* 0x000fc60003f06270 */ /*0280*/ IMAD.MOV.U32 R8, RZ, RZ, R11 ; /* 0x000000ffff087224 */ /* 0x000fe200078e000b */ /*0290*/ ISETP.LE.AND P1, PT, R11, c[0x0][0x180], PT ; /* 0x000060000b007a0c */ /* 0x000fda0003f23270 */ /*02a0*/ @!P0 BRA P1, 0x1b0 ; /* 0xffffff0000008947 */ /* 0x000fea000083ffff */ /*02b0*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*02c0*/ ISETP.GT.AND P0, PT, R8, c[0x0][0x180], PT ; /* 0x0000600008007a0c */ /* 0x000fe40003f04270 */ /*02d0*/ SHF.R.S32.HI R5, RZ, 0x1f, R0 ; /* 0x0000001fff057819 */ /* 0x000fe40000011400 */ /*02e0*/ SHF.R.S32.HI R8, RZ, 0x1f, R9 ; /* 0x0000001fff087819 */ /* 0x000fd20000011409 */ /*02f0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0300*/ LEA R6, P0, R0.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a0000067a11 */ /* 0x040fe400078010ff */ /*0310*/ LEA R4, P1, R9.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a0009047a11 */ /* 0x040fe400078210ff */ /*0320*/ LEA.HI.X R7, R0, c[0x0][0x16c], R5, 0x2, P0 ; /* 0x00005b0000077a11 */ /* 0x001fe400000f1405 */ /*0330*/ LEA.HI.X R5, R9, c[0x0][0x16c], R8, 0x2, P1 ; /* 0x00005b0009057a11 */ /* 0x000fc800008f1408 */ /*0340*/ LDG.E R7, [R6.64] ; /* 0x0000000406077981 */ /* 0x000ea8000c1e1900 */ /*0350*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea2000c1e1900 */ /*0360*/ IMAD.MOV.U32 R11, RZ, RZ, 0x1 ; /* 0x00000001ff0b7424 */ /* 0x000fe400078e00ff */ /*0370*/ IMAD.IADD R9, R0, 0x1, R7 ; /* 0x0000000100097824 */ /* 0x004fca00078e0207 */ /*0380*/ STG.E [R4.64], R9 ; /* 0x0000000904007986 */ /* 0x000fe8000c101904 */ /*0390*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x000fe2000c101904 */ /*03a0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*03b0*/ BRA 0x3b0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*03c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*03d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*03e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*03f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0400*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0410*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0420*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0430*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0440*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0450*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0460*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0470*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __device__ int position; //index of the largest value __device__ int largest; //value of the largest value int lenString = 593; int maxNumStrings = 1000000; int threshold = 2; __global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) { int my_id = blockDim.x * blockIdx.x + threadIdx.x; if (my_id == position) d_c[my_id] = 2; if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) { int x, diffs = 0; for (x = 0; x < lenString; x++) { diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]); if (diffs > threshold) break; } if (diffs <= threshold) { d_b[position] += d_b[my_id]; d_c[my_id] = 1; } } }
.file "tmpxft_001273ad_00000000-6_compare.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 _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii .type _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii, @function _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii: .LFB2051: .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 .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 _Z7comparePcPiS0_iii(%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 _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii, .-_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii .globl _Z7comparePcPiS0_iii .type _Z7comparePcPiS0_iii, @function _Z7comparePcPiS0_iii: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z7comparePcPiS0_iii, .-_Z7comparePcPiS0_iii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z7comparePcPiS0_iii" .LC1: .string "position" .LC2: .string "largest" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2054: .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 .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z7comparePcPiS0_iii(%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 .LC1(%rip), %rdx movq %rdx, %rcx leaq _ZL8position(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@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 .LC2(%rip), %rdx movq %rdx, %rcx leaq _ZL7largest(%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 .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 .globl threshold .data .align 4 .type threshold, @object .size threshold, 4 threshold: .long 2 .globl maxNumStrings .align 4 .type maxNumStrings, @object .size maxNumStrings, 4 maxNumStrings: .long 1000000 .globl lenString .align 4 .type lenString, @object .size lenString, 4 lenString: .long 593 .local _ZL7largest .comm _ZL7largest,4,4 .local _ZL8position .comm _ZL8position,4,4 .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__ int position; //index of the largest value __device__ int largest; //value of the largest value int lenString = 593; int maxNumStrings = 1000000; int threshold = 2; __global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) { int my_id = blockDim.x * blockIdx.x + threadIdx.x; if (my_id == position) d_c[my_id] = 2; if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) { int x, diffs = 0; for (x = 0; x < lenString; x++) { diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]); if (diffs > threshold) break; } if (diffs <= threshold) { d_b[position] += d_b[my_id]; d_c[my_id] = 1; } } }
#include <hip/hip_runtime.h> #include "includes.h" __device__ int position; //index of the largest value __device__ int largest; //value of the largest value int lenString = 593; int maxNumStrings = 1000000; int threshold = 2; __global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) { int my_id = blockDim.x * blockIdx.x + threadIdx.x; if (my_id == position) d_c[my_id] = 2; if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) { int x, diffs = 0; for (x = 0; x < lenString; x++) { diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]); if (diffs > threshold) break; } if (diffs <= threshold) { d_b[position] += d_b[my_id]; d_c[my_id] = 1; } } }
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__ int position; //index of the largest value __device__ int largest; //value of the largest value int lenString = 593; int maxNumStrings = 1000000; int threshold = 2; __global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) { int my_id = blockDim.x * blockIdx.x + threadIdx.x; if (my_id == position) d_c[my_id] = 2; if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) { int x, diffs = 0; for (x = 0; x < lenString; x++) { diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]); if (diffs > threshold) break; } if (diffs <= threshold) { d_b[position] += d_b[my_id]; d_c[my_id] = 1; } } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z7comparePcPiS0_iii .globl _Z7comparePcPiS0_iii .p2align 8 .type _Z7comparePcPiS0_iii,@function _Z7comparePcPiS0_iii: s_load_b32 s4, s[0:1], 0x34 s_getpc_b64 s[2:3] s_add_u32 s2, s2, position@rel32@lo+4 s_addc_u32 s3, s3, position@rel32@hi+12 s_load_b32 s5, s[2:3], 0x0 s_load_b64 s[2:3], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_and_b32 s4, s4, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1] s_mov_b32 s4, exec_lo v_ashrrev_i32_e32 v2, 31, v1 v_cmpx_eq_u32_e64 s5, v1 s_cbranch_execz .LBB0_2 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_lshlrev_b64 v[3:4], 2, v[1:2] v_mov_b32_e32 v0, 2 v_add_co_u32 v3, vcc_lo, s2, v3 s_delay_alu instid0(VALU_DEP_3) v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo global_store_b32 v[3:4], v0, off .LBB0_2: s_or_b32 exec_lo, exec_lo, s4 s_load_b32 s4, s[0:1], 0x18 s_waitcnt lgkmcnt(0) v_cmp_gt_i32_e32 vcc_lo, s4, v1 s_and_saveexec_b32 s4, vcc_lo s_cbranch_execz .LBB0_10 v_lshlrev_b64 v[3:4], 2, v[1:2] v_mov_b32_e32 v0, 0 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_getpc_b64 s[2:3] s_add_u32 s2, s2, position@rel32@lo+4 s_addc_u32 s3, s3, position@rel32@hi+12 global_load_b32 v5, v[3:4], off global_load_b32 v6, v0, s[2:3] s_waitcnt vmcnt(1) v_cmp_eq_u32_e32 vcc_lo, 0, v5 s_waitcnt vmcnt(0) v_cmp_ne_u32_e64 s2, v1, v6 v_readfirstlane_b32 s4, v6 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s2, vcc_lo, s2 s_and_b32 exec_lo, exec_lo, s2 s_cbranch_execz .LBB0_10 s_load_b64 s[2:3], s[0:1], 0x1c s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s2, 1 s_cbranch_scc1 .LBB0_8 s_load_b64 s[6:7], s[0:1], 0x0 v_mul_lo_u32 v5, v1, s2 s_mul_i32 s8, s4, s2 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v7, 0 s_add_i32 s5, s2, -1 s_ashr_i32 s2, s8, 31 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v6, 31, v5 s_waitcnt lgkmcnt(0) v_add_co_u32 v5, vcc_lo, s6, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s7, v6, vcc_lo s_add_u32 s6, s6, s8 s_addc_u32 s7, s7, s2 s_mov_b32 s8, 0 .p2align 6 .LBB0_6: global_load_u8 v8, v7, s[6:7] global_load_u8 v9, v[5:6], off s_cmp_eq_u32 s5, 0 s_cselect_b32 s9, -1, 0 s_add_i32 s5, s5, -1 s_waitcnt vmcnt(0) v_cmp_ne_u16_e32 vcc_lo, v8, v9 v_add_co_ci_u32_e32 v0, vcc_lo, 0, v0, vcc_lo v_add_co_u32 v5, vcc_lo, v5, 1 v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_lt_i32_e64 s2, s3, v0 s_or_b32 s2, s2, s9 s_add_u32 s6, s6, 1 s_addc_u32 s7, s7, 0 s_and_b32 s2, exec_lo, s2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_or_b32 s8, s2, s8 s_and_not1_b32 exec_lo, exec_lo, s8 s_cbranch_execnz .LBB0_6 s_or_b32 exec_lo, exec_lo, s8 .LBB0_8: v_cmp_ge_i32_e32 vcc_lo, s3, v0 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_10 s_load_b64 s[0:1], s[0:1], 0x8 v_lshlrev_b64 v[0:1], 2, v[1:2] s_ashr_i32 s5, s4, 31 v_mov_b32_e32 v2, 0 s_lshl_b64 s[2:3], s[4:5], 2 s_waitcnt lgkmcnt(0) s_delay_alu instid0(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 s_add_u32 s0, s0, s2 s_addc_u32 s1, s1, s3 s_clause 0x1 global_load_b32 v0, v[0:1], off global_load_b32 v1, v2, s[0:1] s_waitcnt vmcnt(0) v_dual_mov_b32 v1, 1 :: v_dual_add_nc_u32 v0, v1, v0 global_store_b32 v2, v0, s[0:1] global_store_b32 v[3:4], v1, off .LBB0_10: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z7comparePcPiS0_iii .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 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 _Z7comparePcPiS0_iii, .Lfunc_end0-_Z7comparePcPiS0_iii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .protected position .type position,@object .section .bss,"aw",@nobits .globl position .p2align 2, 0x0 position: .long 0 .size position, 4 .protected largest .type largest,@object .globl largest .p2align 2, 0x0 largest: .long 0 .size largest, 4 .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 position .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: _Z7comparePcPiS0_iii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z7comparePcPiS0_iii.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 <hip/hip_runtime.h> #include "includes.h" __device__ int position; //index of the largest value __device__ int largest; //value of the largest value int lenString = 593; int maxNumStrings = 1000000; int threshold = 2; __global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) { int my_id = blockDim.x * blockIdx.x + threadIdx.x; if (my_id == position) d_c[my_id] = 2; if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) { int x, diffs = 0; for (x = 0; x < lenString; x++) { diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]); if (diffs > threshold) break; } if (diffs <= threshold) { d_b[position] += d_b[my_id]; d_c[my_id] = 1; } } }
.text .file "compare.hip" .globl _Z22__device_stub__comparePcPiS0_iii # -- Begin function _Z22__device_stub__comparePcPiS0_iii .p2align 4, 0x90 .type _Z22__device_stub__comparePcPiS0_iii,@function _Z22__device_stub__comparePcPiS0_iii: # @_Z22__device_stub__comparePcPiS0_iii .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 $_Z7comparePcPiS0_iii, %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_end0: .size _Z22__device_stub__comparePcPiS0_iii, .Lfunc_end0-_Z22__device_stub__comparePcPiS0_iii .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 .cfi_offset %rbx, -16 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), %rbx subq $32, %rsp .cfi_adjust_cfa_offset 32 xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z7comparePcPiS0_iii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction addq $32, %rsp .cfi_adjust_cfa_offset -32 movl $position, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movl $4, %r9d movq %rbx, %rdi xorl %r8d, %r8d pushq $0 .cfi_adjust_cfa_offset 8 pushq $0 .cfi_adjust_cfa_offset 8 callq __hipRegisterVar addq $16, %rsp .cfi_adjust_cfa_offset -16 movl $largest, %esi movl $.L__unnamed_3, %edx movl $.L__unnamed_3, %ecx movl $4, %r9d movq %rbx, %rdi xorl %r8d, %r8d pushq $0 .cfi_adjust_cfa_offset 8 pushq $0 .cfi_adjust_cfa_offset 8 callq __hipRegisterVar addq $16, %rsp .cfi_adjust_cfa_offset -16 movl $__hip_module_dtor, %edi popq %rbx .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 position,@object # @position .local position .comm position,4,4 .type largest,@object # @largest .local largest .comm largest,4,4 .type lenString,@object # @lenString .data .globl lenString .p2align 2, 0x0 lenString: .long 593 # 0x251 .size lenString, 4 .type maxNumStrings,@object # @maxNumStrings .globl maxNumStrings .p2align 2, 0x0 maxNumStrings: .long 1000000 # 0xf4240 .size maxNumStrings, 4 .type threshold,@object # @threshold .globl threshold .p2align 2, 0x0 threshold: .long 2 # 0x2 .size threshold, 4 .type _Z7comparePcPiS0_iii,@object # @_Z7comparePcPiS0_iii .section .rodata,"a",@progbits .globl _Z7comparePcPiS0_iii .p2align 3, 0x0 _Z7comparePcPiS0_iii: .quad _Z22__device_stub__comparePcPiS0_iii .size _Z7comparePcPiS0_iii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z7comparePcPiS0_iii" .size .L__unnamed_1, 21 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "position" .size .L__unnamed_2, 9 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "largest" .size .L__unnamed_3, 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 _Z22__device_stub__comparePcPiS0_iii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym position .addrsig_sym largest .addrsig_sym _Z7comparePcPiS0_iii .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 : _Z7comparePcPiS0_iii .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[0x4][0x0] ; /* 0x01000000ff047624 */ /* 0x000fe200078e00ff */ /*0020*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0030*/ IMAD.MOV.U32 R5, RZ, RZ, c[0x4][0x4] ; /* 0x01000100ff057624 */ /* 0x000fca00078e00ff */ /*0040*/ LDG.E R3, [R4.64] ; /* 0x0000000404037981 */ /* 0x000ea8000c1e1900 */ /*0050*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0060*/ S2R R7, SR_TID.X ; /* 0x0000000000077919 */ /* 0x000e240000002100 */ /*0070*/ IMAD R0, R0, c[0x0][0x0], R7 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0207 */ /*0080*/ ISETP.GE.AND P1, PT, R0.reuse, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x040fe40003f26270 */ /*0090*/ ISETP.NE.AND P0, PT, R0, R3, PT ; /* 0x000000030000720c */ /* 0x004fe20003f05270 */ /*00a0*/ IMAD.MOV.U32 R3, RZ, RZ, 0x4 ; /* 0x00000004ff037424 */ /* 0x000fc800078e00ff */ /*00b0*/ IMAD.WIDE R2, R0, R3, c[0x0][0x170] ; /* 0x00005c0000027625 */ /* 0x000fd000078e0203 */ /*00c0*/ @!P0 IMAD.MOV.U32 R7, RZ, RZ, 0x2 ; /* 0x00000002ff078424 */ /* 0x000fca00078e00ff */ /*00d0*/ @!P0 STG.E [R2.64], R7 ; /* 0x0000000702008986 */ /* 0x0001e2000c101904 */ /*00e0*/ @P1 EXIT ; /* 0x000000000000194d */ /* 0x000fea0003800000 */ /*00f0*/ LDG.E R9, [R4.64] ; /* 0x0000000404097981 */ /* 0x000ea8000c1e1900 */ /*0100*/ LDG.E R6, [R2.64] ; /* 0x0000000402067981 */ /* 0x000ee2000c1e1900 */ /*0110*/ ISETP.NE.AND P0, PT, R0, R9, PT ; /* 0x000000090000720c */ /* 0x004fc80003f05270 */ /*0120*/ ISETP.NE.OR P0, PT, R6, RZ, !P0 ; /* 0x000000ff0600720c */ /* 0x008fda0004705670 */ /*0130*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0140*/ IMAD.MOV.U32 R4, RZ, RZ, c[0x0][0x17c] ; /* 0x00005f00ff047624 */ /* 0x000fe400078e00ff */ /*0150*/ IMAD.MOV.U32 R8, RZ, RZ, RZ ; /* 0x000000ffff087224 */ /* 0x000fc600078e00ff */ /*0160*/ ISETP.GE.AND P0, PT, R4, 0x1, PT ; /* 0x000000010400780c */ /* 0x000fda0003f06270 */ /*0170*/ @!P0 BRA 0x2c0 ; /* 0x0000014000008947 */ /* 0x000fea0003800000 */ /*0180*/ BSSY B0, 0x2c0 ; /* 0x0000013000007945 */ /* 0x000fe20003800000 */ /*0190*/ IMAD.MOV.U32 R8, RZ, RZ, RZ ; /* 0x000000ffff087224 */ /* 0x000fe400078e00ff */ /*01a0*/ IMAD.MOV.U32 R10, RZ, RZ, RZ ; /* 0x000000ffff0a7224 */ /* 0x000fc800078e00ff */ /*01b0*/ IMAD R5, R9, c[0x0][0x17c], R10.reuse ; /* 0x00005f0009057a24 */ /* 0x100fe400078e020a */ /*01c0*/ IMAD R11, R0, c[0x0][0x17c], R10 ; /* 0x00005f00000b7a24 */ /* 0x000fc600078e020a */ /*01d0*/ IADD3 R6, P0, R5, c[0x0][0x160], RZ ; /* 0x0000580005067a10 */ /* 0x000fe40007f1e0ff */ /*01e0*/ IADD3 R4, P1, R11, c[0x0][0x160], RZ ; /* 0x000058000b047a10 */ /* 0x000fe40007f3e0ff */ /*01f0*/ LEA.HI.X.SX32 R7, R5, c[0x0][0x164], 0x1, P0 ; /* 0x0000590005077a11 */ /* 0x001fe400000f0eff */ /*0200*/ LEA.HI.X.SX32 R5, R11, c[0x0][0x164], 0x1, P1 ; /* 0x000059000b057a11 */ /* 0x000fc800008f0eff */ /*0210*/ LDG.E.U8 R7, [R6.64] ; /* 0x0000000406077981 */ /* 0x000ea8000c1e1100 */ /*0220*/ LDG.E.U8 R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ea2000c1e1100 */ /*0230*/ IADD3 R11, R8, 0x1, RZ ; /* 0x00000001080b7810 */ /* 0x000fe40007ffe0ff */ /*0240*/ IADD3 R10, R10, 0x1, RZ ; /* 0x000000010a0a7810 */ /* 0x000fe40007ffe0ff */ /*0250*/ ISETP.NE.AND P0, PT, R7, R4, PT ; /* 0x000000040700720c */ /* 0x004fda0003f05270 */ /*0260*/ @!P0 IMAD.MOV R11, RZ, RZ, R8 ; /* 0x000000ffff0b8224 */ /* 0x000fe200078e0208 */ /*0270*/ ISETP.GE.AND P0, PT, R10, c[0x0][0x17c], PT ; /* 0x00005f000a007a0c */ /* 0x000fc60003f06270 */ /*0280*/ IMAD.MOV.U32 R8, RZ, RZ, R11 ; /* 0x000000ffff087224 */ /* 0x000fe200078e000b */ /*0290*/ ISETP.LE.AND P1, PT, R11, c[0x0][0x180], PT ; /* 0x000060000b007a0c */ /* 0x000fda0003f23270 */ /*02a0*/ @!P0 BRA P1, 0x1b0 ; /* 0xffffff0000008947 */ /* 0x000fea000083ffff */ /*02b0*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*02c0*/ ISETP.GT.AND P0, PT, R8, c[0x0][0x180], PT ; /* 0x0000600008007a0c */ /* 0x000fe40003f04270 */ /*02d0*/ SHF.R.S32.HI R5, RZ, 0x1f, R0 ; /* 0x0000001fff057819 */ /* 0x000fe40000011400 */ /*02e0*/ SHF.R.S32.HI R8, RZ, 0x1f, R9 ; /* 0x0000001fff087819 */ /* 0x000fd20000011409 */ /*02f0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0300*/ LEA R6, P0, R0.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a0000067a11 */ /* 0x040fe400078010ff */ /*0310*/ LEA R4, P1, R9.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a0009047a11 */ /* 0x040fe400078210ff */ /*0320*/ LEA.HI.X R7, R0, c[0x0][0x16c], R5, 0x2, P0 ; /* 0x00005b0000077a11 */ /* 0x001fe400000f1405 */ /*0330*/ LEA.HI.X R5, R9, c[0x0][0x16c], R8, 0x2, P1 ; /* 0x00005b0009057a11 */ /* 0x000fc800008f1408 */ /*0340*/ LDG.E R7, [R6.64] ; /* 0x0000000406077981 */ /* 0x000ea8000c1e1900 */ /*0350*/ LDG.E R0, [R4.64] ; /* 0x0000000404007981 */ /* 0x000ea2000c1e1900 */ /*0360*/ IMAD.MOV.U32 R11, RZ, RZ, 0x1 ; /* 0x00000001ff0b7424 */ /* 0x000fe400078e00ff */ /*0370*/ IMAD.IADD R9, R0, 0x1, R7 ; /* 0x0000000100097824 */ /* 0x004fca00078e0207 */ /*0380*/ STG.E [R4.64], R9 ; /* 0x0000000904007986 */ /* 0x000fe8000c101904 */ /*0390*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x000fe2000c101904 */ /*03a0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*03b0*/ BRA 0x3b0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*03c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*03d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*03e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*03f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0400*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0410*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0420*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0430*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0440*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0450*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0460*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0470*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z7comparePcPiS0_iii .globl _Z7comparePcPiS0_iii .p2align 8 .type _Z7comparePcPiS0_iii,@function _Z7comparePcPiS0_iii: s_load_b32 s4, s[0:1], 0x34 s_getpc_b64 s[2:3] s_add_u32 s2, s2, position@rel32@lo+4 s_addc_u32 s3, s3, position@rel32@hi+12 s_load_b32 s5, s[2:3], 0x0 s_load_b64 s[2:3], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_and_b32 s4, s4, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1] s_mov_b32 s4, exec_lo v_ashrrev_i32_e32 v2, 31, v1 v_cmpx_eq_u32_e64 s5, v1 s_cbranch_execz .LBB0_2 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_lshlrev_b64 v[3:4], 2, v[1:2] v_mov_b32_e32 v0, 2 v_add_co_u32 v3, vcc_lo, s2, v3 s_delay_alu instid0(VALU_DEP_3) v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo global_store_b32 v[3:4], v0, off .LBB0_2: s_or_b32 exec_lo, exec_lo, s4 s_load_b32 s4, s[0:1], 0x18 s_waitcnt lgkmcnt(0) v_cmp_gt_i32_e32 vcc_lo, s4, v1 s_and_saveexec_b32 s4, vcc_lo s_cbranch_execz .LBB0_10 v_lshlrev_b64 v[3:4], 2, v[1:2] v_mov_b32_e32 v0, 0 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_getpc_b64 s[2:3] s_add_u32 s2, s2, position@rel32@lo+4 s_addc_u32 s3, s3, position@rel32@hi+12 global_load_b32 v5, v[3:4], off global_load_b32 v6, v0, s[2:3] s_waitcnt vmcnt(1) v_cmp_eq_u32_e32 vcc_lo, 0, v5 s_waitcnt vmcnt(0) v_cmp_ne_u32_e64 s2, v1, v6 v_readfirstlane_b32 s4, v6 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s2, vcc_lo, s2 s_and_b32 exec_lo, exec_lo, s2 s_cbranch_execz .LBB0_10 s_load_b64 s[2:3], s[0:1], 0x1c s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s2, 1 s_cbranch_scc1 .LBB0_8 s_load_b64 s[6:7], s[0:1], 0x0 v_mul_lo_u32 v5, v1, s2 s_mul_i32 s8, s4, s2 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v7, 0 s_add_i32 s5, s2, -1 s_ashr_i32 s2, s8, 31 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v6, 31, v5 s_waitcnt lgkmcnt(0) v_add_co_u32 v5, vcc_lo, s6, v5 v_add_co_ci_u32_e32 v6, vcc_lo, s7, v6, vcc_lo s_add_u32 s6, s6, s8 s_addc_u32 s7, s7, s2 s_mov_b32 s8, 0 .p2align 6 .LBB0_6: global_load_u8 v8, v7, s[6:7] global_load_u8 v9, v[5:6], off s_cmp_eq_u32 s5, 0 s_cselect_b32 s9, -1, 0 s_add_i32 s5, s5, -1 s_waitcnt vmcnt(0) v_cmp_ne_u16_e32 vcc_lo, v8, v9 v_add_co_ci_u32_e32 v0, vcc_lo, 0, v0, vcc_lo v_add_co_u32 v5, vcc_lo, v5, 1 v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_lt_i32_e64 s2, s3, v0 s_or_b32 s2, s2, s9 s_add_u32 s6, s6, 1 s_addc_u32 s7, s7, 0 s_and_b32 s2, exec_lo, s2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_or_b32 s8, s2, s8 s_and_not1_b32 exec_lo, exec_lo, s8 s_cbranch_execnz .LBB0_6 s_or_b32 exec_lo, exec_lo, s8 .LBB0_8: v_cmp_ge_i32_e32 vcc_lo, s3, v0 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_10 s_load_b64 s[0:1], s[0:1], 0x8 v_lshlrev_b64 v[0:1], 2, v[1:2] s_ashr_i32 s5, s4, 31 v_mov_b32_e32 v2, 0 s_lshl_b64 s[2:3], s[4:5], 2 s_waitcnt lgkmcnt(0) s_delay_alu instid0(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 s_add_u32 s0, s0, s2 s_addc_u32 s1, s1, s3 s_clause 0x1 global_load_b32 v0, v[0:1], off global_load_b32 v1, v2, s[0:1] s_waitcnt vmcnt(0) v_dual_mov_b32 v1, 1 :: v_dual_add_nc_u32 v0, v1, v0 global_store_b32 v2, v0, s[0:1] global_store_b32 v[3:4], v1, off .LBB0_10: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z7comparePcPiS0_iii .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 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 _Z7comparePcPiS0_iii, .Lfunc_end0-_Z7comparePcPiS0_iii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .protected position .type position,@object .section .bss,"aw",@nobits .globl position .p2align 2, 0x0 position: .long 0 .size position, 4 .protected largest .type largest,@object .globl largest .p2align 2, 0x0 largest: .long 0 .size largest, 4 .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 position .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: _Z7comparePcPiS0_iii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z7comparePcPiS0_iii.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_001273ad_00000000-6_compare.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 _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii .type _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii, @function _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii: .LFB2051: .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 .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 _Z7comparePcPiS0_iii(%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 _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii, .-_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii .globl _Z7comparePcPiS0_iii .type _Z7comparePcPiS0_iii, @function _Z7comparePcPiS0_iii: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z7comparePcPiS0_iii, .-_Z7comparePcPiS0_iii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z7comparePcPiS0_iii" .LC1: .string "position" .LC2: .string "largest" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2054: .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 .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z7comparePcPiS0_iii(%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 .LC1(%rip), %rdx movq %rdx, %rcx leaq _ZL8position(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@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 .LC2(%rip), %rdx movq %rdx, %rcx leaq _ZL7largest(%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 .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 .globl threshold .data .align 4 .type threshold, @object .size threshold, 4 threshold: .long 2 .globl maxNumStrings .align 4 .type maxNumStrings, @object .size maxNumStrings, 4 maxNumStrings: .long 1000000 .globl lenString .align 4 .type lenString, @object .size lenString, 4 lenString: .long 593 .local _ZL7largest .comm _ZL7largest,4,4 .local _ZL8position .comm _ZL8position,4,4 .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 "compare.hip" .globl _Z22__device_stub__comparePcPiS0_iii # -- Begin function _Z22__device_stub__comparePcPiS0_iii .p2align 4, 0x90 .type _Z22__device_stub__comparePcPiS0_iii,@function _Z22__device_stub__comparePcPiS0_iii: # @_Z22__device_stub__comparePcPiS0_iii .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 $_Z7comparePcPiS0_iii, %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_end0: .size _Z22__device_stub__comparePcPiS0_iii, .Lfunc_end0-_Z22__device_stub__comparePcPiS0_iii .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 .cfi_offset %rbx, -16 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), %rbx subq $32, %rsp .cfi_adjust_cfa_offset 32 xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z7comparePcPiS0_iii, %esi movl $.L__unnamed_1, %edx movl $.L__unnamed_1, %ecx movq %rbx, %rdi movl $-1, %r8d xorl %r9d, %r9d callq __hipRegisterFunction addq $32, %rsp .cfi_adjust_cfa_offset -32 movl $position, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movl $4, %r9d movq %rbx, %rdi xorl %r8d, %r8d pushq $0 .cfi_adjust_cfa_offset 8 pushq $0 .cfi_adjust_cfa_offset 8 callq __hipRegisterVar addq $16, %rsp .cfi_adjust_cfa_offset -16 movl $largest, %esi movl $.L__unnamed_3, %edx movl $.L__unnamed_3, %ecx movl $4, %r9d movq %rbx, %rdi xorl %r8d, %r8d pushq $0 .cfi_adjust_cfa_offset 8 pushq $0 .cfi_adjust_cfa_offset 8 callq __hipRegisterVar addq $16, %rsp .cfi_adjust_cfa_offset -16 movl $__hip_module_dtor, %edi popq %rbx .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 position,@object # @position .local position .comm position,4,4 .type largest,@object # @largest .local largest .comm largest,4,4 .type lenString,@object # @lenString .data .globl lenString .p2align 2, 0x0 lenString: .long 593 # 0x251 .size lenString, 4 .type maxNumStrings,@object # @maxNumStrings .globl maxNumStrings .p2align 2, 0x0 maxNumStrings: .long 1000000 # 0xf4240 .size maxNumStrings, 4 .type threshold,@object # @threshold .globl threshold .p2align 2, 0x0 threshold: .long 2 # 0x2 .size threshold, 4 .type _Z7comparePcPiS0_iii,@object # @_Z7comparePcPiS0_iii .section .rodata,"a",@progbits .globl _Z7comparePcPiS0_iii .p2align 3, 0x0 _Z7comparePcPiS0_iii: .quad _Z22__device_stub__comparePcPiS0_iii .size _Z7comparePcPiS0_iii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z7comparePcPiS0_iii" .size .L__unnamed_1, 21 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "position" .size .L__unnamed_2, 9 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "largest" .size .L__unnamed_3, 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 _Z22__device_stub__comparePcPiS0_iii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym position .addrsig_sym largest .addrsig_sym _Z7comparePcPiS0_iii .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" __global__ void gGetValueByKey(float* d_in, float* d_out, int* indeces, int n) { int tid = threadIdx.x + blockDim.x * blockIdx.x; if(tid < n) { int index = indeces[tid]; d_out[tid] = d_in[index]; } }
code for sm_80 Function : _Z14gGetValueByKeyPfS_Pii .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 R6, SR_TID.X ; /* 0x0000000000067919 */ /* 0x000e280000002100 */ /*0020*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000e240000002500 */ /*0030*/ IMAD R6, R3, c[0x0][0x0], R6 ; /* 0x0000000003067a24 */ /* 0x001fca00078e0206 */ /*0040*/ ISETP.GE.AND P0, PT, R6, c[0x0][0x178], PT ; /* 0x00005e0006007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0070*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0080*/ IMAD.WIDE R2, R6, R7, c[0x0][0x170] ; /* 0x00005c0006027625 */ /* 0x000fcc00078e0207 */ /*0090*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea4000c1e1900 */ /*00a0*/ IMAD.WIDE R4, R2, R7, c[0x0][0x160] ; /* 0x0000580002047625 */ /* 0x004fcc00078e0207 */ /*00b0*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x168] ; /* 0x00005a0006067625 */ /* 0x000fca00078e0207 */ /*00d0*/ STG.E [R6.64], R5 ; /* 0x0000000506007986 */ /* 0x004fe2000c101904 */ /*00e0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00f0*/ BRA 0xf0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 CUDA host assembly.
#include "includes.h" __global__ void gGetValueByKey(float* d_in, float* d_out, int* indeces, int n) { int tid = threadIdx.x + blockDim.x * blockIdx.x; if(tid < n) { int index = indeces[tid]; d_out[tid] = d_in[index]; } }
.file "tmpxft_0012d4ff_00000000-6_gGetValueByKey.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 _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii .type _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii, @function _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii: .LFB2051: .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 _Z14gGetValueByKeyPfS_Pii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii, .-_Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii .globl _Z14gGetValueByKeyPfS_Pii .type _Z14gGetValueByKeyPfS_Pii, @function _Z14gGetValueByKeyPfS_Pii: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z14gGetValueByKeyPfS_Pii, .-_Z14gGetValueByKeyPfS_Pii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z14gGetValueByKeyPfS_Pii" .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 _Z14gGetValueByKeyPfS_Pii(%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 gGetValueByKey(float* d_in, float* d_out, int* indeces, int n) { int tid = threadIdx.x + blockDim.x * blockIdx.x; if(tid < n) { int index = indeces[tid]; d_out[tid] = d_in[index]; } }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void gGetValueByKey(float* d_in, float* d_out, int* indeces, int n) { int tid = threadIdx.x + blockDim.x * blockIdx.x; if(tid < n) { int index = indeces[tid]; d_out[tid] = d_in[index]; } }
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 gGetValueByKey(float* d_in, float* d_out, int* indeces, int n) { int tid = threadIdx.x + blockDim.x * blockIdx.x; if(tid < n) { int index = indeces[tid]; d_out[tid] = d_in[index]; } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z14gGetValueByKeyPfS_Pii .globl _Z14gGetValueByKeyPfS_Pii .p2align 8 .type _Z14gGetValueByKeyPfS_Pii,@function _Z14gGetValueByKeyPfS_Pii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s3, s[0:1], 0x18 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_2 s_load_b64 s[2:3], s[0:1], 0x10 v_ashrrev_i32_e32 v2, 31, v1 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) | instskip(SKIP_4) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo s_load_b128 s[0:3], s[0:1], 0x0 global_load_b32 v2, v[2:3], off s_waitcnt vmcnt(0) v_ashrrev_i32_e32 v3, 31, v2 v_lshlrev_b64 v[2:3], 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 v2, vcc_lo, s0, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo 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 v2, v[2:3], off s_waitcnt vmcnt(0) 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 _Z14gGetValueByKeyPfS_Pii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .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 _Z14gGetValueByKeyPfS_Pii, .Lfunc_end0-_Z14gGetValueByKeyPfS_Pii .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: 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: _Z14gGetValueByKeyPfS_Pii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14gGetValueByKeyPfS_Pii.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.
#include <hip/hip_runtime.h> #include "includes.h" __global__ void gGetValueByKey(float* d_in, float* d_out, int* indeces, int n) { int tid = threadIdx.x + blockDim.x * blockIdx.x; if(tid < n) { int index = indeces[tid]; d_out[tid] = d_in[index]; } }
.text .file "gGetValueByKey.hip" .globl _Z29__device_stub__gGetValueByKeyPfS_Pii # -- Begin function _Z29__device_stub__gGetValueByKeyPfS_Pii .p2align 4, 0x90 .type _Z29__device_stub__gGetValueByKeyPfS_Pii,@function _Z29__device_stub__gGetValueByKeyPfS_Pii: # @_Z29__device_stub__gGetValueByKeyPfS_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 $_Z14gGetValueByKeyPfS_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__gGetValueByKeyPfS_Pii, .Lfunc_end0-_Z29__device_stub__gGetValueByKeyPfS_Pii .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 $_Z14gGetValueByKeyPfS_Pii, %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 _Z14gGetValueByKeyPfS_Pii,@object # @_Z14gGetValueByKeyPfS_Pii .section .rodata,"a",@progbits .globl _Z14gGetValueByKeyPfS_Pii .p2align 3, 0x0 _Z14gGetValueByKeyPfS_Pii: .quad _Z29__device_stub__gGetValueByKeyPfS_Pii .size _Z14gGetValueByKeyPfS_Pii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z14gGetValueByKeyPfS_Pii" .size .L__unnamed_1, 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__gGetValueByKeyPfS_Pii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14gGetValueByKeyPfS_Pii .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 : _Z14gGetValueByKeyPfS_Pii .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 R6, SR_TID.X ; /* 0x0000000000067919 */ /* 0x000e280000002100 */ /*0020*/ S2R R3, SR_CTAID.X ; /* 0x0000000000037919 */ /* 0x000e240000002500 */ /*0030*/ IMAD R6, R3, c[0x0][0x0], R6 ; /* 0x0000000003067a24 */ /* 0x001fca00078e0206 */ /*0040*/ ISETP.GE.AND P0, PT, R6, c[0x0][0x178], PT ; /* 0x00005e0006007a0c */ /* 0x000fda0003f06270 */ /*0050*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0060*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0070*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0080*/ IMAD.WIDE R2, R6, R7, c[0x0][0x170] ; /* 0x00005c0006027625 */ /* 0x000fcc00078e0207 */ /*0090*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea4000c1e1900 */ /*00a0*/ IMAD.WIDE R4, R2, R7, c[0x0][0x160] ; /* 0x0000580002047625 */ /* 0x004fcc00078e0207 */ /*00b0*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea2000c1e1900 */ /*00c0*/ IMAD.WIDE R6, R6, R7, c[0x0][0x168] ; /* 0x00005a0006067625 */ /* 0x000fca00078e0207 */ /*00d0*/ STG.E [R6.64], R5 ; /* 0x0000000506007986 */ /* 0x004fe2000c101904 */ /*00e0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00f0*/ BRA 0xf0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z14gGetValueByKeyPfS_Pii .globl _Z14gGetValueByKeyPfS_Pii .p2align 8 .type _Z14gGetValueByKeyPfS_Pii,@function _Z14gGetValueByKeyPfS_Pii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x2c s_load_b32 s3, s[0:1], 0x18 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_2 s_load_b64 s[2:3], s[0:1], 0x10 v_ashrrev_i32_e32 v2, 31, v1 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) | instskip(SKIP_4) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo s_load_b128 s[0:3], s[0:1], 0x0 global_load_b32 v2, v[2:3], off s_waitcnt vmcnt(0) v_ashrrev_i32_e32 v3, 31, v2 v_lshlrev_b64 v[2:3], 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 v2, vcc_lo, s0, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo 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 v2, v[2:3], off s_waitcnt vmcnt(0) 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 _Z14gGetValueByKeyPfS_Pii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 288 .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 _Z14gGetValueByKeyPfS_Pii, .Lfunc_end0-_Z14gGetValueByKeyPfS_Pii .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: 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: _Z14gGetValueByKeyPfS_Pii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14gGetValueByKeyPfS_Pii.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_0012d4ff_00000000-6_gGetValueByKey.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 _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii .type _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii, @function _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii: .LFB2051: .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 _Z14gGetValueByKeyPfS_Pii(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii, .-_Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii .globl _Z14gGetValueByKeyPfS_Pii .type _Z14gGetValueByKeyPfS_Pii, @function _Z14gGetValueByKeyPfS_Pii: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z14gGetValueByKeyPfS_PiiPfS_Pii addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z14gGetValueByKeyPfS_Pii, .-_Z14gGetValueByKeyPfS_Pii .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z14gGetValueByKeyPfS_Pii" .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 _Z14gGetValueByKeyPfS_Pii(%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 "gGetValueByKey.hip" .globl _Z29__device_stub__gGetValueByKeyPfS_Pii # -- Begin function _Z29__device_stub__gGetValueByKeyPfS_Pii .p2align 4, 0x90 .type _Z29__device_stub__gGetValueByKeyPfS_Pii,@function _Z29__device_stub__gGetValueByKeyPfS_Pii: # @_Z29__device_stub__gGetValueByKeyPfS_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 $_Z14gGetValueByKeyPfS_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__gGetValueByKeyPfS_Pii, .Lfunc_end0-_Z29__device_stub__gGetValueByKeyPfS_Pii .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 $_Z14gGetValueByKeyPfS_Pii, %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 _Z14gGetValueByKeyPfS_Pii,@object # @_Z14gGetValueByKeyPfS_Pii .section .rodata,"a",@progbits .globl _Z14gGetValueByKeyPfS_Pii .p2align 3, 0x0 _Z14gGetValueByKeyPfS_Pii: .quad _Z29__device_stub__gGetValueByKeyPfS_Pii .size _Z14gGetValueByKeyPfS_Pii, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z14gGetValueByKeyPfS_Pii" .size .L__unnamed_1, 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__gGetValueByKeyPfS_Pii .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14gGetValueByKeyPfS_Pii .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.
/* kernel routine starts with keyword __global__ */ __global__ void vecadd(float* A, float* B, float* C) { int i = threadIdx.x; // threadIdx is a CUDA built-in variable C[i] = A[i] + B[i]; } int main(int argc, char * argv[]) { float *host_A, *host_B, *host_C; float *dev_A, *dev_B, *dev_C; int n; if (argc == 1) n = 1024; else n = atoi(argv[1]); /* 1. allocate host memory */ host_A = (float*)malloc( n*sizeof(float) ); host_B = (float*)malloc( n*sizeof(float) ); host_C = (float*)malloc( n*sizeof(float) ); /* 2. allocate GPU memory */ cudaMalloc( &dev_A, n*sizeof(float) ); cudaMalloc( &dev_B, n*sizeof(float) ); cudaMalloc( &dev_C, n*sizeof(float) ); /* initialize array A and B */ for( int i = 0; i < n; ++i ) { host_A[i] = (float) i; host_B[i] = (float) i; } /* 3. Copydata (host_A and host_B) to GPU */ cudaMemcpy( dev_A, host_A, n*sizeof(float), cudaMemcpyHostToDevice ); cudaMemcpy( dev_B, host_B, n*sizeof(float), cudaMemcpyHostToDevice ); /* 4. call kernel routine to execute on GPU */ /* launch 1 thread per vector-element, 1024 threads per block */ vecadd<<<1,n>>>( dev_A, dev_B, dev_C ); /* transfer results from GPU (dev_C) to CPU (host_C) */ cudaMemcpy( host_C, dev_C, n*sizeof(float), cudaMemcpyDeviceToHost ); /* free host and GPU memory */ free(host_A); free(host_B); free(host_C); cudaFree(dev_A); cudaFree(dev_B); cudaFree(dev_C); return( 0 ); }
code for sm_80 Function : _Z6vecaddPfS_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 R6, SR_TID.X ; /* 0x0000000000067919 */ /* 0x000e220000002100 */ /*0020*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0040*/ IMAD.WIDE R2, R6, R7, c[0x0][0x160] ; /* 0x0000580006027625 */ /* 0x001fc800078e0207 */ /*0050*/ IMAD.WIDE R4, R6.reuse, R7.reuse, c[0x0][0x168] ; /* 0x00005a0006047625 */ /* 0x0c0fe400078e0207 */ /*0060*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea8000c1e1900 */ /*0070*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea2000c1e1900 */ /*0080*/ IMAD.WIDE R6, R6, R7, c[0x0][0x170] ; /* 0x00005c0006067625 */ /* 0x000fc800078e0207 */ /*0090*/ FADD R9, R2, R5 ; /* 0x0000000502097221 */ /* 0x004fca0000000000 */ /*00a0*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*00b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00c0*/ BRA 0xc0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 CUDA host assembly.
/* kernel routine starts with keyword __global__ */ __global__ void vecadd(float* A, float* B, float* C) { int i = threadIdx.x; // threadIdx is a CUDA built-in variable C[i] = A[i] + B[i]; } int main(int argc, char * argv[]) { float *host_A, *host_B, *host_C; float *dev_A, *dev_B, *dev_C; int n; if (argc == 1) n = 1024; else n = atoi(argv[1]); /* 1. allocate host memory */ host_A = (float*)malloc( n*sizeof(float) ); host_B = (float*)malloc( n*sizeof(float) ); host_C = (float*)malloc( n*sizeof(float) ); /* 2. allocate GPU memory */ cudaMalloc( &dev_A, n*sizeof(float) ); cudaMalloc( &dev_B, n*sizeof(float) ); cudaMalloc( &dev_C, n*sizeof(float) ); /* initialize array A and B */ for( int i = 0; i < n; ++i ) { host_A[i] = (float) i; host_B[i] = (float) i; } /* 3. Copydata (host_A and host_B) to GPU */ cudaMemcpy( dev_A, host_A, n*sizeof(float), cudaMemcpyHostToDevice ); cudaMemcpy( dev_B, host_B, n*sizeof(float), cudaMemcpyHostToDevice ); /* 4. call kernel routine to execute on GPU */ /* launch 1 thread per vector-element, 1024 threads per block */ vecadd<<<1,n>>>( dev_A, dev_B, dev_C ); /* transfer results from GPU (dev_C) to CPU (host_C) */ cudaMemcpy( host_C, dev_C, n*sizeof(float), cudaMemcpyDeviceToHost ); /* free host and GPU memory */ free(host_A); free(host_B); free(host_C); cudaFree(dev_A); cudaFree(dev_B); cudaFree(dev_C); return( 0 ); }
.file "tmpxft_00039b57_00000000-6_vectoradd.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 _Z29__device_stub__Z6vecaddPfS_S_PfS_S_ .type _Z29__device_stub__Z6vecaddPfS_S_PfS_S_, @function _Z29__device_stub__Z6vecaddPfS_S_PfS_S_: .LFB2052: .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 _Z6vecaddPfS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2052: .size _Z29__device_stub__Z6vecaddPfS_S_PfS_S_, .-_Z29__device_stub__Z6vecaddPfS_S_PfS_S_ .globl _Z6vecaddPfS_S_ .type _Z6vecaddPfS_S_, @function _Z6vecaddPfS_S_: .LFB2053: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z29__device_stub__Z6vecaddPfS_S_PfS_S_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2053: .size _Z6vecaddPfS_S_, .-_Z6vecaddPfS_S_ .globl main .type main, @function main: .LFB2027: .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 $88, %rsp .cfi_def_cfa_offset 144 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax cmpl $1, %edi jne .L21 movl $4096, %edi call malloc@PLT movq %rax, %rbp movl $4096, %edi call malloc@PLT movq %rax, %rbx movl $4096, %edi call malloc@PLT movq %rax, %r14 leaq 24(%rsp), %rdi movl $4096, %esi call cudaMalloc@PLT leaq 32(%rsp), %rdi movl $4096, %esi call cudaMalloc@PLT leaq 40(%rsp), %rdi movl $4096, %esi call cudaMalloc@PLT movl $1024, 12(%rsp) movl $4096, %r13d movl $1024, %r12d .L16: movl $0, %eax .L14: pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 movss %xmm0, 0(%rbp,%rax,4) movss %xmm0, (%rbx,%rax,4) addq $1, %rax cmpq %r12, %rax jne .L14 .L13: movl $1, %ecx movq %r13, %rdx movq %rbp, %rsi movq 24(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r13, %rdx movq %rbx, %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl 12(%rsp), %eax movl %eax, 60(%rsp) movl $1, 64(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $0, %r9d movl $0, %r8d movq 60(%rsp), %rdx movl $1, %ecx movq 48(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L22 .L15: movl $2, %ecx movq %r13, %rdx movq 40(%rsp), %rsi movq %r14, %rdi call cudaMemcpy@PLT movq %rbp, %rdi call free@PLT movq %rbx, %rdi call free@PLT movq %r14, %rdi call free@PLT movq 24(%rsp), %rdi call cudaFree@PLT movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L23 movl $0, %eax addq $88, %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 .L21: .cfi_restore_state movq 8(%rsi), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movq %rax, %r15 movl %eax, 12(%rsp) movslq %eax, %r12 leaq 0(,%r12,4), %r13 movq %r13, %rdi call malloc@PLT movq %rax, %rbp movq %r13, %rdi call malloc@PLT movq %rax, %rbx movq %r13, %rdi call malloc@PLT movq %rax, %r14 leaq 24(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 32(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 40(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT testl %r15d, %r15d jg .L16 jmp .L13 .L22: movq 40(%rsp), %rdx movq 32(%rsp), %rsi movq 24(%rsp), %rdi call _Z29__device_stub__Z6vecaddPfS_S_PfS_S_ jmp .L15 .L23: call __stack_chk_fail@PLT .cfi_endproc .LFE2027: .size main, .-main .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z6vecaddPfS_S_" .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 _Z6vecaddPfS_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 .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.
/* kernel routine starts with keyword __global__ */ __global__ void vecadd(float* A, float* B, float* C) { int i = threadIdx.x; // threadIdx is a CUDA built-in variable C[i] = A[i] + B[i]; } int main(int argc, char * argv[]) { float *host_A, *host_B, *host_C; float *dev_A, *dev_B, *dev_C; int n; if (argc == 1) n = 1024; else n = atoi(argv[1]); /* 1. allocate host memory */ host_A = (float*)malloc( n*sizeof(float) ); host_B = (float*)malloc( n*sizeof(float) ); host_C = (float*)malloc( n*sizeof(float) ); /* 2. allocate GPU memory */ cudaMalloc( &dev_A, n*sizeof(float) ); cudaMalloc( &dev_B, n*sizeof(float) ); cudaMalloc( &dev_C, n*sizeof(float) ); /* initialize array A and B */ for( int i = 0; i < n; ++i ) { host_A[i] = (float) i; host_B[i] = (float) i; } /* 3. Copydata (host_A and host_B) to GPU */ cudaMemcpy( dev_A, host_A, n*sizeof(float), cudaMemcpyHostToDevice ); cudaMemcpy( dev_B, host_B, n*sizeof(float), cudaMemcpyHostToDevice ); /* 4. call kernel routine to execute on GPU */ /* launch 1 thread per vector-element, 1024 threads per block */ vecadd<<<1,n>>>( dev_A, dev_B, dev_C ); /* transfer results from GPU (dev_C) to CPU (host_C) */ cudaMemcpy( host_C, dev_C, n*sizeof(float), cudaMemcpyDeviceToHost ); /* free host and GPU memory */ free(host_A); free(host_B); free(host_C); cudaFree(dev_A); cudaFree(dev_B); cudaFree(dev_C); return( 0 ); }
#include <hip/hip_runtime.h> /* kernel routine starts with keyword __global__ */ __global__ void vecadd(float* A, float* B, float* C) { int i = threadIdx.x; // threadIdx is a CUDA built-in variable C[i] = A[i] + B[i]; } int main(int argc, char * argv[]) { float *host_A, *host_B, *host_C; float *dev_A, *dev_B, *dev_C; int n; if (argc == 1) n = 1024; else n = atoi(argv[1]); /* 1. allocate host memory */ host_A = (float*)malloc( n*sizeof(float) ); host_B = (float*)malloc( n*sizeof(float) ); host_C = (float*)malloc( n*sizeof(float) ); /* 2. allocate GPU memory */ hipMalloc( &dev_A, n*sizeof(float) ); hipMalloc( &dev_B, n*sizeof(float) ); hipMalloc( &dev_C, n*sizeof(float) ); /* initialize array A and B */ for( int i = 0; i < n; ++i ) { host_A[i] = (float) i; host_B[i] = (float) i; } /* 3. Copydata (host_A and host_B) to GPU */ hipMemcpy( dev_A, host_A, n*sizeof(float), hipMemcpyHostToDevice ); hipMemcpy( dev_B, host_B, n*sizeof(float), hipMemcpyHostToDevice ); /* 4. call kernel routine to execute on GPU */ /* launch 1 thread per vector-element, 1024 threads per block */ vecadd<<<1,n>>>( dev_A, dev_B, dev_C ); /* transfer results from GPU (dev_C) to CPU (host_C) */ hipMemcpy( host_C, dev_C, n*sizeof(float), hipMemcpyDeviceToHost ); /* free host and GPU memory */ free(host_A); free(host_B); free(host_C); hipFree(dev_A); hipFree(dev_B); hipFree(dev_C); return( 0 ); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> /* kernel routine starts with keyword __global__ */ __global__ void vecadd(float* A, float* B, float* C) { int i = threadIdx.x; // threadIdx is a CUDA built-in variable C[i] = A[i] + B[i]; } int main(int argc, char * argv[]) { float *host_A, *host_B, *host_C; float *dev_A, *dev_B, *dev_C; int n; if (argc == 1) n = 1024; else n = atoi(argv[1]); /* 1. allocate host memory */ host_A = (float*)malloc( n*sizeof(float) ); host_B = (float*)malloc( n*sizeof(float) ); host_C = (float*)malloc( n*sizeof(float) ); /* 2. allocate GPU memory */ hipMalloc( &dev_A, n*sizeof(float) ); hipMalloc( &dev_B, n*sizeof(float) ); hipMalloc( &dev_C, n*sizeof(float) ); /* initialize array A and B */ for( int i = 0; i < n; ++i ) { host_A[i] = (float) i; host_B[i] = (float) i; } /* 3. Copydata (host_A and host_B) to GPU */ hipMemcpy( dev_A, host_A, n*sizeof(float), hipMemcpyHostToDevice ); hipMemcpy( dev_B, host_B, n*sizeof(float), hipMemcpyHostToDevice ); /* 4. call kernel routine to execute on GPU */ /* launch 1 thread per vector-element, 1024 threads per block */ vecadd<<<1,n>>>( dev_A, dev_B, dev_C ); /* transfer results from GPU (dev_C) to CPU (host_C) */ hipMemcpy( host_C, dev_C, n*sizeof(float), hipMemcpyDeviceToHost ); /* free host and GPU memory */ free(host_A); free(host_B); free(host_C); hipFree(dev_A); hipFree(dev_B); hipFree(dev_C); return( 0 ); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6vecaddPfS_S_ .globl _Z6vecaddPfS_S_ .p2align 8 .type _Z6vecaddPfS_S_,@function _Z6vecaddPfS_S_: s_load_b128 s[4:7], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 2, v0 s_load_b64 s[0:1], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_clause 0x1 global_load_b32 v1, v0, s[4:5] global_load_b32 v2, v0, s[6:7] s_waitcnt vmcnt(0) v_add_f32_e32 v1, v1, v2 global_store_b32 v0, v1, s[0:1] s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6vecaddPfS_S_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 24 .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 8 .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 _Z6vecaddPfS_S_, .Lfunc_end0-_Z6vecaddPfS_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 .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 24 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z6vecaddPfS_S_ .private_segment_fixed_size: 0 .sgpr_count: 8 .sgpr_spill_count: 0 .symbol: _Z6vecaddPfS_S_.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 <hip/hip_runtime.h> /* kernel routine starts with keyword __global__ */ __global__ void vecadd(float* A, float* B, float* C) { int i = threadIdx.x; // threadIdx is a CUDA built-in variable C[i] = A[i] + B[i]; } int main(int argc, char * argv[]) { float *host_A, *host_B, *host_C; float *dev_A, *dev_B, *dev_C; int n; if (argc == 1) n = 1024; else n = atoi(argv[1]); /* 1. allocate host memory */ host_A = (float*)malloc( n*sizeof(float) ); host_B = (float*)malloc( n*sizeof(float) ); host_C = (float*)malloc( n*sizeof(float) ); /* 2. allocate GPU memory */ hipMalloc( &dev_A, n*sizeof(float) ); hipMalloc( &dev_B, n*sizeof(float) ); hipMalloc( &dev_C, n*sizeof(float) ); /* initialize array A and B */ for( int i = 0; i < n; ++i ) { host_A[i] = (float) i; host_B[i] = (float) i; } /* 3. Copydata (host_A and host_B) to GPU */ hipMemcpy( dev_A, host_A, n*sizeof(float), hipMemcpyHostToDevice ); hipMemcpy( dev_B, host_B, n*sizeof(float), hipMemcpyHostToDevice ); /* 4. call kernel routine to execute on GPU */ /* launch 1 thread per vector-element, 1024 threads per block */ vecadd<<<1,n>>>( dev_A, dev_B, dev_C ); /* transfer results from GPU (dev_C) to CPU (host_C) */ hipMemcpy( host_C, dev_C, n*sizeof(float), hipMemcpyDeviceToHost ); /* free host and GPU memory */ free(host_A); free(host_B); free(host_C); hipFree(dev_A); hipFree(dev_B); hipFree(dev_C); return( 0 ); }
.text .file "vectoradd.hip" .globl _Z21__device_stub__vecaddPfS_S_ # -- Begin function _Z21__device_stub__vecaddPfS_S_ .p2align 4, 0x90 .type _Z21__device_stub__vecaddPfS_S_,@function _Z21__device_stub__vecaddPfS_S_: # @_Z21__device_stub__vecaddPfS_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 $_Z6vecaddPfS_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 _Z21__device_stub__vecaddPfS_S_, .Lfunc_end0-_Z21__device_stub__vecaddPfS_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 %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 $120, %rsp .cfi_def_cfa_offset 176 .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 $1024, %eax # imm = 0x400 cmpl $1, %edi je .LBB1_2 # %bb.1: movq 8(%rsi), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol .LBB1_2: movslq %eax, %rbp leaq (,%rbp,4), %rbx movq %rbx, %rdi callq malloc movq %rax, %r14 movq %rbx, %rdi callq malloc movq %rax, %r15 movq %rbx, %rdi callq malloc movq %rax, %r12 leaq 16(%rsp), %rdi movq %rbx, %rsi callq hipMalloc leaq 8(%rsp), %rdi movq %rbx, %rsi callq hipMalloc movq %rsp, %rdi movq %rbx, %rsi callq hipMalloc movl %ebp, %r13d testl %ebp, %ebp jle .LBB1_5 # %bb.3: # %.lr.ph.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_4: # %.lr.ph # =>This Inner Loop Header: Depth=1 xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%r14,%rax,4) movss %xmm0, (%r15,%rax,4) incq %rax cmpq %rax, %r13 jne .LBB1_4 .LBB1_5: # %._crit_edge movq 16(%rsp), %rdi movq %r14, %rsi movq %rbx, %rdx movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi movq %r15, %rsi movq %rbx, %rdx movl $1, %ecx callq hipMemcpy movabsq $4294967296, %rdi # imm = 0x100000000 orq %rdi, %r13 orq $1, %rdi movl $1, %esi movq %r13, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_7 # %bb.6: 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 $_Z6vecaddPfS_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_7: movq (%rsp), %rsi movq %r12, %rdi movq %rbx, %rdx movl $2, %ecx callq hipMemcpy movq %r14, %rdi callq free movq %r15, %rdi callq free movq %r12, %rdi callq free movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $120, %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 .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 $_Z6vecaddPfS_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 _Z6vecaddPfS_S_,@object # @_Z6vecaddPfS_S_ .section .rodata,"a",@progbits .globl _Z6vecaddPfS_S_ .p2align 3, 0x0 _Z6vecaddPfS_S_: .quad _Z21__device_stub__vecaddPfS_S_ .size _Z6vecaddPfS_S_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z6vecaddPfS_S_" .size .L__unnamed_1, 16 .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 _Z21__device_stub__vecaddPfS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6vecaddPfS_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 : _Z6vecaddPfS_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 R6, SR_TID.X ; /* 0x0000000000067919 */ /* 0x000e220000002100 */ /*0020*/ HFMA2.MMA R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fd20000000a00 */ /*0040*/ IMAD.WIDE R2, R6, R7, c[0x0][0x160] ; /* 0x0000580006027625 */ /* 0x001fc800078e0207 */ /*0050*/ IMAD.WIDE R4, R6.reuse, R7.reuse, c[0x0][0x168] ; /* 0x00005a0006047625 */ /* 0x0c0fe400078e0207 */ /*0060*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea8000c1e1900 */ /*0070*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea2000c1e1900 */ /*0080*/ IMAD.WIDE R6, R6, R7, c[0x0][0x170] ; /* 0x00005c0006067625 */ /* 0x000fc800078e0207 */ /*0090*/ FADD R9, R2, R5 ; /* 0x0000000502097221 */ /* 0x004fca0000000000 */ /*00a0*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*00b0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*00c0*/ BRA 0xc0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6vecaddPfS_S_ .globl _Z6vecaddPfS_S_ .p2align 8 .type _Z6vecaddPfS_S_,@function _Z6vecaddPfS_S_: s_load_b128 s[4:7], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 2, v0 s_load_b64 s[0:1], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_clause 0x1 global_load_b32 v1, v0, s[4:5] global_load_b32 v2, v0, s[6:7] s_waitcnt vmcnt(0) v_add_f32_e32 v1, v1, v2 global_store_b32 v0, v1, s[0:1] s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6vecaddPfS_S_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 24 .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 8 .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 _Z6vecaddPfS_S_, .Lfunc_end0-_Z6vecaddPfS_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 .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 24 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z6vecaddPfS_S_ .private_segment_fixed_size: 0 .sgpr_count: 8 .sgpr_spill_count: 0 .symbol: _Z6vecaddPfS_S_.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_00039b57_00000000-6_vectoradd.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 _Z29__device_stub__Z6vecaddPfS_S_PfS_S_ .type _Z29__device_stub__Z6vecaddPfS_S_PfS_S_, @function _Z29__device_stub__Z6vecaddPfS_S_PfS_S_: .LFB2052: .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 _Z6vecaddPfS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2052: .size _Z29__device_stub__Z6vecaddPfS_S_PfS_S_, .-_Z29__device_stub__Z6vecaddPfS_S_PfS_S_ .globl _Z6vecaddPfS_S_ .type _Z6vecaddPfS_S_, @function _Z6vecaddPfS_S_: .LFB2053: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z29__device_stub__Z6vecaddPfS_S_PfS_S_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2053: .size _Z6vecaddPfS_S_, .-_Z6vecaddPfS_S_ .globl main .type main, @function main: .LFB2027: .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 $88, %rsp .cfi_def_cfa_offset 144 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax cmpl $1, %edi jne .L21 movl $4096, %edi call malloc@PLT movq %rax, %rbp movl $4096, %edi call malloc@PLT movq %rax, %rbx movl $4096, %edi call malloc@PLT movq %rax, %r14 leaq 24(%rsp), %rdi movl $4096, %esi call cudaMalloc@PLT leaq 32(%rsp), %rdi movl $4096, %esi call cudaMalloc@PLT leaq 40(%rsp), %rdi movl $4096, %esi call cudaMalloc@PLT movl $1024, 12(%rsp) movl $4096, %r13d movl $1024, %r12d .L16: movl $0, %eax .L14: pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 movss %xmm0, 0(%rbp,%rax,4) movss %xmm0, (%rbx,%rax,4) addq $1, %rax cmpq %r12, %rax jne .L14 .L13: movl $1, %ecx movq %r13, %rdx movq %rbp, %rsi movq 24(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r13, %rdx movq %rbx, %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT movl 12(%rsp), %eax movl %eax, 60(%rsp) movl $1, 64(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $0, %r9d movl $0, %r8d movq 60(%rsp), %rdx movl $1, %ecx movq 48(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L22 .L15: movl $2, %ecx movq %r13, %rdx movq 40(%rsp), %rsi movq %r14, %rdi call cudaMemcpy@PLT movq %rbp, %rdi call free@PLT movq %rbx, %rdi call free@PLT movq %r14, %rdi call free@PLT movq 24(%rsp), %rdi call cudaFree@PLT movq 32(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L23 movl $0, %eax addq $88, %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 .L21: .cfi_restore_state movq 8(%rsi), %rdi movl $10, %edx movl $0, %esi call __isoc23_strtol@PLT movq %rax, %r15 movl %eax, 12(%rsp) movslq %eax, %r12 leaq 0(,%r12,4), %r13 movq %r13, %rdi call malloc@PLT movq %rax, %rbp movq %r13, %rdi call malloc@PLT movq %rax, %rbx movq %r13, %rdi call malloc@PLT movq %rax, %r14 leaq 24(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 32(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT leaq 40(%rsp), %rdi movq %r13, %rsi call cudaMalloc@PLT testl %r15d, %r15d jg .L16 jmp .L13 .L22: movq 40(%rsp), %rdx movq 32(%rsp), %rsi movq 24(%rsp), %rdi call _Z29__device_stub__Z6vecaddPfS_S_PfS_S_ jmp .L15 .L23: call __stack_chk_fail@PLT .cfi_endproc .LFE2027: .size main, .-main .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z6vecaddPfS_S_" .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 _Z6vecaddPfS_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 .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 "vectoradd.hip" .globl _Z21__device_stub__vecaddPfS_S_ # -- Begin function _Z21__device_stub__vecaddPfS_S_ .p2align 4, 0x90 .type _Z21__device_stub__vecaddPfS_S_,@function _Z21__device_stub__vecaddPfS_S_: # @_Z21__device_stub__vecaddPfS_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 $_Z6vecaddPfS_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 _Z21__device_stub__vecaddPfS_S_, .Lfunc_end0-_Z21__device_stub__vecaddPfS_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 %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 $120, %rsp .cfi_def_cfa_offset 176 .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 $1024, %eax # imm = 0x400 cmpl $1, %edi je .LBB1_2 # %bb.1: movq 8(%rsi), %rdi xorl %esi, %esi movl $10, %edx callq __isoc23_strtol .LBB1_2: movslq %eax, %rbp leaq (,%rbp,4), %rbx movq %rbx, %rdi callq malloc movq %rax, %r14 movq %rbx, %rdi callq malloc movq %rax, %r15 movq %rbx, %rdi callq malloc movq %rax, %r12 leaq 16(%rsp), %rdi movq %rbx, %rsi callq hipMalloc leaq 8(%rsp), %rdi movq %rbx, %rsi callq hipMalloc movq %rsp, %rdi movq %rbx, %rsi callq hipMalloc movl %ebp, %r13d testl %ebp, %ebp jle .LBB1_5 # %bb.3: # %.lr.ph.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_4: # %.lr.ph # =>This Inner Loop Header: Depth=1 xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 movss %xmm0, (%r14,%rax,4) movss %xmm0, (%r15,%rax,4) incq %rax cmpq %rax, %r13 jne .LBB1_4 .LBB1_5: # %._crit_edge movq 16(%rsp), %rdi movq %r14, %rsi movq %rbx, %rdx movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi movq %r15, %rsi movq %rbx, %rdx movl $1, %ecx callq hipMemcpy movabsq $4294967296, %rdi # imm = 0x100000000 orq %rdi, %r13 orq $1, %rdi movl $1, %esi movq %r13, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_7 # %bb.6: 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 $_Z6vecaddPfS_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_7: movq (%rsp), %rsi movq %r12, %rdi movq %rbx, %rdx movl $2, %ecx callq hipMemcpy movq %r14, %rdi callq free movq %r15, %rdi callq free movq %r12, %rdi callq free movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq (%rsp), %rdi callq hipFree xorl %eax, %eax addq $120, %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 .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 $_Z6vecaddPfS_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 _Z6vecaddPfS_S_,@object # @_Z6vecaddPfS_S_ .section .rodata,"a",@progbits .globl _Z6vecaddPfS_S_ .p2align 3, 0x0 _Z6vecaddPfS_S_: .quad _Z21__device_stub__vecaddPfS_S_ .size _Z6vecaddPfS_S_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z6vecaddPfS_S_" .size .L__unnamed_1, 16 .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 _Z21__device_stub__vecaddPfS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6vecaddPfS_S_ .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_