system
stringclasses
7 values
input
stringlengths
10
94.5k
output
stringlengths
14
55.5k
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> #include <iostream> #include <cstdio> #include <chrono> typedef std::chrono::high_resolution_clock Clock; #define ITER 1000000000 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true) { if (code != hipSuccess) { fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line); if (abort) exit(code); } } // CPU version of the vector add function void vector_add_cpu(int *a, int *b, int *c, int n) { int i; // Add the vector elements a and b to the vector c for (i = 0; i < n; ++i) { c[i] = a[i] + b[i]; } } // GPU version of the vector add function __global__ void vector_add_gpu(int *gpu_a, int *gpu_b, int *gpu_c, int n) { int i = blockIdx.x; // No for loop needed because the CUDA runtime // will thread this ITER times gpu_c[i] = gpu_a[i] + gpu_b[i]; } int main() { int *a, *b, *c; int *gpu_a, *gpu_b, *gpu_c; int *ha, *hb, *hc; a = (int *)malloc(ITER * sizeof(int)); b = (int *)malloc(ITER * sizeof(int)); c = (int *)malloc(ITER * sizeof(int)); ha = (int *)malloc(ITER * sizeof(int)); hb = (int *)malloc(ITER * sizeof(int)); hc = (int *)malloc(ITER * sizeof(int)); // We need variables accessible to the GPU, // so cudaMallocManaged provides these hipMallocManaged(&gpu_a, ITER * sizeof(int)); hipMallocManaged(&gpu_b, ITER * sizeof(int)); hipMallocManaged(&gpu_c, ITER * sizeof(int)); for (int i = 0; i < ITER; ++i) { a[i] = i; b[i] = i; c[i] = i; } // Call the CPU function and time it auto cpu_start = Clock::now(); vector_add_cpu(a, b, c, ITER); auto cpu_end = Clock::now(); std::cout << "vector_add_cpu: " << std::chrono::duration_cast<std::chrono::nanoseconds>(cpu_end - cpu_start).count() << " nanoseconds.\n"; // Call the GPU function and time it // The triple angle brakets is a CUDA runtime extension that allows // parameters of a CUDA kernel call to be passed. // In this example, we are passing one thread block with ITER threads. hipMemcpy(gpu_a,a,ITER*sizeof(int),hipMemcpyHostToDevice); hipMemcpy(gpu_b,b,ITER*sizeof(int),hipMemcpyHostToDevice); auto gpu_start = Clock::now(); vector_add_gpu <<<ITER, 1024>>> (gpu_a, gpu_b, gpu_c, ITER); hipDeviceSynchronize(); auto gpu_end = Clock::now(); std::cout << "vector_add_gpu: " << std::chrono::duration_cast<std::chrono::nanoseconds>(gpu_end - gpu_start).count() << " nanoseconds.\n"; hipMemcpy(hc,gpu_c,ITER*sizeof(int),hipMemcpyDeviceToHost); hipMemcpy(hb,gpu_b,ITER*sizeof(int),hipMemcpyDeviceToHost); gpuErrchk(hipMemcpy(ha,gpu_a,ITER*sizeof(int),hipMemcpyDeviceToHost)); std::cout<<c[0]<<"\t"<<hc[0]<<std::endl; std::cout<<c[int(ITER/3)]<<"\t"<<hc[int(ITER/3)]<<std::endl; std::cout<<c[int(2*ITER/3)]<<"\t"<<hc[int(2*ITER/3)]<<std::endl; std::cout<<c[int(ITER-1)]<<"\t"<<hc[int(ITER-1)]<<std::endl; // Free the GPU-function based memory allocations hipFree(a); hipFree(b); hipFree(c); // Free the CPU-function based memory allocations free(a); free(b); free(c); return 0; }
.text .file "gpu-example.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z14vector_add_cpuPiS_S_i # -- Begin function _Z14vector_add_cpuPiS_S_i .p2align 4, 0x90 .type _Z14vector_add_cpuPiS_S_i,@function _Z14vector_add_cpuPiS_S_i: # @_Z14vector_add_cpuPiS_S_i .cfi_startproc # %bb.0: testl %ecx, %ecx jle .LBB0_3 # %bb.1: # %.lr.ph.preheader movl %ecx, %eax xorl %ecx, %ecx .p2align 4, 0x90 .LBB0_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 movl (%rsi,%rcx,4), %r8d addl (%rdi,%rcx,4), %r8d movl %r8d, (%rdx,%rcx,4) incq %rcx cmpq %rcx, %rax jne .LBB0_2 .LBB0_3: # %._crit_edge retq .Lfunc_end0: .size _Z14vector_add_cpuPiS_S_i, .Lfunc_end0-_Z14vector_add_cpuPiS_S_i .cfi_endproc # -- End function .globl _Z29__device_stub__vector_add_gpuPiS_S_i # -- Begin function _Z29__device_stub__vector_add_gpuPiS_S_i .p2align 4, 0x90 .type _Z29__device_stub__vector_add_gpuPiS_S_i,@function _Z29__device_stub__vector_add_gpuPiS_S_i: # @_Z29__device_stub__vector_add_gpuPiS_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 $_Z14vector_add_gpuPiS_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 _Z29__device_stub__vector_add_gpuPiS_S_i, .Lfunc_end1-_Z29__device_stub__vector_add_gpuPiS_S_i .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 $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 $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %rbx movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %r14 movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %r15 movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, 48(%rsp) # 8-byte Spill movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, 40(%rsp) # 8-byte Spill movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %r12 leaq 16(%rsp), %rdi movl $4000000000, %esi # imm = 0xEE6B2800 movl $1, %edx callq hipMallocManaged leaq 8(%rsp), %rdi movl $4000000000, %esi # imm = 0xEE6B2800 movl $1, %edx callq hipMallocManaged leaq 32(%rsp), %rdi movl $4000000000, %esi # imm = 0xEE6B2800 movl $1, %edx callq hipMallocManaged xorl %eax, %eax .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 movl %eax, (%rbx,%rax,4) movl %eax, (%r14,%rax,4) movl %eax, (%r15,%rax,4) incq %rax cmpq $1000000000, %rax # imm = 0x3B9ACA00 jne .LBB2_1 # %bb.2: xorl %ebp, %ebp callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %r13 .p2align 4, 0x90 .LBB2_3: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 movl (%r14,%rbp,4), %eax addl (%rbx,%rbp,4), %eax movl %eax, (%r15,%rbp,4) incq %rbp cmpq $1000000000, %rbp # imm = 0x3B9ACA00 jne .LBB2_3 # %bb.4: # %_Z14vector_add_cpuPiS_S_i.exit callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %rbp movl $_ZSt4cout, %edi movl $.L.str, %esi movl $16, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l subq %r13, %rbp movl $_ZSt4cout, %edi movq %rbp, %rsi callq _ZNSo9_M_insertIlEERSoT_ movl $.L.str.1, %esi movl $14, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq 16(%rsp), %rdi movl $4000000000, %edx # imm = 0xEE6B2800 movq %rbx, %rsi movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi movl $4000000000, %edx # imm = 0xEE6B2800 movq %r14, %rsi movl $1, %ecx callq hipMemcpy callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %r13 movl $4000000000, %eax # imm = 0xEE6B2800 leaq 294968320(%rax), %rdx leaq 1294967296(%rax), %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_6 # %bb.5: movq 16(%rsp), %rax movq 8(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 120(%rsp) movq %rcx, 112(%rsp) movq %rdx, 104(%rsp) movl $1000000000, 28(%rsp) # imm = 0x3B9ACA00 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 $_Z14vector_add_gpuPiS_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: callq hipDeviceSynchronize callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %rbp movl $_ZSt4cout, %edi movl $.L.str.2, %esi movl $16, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l subq %r13, %rbp movl $_ZSt4cout, %edi movq %rbp, %rsi callq _ZNSo9_M_insertIlEERSoT_ movl $.L.str.1, %esi movl $14, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq 32(%rsp), %rsi movl $4000000000, %edx # imm = 0xEE6B2800 movq %r12, %rdi movl $2, %ecx callq hipMemcpy movq 8(%rsp), %rsi movl $4000000000, %edx # imm = 0xEE6B2800 movq 40(%rsp), %rdi # 8-byte Reload movl $2, %ecx callq hipMemcpy movq 16(%rsp), %rsi movl $4000000000, %edx # imm = 0xEE6B2800 movq 48(%rsp), %rdi # 8-byte Reload movl $2, %ecx callq hipMemcpy testl %eax, %eax jne .LBB2_24 # %bb.7: # %_Z9gpuAssert10hipError_tPKcib.exit movl (%r15), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl (%r12), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r13 testq %r13, %r13 je .LBB2_25 # %bb.8: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%r13) je .LBB2_10 # %bb.9: movzbl 67(%r13), %ecx jmp .LBB2_11 .LBB2_10: movq %r13, %rdi movq %rax, %rbp callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r13), %rax movq %r13, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %rbp, %rax .LBB2_11: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 1333333332(%r15), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 1333333332(%r12), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r13 testq %r13, %r13 je .LBB2_25 # %bb.12: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i39 cmpb $0, 56(%r13) je .LBB2_14 # %bb.13: movzbl 67(%r13), %ecx jmp .LBB2_15 .LBB2_14: movq %r13, %rdi movq %rax, %rbp callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r13), %rax movq %r13, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %rbp, %rax .LBB2_15: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit42 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $2666666664, %ebp # imm = 0x9EF21AA8 movl (%r15,%rbp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl (%r12,%rbp), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r13 testq %r13, %r13 je .LBB2_25 # %bb.16: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i44 cmpb $0, 56(%r13) je .LBB2_18 # %bb.17: movzbl 67(%r13), %ecx jmp .LBB2_19 .LBB2_18: movq %r13, %rdi movq %rax, %rbp callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r13), %rax movq %r13, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %rbp, %rax .LBB2_19: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit47 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $3999999996, %ebp # imm = 0xEE6B27FC movl (%r15,%rbp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl (%r12,%rbp), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r12 testq %r12, %r12 je .LBB2_25 # %bb.20: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i49 cmpb $0, 56(%r12) je .LBB2_22 # %bb.21: movzbl 67(%r12), %ecx jmp .LBB2_23 .LBB2_22: movq %r12, %rdi movq %rax, %r13 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r12), %rax movq %r12, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r13, %rax .LBB2_23: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit52 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movq %rbx, %rdi callq hipFree movq %r14, %rdi callq hipFree movq %r15, %rdi callq hipFree movq %rbx, %rdi callq free movq %r14, %rdi callq free movq %r15, %rdi callq free 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 .LBB2_25: .cfi_def_cfa_offset 224 callq _ZSt16__throw_bad_castv .LBB2_24: movq stderr(%rip), %rbx movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str.5, %esi movl $.L.str.3, %ecx movq %rbx, %rdi movq %rax, %rdx movl $90, %r8d xorl %eax, %eax callq fprintf movl %ebp, %edi callq exit .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 $_Z14vector_add_gpuPiS_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 _Z14vector_add_gpuPiS_S_i,@object # @_Z14vector_add_gpuPiS_S_i .section .rodata,"a",@progbits .globl _Z14vector_add_gpuPiS_S_i .p2align 3, 0x0 _Z14vector_add_gpuPiS_S_i: .quad _Z29__device_stub__vector_add_gpuPiS_S_i .size _Z14vector_add_gpuPiS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "vector_add_cpu: " .size .L.str, 17 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz " nanoseconds.\n" .size .L.str.1, 15 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "vector_add_gpu: " .size .L.str.2, 17 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "/home/ubuntu/Datasets/stackv2/train-structured-repos-hip/rmhsik/TFM/master/CUDATest/gpu-example.hip" .size .L.str.3, 100 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "\t" .size .L.str.4, 2 .type .L.str.5,@object # @.str.5 .L.str.5: .asciz "GPUassert: %s %s %d\n" .size .L.str.5, 21 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z14vector_add_gpuPiS_S_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 _Z29__device_stub__vector_add_gpuPiS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14vector_add_gpuPiS_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 : _Z14vector_add_gpuPiS_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 */ /* 0x000e220000002500 */ /*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 */ /* 0x000fe200078e0207 */ /*0090*/ IADD3 R9, R2, R5, RZ ; /* 0x0000000502097210 */ /* 0x004fca0007ffe0ff */ /*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 _Z14vector_add_gpuPiS_S_i .globl _Z14vector_add_gpuPiS_S_i .p2align 8 .type _Z14vector_add_gpuPiS_S_i,@function _Z14vector_add_gpuPiS_S_i: s_load_b128 s[4:7], s[0:1], 0x0 s_mov_b32 s2, s15 s_ashr_i32 s3, s15, 31 s_load_b64 s[0:1], s[0:1], 0x10 s_lshl_b64 s[2:3], s[2:3], 2 s_waitcnt lgkmcnt(0) s_add_u32 s4, s4, s2 s_addc_u32 s5, s5, s3 s_add_u32 s6, s6, s2 s_addc_u32 s7, s7, s3 s_load_b32 s4, s[4:5], 0x0 s_load_b32 s5, s[6:7], 0x0 s_waitcnt lgkmcnt(0) s_add_i32 s4, s5, s4 s_delay_alu instid0(SALU_CYCLE_1) v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s4 s_add_u32 s0, s0, s2 s_addc_u32 s1, s1, s3 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 _Z14vector_add_gpuPiS_S_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 28 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 2 .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 _Z14vector_add_gpuPiS_S_i, .Lfunc_end0-_Z14vector_add_gpuPiS_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 .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 28 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14vector_add_gpuPiS_S_i .private_segment_fixed_size: 0 .sgpr_count: 16 .sgpr_spill_count: 0 .symbol: _Z14vector_add_gpuPiS_S_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 2 .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_0003b58d_00000000-6_gpu-example.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3775: .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 .LFE3775: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z14vector_add_cpuPiS_S_i .type _Z14vector_add_cpuPiS_S_i, @function _Z14vector_add_cpuPiS_S_i: .LFB3769: .cfi_startproc endbr64 testl %ecx, %ecx jle .L3 movslq %ecx, %rcx leaq 0(,%rcx,4), %r8 movl $0, %eax .L5: movl (%rsi,%rax), %ecx addl (%rdi,%rax), %ecx movl %ecx, (%rdx,%rax) addq $4, %rax cmpq %r8, %rax jne .L5 .L3: ret .cfi_endproc .LFE3769: .size _Z14vector_add_cpuPiS_S_i, .-_Z14vector_add_cpuPiS_S_i .globl _Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i .type _Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i, @function _Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i: .LFB3797: .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 .L11 .L7: movq 136(%rsp), %rax subq %fs:40, %rax jne .L12 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L11: .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 _Z14vector_add_gpuPiS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L7 .L12: call __stack_chk_fail@PLT .cfi_endproc .LFE3797: .size _Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i, .-_Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i .globl _Z14vector_add_gpuPiS_S_i .type _Z14vector_add_gpuPiS_S_i, @function _Z14vector_add_gpuPiS_S_i: .LFB3798: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3798: .size _Z14vector_add_gpuPiS_S_i, .-_Z14vector_add_gpuPiS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "vector_add_cpu: " .LC1: .string " nanoseconds.\n" .LC2: .string "vector_add_gpu: " .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC3: .string "/home/ubuntu/Datasets/stackv2/train-structured/rmhsik/TFM/master/CUDATest/gpu-example.cu" .section .rodata.str1.1 .LC4: .string "GPUassert: %s %s %d\n" .LC5: .string "\t" .text .globl main .type main, @function main: .LFB3770: .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 movl $4000000000, %r14d movq %r14, %rdi call malloc@PLT movq %rax, %r12 movq %r14, %rdi call malloc@PLT movq %rax, %rbp movq %r14, %rdi call malloc@PLT movq %rax, %rbx movq %r14, %rdi call malloc@PLT movq %rax, (%rsp) movq %r14, %rdi call malloc@PLT movq %rax, 8(%rsp) movq %r14, %rdi call malloc@PLT movq %rax, %r13 leaq 24(%rsp), %rdi movl $1, %edx movq %r14, %rsi call cudaMallocManaged@PLT leaq 32(%rsp), %rdi movl $1, %edx movq %r14, %rsi call cudaMallocManaged@PLT leaq 40(%rsp), %rdi movl $1, %edx movq %r14, %rsi call cudaMallocManaged@PLT movl $0, %eax .L16: movl %eax, (%r12,%rax,4) movl %eax, 0(%rbp,%rax,4) movl %eax, (%rbx,%rax,4) addq $1, %rax cmpq $1000000000, %rax jne .L16 call _ZNSt6chrono3_V212system_clock3nowEv@PLT movq %rax, %r15 movl $1000000000, %ecx movq %rbx, %rdx movq %rbp, %rsi movq %r12, %rdi call _Z14vector_add_cpuPiS_S_i call _ZNSt6chrono3_V212system_clock3nowEv@PLT movq %rax, %r14 leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq %r14, %rsi subq %r15, %rsi call _ZNSo9_M_insertIlEERSoT_@PLT movq %rax, %rdi leaq .LC1(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movl $1, %ecx movl $4000000000, %r14d movq %r14, %rdx movq %r12, %rsi movq 24(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movq %r14, %rdx movq %rbp, %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT call _ZNSt6chrono3_V212system_clock3nowEv@PLT movq %rax, %r15 movl $1024, 60(%rsp) movl $1, 64(%rsp) movl $1000000000, 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 .L17: call cudaDeviceSynchronize@PLT call _ZNSt6chrono3_V212system_clock3nowEv@PLT movq %rax, %r14 leaq .LC2(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq %r14, %rsi subq %r15, %rsi call _ZNSo9_M_insertIlEERSoT_@PLT movq %rax, %rdi leaq .LC1(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movl $2, %ecx movl $4000000000, %r14d movq %r14, %rdx movq 40(%rsp), %rsi movq %r13, %rdi call cudaMemcpy@PLT movl $2, %ecx movq %r14, %rdx movq 32(%rsp), %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl $2, %ecx movq %r14, %rdx movq 24(%rsp), %rsi movq (%rsp), %rdi call cudaMemcpy@PLT movl %eax, %r14d testl %eax, %eax jne .L23 movl (%rbx), %esi leaq _ZSt4cout(%rip), %r14 movq %r14, %rdi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC5(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 0(%r13), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl 1333333332(%rbx), %esi movq %r14, %rdi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC5(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 1333333332(%r13), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movl $2666666664, %r15d movl (%rbx,%r15), %esi movq %r14, %rdi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC5(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 0(%r13,%r15), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq 1333333332(%r15), %r15 movl (%rbx,%r15), %esi movq %r14, %rdi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC5(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 0(%r13,%r15), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT movq %r12, %rdi call cudaFree@PLT movq %rbp, %rdi call cudaFree@PLT movq %rbx, %rdi call cudaFree@PLT movq %r12, %rdi call free@PLT movq %rbp, %rdi call free@PLT movq %rbx, %rdi call free@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L24 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 .L22: .cfi_restore_state movl $1000000000, %ecx movq 40(%rsp), %rdx movq 32(%rsp), %rsi movq 24(%rsp), %rdi call _Z39__device_stub__Z14vector_add_gpuPiS_S_iPiS_S_i jmp .L17 .L23: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rcx movl $90, %r9d leaq .LC3(%rip), %r8 leaq .LC4(%rip), %rdx movl $2, %esi movq stderr(%rip), %rdi movl $0, %eax call __fprintf_chk@PLT movl %r14d, %edi call exit@PLT .L24: call __stack_chk_fail@PLT .cfi_endproc .LFE3770: .size main, .-main .section .rodata.str1.1 .LC6: .string "_Z14vector_add_gpuPiS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3800: .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 .LC6(%rip), %rdx movq %rdx, %rcx leaq _Z14vector_add_gpuPiS_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 .LFE3800: .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 "gpu-example.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z14vector_add_cpuPiS_S_i # -- Begin function _Z14vector_add_cpuPiS_S_i .p2align 4, 0x90 .type _Z14vector_add_cpuPiS_S_i,@function _Z14vector_add_cpuPiS_S_i: # @_Z14vector_add_cpuPiS_S_i .cfi_startproc # %bb.0: testl %ecx, %ecx jle .LBB0_3 # %bb.1: # %.lr.ph.preheader movl %ecx, %eax xorl %ecx, %ecx .p2align 4, 0x90 .LBB0_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 movl (%rsi,%rcx,4), %r8d addl (%rdi,%rcx,4), %r8d movl %r8d, (%rdx,%rcx,4) incq %rcx cmpq %rcx, %rax jne .LBB0_2 .LBB0_3: # %._crit_edge retq .Lfunc_end0: .size _Z14vector_add_cpuPiS_S_i, .Lfunc_end0-_Z14vector_add_cpuPiS_S_i .cfi_endproc # -- End function .globl _Z29__device_stub__vector_add_gpuPiS_S_i # -- Begin function _Z29__device_stub__vector_add_gpuPiS_S_i .p2align 4, 0x90 .type _Z29__device_stub__vector_add_gpuPiS_S_i,@function _Z29__device_stub__vector_add_gpuPiS_S_i: # @_Z29__device_stub__vector_add_gpuPiS_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 $_Z14vector_add_gpuPiS_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 _Z29__device_stub__vector_add_gpuPiS_S_i, .Lfunc_end1-_Z29__device_stub__vector_add_gpuPiS_S_i .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 $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 $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %rbx movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %r14 movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %r15 movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, 48(%rsp) # 8-byte Spill movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, 40(%rsp) # 8-byte Spill movl $4000000000, %edi # imm = 0xEE6B2800 callq malloc movq %rax, %r12 leaq 16(%rsp), %rdi movl $4000000000, %esi # imm = 0xEE6B2800 movl $1, %edx callq hipMallocManaged leaq 8(%rsp), %rdi movl $4000000000, %esi # imm = 0xEE6B2800 movl $1, %edx callq hipMallocManaged leaq 32(%rsp), %rdi movl $4000000000, %esi # imm = 0xEE6B2800 movl $1, %edx callq hipMallocManaged xorl %eax, %eax .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 movl %eax, (%rbx,%rax,4) movl %eax, (%r14,%rax,4) movl %eax, (%r15,%rax,4) incq %rax cmpq $1000000000, %rax # imm = 0x3B9ACA00 jne .LBB2_1 # %bb.2: xorl %ebp, %ebp callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %r13 .p2align 4, 0x90 .LBB2_3: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 movl (%r14,%rbp,4), %eax addl (%rbx,%rbp,4), %eax movl %eax, (%r15,%rbp,4) incq %rbp cmpq $1000000000, %rbp # imm = 0x3B9ACA00 jne .LBB2_3 # %bb.4: # %_Z14vector_add_cpuPiS_S_i.exit callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %rbp movl $_ZSt4cout, %edi movl $.L.str, %esi movl $16, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l subq %r13, %rbp movl $_ZSt4cout, %edi movq %rbp, %rsi callq _ZNSo9_M_insertIlEERSoT_ movl $.L.str.1, %esi movl $14, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq 16(%rsp), %rdi movl $4000000000, %edx # imm = 0xEE6B2800 movq %rbx, %rsi movl $1, %ecx callq hipMemcpy movq 8(%rsp), %rdi movl $4000000000, %edx # imm = 0xEE6B2800 movq %r14, %rsi movl $1, %ecx callq hipMemcpy callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %r13 movl $4000000000, %eax # imm = 0xEE6B2800 leaq 294968320(%rax), %rdx leaq 1294967296(%rax), %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_6 # %bb.5: movq 16(%rsp), %rax movq 8(%rsp), %rcx movq 32(%rsp), %rdx movq %rax, 120(%rsp) movq %rcx, 112(%rsp) movq %rdx, 104(%rsp) movl $1000000000, 28(%rsp) # imm = 0x3B9ACA00 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 $_Z14vector_add_gpuPiS_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: callq hipDeviceSynchronize callq _ZNSt6chrono3_V212system_clock3nowEv movq %rax, %rbp movl $_ZSt4cout, %edi movl $.L.str.2, %esi movl $16, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l subq %r13, %rbp movl $_ZSt4cout, %edi movq %rbp, %rsi callq _ZNSo9_M_insertIlEERSoT_ movl $.L.str.1, %esi movl $14, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq 32(%rsp), %rsi movl $4000000000, %edx # imm = 0xEE6B2800 movq %r12, %rdi movl $2, %ecx callq hipMemcpy movq 8(%rsp), %rsi movl $4000000000, %edx # imm = 0xEE6B2800 movq 40(%rsp), %rdi # 8-byte Reload movl $2, %ecx callq hipMemcpy movq 16(%rsp), %rsi movl $4000000000, %edx # imm = 0xEE6B2800 movq 48(%rsp), %rdi # 8-byte Reload movl $2, %ecx callq hipMemcpy testl %eax, %eax jne .LBB2_24 # %bb.7: # %_Z9gpuAssert10hipError_tPKcib.exit movl (%r15), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl (%r12), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r13 testq %r13, %r13 je .LBB2_25 # %bb.8: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i cmpb $0, 56(%r13) je .LBB2_10 # %bb.9: movzbl 67(%r13), %ecx jmp .LBB2_11 .LBB2_10: movq %r13, %rdi movq %rax, %rbp callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r13), %rax movq %r13, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %rbp, %rax .LBB2_11: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl 1333333332(%r15), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 1333333332(%r12), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r13 testq %r13, %r13 je .LBB2_25 # %bb.12: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i39 cmpb $0, 56(%r13) je .LBB2_14 # %bb.13: movzbl 67(%r13), %ecx jmp .LBB2_15 .LBB2_14: movq %r13, %rdi movq %rax, %rbp callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r13), %rax movq %r13, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %rbp, %rax .LBB2_15: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit42 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $2666666664, %ebp # imm = 0x9EF21AA8 movl (%r15,%rbp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl (%r12,%rbp), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r13 testq %r13, %r13 je .LBB2_25 # %bb.16: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i44 cmpb $0, 56(%r13) je .LBB2_18 # %bb.17: movzbl 67(%r13), %ecx jmp .LBB2_19 .LBB2_18: movq %r13, %rdi movq %rax, %rbp callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r13), %rax movq %r13, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %rbp, %rax .LBB2_19: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit47 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movl $3999999996, %ebp # imm = 0xEE6B27FC movl (%r15,%rbp), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movq %rax, %r13 movl $.L.str.4, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl (%r12,%rbp), %esi movq %r13, %rdi callq _ZNSolsEi movq (%rax), %rcx movq -24(%rcx), %rcx movq 240(%rax,%rcx), %r12 testq %r12, %r12 je .LBB2_25 # %bb.20: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i49 cmpb $0, 56(%r12) je .LBB2_22 # %bb.21: movzbl 67(%r12), %ecx jmp .LBB2_23 .LBB2_22: movq %r12, %rdi movq %rax, %r13 callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r12), %rax movq %r12, %rdi movl $10, %esi callq *48(%rax) movl %eax, %ecx movq %r13, %rax .LBB2_23: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit52 movsbl %cl, %esi movq %rax, %rdi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv movq %rbx, %rdi callq hipFree movq %r14, %rdi callq hipFree movq %r15, %rdi callq hipFree movq %rbx, %rdi callq free movq %r14, %rdi callq free movq %r15, %rdi callq free 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 .LBB2_25: .cfi_def_cfa_offset 224 callq _ZSt16__throw_bad_castv .LBB2_24: movq stderr(%rip), %rbx movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str.5, %esi movl $.L.str.3, %ecx movq %rbx, %rdi movq %rax, %rdx movl $90, %r8d xorl %eax, %eax callq fprintf movl %ebp, %edi callq exit .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 $_Z14vector_add_gpuPiS_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 _Z14vector_add_gpuPiS_S_i,@object # @_Z14vector_add_gpuPiS_S_i .section .rodata,"a",@progbits .globl _Z14vector_add_gpuPiS_S_i .p2align 3, 0x0 _Z14vector_add_gpuPiS_S_i: .quad _Z29__device_stub__vector_add_gpuPiS_S_i .size _Z14vector_add_gpuPiS_S_i, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "vector_add_cpu: " .size .L.str, 17 .type .L.str.1,@object # @.str.1 .L.str.1: .asciz " nanoseconds.\n" .size .L.str.1, 15 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz "vector_add_gpu: " .size .L.str.2, 17 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "/home/ubuntu/Datasets/stackv2/train-structured-repos-hip/rmhsik/TFM/master/CUDATest/gpu-example.hip" .size .L.str.3, 100 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "\t" .size .L.str.4, 2 .type .L.str.5,@object # @.str.5 .L.str.5: .asciz "GPUassert: %s %s %d\n" .size .L.str.5, 21 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z14vector_add_gpuPiS_S_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 _Z29__device_stub__vector_add_gpuPiS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14vector_add_gpuPiS_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 "includes.h" __global__ void power_spectrum_kernel(int row_length, float *A_in, int32_t ldi, float *A_out, int32_t ldo) { int thread_id = threadIdx.x; int block_id = blockIdx.x; float *Ar = A_in + block_id * ldi; float *Aw = A_out + block_id * ldo; int half_length = row_length / 2; for (int idx = thread_id; idx < half_length; idx += CU1DBLOCK) { // ignore special case if (idx == 0) continue; float2 val = reinterpret_cast<float2 *>(Ar)[idx]; float ret = val.x * val.x + val.y * val.y; Aw[idx] = ret; } // handle special case if (threadIdx.x == 0) { float real = Ar[0]; // cufft puts this at the end, this is different than kaldi does with its // own // internal implementation float im = Ar[row_length]; Aw[0] = real * real; Aw[half_length] = im * im; } }
code for sm_80 Function : _Z21power_spectrum_kerneliPfiS_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_TID.X ; /* 0x0000000000007919 */ /* 0x000e220000002100 */ /*0020*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x160] ; /* 0x00005800ff077624 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0040*/ IMAD.MOV.U32 R2, RZ, RZ, 0x4 ; /* 0x00000004ff027424 */ /* 0x000fe200078e00ff */ /*0050*/ S2R R11, SR_CTAID.X ; /* 0x00000000000b7919 */ /* 0x000e620000002500 */ /*0060*/ BSSY B0, 0x610 ; /* 0x000005a000007945 */ /* 0x000fe20003800000 */ /*0070*/ LEA.HI R7, R7, c[0x0][0x160], RZ, 0x1 ; /* 0x0000580007077a11 */ /* 0x000fc800078f08ff */ /*0080*/ SHF.R.S32.HI R7, RZ, 0x1, R7 ; /* 0x00000001ff077819 */ /* 0x000fc80000011407 */ /*0090*/ ISETP.GE.AND P0, PT, R0, R7, PT ; /* 0x000000070000720c */ /* 0x001fe20003f06270 */ /*00a0*/ IMAD R4, R11.reuse, c[0x0][0x170], RZ ; /* 0x00005c000b047a24 */ /* 0x042fe400078e02ff */ /*00b0*/ IMAD R11, R11, c[0x0][0x180], RZ ; /* 0x000060000b0b7a24 */ /* 0x000fc600078e02ff */ /*00c0*/ SHF.R.S32.HI R5, RZ, 0x1f, R4 ; /* 0x0000001fff057819 */ /* 0x000fe20000011404 */ /*00d0*/ IMAD.WIDE R2, R11, R2, c[0x0][0x178] ; /* 0x00005e000b027625 */ /* 0x000fcc00078e0202 */ /*00e0*/ @P0 BRA 0x600 ; /* 0x0000051000000947 */ /* 0x000fea0003800000 */ /*00f0*/ LOP3.LUT R6, RZ, R0, RZ, 0x33, !PT ; /* 0x00000000ff067212 */ /* 0x000fe200078e33ff */ /*0100*/ BSSY B1, 0x320 ; /* 0x0000021000017945 */ /* 0x000fe80003800000 */ /*0110*/ IMAD.IADD R6, R7, 0x1, R6 ; /* 0x0000000107067824 */ /* 0x000fca00078e0206 */ /*0120*/ LEA.HI R8, R6.reuse, 0x1, RZ, 0x18 ; /* 0x0000000106087811 */ /* 0x040fe400078fc0ff */ /*0130*/ ISETP.GE.U32.AND P0, PT, R6, 0x300, PT ; /* 0x000003000600780c */ /* 0x000fe20003f06070 */ /*0140*/ IMAD.MOV.U32 R6, RZ, RZ, R0 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0000 */ /*0150*/ LOP3.LUT P1, R10, R8, 0x3, RZ, 0xc0, !PT ; /* 0x00000003080a7812 */ /* 0x000fda000782c0ff */ /*0160*/ @!P1 BRA 0x310 ; /* 0x000001a000009947 */ /* 0x000fea0003800000 */ /*0170*/ SHF.R.S32.HI R6, RZ, 0x1f, R0 ; /* 0x0000001fff067819 */ /* 0x000fe20000011400 */ /*0180*/ IMAD.WIDE R8, R0, 0x2, R4 ; /* 0x0000000200087825 */ /* 0x000fe200078e0204 */ /*0190*/ IADD3 R15, P1, R11, R0, RZ ; /* 0x000000000b0f7210 */ /* 0x000fc80007f3e0ff */ /*01a0*/ LEA.HI.X.SX32 R6, R11, R6, 0x1, P1 ; /* 0x000000060b067211 */ /* 0x000fe400008f0eff */ /*01b0*/ LEA R14, P1, R15.reuse, c[0x0][0x178], 0x2 ; /* 0x00005e000f0e7a11 */ /* 0x040fe400078210ff */ /*01c0*/ LEA R12, P2, R8.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a00080c7a11 */ /* 0x040fe400078410ff */ /*01d0*/ LEA.HI.X R15, R15, c[0x0][0x17c], R6, 0x2, P1 ; /* 0x00005f000f0f7a11 */ /* 0x000fe200008f1406 */ /*01e0*/ IMAD.MOV.U32 R6, RZ, RZ, R0 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0000 */ /*01f0*/ LEA.HI.X R13, R8, c[0x0][0x16c], R9, 0x2, P2 ; /* 0x00005b00080d7a11 */ /* 0x000fc800010f1409 */ /*0200*/ ISETP.NE.AND P1, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fda0003f25270 */ /*0210*/ @P1 MOV R8, R12 ; /* 0x0000000c00081202 */ /* 0x001fe20000000f00 */ /*0220*/ @P1 IMAD.MOV.U32 R9, RZ, RZ, R13 ; /* 0x000000ffff091224 */ /* 0x000fcc00078e000d */ /*0230*/ @P1 LDG.E.64 R8, [R8.64] ; /* 0x0000000408081981 */ /* 0x000ea2000c1e1b00 */ /*0240*/ IADD3 R10, R10, -0x1, RZ ; /* 0xffffffff0a0a7810 */ /* 0x000fe40007ffe0ff */ /*0250*/ IADD3 R12, P2, R12, 0x800, RZ ; /* 0x000008000c0c7810 */ /* 0x000fe40007f5e0ff */ /*0260*/ ISETP.NE.AND P3, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fe40003f65270 */ /*0270*/ IADD3 R6, R6, 0x100, RZ ; /* 0x0000010006067810 */ /* 0x000fe40007ffe0ff */ /*0280*/ IADD3.X R13, RZ, R13, RZ, P2, !PT ; /* 0x0000000dff0d7210 */ /* 0x000fe200017fe4ff */ /*0290*/ @P1 FMUL R11, R9, R9 ; /* 0x00000009090b1220 */ /* 0x004fc40000400000 */ /*02a0*/ @P1 IMAD.MOV.U32 R9, RZ, RZ, R15 ; /* 0x000000ffff091224 */ /* 0x000fe400078e000f */ /*02b0*/ @P1 FFMA R11, R8, R8, R11 ; /* 0x00000008080b1223 */ /* 0x000fe4000000000b */ /*02c0*/ @P1 IMAD.MOV.U32 R8, RZ, RZ, R14 ; /* 0x000000ffff081224 */ /* 0x000fca00078e000e */ /*02d0*/ @P1 STG.E [R8.64], R11 ; /* 0x0000000b08001986 */ /* 0x0001e2000c101904 */ /*02e0*/ IADD3 R14, P1, R14, 0x400, RZ ; /* 0x000004000e0e7810 */ /* 0x000fca0007f3e0ff */ /*02f0*/ IMAD.X R15, RZ, RZ, R15, P1 ; /* 0x000000ffff0f7224 */ /* 0x000fe200008e060f */ /*0300*/ @P3 BRA 0x200 ; /* 0xfffffef000003947 */ /* 0x000fea000383ffff */ /*0310*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0320*/ @!P0 BRA 0x600 ; /* 0x000002d000008947 */ /* 0x000fea0003800000 */ /*0330*/ IMAD.WIDE R8, R6, 0x2, R4 ; /* 0x0000000206087825 */ /* 0x001fc800078e0204 */ /*0340*/ IMAD.MOV.U32 R12, RZ, RZ, R6 ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e0006 */ /*0350*/ LEA R13, P0, R8.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a00080d7a11 */ /* 0x040fe200078010ff */ /*0360*/ IMAD.MOV.U32 R14, RZ, RZ, R2 ; /* 0x000000ffff0e7224 */ /* 0x000fe400078e0002 */ /*0370*/ IMAD.MOV.U32 R15, RZ, RZ, R3 ; /* 0x000000ffff0f7224 */ /* 0x000fe200078e0003 */ /*0380*/ LEA.HI.X R16, R8, c[0x0][0x16c], R9, 0x2, P0 ; /* 0x00005b0008107a11 */ /* 0x000fe400000f1409 */ /*0390*/ ISETP.NE.AND P0, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fe20003f05270 */ /*03a0*/ IMAD.MOV.U32 R8, RZ, RZ, R13 ; /* 0x000000ffff087224 */ /* 0x000fe200078e000d */ /*03b0*/ MOV R9, R16 ; /* 0x0000001000097202 */ /* 0x000fd60000000f00 */ /*03c0*/ @P0 LDG.E.64 R16, [R8.64] ; /* 0x0000000408100981 */ /* 0x000ea2000c1e1b00 */ /*03d0*/ IMAD.WIDE R10, R12, 0x4, R14 ; /* 0x000000040c0a7825 */ /* 0x000fe200078e020e */ /*03e0*/ IADD3 R13, R6, 0x100, RZ ; /* 0x00000100060d7810 */ /* 0x000fe20007ffe0ff */ /*03f0*/ BSSY B1, 0x4c0 ; /* 0x000000c000017945 */ /* 0x000fe40003800000 */ /*0400*/ @P0 FMUL R17, R17, R17 ; /* 0x0000001111110220 */ /* 0x004fc80000400000 */ /*0410*/ @P0 FFMA R17, R16, R16, R17 ; /* 0x0000001010110223 */ /* 0x000fe20000000011 */ /*0420*/ IADD3 R16, R6, 0x200, RZ ; /* 0x0000020006107810 */ /* 0x000fc80007ffe0ff */ /*0430*/ @P0 STG.E [R10.64], R17 ; /* 0x000000110a000986 */ /* 0x0001e2000c101904 */ /*0440*/ ISETP.NE.AND P0, PT, R13, RZ, PT ; /* 0x000000ff0d00720c */ /* 0x000fe40003f05270 */ /*0450*/ ISETP.NE.AND P1, PT, R16, RZ, PT ; /* 0x000000ff1000720c */ /* 0x000fd60003f25270 */ /*0460*/ @!P0 BRA 0x4b0 ; /* 0x0000004000008947 */ /* 0x000fea0003800000 */ /*0470*/ LDG.E.64 R16, [R8.64+0x800] ; /* 0x0008000408107981 */ /* 0x001ea4000c1e1b00 */ /*0480*/ FMUL R17, R17, R17 ; /* 0x0000001111117220 */ /* 0x004fc80000400000 */ /*0490*/ FFMA R17, R16, R16, R17 ; /* 0x0000001010117223 */ /* 0x000fca0000000011 */ /*04a0*/ STG.E [R10.64+0x400], R17 ; /* 0x000400110a007986 */ /* 0x0001e4000c101904 */ /*04b0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x001fea0003800000 */ /*04c0*/ BSSY B1, 0x530 ; /* 0x0000006000017945 */ /* 0x000fe20003800000 */ /*04d0*/ @!P1 BRA 0x520 ; /* 0x0000004000009947 */ /* 0x000fea0003800000 */ /*04e0*/ LDG.E.64 R16, [R8.64+0x1000] ; /* 0x0010000408107981 */ /* 0x000ea4000c1e1b00 */ /*04f0*/ FMUL R17, R17, R17 ; /* 0x0000001111117220 */ /* 0x004fc80000400000 */ /*0500*/ FFMA R17, R16, R16, R17 ; /* 0x0000001010117223 */ /* 0x000fca0000000011 */ /*0510*/ STG.E [R10.64+0x800], R17 ; /* 0x000800110a007986 */ /* 0x0001e4000c101904 */ /*0520*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0530*/ IADD3 R13, R6, 0x300, RZ ; /* 0x00000300060d7810 */ /* 0x000fc80007ffe0ff */ /*0540*/ ISETP.NE.AND P0, PT, R13, RZ, PT ; /* 0x000000ff0d00720c */ /* 0x000fda0003f05270 */ /*0550*/ @P0 LDG.E.64 R16, [R8.64+0x1800] ; /* 0x0018000408100981 */ /* 0x001ea2000c1e1b00 */ /*0560*/ IADD3 R6, R6, 0x400, RZ ; /* 0x0000040006067810 */ /* 0x000fe40007ffe0ff */ /*0570*/ IADD3 R14, P1, R14, 0x1000, RZ ; /* 0x000010000e0e7810 */ /* 0x000fe40007f3e0ff */ /*0580*/ IADD3 R13, P2, R8, 0x2000, RZ ; /* 0x00002000080d7810 */ /* 0x000fc60007f5e0ff */ /*0590*/ IMAD.X R15, RZ, RZ, R15, P1 ; /* 0x000000ffff0f7224 */ /* 0x000fe400008e060f */ /*05a0*/ @P0 FMUL R17, R17, R17 ; /* 0x0000001111110220 */ /* 0x004fc80000400000 */ /*05b0*/ @P0 FFMA R17, R16, R16, R17 ; /* 0x0000001010110223 */ /* 0x000fe40000000011 */ /*05c0*/ IMAD.X R16, RZ, RZ, R9, P2 ; /* 0x000000ffff107224 */ /* 0x000fc600010e0609 */ /*05d0*/ @P0 STG.E [R10.64+0xc00], R17 ; /* 0x000c00110a000986 */ /* 0x0001e2000c101904 */ /*05e0*/ ISETP.GE.AND P0, PT, R6, R7, PT ; /* 0x000000070600720c */ /* 0x000fda0003f06270 */ /*05f0*/ @!P0 BRA 0x390 ; /* 0xfffffd9000008947 */ /* 0x001fea000383ffff */ /*0600*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0610*/ ISETP.NE.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fe40003f05270 */ /*0620*/ LEA R8, P1, R4, c[0x0][0x168], 0x2 ; /* 0x00005a0004087a11 */ /* 0x001fc800078210ff */ /*0630*/ LEA.HI.X R9, R4, c[0x0][0x16c], R5, 0x2, P1 ; /* 0x00005b0004097a11 */ /* 0x000fce00008f1405 */ /*0640*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0650*/ IMAD.MOV.U32 R5, RZ, RZ, c[0x0][0x160] ; /* 0x00005800ff057624 */ /* 0x000fc800078e00ff */ /*0660*/ IMAD.WIDE R4, R5, 0x4, R8 ; /* 0x0000000405047825 */ /* 0x000fe400078e0208 */ /*0670*/ LDG.E R8, [R8.64] ; /* 0x0000000408087981 */ /* 0x000ea8000c1e1900 */ /*0680*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ee2000c1e1900 */ /*0690*/ IMAD.WIDE R6, R7, 0x4, R2 ; /* 0x0000000407067825 */ /* 0x000fc800078e0202 */ /*06a0*/ FMUL R11, R8, R8 ; /* 0x00000008080b7220 */ /* 0x004fe40000400000 */ /*06b0*/ FMUL R13, R4, R4 ; /* 0x00000004040d7220 */ /* 0x008fc60000400000 */ /*06c0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x000fe8000c101904 */ /*06d0*/ STG.E [R6.64], R13 ; /* 0x0000000d06007986 */ /* 0x000fe2000c101904 */ /*06e0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*06f0*/ BRA 0x6f0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0700*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0710*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0720*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0730*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0740*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0750*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0760*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0770*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __global__ void power_spectrum_kernel(int row_length, float *A_in, int32_t ldi, float *A_out, int32_t ldo) { int thread_id = threadIdx.x; int block_id = blockIdx.x; float *Ar = A_in + block_id * ldi; float *Aw = A_out + block_id * ldo; int half_length = row_length / 2; for (int idx = thread_id; idx < half_length; idx += CU1DBLOCK) { // ignore special case if (idx == 0) continue; float2 val = reinterpret_cast<float2 *>(Ar)[idx]; float ret = val.x * val.x + val.y * val.y; Aw[idx] = ret; } // handle special case if (threadIdx.x == 0) { float real = Ar[0]; // cufft puts this at the end, this is different than kaldi does with its // own // internal implementation float im = Ar[row_length]; Aw[0] = real * real; Aw[half_length] = im * im; } }
.file "tmpxft_001238a6_00000000-6_power_spectrum_kernel.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 _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i .type _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i, @function _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i: .LFB2051: .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 .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 _Z21power_spectrum_kerneliPfiS_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 _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i, .-_Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i .globl _Z21power_spectrum_kerneliPfiS_i .type _Z21power_spectrum_kerneliPfiS_i, @function _Z21power_spectrum_kerneliPfiS_i: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z21power_spectrum_kerneliPfiS_i, .-_Z21power_spectrum_kerneliPfiS_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z21power_spectrum_kerneliPfiS_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 _Z21power_spectrum_kerneliPfiS_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 power_spectrum_kernel(int row_length, float *A_in, int32_t ldi, float *A_out, int32_t ldo) { int thread_id = threadIdx.x; int block_id = blockIdx.x; float *Ar = A_in + block_id * ldi; float *Aw = A_out + block_id * ldo; int half_length = row_length / 2; for (int idx = thread_id; idx < half_length; idx += CU1DBLOCK) { // ignore special case if (idx == 0) continue; float2 val = reinterpret_cast<float2 *>(Ar)[idx]; float ret = val.x * val.x + val.y * val.y; Aw[idx] = ret; } // handle special case if (threadIdx.x == 0) { float real = Ar[0]; // cufft puts this at the end, this is different than kaldi does with its // own // internal implementation float im = Ar[row_length]; Aw[0] = real * real; Aw[half_length] = im * im; } }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void power_spectrum_kernel(int row_length, float *A_in, int32_t ldi, float *A_out, int32_t ldo) { int thread_id = threadIdx.x; int block_id = blockIdx.x; float *Ar = A_in + block_id * ldi; float *Aw = A_out + block_id * ldo; int half_length = row_length / 2; for (int idx = thread_id; idx < half_length; idx += CU1DBLOCK) { // ignore special case if (idx == 0) continue; float2 val = reinterpret_cast<float2 *>(Ar)[idx]; float ret = val.x * val.x + val.y * val.y; Aw[idx] = ret; } // handle special case if (threadIdx.x == 0) { float real = Ar[0]; // cufft puts this at the end, this is different than kaldi does with its // own // internal implementation float im = Ar[row_length]; Aw[0] = real * real; Aw[half_length] = im * im; } }
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 power_spectrum_kernel(int row_length, float *A_in, int32_t ldi, float *A_out, int32_t ldo) { int thread_id = threadIdx.x; int block_id = blockIdx.x; float *Ar = A_in + block_id * ldi; float *Aw = A_out + block_id * ldo; int half_length = row_length / 2; for (int idx = thread_id; idx < half_length; idx += CU1DBLOCK) { // ignore special case if (idx == 0) continue; float2 val = reinterpret_cast<float2 *>(Ar)[idx]; float ret = val.x * val.x + val.y * val.y; Aw[idx] = ret; } // handle special case if (threadIdx.x == 0) { float real = Ar[0]; // cufft puts this at the end, this is different than kaldi does with its // own // internal implementation float im = Ar[row_length]; Aw[0] = real * real; Aw[half_length] = im * im; } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z21power_spectrum_kerneliPfiS_i .globl _Z21power_spectrum_kerneliPfiS_i .p2align 8 .type _Z21power_spectrum_kerneliPfiS_i,@function _Z21power_spectrum_kerneliPfiS_i: s_clause 0x4 s_load_b32 s2, s[0:1], 0x0 s_load_b32 s3, s[0:1], 0x10 s_load_b32 s5, s[0:1], 0x20 s_load_b64 s[8:9], s[0:1], 0x8 s_load_b64 s[6:7], s[0:1], 0x18 s_mov_b32 s1, exec_lo s_waitcnt lgkmcnt(0) s_lshr_b32 s0, s2, 31 s_mul_i32 s12, s15, s3 s_add_i32 s0, s2, s0 s_mul_i32 s10, s15, s5 s_ashr_i32 s4, s0, 1 s_ashr_i32 s13, s12, 31 s_ashr_i32 s11, s10, 31 v_cmpx_gt_i32_e64 s4, v0 s_cbranch_execz .LBB0_5 v_lshlrev_b32_e32 v1, 3, v0 s_lshl_b64 s[14:15], s[12:13], 2 v_lshlrev_b32_e32 v3, 2, v0 s_add_u32 s0, s8, s14 s_addc_u32 s3, s9, s15 v_add_co_u32 v1, s0, s0, v1 s_lshl_b64 s[14:15], s[10:11], 2 v_add_co_ci_u32_e64 v2, null, s3, 0, s0 s_add_u32 s0, s6, s14 s_delay_alu instid0(VALU_DEP_2) v_add_co_u32 v1, vcc_lo, v1, 4 s_addc_u32 s3, s7, s15 v_add_co_u32 v3, s0, s0, v3 v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo v_add_co_ci_u32_e64 v4, null, s3, 0, s0 v_mov_b32_e32 v5, v0 s_mov_b32 s3, 0 s_set_inst_prefetch_distance 0x1 s_branch .LBB0_3 .p2align 6 .LBB0_2: s_or_b32 exec_lo, exec_lo, s0 v_add_nc_u32_e32 v5, 0x100, v5 v_add_co_u32 v1, vcc_lo, v1, 0x800 v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_cmp_le_i32_e32 vcc_lo, s4, v5 v_add_co_u32 v3, s0, v3, 0x400 v_add_co_ci_u32_e64 v4, s0, 0, v4, s0 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_execz .LBB0_5 .LBB0_3: s_mov_b32 s0, exec_lo v_cmpx_ne_u32_e32 0, v5 s_cbranch_execz .LBB0_2 s_clause 0x1 global_load_b32 v6, v[1:2], off global_load_b32 v7, v[1:2], off offset:-4 s_waitcnt vmcnt(1) v_mul_f32_e32 v6, v6, v6 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) v_fmac_f32_e32 v6, v7, v7 global_store_b32 v[3:4], v6, off s_branch .LBB0_2 .LBB0_5: s_set_inst_prefetch_distance 0x2 s_or_b32 exec_lo, exec_lo, s1 s_delay_alu instid0(SALU_CYCLE_1) s_mov_b32 s0, exec_lo v_cmpx_eq_u32_e32 0, v0 s_cbranch_execz .LBB0_7 s_lshl_b64 s[0:1], s[12:13], 2 v_mov_b32_e32 v0, 0 s_add_u32 s0, s8, s0 s_addc_u32 s1, s9, s1 s_lshl_b64 s[8:9], s[10:11], 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) s_add_u32 s6, s6, s8 s_addc_u32 s7, s7, s9 s_ashr_i32 s3, s2, 31 s_lshl_b64 s[2:3], s[2:3], 2 s_delay_alu instid0(SALU_CYCLE_1) s_add_u32 s2, s0, s2 s_addc_u32 s3, s1, s3 s_clause 0x1 global_load_b32 v1, v0, s[0:1] global_load_b32 v2, v0, s[2:3] s_ashr_i32 s5, s4, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[0:1], s[4:5], 2 s_add_u32 s0, s6, s0 s_addc_u32 s1, s7, s1 s_waitcnt vmcnt(0) v_dual_mul_f32 v1, v1, v1 :: v_dual_mul_f32 v2, v2, v2 s_clause 0x1 global_store_b32 v0, v1, s[6:7] global_store_b32 v0, v2, s[0:1] .LBB0_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z21power_spectrum_kerneliPfiS_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 36 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z21power_spectrum_kerneliPfiS_i, .Lfunc_end0-_Z21power_spectrum_kerneliPfiS_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: - .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 .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 36 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z21power_spectrum_kerneliPfiS_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z21power_spectrum_kerneliPfiS_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include "includes.h" __global__ void power_spectrum_kernel(int row_length, float *A_in, int32_t ldi, float *A_out, int32_t ldo) { int thread_id = threadIdx.x; int block_id = blockIdx.x; float *Ar = A_in + block_id * ldi; float *Aw = A_out + block_id * ldo; int half_length = row_length / 2; for (int idx = thread_id; idx < half_length; idx += CU1DBLOCK) { // ignore special case if (idx == 0) continue; float2 val = reinterpret_cast<float2 *>(Ar)[idx]; float ret = val.x * val.x + val.y * val.y; Aw[idx] = ret; } // handle special case if (threadIdx.x == 0) { float real = Ar[0]; // cufft puts this at the end, this is different than kaldi does with its // own // internal implementation float im = Ar[row_length]; Aw[0] = real * real; Aw[half_length] = im * im; } }
.text .file "power_spectrum_kernel.hip" .globl _Z36__device_stub__power_spectrum_kerneliPfiS_i # -- Begin function _Z36__device_stub__power_spectrum_kerneliPfiS_i .p2align 4, 0x90 .type _Z36__device_stub__power_spectrum_kerneliPfiS_i,@function _Z36__device_stub__power_spectrum_kerneliPfiS_i: # @_Z36__device_stub__power_spectrum_kerneliPfiS_i .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 $_Z21power_spectrum_kerneliPfiS_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 _Z36__device_stub__power_spectrum_kerneliPfiS_i, .Lfunc_end0-_Z36__device_stub__power_spectrum_kerneliPfiS_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 $_Z21power_spectrum_kerneliPfiS_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 _Z21power_spectrum_kerneliPfiS_i,@object # @_Z21power_spectrum_kerneliPfiS_i .section .rodata,"a",@progbits .globl _Z21power_spectrum_kerneliPfiS_i .p2align 3, 0x0 _Z21power_spectrum_kerneliPfiS_i: .quad _Z36__device_stub__power_spectrum_kerneliPfiS_i .size _Z21power_spectrum_kerneliPfiS_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z21power_spectrum_kerneliPfiS_i" .size .L__unnamed_1, 33 .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 _Z36__device_stub__power_spectrum_kerneliPfiS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z21power_spectrum_kerneliPfiS_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 : _Z21power_spectrum_kerneliPfiS_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_TID.X ; /* 0x0000000000007919 */ /* 0x000e220000002100 */ /*0020*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x160] ; /* 0x00005800ff077624 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe20000000a00 */ /*0040*/ IMAD.MOV.U32 R2, RZ, RZ, 0x4 ; /* 0x00000004ff027424 */ /* 0x000fe200078e00ff */ /*0050*/ S2R R11, SR_CTAID.X ; /* 0x00000000000b7919 */ /* 0x000e620000002500 */ /*0060*/ BSSY B0, 0x610 ; /* 0x000005a000007945 */ /* 0x000fe20003800000 */ /*0070*/ LEA.HI R7, R7, c[0x0][0x160], RZ, 0x1 ; /* 0x0000580007077a11 */ /* 0x000fc800078f08ff */ /*0080*/ SHF.R.S32.HI R7, RZ, 0x1, R7 ; /* 0x00000001ff077819 */ /* 0x000fc80000011407 */ /*0090*/ ISETP.GE.AND P0, PT, R0, R7, PT ; /* 0x000000070000720c */ /* 0x001fe20003f06270 */ /*00a0*/ IMAD R4, R11.reuse, c[0x0][0x170], RZ ; /* 0x00005c000b047a24 */ /* 0x042fe400078e02ff */ /*00b0*/ IMAD R11, R11, c[0x0][0x180], RZ ; /* 0x000060000b0b7a24 */ /* 0x000fc600078e02ff */ /*00c0*/ SHF.R.S32.HI R5, RZ, 0x1f, R4 ; /* 0x0000001fff057819 */ /* 0x000fe20000011404 */ /*00d0*/ IMAD.WIDE R2, R11, R2, c[0x0][0x178] ; /* 0x00005e000b027625 */ /* 0x000fcc00078e0202 */ /*00e0*/ @P0 BRA 0x600 ; /* 0x0000051000000947 */ /* 0x000fea0003800000 */ /*00f0*/ LOP3.LUT R6, RZ, R0, RZ, 0x33, !PT ; /* 0x00000000ff067212 */ /* 0x000fe200078e33ff */ /*0100*/ BSSY B1, 0x320 ; /* 0x0000021000017945 */ /* 0x000fe80003800000 */ /*0110*/ IMAD.IADD R6, R7, 0x1, R6 ; /* 0x0000000107067824 */ /* 0x000fca00078e0206 */ /*0120*/ LEA.HI R8, R6.reuse, 0x1, RZ, 0x18 ; /* 0x0000000106087811 */ /* 0x040fe400078fc0ff */ /*0130*/ ISETP.GE.U32.AND P0, PT, R6, 0x300, PT ; /* 0x000003000600780c */ /* 0x000fe20003f06070 */ /*0140*/ IMAD.MOV.U32 R6, RZ, RZ, R0 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0000 */ /*0150*/ LOP3.LUT P1, R10, R8, 0x3, RZ, 0xc0, !PT ; /* 0x00000003080a7812 */ /* 0x000fda000782c0ff */ /*0160*/ @!P1 BRA 0x310 ; /* 0x000001a000009947 */ /* 0x000fea0003800000 */ /*0170*/ SHF.R.S32.HI R6, RZ, 0x1f, R0 ; /* 0x0000001fff067819 */ /* 0x000fe20000011400 */ /*0180*/ IMAD.WIDE R8, R0, 0x2, R4 ; /* 0x0000000200087825 */ /* 0x000fe200078e0204 */ /*0190*/ IADD3 R15, P1, R11, R0, RZ ; /* 0x000000000b0f7210 */ /* 0x000fc80007f3e0ff */ /*01a0*/ LEA.HI.X.SX32 R6, R11, R6, 0x1, P1 ; /* 0x000000060b067211 */ /* 0x000fe400008f0eff */ /*01b0*/ LEA R14, P1, R15.reuse, c[0x0][0x178], 0x2 ; /* 0x00005e000f0e7a11 */ /* 0x040fe400078210ff */ /*01c0*/ LEA R12, P2, R8.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a00080c7a11 */ /* 0x040fe400078410ff */ /*01d0*/ LEA.HI.X R15, R15, c[0x0][0x17c], R6, 0x2, P1 ; /* 0x00005f000f0f7a11 */ /* 0x000fe200008f1406 */ /*01e0*/ IMAD.MOV.U32 R6, RZ, RZ, R0 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0000 */ /*01f0*/ LEA.HI.X R13, R8, c[0x0][0x16c], R9, 0x2, P2 ; /* 0x00005b00080d7a11 */ /* 0x000fc800010f1409 */ /*0200*/ ISETP.NE.AND P1, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fda0003f25270 */ /*0210*/ @P1 MOV R8, R12 ; /* 0x0000000c00081202 */ /* 0x001fe20000000f00 */ /*0220*/ @P1 IMAD.MOV.U32 R9, RZ, RZ, R13 ; /* 0x000000ffff091224 */ /* 0x000fcc00078e000d */ /*0230*/ @P1 LDG.E.64 R8, [R8.64] ; /* 0x0000000408081981 */ /* 0x000ea2000c1e1b00 */ /*0240*/ IADD3 R10, R10, -0x1, RZ ; /* 0xffffffff0a0a7810 */ /* 0x000fe40007ffe0ff */ /*0250*/ IADD3 R12, P2, R12, 0x800, RZ ; /* 0x000008000c0c7810 */ /* 0x000fe40007f5e0ff */ /*0260*/ ISETP.NE.AND P3, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fe40003f65270 */ /*0270*/ IADD3 R6, R6, 0x100, RZ ; /* 0x0000010006067810 */ /* 0x000fe40007ffe0ff */ /*0280*/ IADD3.X R13, RZ, R13, RZ, P2, !PT ; /* 0x0000000dff0d7210 */ /* 0x000fe200017fe4ff */ /*0290*/ @P1 FMUL R11, R9, R9 ; /* 0x00000009090b1220 */ /* 0x004fc40000400000 */ /*02a0*/ @P1 IMAD.MOV.U32 R9, RZ, RZ, R15 ; /* 0x000000ffff091224 */ /* 0x000fe400078e000f */ /*02b0*/ @P1 FFMA R11, R8, R8, R11 ; /* 0x00000008080b1223 */ /* 0x000fe4000000000b */ /*02c0*/ @P1 IMAD.MOV.U32 R8, RZ, RZ, R14 ; /* 0x000000ffff081224 */ /* 0x000fca00078e000e */ /*02d0*/ @P1 STG.E [R8.64], R11 ; /* 0x0000000b08001986 */ /* 0x0001e2000c101904 */ /*02e0*/ IADD3 R14, P1, R14, 0x400, RZ ; /* 0x000004000e0e7810 */ /* 0x000fca0007f3e0ff */ /*02f0*/ IMAD.X R15, RZ, RZ, R15, P1 ; /* 0x000000ffff0f7224 */ /* 0x000fe200008e060f */ /*0300*/ @P3 BRA 0x200 ; /* 0xfffffef000003947 */ /* 0x000fea000383ffff */ /*0310*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0320*/ @!P0 BRA 0x600 ; /* 0x000002d000008947 */ /* 0x000fea0003800000 */ /*0330*/ IMAD.WIDE R8, R6, 0x2, R4 ; /* 0x0000000206087825 */ /* 0x001fc800078e0204 */ /*0340*/ IMAD.MOV.U32 R12, RZ, RZ, R6 ; /* 0x000000ffff0c7224 */ /* 0x000fe200078e0006 */ /*0350*/ LEA R13, P0, R8.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a00080d7a11 */ /* 0x040fe200078010ff */ /*0360*/ IMAD.MOV.U32 R14, RZ, RZ, R2 ; /* 0x000000ffff0e7224 */ /* 0x000fe400078e0002 */ /*0370*/ IMAD.MOV.U32 R15, RZ, RZ, R3 ; /* 0x000000ffff0f7224 */ /* 0x000fe200078e0003 */ /*0380*/ LEA.HI.X R16, R8, c[0x0][0x16c], R9, 0x2, P0 ; /* 0x00005b0008107a11 */ /* 0x000fe400000f1409 */ /*0390*/ ISETP.NE.AND P0, PT, R6, RZ, PT ; /* 0x000000ff0600720c */ /* 0x000fe20003f05270 */ /*03a0*/ IMAD.MOV.U32 R8, RZ, RZ, R13 ; /* 0x000000ffff087224 */ /* 0x000fe200078e000d */ /*03b0*/ MOV R9, R16 ; /* 0x0000001000097202 */ /* 0x000fd60000000f00 */ /*03c0*/ @P0 LDG.E.64 R16, [R8.64] ; /* 0x0000000408100981 */ /* 0x000ea2000c1e1b00 */ /*03d0*/ IMAD.WIDE R10, R12, 0x4, R14 ; /* 0x000000040c0a7825 */ /* 0x000fe200078e020e */ /*03e0*/ IADD3 R13, R6, 0x100, RZ ; /* 0x00000100060d7810 */ /* 0x000fe20007ffe0ff */ /*03f0*/ BSSY B1, 0x4c0 ; /* 0x000000c000017945 */ /* 0x000fe40003800000 */ /*0400*/ @P0 FMUL R17, R17, R17 ; /* 0x0000001111110220 */ /* 0x004fc80000400000 */ /*0410*/ @P0 FFMA R17, R16, R16, R17 ; /* 0x0000001010110223 */ /* 0x000fe20000000011 */ /*0420*/ IADD3 R16, R6, 0x200, RZ ; /* 0x0000020006107810 */ /* 0x000fc80007ffe0ff */ /*0430*/ @P0 STG.E [R10.64], R17 ; /* 0x000000110a000986 */ /* 0x0001e2000c101904 */ /*0440*/ ISETP.NE.AND P0, PT, R13, RZ, PT ; /* 0x000000ff0d00720c */ /* 0x000fe40003f05270 */ /*0450*/ ISETP.NE.AND P1, PT, R16, RZ, PT ; /* 0x000000ff1000720c */ /* 0x000fd60003f25270 */ /*0460*/ @!P0 BRA 0x4b0 ; /* 0x0000004000008947 */ /* 0x000fea0003800000 */ /*0470*/ LDG.E.64 R16, [R8.64+0x800] ; /* 0x0008000408107981 */ /* 0x001ea4000c1e1b00 */ /*0480*/ FMUL R17, R17, R17 ; /* 0x0000001111117220 */ /* 0x004fc80000400000 */ /*0490*/ FFMA R17, R16, R16, R17 ; /* 0x0000001010117223 */ /* 0x000fca0000000011 */ /*04a0*/ STG.E [R10.64+0x400], R17 ; /* 0x000400110a007986 */ /* 0x0001e4000c101904 */ /*04b0*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x001fea0003800000 */ /*04c0*/ BSSY B1, 0x530 ; /* 0x0000006000017945 */ /* 0x000fe20003800000 */ /*04d0*/ @!P1 BRA 0x520 ; /* 0x0000004000009947 */ /* 0x000fea0003800000 */ /*04e0*/ LDG.E.64 R16, [R8.64+0x1000] ; /* 0x0010000408107981 */ /* 0x000ea4000c1e1b00 */ /*04f0*/ FMUL R17, R17, R17 ; /* 0x0000001111117220 */ /* 0x004fc80000400000 */ /*0500*/ FFMA R17, R16, R16, R17 ; /* 0x0000001010117223 */ /* 0x000fca0000000011 */ /*0510*/ STG.E [R10.64+0x800], R17 ; /* 0x000800110a007986 */ /* 0x0001e4000c101904 */ /*0520*/ BSYNC B1 ; /* 0x0000000000017941 */ /* 0x000fea0003800000 */ /*0530*/ IADD3 R13, R6, 0x300, RZ ; /* 0x00000300060d7810 */ /* 0x000fc80007ffe0ff */ /*0540*/ ISETP.NE.AND P0, PT, R13, RZ, PT ; /* 0x000000ff0d00720c */ /* 0x000fda0003f05270 */ /*0550*/ @P0 LDG.E.64 R16, [R8.64+0x1800] ; /* 0x0018000408100981 */ /* 0x001ea2000c1e1b00 */ /*0560*/ IADD3 R6, R6, 0x400, RZ ; /* 0x0000040006067810 */ /* 0x000fe40007ffe0ff */ /*0570*/ IADD3 R14, P1, R14, 0x1000, RZ ; /* 0x000010000e0e7810 */ /* 0x000fe40007f3e0ff */ /*0580*/ IADD3 R13, P2, R8, 0x2000, RZ ; /* 0x00002000080d7810 */ /* 0x000fc60007f5e0ff */ /*0590*/ IMAD.X R15, RZ, RZ, R15, P1 ; /* 0x000000ffff0f7224 */ /* 0x000fe400008e060f */ /*05a0*/ @P0 FMUL R17, R17, R17 ; /* 0x0000001111110220 */ /* 0x004fc80000400000 */ /*05b0*/ @P0 FFMA R17, R16, R16, R17 ; /* 0x0000001010110223 */ /* 0x000fe40000000011 */ /*05c0*/ IMAD.X R16, RZ, RZ, R9, P2 ; /* 0x000000ffff107224 */ /* 0x000fc600010e0609 */ /*05d0*/ @P0 STG.E [R10.64+0xc00], R17 ; /* 0x000c00110a000986 */ /* 0x0001e2000c101904 */ /*05e0*/ ISETP.GE.AND P0, PT, R6, R7, PT ; /* 0x000000070600720c */ /* 0x000fda0003f06270 */ /*05f0*/ @!P0 BRA 0x390 ; /* 0xfffffd9000008947 */ /* 0x001fea000383ffff */ /*0600*/ BSYNC B0 ; /* 0x0000000000007941 */ /* 0x000fea0003800000 */ /*0610*/ ISETP.NE.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fe40003f05270 */ /*0620*/ LEA R8, P1, R4, c[0x0][0x168], 0x2 ; /* 0x00005a0004087a11 */ /* 0x001fc800078210ff */ /*0630*/ LEA.HI.X R9, R4, c[0x0][0x16c], R5, 0x2, P1 ; /* 0x00005b0004097a11 */ /* 0x000fce00008f1405 */ /*0640*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0650*/ IMAD.MOV.U32 R5, RZ, RZ, c[0x0][0x160] ; /* 0x00005800ff057624 */ /* 0x000fc800078e00ff */ /*0660*/ IMAD.WIDE R4, R5, 0x4, R8 ; /* 0x0000000405047825 */ /* 0x000fe400078e0208 */ /*0670*/ LDG.E R8, [R8.64] ; /* 0x0000000408087981 */ /* 0x000ea8000c1e1900 */ /*0680*/ LDG.E R4, [R4.64] ; /* 0x0000000404047981 */ /* 0x000ee2000c1e1900 */ /*0690*/ IMAD.WIDE R6, R7, 0x4, R2 ; /* 0x0000000407067825 */ /* 0x000fc800078e0202 */ /*06a0*/ FMUL R11, R8, R8 ; /* 0x00000008080b7220 */ /* 0x004fe40000400000 */ /*06b0*/ FMUL R13, R4, R4 ; /* 0x00000004040d7220 */ /* 0x008fc60000400000 */ /*06c0*/ STG.E [R2.64], R11 ; /* 0x0000000b02007986 */ /* 0x000fe8000c101904 */ /*06d0*/ STG.E [R6.64], R13 ; /* 0x0000000d06007986 */ /* 0x000fe2000c101904 */ /*06e0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*06f0*/ BRA 0x6f0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0700*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0710*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0720*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0730*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0740*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0750*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0760*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0770*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z21power_spectrum_kerneliPfiS_i .globl _Z21power_spectrum_kerneliPfiS_i .p2align 8 .type _Z21power_spectrum_kerneliPfiS_i,@function _Z21power_spectrum_kerneliPfiS_i: s_clause 0x4 s_load_b32 s2, s[0:1], 0x0 s_load_b32 s3, s[0:1], 0x10 s_load_b32 s5, s[0:1], 0x20 s_load_b64 s[8:9], s[0:1], 0x8 s_load_b64 s[6:7], s[0:1], 0x18 s_mov_b32 s1, exec_lo s_waitcnt lgkmcnt(0) s_lshr_b32 s0, s2, 31 s_mul_i32 s12, s15, s3 s_add_i32 s0, s2, s0 s_mul_i32 s10, s15, s5 s_ashr_i32 s4, s0, 1 s_ashr_i32 s13, s12, 31 s_ashr_i32 s11, s10, 31 v_cmpx_gt_i32_e64 s4, v0 s_cbranch_execz .LBB0_5 v_lshlrev_b32_e32 v1, 3, v0 s_lshl_b64 s[14:15], s[12:13], 2 v_lshlrev_b32_e32 v3, 2, v0 s_add_u32 s0, s8, s14 s_addc_u32 s3, s9, s15 v_add_co_u32 v1, s0, s0, v1 s_lshl_b64 s[14:15], s[10:11], 2 v_add_co_ci_u32_e64 v2, null, s3, 0, s0 s_add_u32 s0, s6, s14 s_delay_alu instid0(VALU_DEP_2) v_add_co_u32 v1, vcc_lo, v1, 4 s_addc_u32 s3, s7, s15 v_add_co_u32 v3, s0, s0, v3 v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo v_add_co_ci_u32_e64 v4, null, s3, 0, s0 v_mov_b32_e32 v5, v0 s_mov_b32 s3, 0 s_set_inst_prefetch_distance 0x1 s_branch .LBB0_3 .p2align 6 .LBB0_2: s_or_b32 exec_lo, exec_lo, s0 v_add_nc_u32_e32 v5, 0x100, v5 v_add_co_u32 v1, vcc_lo, v1, 0x800 v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_cmp_le_i32_e32 vcc_lo, s4, v5 v_add_co_u32 v3, s0, v3, 0x400 v_add_co_ci_u32_e64 v4, s0, 0, v4, s0 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_execz .LBB0_5 .LBB0_3: s_mov_b32 s0, exec_lo v_cmpx_ne_u32_e32 0, v5 s_cbranch_execz .LBB0_2 s_clause 0x1 global_load_b32 v6, v[1:2], off global_load_b32 v7, v[1:2], off offset:-4 s_waitcnt vmcnt(1) v_mul_f32_e32 v6, v6, v6 s_waitcnt vmcnt(0) s_delay_alu instid0(VALU_DEP_1) v_fmac_f32_e32 v6, v7, v7 global_store_b32 v[3:4], v6, off s_branch .LBB0_2 .LBB0_5: s_set_inst_prefetch_distance 0x2 s_or_b32 exec_lo, exec_lo, s1 s_delay_alu instid0(SALU_CYCLE_1) s_mov_b32 s0, exec_lo v_cmpx_eq_u32_e32 0, v0 s_cbranch_execz .LBB0_7 s_lshl_b64 s[0:1], s[12:13], 2 v_mov_b32_e32 v0, 0 s_add_u32 s0, s8, s0 s_addc_u32 s1, s9, s1 s_lshl_b64 s[8:9], s[10:11], 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) s_add_u32 s6, s6, s8 s_addc_u32 s7, s7, s9 s_ashr_i32 s3, s2, 31 s_lshl_b64 s[2:3], s[2:3], 2 s_delay_alu instid0(SALU_CYCLE_1) s_add_u32 s2, s0, s2 s_addc_u32 s3, s1, s3 s_clause 0x1 global_load_b32 v1, v0, s[0:1] global_load_b32 v2, v0, s[2:3] s_ashr_i32 s5, s4, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[0:1], s[4:5], 2 s_add_u32 s0, s6, s0 s_addc_u32 s1, s7, s1 s_waitcnt vmcnt(0) v_dual_mul_f32 v1, v1, v1 :: v_dual_mul_f32 v2, v2, v2 s_clause 0x1 global_store_b32 v0, v1, s[6:7] global_store_b32 v0, v2, s[0:1] .LBB0_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z21power_spectrum_kerneliPfiS_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 36 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z21power_spectrum_kerneliPfiS_i, .Lfunc_end0-_Z21power_spectrum_kerneliPfiS_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: - .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 .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 36 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z21power_spectrum_kerneliPfiS_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z21power_spectrum_kerneliPfiS_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_001238a6_00000000-6_power_spectrum_kernel.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 _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i .type _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i, @function _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i: .LFB2051: .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 .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 _Z21power_spectrum_kerneliPfiS_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 _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i, .-_Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i .globl _Z21power_spectrum_kerneliPfiS_i .type _Z21power_spectrum_kerneliPfiS_i, @function _Z21power_spectrum_kerneliPfiS_i: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z46__device_stub__Z21power_spectrum_kerneliPfiS_iiPfiS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z21power_spectrum_kerneliPfiS_i, .-_Z21power_spectrum_kerneliPfiS_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z21power_spectrum_kerneliPfiS_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 _Z21power_spectrum_kerneliPfiS_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 "power_spectrum_kernel.hip" .globl _Z36__device_stub__power_spectrum_kerneliPfiS_i # -- Begin function _Z36__device_stub__power_spectrum_kerneliPfiS_i .p2align 4, 0x90 .type _Z36__device_stub__power_spectrum_kerneliPfiS_i,@function _Z36__device_stub__power_spectrum_kerneliPfiS_i: # @_Z36__device_stub__power_spectrum_kerneliPfiS_i .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 $_Z21power_spectrum_kerneliPfiS_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 _Z36__device_stub__power_spectrum_kerneliPfiS_i, .Lfunc_end0-_Z36__device_stub__power_spectrum_kerneliPfiS_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 $_Z21power_spectrum_kerneliPfiS_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 _Z21power_spectrum_kerneliPfiS_i,@object # @_Z21power_spectrum_kerneliPfiS_i .section .rodata,"a",@progbits .globl _Z21power_spectrum_kerneliPfiS_i .p2align 3, 0x0 _Z21power_spectrum_kerneliPfiS_i: .quad _Z36__device_stub__power_spectrum_kerneliPfiS_i .size _Z21power_spectrum_kerneliPfiS_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z21power_spectrum_kerneliPfiS_i" .size .L__unnamed_1, 33 .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 _Z36__device_stub__power_spectrum_kerneliPfiS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z21power_spectrum_kerneliPfiS_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 <stdio.h> #include <cuda_runtime.h> __constant__ int test_arr_d[5]; __constant__ int a; __global__ void print() { int id = threadIdx.x; printf("%d: %d\n", id, test_arr_d[id]); __syncthreads(); } int main() { int test_arr_h[5] = {1, 2, 3, 4, 5}; cudaError_t result = cudaMemcpyToSymbolAsync(test_arr_d, &test_arr_h, 5*sizeof(int), 0, cudaMemcpyHostToDevice); print<<<1,5>>>(); cudaDeviceSynchronize(); return 0; }
code for sm_80 Function : _Z5printv .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 R8, SR_TID.X ; /* 0x0000000000087919 */ /* 0x000e220000002100 */ /*0020*/ MOV R2, 0x0 ; /* 0x0000000000027802 */ /* 0x000fe20000000f00 */ /*0030*/ IMAD.MOV.U32 R4, RZ, RZ, c[0x4][0x8] ; /* 0x01000200ff047624 */ /* 0x000fe200078e00ff */ /*0040*/ IADD3 R1, R1, -0x8, RZ ; /* 0xfffffff801017810 */ /* 0x000fe20007ffe0ff */ /*0050*/ IMAD.MOV.U32 R5, RZ, RZ, c[0x4][0xc] ; /* 0x01000300ff057624 */ /* 0x000fc600078e00ff */ /*0060*/ LDC.64 R2, c[0x4][R2] ; /* 0x0100000002027b82 */ /* 0x000e620000000a00 */ /*0070*/ IADD3 R6, P0, R1, c[0x0][0x20], RZ ; /* 0x0000080001067a10 */ /* 0x000fca0007f1e0ff */ /*0080*/ IMAD.X R7, RZ, RZ, c[0x0][0x24], P0 ; /* 0x00000900ff077624 */ /* 0x000fe400000e06ff */ /*0090*/ IMAD.SHL.U32 R0, R8, 0x4, RZ ; /* 0x0000000408007824 */ /* 0x001fc800078e00ff */ /*00a0*/ LDC R9, c[0x3][R0] ; /* 0x00c0000000097b82 */ /* 0x000e240000000800 */ /*00b0*/ STL.64 [R1], R8 ; /* 0x0000000801007387 */ /* 0x0011e40000100a00 */ /*00c0*/ LEPC R8 ; /* 0x000000000008734e */ /* 0x003fe40000000000 */ /*00d0*/ MOV R11, 0x140 ; /* 0x00000140000b7802 */ /* 0x000fe40000000f00 */ /*00e0*/ MOV R20, 0xc0 ; /* 0x000000c000147802 */ /* 0x000fe40000000f00 */ /*00f0*/ MOV R21, 0x0 ; /* 0x0000000000157802 */ /* 0x000fe40000000f00 */ /*0100*/ MOV R0, 0x0 ; /* 0x0000000000007802 */ /* 0x000fe40000000f00 */ /*0110*/ IADD3 R20, P0, P1, -R20, R11, R8 ; /* 0x0000000b14147210 */ /* 0x000fc8000791e108 */ /*0120*/ IADD3.X R21, ~R0, R21, R9, P0, P1 ; /* 0x0000001500157210 */ /* 0x000fc800007e2509 */ /*0130*/ CALL.ABS.NOINC R2 ; /* 0x0000000002007343 */ /* 0x000fea0003c00000 */ /*0140*/ WARPSYNC 0xffffffff ; /* 0xffffffff00007948 */ /* 0x000fe20003800000 */ /*0150*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0160*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0170*/ BRA 0x170; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 <stdio.h> #include <cuda_runtime.h> __constant__ int test_arr_d[5]; __constant__ int a; __global__ void print() { int id = threadIdx.x; printf("%d: %d\n", id, test_arr_d[id]); __syncthreads(); } int main() { int test_arr_h[5] = {1, 2, 3, 4, 5}; cudaError_t result = cudaMemcpyToSymbolAsync(test_arr_d, &test_arr_h, 5*sizeof(int), 0, cudaMemcpyHostToDevice); print<<<1,5>>>(); cudaDeviceSynchronize(); return 0; }
.file "tmpxft_00157e12_00000000-6_constant_mem.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 _Z23__device_stub__Z5printvv .type _Z23__device_stub__Z5printvv, @function _Z23__device_stub__Z5printvv: .LFB2082: .cfi_startproc endbr64 subq $88, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax movl $1, 16(%rsp) movl $1, 20(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) leaq 8(%rsp), %rcx movq %rsp, %rdx leaq 28(%rsp), %rsi leaq 16(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 72(%rsp), %rax subq %fs:40, %rax jne .L8 addq $88, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 8(%rsp) .cfi_def_cfa_offset 104 pushq 8(%rsp) .cfi_def_cfa_offset 112 leaq 80(%rsp), %r9 movq 44(%rsp), %rcx movl 52(%rsp), %r8d movq 32(%rsp), %rsi movl 40(%rsp), %edx leaq _Z5printv(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 96 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z23__device_stub__Z5printvv, .-_Z23__device_stub__Z5printvv .globl _Z5printv .type _Z5printv, @function _Z5printv: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z23__device_stub__Z5printvv addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z5printv, .-_Z5printv .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 subq $72, %rsp .cfi_def_cfa_offset 80 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $1, 32(%rsp) movl $2, 36(%rsp) movl $3, 40(%rsp) movl $4, 44(%rsp) movl $5, 48(%rsp) leaq 32(%rsp), %rsi movl $0, %r9d movl $1, %r8d movl $0, %ecx movl $20, %edx leaq _ZL10test_arr_d(%rip), %rdi call cudaMemcpyToSymbolAsync@PLT movl $5, 20(%rsp) movl $1, 24(%rsp) movl $1, 8(%rsp) movl $1, 12(%rsp) movl $0, %r9d movl $0, %r8d movq 20(%rsp), %rdx movl $1, %ecx movq 8(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L15 .L12: call cudaDeviceSynchronize@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L16 movl $0, %eax addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .cfi_restore_state call _Z23__device_stub__Z5printvv jmp .L12 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z5printv" .LC1: .string "test_arr_d" .LC2: .string "a" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z5printv(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $1 .cfi_def_cfa_offset 32 movl $20, %r9d movl $0, %r8d leaq .LC1(%rip), %rdx movq %rdx, %rcx leaq _ZL10test_arr_d(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $1 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC2(%rip), %rdx movq %rdx, %rcx leaq _ZL1a(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .local _ZL1a .comm _ZL1a,4,4 .local _ZL10test_arr_d .comm _ZL10test_arr_d,20,16 .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 <cuda_runtime.h> __constant__ int test_arr_d[5]; __constant__ int a; __global__ void print() { int id = threadIdx.x; printf("%d: %d\n", id, test_arr_d[id]); __syncthreads(); } int main() { int test_arr_h[5] = {1, 2, 3, 4, 5}; cudaError_t result = cudaMemcpyToSymbolAsync(test_arr_d, &test_arr_h, 5*sizeof(int), 0, cudaMemcpyHostToDevice); print<<<1,5>>>(); cudaDeviceSynchronize(); return 0; }
#include <stdio.h> #include <hip/hip_runtime.h> __constant__ int test_arr_d[5]; __constant__ int a; __global__ void print() { int id = threadIdx.x; printf("%d: %d\n", id, test_arr_d[id]); __syncthreads(); } int main() { int test_arr_h[5] = {1, 2, 3, 4, 5}; hipError_t result = hipMemcpyToSymbolAsync(HIP_SYMBOL(test_arr_d), &test_arr_h, 5*sizeof(int), 0, hipMemcpyHostToDevice); print<<<1,5>>>(); hipDeviceSynchronize(); return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <stdio.h> #include <hip/hip_runtime.h> __constant__ int test_arr_d[5]; __constant__ int a; __global__ void print() { int id = threadIdx.x; printf("%d: %d\n", id, test_arr_d[id]); __syncthreads(); } int main() { int test_arr_h[5] = {1, 2, 3, 4, 5}; hipError_t result = hipMemcpyToSymbolAsync(HIP_SYMBOL(test_arr_d), &test_arr_h, 5*sizeof(int), 0, hipMemcpyHostToDevice); print<<<1,5>>>(); hipDeviceSynchronize(); return 0; }
.text .file "constant_mem.hip" .globl _Z20__device_stub__printv # -- Begin function _Z20__device_stub__printv .p2align 4, 0x90 .type _Z20__device_stub__printv,@function _Z20__device_stub__printv: # @_Z20__device_stub__printv .cfi_startproc # %bb.0: subq $56, %rsp .cfi_def_cfa_offset 64 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 48(%rsp), %r9 movl $_Z5printv, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $72, %rsp .cfi_adjust_cfa_offset -72 retq .Lfunc_end0: .size _Z20__device_stub__printv, .Lfunc_end0-_Z20__device_stub__printv .cfi_endproc # -- End function .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 # -- Begin function main .LCPI1_0: .long 1 # 0x1 .long 2 # 0x2 .long 3 # 0x3 .long 4 # 0x4 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movaps .LCPI1_0(%rip), %xmm0 # xmm0 = [1,2,3,4] movaps %xmm0, 48(%rsp) movl $5, 64(%rsp) leaq 48(%rsp), %rsi movl $test_arr_d, %edi movl $20, %edx xorl %ecx, %ecx movl $1, %r8d xorl %r9d, %r9d callq hipMemcpyToSymbolAsync movabsq $4294967297, %rdi # imm = 0x100000001 leaq 4(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_2 # %bb.1: 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 80(%rsp), %r9 movl $_Z5printv, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_2: callq hipDeviceSynchronize xorl %eax, %eax addq $88, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rbx subq $32, %rsp .cfi_adjust_cfa_offset 32 xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z5printv, %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 $test_arr_d, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movl $20, %r9d movq %rbx, %rdi xorl %r8d, %r8d pushq $0 .cfi_adjust_cfa_offset 8 pushq $1 .cfi_adjust_cfa_offset 8 callq __hipRegisterVar addq $16, %rsp .cfi_adjust_cfa_offset -16 movl $a, %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 $1 .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_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 test_arr_d,@object # @test_arr_d .local test_arr_d .comm test_arr_d,20,16 .type a,@object # @a .local a .comm a,4,4 .type _Z5printv,@object # @_Z5printv .section .rodata,"a",@progbits .globl _Z5printv .p2align 3, 0x0 _Z5printv: .quad _Z20__device_stub__printv .size _Z5printv, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z5printv" .size .L__unnamed_1, 10 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "test_arr_d" .size .L__unnamed_2, 11 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "a" .size .L__unnamed_3, 2 .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 _Z20__device_stub__printv .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym test_arr_d .addrsig_sym a .addrsig_sym _Z5printv .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_00157e12_00000000-6_constant_mem.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 _Z23__device_stub__Z5printvv .type _Z23__device_stub__Z5printvv, @function _Z23__device_stub__Z5printvv: .LFB2082: .cfi_startproc endbr64 subq $88, %rsp .cfi_def_cfa_offset 96 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax movl $1, 16(%rsp) movl $1, 20(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) leaq 8(%rsp), %rcx movq %rsp, %rdx leaq 28(%rsp), %rsi leaq 16(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 72(%rsp), %rax subq %fs:40, %rax jne .L8 addq $88, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 8(%rsp) .cfi_def_cfa_offset 104 pushq 8(%rsp) .cfi_def_cfa_offset 112 leaq 80(%rsp), %r9 movq 44(%rsp), %rcx movl 52(%rsp), %r8d movq 32(%rsp), %rsi movl 40(%rsp), %edx leaq _Z5printv(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 96 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2082: .size _Z23__device_stub__Z5printvv, .-_Z23__device_stub__Z5printvv .globl _Z5printv .type _Z5printv, @function _Z5printv: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z23__device_stub__Z5printvv addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z5printv, .-_Z5printv .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 subq $72, %rsp .cfi_def_cfa_offset 80 movq %fs:40, %rax movq %rax, 56(%rsp) xorl %eax, %eax movl $1, 32(%rsp) movl $2, 36(%rsp) movl $3, 40(%rsp) movl $4, 44(%rsp) movl $5, 48(%rsp) leaq 32(%rsp), %rsi movl $0, %r9d movl $1, %r8d movl $0, %ecx movl $20, %edx leaq _ZL10test_arr_d(%rip), %rdi call cudaMemcpyToSymbolAsync@PLT movl $5, 20(%rsp) movl $1, 24(%rsp) movl $1, 8(%rsp) movl $1, 12(%rsp) movl $0, %r9d movl $0, %r8d movq 20(%rsp), %rdx movl $1, %ecx movq 8(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L15 .L12: call cudaDeviceSynchronize@PLT movq 56(%rsp), %rax subq %fs:40, %rax jne .L16 movl $0, %eax addq $72, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .cfi_restore_state call _Z23__device_stub__Z5printvv jmp .L12 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z5printv" .LC1: .string "test_arr_d" .LC2: .string "a" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2085: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rbx movq %rax, _ZL20__cudaFatCubinHandle(%rip) pushq $0 .cfi_def_cfa_offset 24 pushq $0 .cfi_def_cfa_offset 32 pushq $0 .cfi_def_cfa_offset 40 pushq $0 .cfi_def_cfa_offset 48 movl $0, %r9d movl $-1, %r8d leaq .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z5printv(%rip), %rsi movq %rax, %rdi call __cudaRegisterFunction@PLT addq $32, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $1 .cfi_def_cfa_offset 32 movl $20, %r9d movl $0, %r8d leaq .LC1(%rip), %rdx movq %rdx, %rcx leaq _ZL10test_arr_d(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 pushq $0 .cfi_def_cfa_offset 24 pushq $1 .cfi_def_cfa_offset 32 movl $4, %r9d movl $0, %r8d leaq .LC2(%rip), %rdx movq %rdx, %rcx leaq _ZL1a(%rip), %rsi movq %rbx, %rdi call __cudaRegisterVar@PLT addq $16, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .local _ZL1a .comm _ZL1a,4,4 .local _ZL10test_arr_d .comm _ZL10test_arr_d,20,16 .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 "constant_mem.hip" .globl _Z20__device_stub__printv # -- Begin function _Z20__device_stub__printv .p2align 4, 0x90 .type _Z20__device_stub__printv,@function _Z20__device_stub__printv: # @_Z20__device_stub__printv .cfi_startproc # %bb.0: subq $56, %rsp .cfi_def_cfa_offset 64 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 48(%rsp), %r9 movl $_Z5printv, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $72, %rsp .cfi_adjust_cfa_offset -72 retq .Lfunc_end0: .size _Z20__device_stub__printv, .Lfunc_end0-_Z20__device_stub__printv .cfi_endproc # -- End function .section .rodata.cst16,"aM",@progbits,16 .p2align 4, 0x0 # -- Begin function main .LCPI1_0: .long 1 # 0x1 .long 2 # 0x2 .long 3 # 0x3 .long 4 # 0x4 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: subq $88, %rsp .cfi_def_cfa_offset 96 movaps .LCPI1_0(%rip), %xmm0 # xmm0 = [1,2,3,4] movaps %xmm0, 48(%rsp) movl $5, 64(%rsp) leaq 48(%rsp), %rsi movl $test_arr_d, %edi movl $20, %edx xorl %ecx, %ecx movl $1, %r8d xorl %r9d, %r9d callq hipMemcpyToSymbolAsync movabsq $4294967297, %rdi # imm = 0x100000001 leaq 4(%rdi), %rdx movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_2 # %bb.1: 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 80(%rsp), %r9 movl $_Z5printv, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_2: callq hipDeviceSynchronize xorl %eax, %eax addq $88, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rbx subq $32, %rsp .cfi_adjust_cfa_offset 32 xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $_Z5printv, %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 $test_arr_d, %esi movl $.L__unnamed_2, %edx movl $.L__unnamed_2, %ecx movl $20, %r9d movq %rbx, %rdi xorl %r8d, %r8d pushq $0 .cfi_adjust_cfa_offset 8 pushq $1 .cfi_adjust_cfa_offset 8 callq __hipRegisterVar addq $16, %rsp .cfi_adjust_cfa_offset -16 movl $a, %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 $1 .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_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 test_arr_d,@object # @test_arr_d .local test_arr_d .comm test_arr_d,20,16 .type a,@object # @a .local a .comm a,4,4 .type _Z5printv,@object # @_Z5printv .section .rodata,"a",@progbits .globl _Z5printv .p2align 3, 0x0 _Z5printv: .quad _Z20__device_stub__printv .size _Z5printv, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z5printv" .size .L__unnamed_1, 10 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "test_arr_d" .size .L__unnamed_2, 11 .type .L__unnamed_3,@object # @2 .L__unnamed_3: .asciz "a" .size .L__unnamed_3, 2 .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 _Z20__device_stub__printv .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym test_arr_d .addrsig_sym a .addrsig_sym _Z5printv .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.
__global__ void groupSumKernel( int dimension, int maximumKeys, int* mapping, float* gradient, float* groupSum) { int indexInstance = blockIdx.x; int indexKey = blockIdx.y; int indexMapping = indexInstance * maximumKeys + indexKey; int slot = mapping[indexMapping]; if(slot != -1) { int indexEntry = threadIdx.x; int indexGroupSumEntry = slot * dimension + indexEntry; int indexGradientEntry = indexInstance * maximumKeys * dimension + indexKey * dimension + indexEntry; float gradientEntry = gradient[indexGradientEntry]; atomicAdd(&groupSum[indexGroupSumEntry], gradientEntry); } }
code for sm_80 Function : _Z14groupSumKerneliiPiPfS0_ .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 R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_CTAID.Y ; /* 0x0000000000037919 */ /* 0x000e240000002600 */ /*0050*/ IMAD R0, R0, c[0x0][0x164], R3 ; /* 0x0000590000007a24 */ /* 0x001fca00078e0203 */ /*0060*/ IMAD.WIDE R2, R0, R7, c[0x0][0x168] ; /* 0x00005a0000027625 */ /* 0x000fca00078e0207 */ /*0070*/ LDG.E R4, [R2.64] ; /* 0x0000000402047981 */ /* 0x000ea4000c1e1900 */ /*0080*/ ISETP.NE.AND P0, PT, R4, -0x1, PT ; /* 0xffffffff0400780c */ /* 0x004fda0003f05270 */ /*0090*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*00a0*/ S2R R5, SR_TID.X ; /* 0x0000000000057919 */ /* 0x000e240000002100 */ /*00b0*/ IMAD R2, R0, c[0x0][0x160], R5 ; /* 0x0000580000027a24 */ /* 0x001fc800078e0205 */ /*00c0*/ IMAD.WIDE R2, R2, R7, c[0x0][0x170] ; /* 0x00005c0002027625 */ /* 0x000fcc00078e0207 */ /*00d0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*00e0*/ IMAD R4, R4, c[0x0][0x160], R5 ; /* 0x0000580004047a24 */ /* 0x000fc800078e0205 */ /*00f0*/ IMAD.WIDE R4, R4, R7, c[0x0][0x178] ; /* 0x00005e0004047625 */ /* 0x000fca00078e0207 */ /*0100*/ RED.E.ADD.F32.FTZ.RN.STRONG.GPU [R4.64], R3 ; /* 0x000000030400798e */ /* 0x004fe2000c10e784 */ /*0110*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0120*/ BRA 0x120; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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.
__global__ void groupSumKernel( int dimension, int maximumKeys, int* mapping, float* gradient, float* groupSum) { int indexInstance = blockIdx.x; int indexKey = blockIdx.y; int indexMapping = indexInstance * maximumKeys + indexKey; int slot = mapping[indexMapping]; if(slot != -1) { int indexEntry = threadIdx.x; int indexGroupSumEntry = slot * dimension + indexEntry; int indexGradientEntry = indexInstance * maximumKeys * dimension + indexKey * dimension + indexEntry; float gradientEntry = gradient[indexGradientEntry]; atomicAdd(&groupSum[indexGroupSumEntry], gradientEntry); } }
.file "tmpxft_000e2e49_00000000-6_GroupSumKernel.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 _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_ .type _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_, @function _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_: .LFB2051: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movl %edi, 28(%rsp) movl %esi, 24(%rsp) movq %rdx, 16(%rsp) movq %rcx, 8(%rsp) movq %r8, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 28(%rsp), %rax movq %rax, 96(%rsp) leaq 24(%rsp), %rax movq %rax, 104(%rsp) leaq 16(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) movq %rsp, %rax movq %rax, 128(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .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 _Z14groupSumKerneliiPiPfS0_(%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 _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_, .-_Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_ .globl _Z14groupSumKerneliiPiPfS0_ .type _Z14groupSumKerneliiPiPfS0_, @function _Z14groupSumKerneliiPiPfS0_: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z14groupSumKerneliiPiPfS0_, .-_Z14groupSumKerneliiPiPfS0_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z14groupSumKerneliiPiPfS0_" .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 _Z14groupSumKerneliiPiPfS0_(%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.
__global__ void groupSumKernel( int dimension, int maximumKeys, int* mapping, float* gradient, float* groupSum) { int indexInstance = blockIdx.x; int indexKey = blockIdx.y; int indexMapping = indexInstance * maximumKeys + indexKey; int slot = mapping[indexMapping]; if(slot != -1) { int indexEntry = threadIdx.x; int indexGroupSumEntry = slot * dimension + indexEntry; int indexGradientEntry = indexInstance * maximumKeys * dimension + indexKey * dimension + indexEntry; float gradientEntry = gradient[indexGradientEntry]; atomicAdd(&groupSum[indexGroupSumEntry], gradientEntry); } }
#include <hip/hip_runtime.h> __global__ void groupSumKernel( int dimension, int maximumKeys, int* mapping, float* gradient, float* groupSum) { int indexInstance = blockIdx.x; int indexKey = blockIdx.y; int indexMapping = indexInstance * maximumKeys + indexKey; int slot = mapping[indexMapping]; if(slot != -1) { int indexEntry = threadIdx.x; int indexGroupSumEntry = slot * dimension + indexEntry; int indexGradientEntry = indexInstance * maximumKeys * dimension + indexKey * dimension + indexEntry; float gradientEntry = gradient[indexGradientEntry]; atomicAdd(&groupSum[indexGroupSumEntry], gradientEntry); } }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> __global__ void groupSumKernel( int dimension, int maximumKeys, int* mapping, float* gradient, float* groupSum) { int indexInstance = blockIdx.x; int indexKey = blockIdx.y; int indexMapping = indexInstance * maximumKeys + indexKey; int slot = mapping[indexMapping]; if(slot != -1) { int indexEntry = threadIdx.x; int indexGroupSumEntry = slot * dimension + indexEntry; int indexGradientEntry = indexInstance * maximumKeys * dimension + indexKey * dimension + indexEntry; float gradientEntry = gradient[indexGradientEntry]; atomicAdd(&groupSum[indexGroupSumEntry], gradientEntry); } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z14groupSumKerneliiPiPfS0_ .globl _Z14groupSumKerneliiPiPfS0_ .p2align 8 .type _Z14groupSumKerneliiPiPfS0_,@function _Z14groupSumKerneliiPiPfS0_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x4 s_load_b64 s[4:5], s[0:1], 0x8 s_waitcnt lgkmcnt(0) s_mul_i32 s2, s14, s2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s2, s2, s15 s_ashr_i32 s3, s2, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[6:7], s[2:3], 2 s_add_u32 s4, s4, s6 s_addc_u32 s5, s5, s7 s_load_b32 s3, s[4:5], 0x0 s_waitcnt lgkmcnt(0) s_cmp_eq_u32 s3, -1 s_cbranch_scc1 .LBB0_3 s_clause 0x1 s_load_b32 s8, s[0:1], 0x0 s_load_b128 s[4:7], s[0:1], 0x10 s_mov_b32 s0, 0 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[1:2], null, s2, s8, v[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[3:4], null, s3, s8, v[0:1] v_ashrrev_i32_e32 v2, 31, v1 v_lshlrev_b64 v[0:1], 2, v[1:2] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[2:3], 2, v[3:4] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v4, vcc_lo, s4, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s5, v1, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v0, vcc_lo, s6, v2 v_add_co_ci_u32_e32 v1, vcc_lo, s7, v3, vcc_lo global_load_b32 v4, v[4:5], off global_load_b32 v3, v[0:1], off .LBB0_2: s_waitcnt vmcnt(0) v_add_f32_e32 v2, v3, v4 global_atomic_cmpswap_b32 v2, v[0:1], v[2:3], off glc s_waitcnt vmcnt(0) v_cmp_eq_u32_e32 vcc_lo, v2, v3 v_mov_b32_e32 v3, v2 s_or_b32 s0, vcc_lo, s0 s_delay_alu instid0(SALU_CYCLE_1) s_and_not1_b32 exec_lo, exec_lo, s0 s_cbranch_execnz .LBB0_2 .LBB0_3: s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z14groupSumKerneliiPiPfS0_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 32 .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 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 _Z14groupSumKerneliiPiPfS0_, .Lfunc_end0-_Z14groupSumKerneliiPiPfS0_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .offset: 0 .size: 4 .value_kind: by_value - .offset: 4 .size: 4 .value_kind: by_value - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 24 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 32 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14groupSumKerneliiPiPfS0_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14groupSumKerneliiPiPfS0_.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> __global__ void groupSumKernel( int dimension, int maximumKeys, int* mapping, float* gradient, float* groupSum) { int indexInstance = blockIdx.x; int indexKey = blockIdx.y; int indexMapping = indexInstance * maximumKeys + indexKey; int slot = mapping[indexMapping]; if(slot != -1) { int indexEntry = threadIdx.x; int indexGroupSumEntry = slot * dimension + indexEntry; int indexGradientEntry = indexInstance * maximumKeys * dimension + indexKey * dimension + indexEntry; float gradientEntry = gradient[indexGradientEntry]; atomicAdd(&groupSum[indexGroupSumEntry], gradientEntry); } }
.text .file "GroupSumKernel.hip" .globl _Z29__device_stub__groupSumKerneliiPiPfS0_ # -- Begin function _Z29__device_stub__groupSumKerneliiPiPfS0_ .p2align 4, 0x90 .type _Z29__device_stub__groupSumKerneliiPiPfS0_,@function _Z29__device_stub__groupSumKerneliiPiPfS0_: # @_Z29__device_stub__groupSumKerneliiPiPfS0_ .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movl %edi, 4(%rsp) movl %esi, (%rsp) movq %rdx, 72(%rsp) movq %rcx, 64(%rsp) movq %r8, 56(%rsp) leaq 4(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) leaq 72(%rsp), %rax movq %rax, 96(%rsp) leaq 64(%rsp), %rax movq %rax, 104(%rsp) leaq 56(%rsp), %rax movq %rax, 112(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z14groupSumKerneliiPiPfS0_, %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__groupSumKerneliiPiPfS0_, .Lfunc_end0-_Z29__device_stub__groupSumKerneliiPiPfS0_ .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 $_Z14groupSumKerneliiPiPfS0_, %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 _Z14groupSumKerneliiPiPfS0_,@object # @_Z14groupSumKerneliiPiPfS0_ .section .rodata,"a",@progbits .globl _Z14groupSumKerneliiPiPfS0_ .p2align 3, 0x0 _Z14groupSumKerneliiPiPfS0_: .quad _Z29__device_stub__groupSumKerneliiPiPfS0_ .size _Z14groupSumKerneliiPiPfS0_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z14groupSumKerneliiPiPfS0_" .size .L__unnamed_1, 28 .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__groupSumKerneliiPiPfS0_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14groupSumKerneliiPiPfS0_ .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 : _Z14groupSumKerneliiPiPfS0_ .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 R7, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff077435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R3, SR_CTAID.Y ; /* 0x0000000000037919 */ /* 0x000e240000002600 */ /*0050*/ IMAD R0, R0, c[0x0][0x164], R3 ; /* 0x0000590000007a24 */ /* 0x001fca00078e0203 */ /*0060*/ IMAD.WIDE R2, R0, R7, c[0x0][0x168] ; /* 0x00005a0000027625 */ /* 0x000fca00078e0207 */ /*0070*/ LDG.E R4, [R2.64] ; /* 0x0000000402047981 */ /* 0x000ea4000c1e1900 */ /*0080*/ ISETP.NE.AND P0, PT, R4, -0x1, PT ; /* 0xffffffff0400780c */ /* 0x004fda0003f05270 */ /*0090*/ @!P0 EXIT ; /* 0x000000000000894d */ /* 0x000fea0003800000 */ /*00a0*/ S2R R5, SR_TID.X ; /* 0x0000000000057919 */ /* 0x000e240000002100 */ /*00b0*/ IMAD R2, R0, c[0x0][0x160], R5 ; /* 0x0000580000027a24 */ /* 0x001fc800078e0205 */ /*00c0*/ IMAD.WIDE R2, R2, R7, c[0x0][0x170] ; /* 0x00005c0002027625 */ /* 0x000fcc00078e0207 */ /*00d0*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*00e0*/ IMAD R4, R4, c[0x0][0x160], R5 ; /* 0x0000580004047a24 */ /* 0x000fc800078e0205 */ /*00f0*/ IMAD.WIDE R4, R4, R7, c[0x0][0x178] ; /* 0x00005e0004047625 */ /* 0x000fca00078e0207 */ /*0100*/ RED.E.ADD.F32.FTZ.RN.STRONG.GPU [R4.64], R3 ; /* 0x000000030400798e */ /* 0x004fe2000c10e784 */ /*0110*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0120*/ BRA 0x120; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 _Z14groupSumKerneliiPiPfS0_ .globl _Z14groupSumKerneliiPiPfS0_ .p2align 8 .type _Z14groupSumKerneliiPiPfS0_,@function _Z14groupSumKerneliiPiPfS0_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x4 s_load_b64 s[4:5], s[0:1], 0x8 s_waitcnt lgkmcnt(0) s_mul_i32 s2, s14, s2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s2, s2, s15 s_ashr_i32 s3, s2, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[6:7], s[2:3], 2 s_add_u32 s4, s4, s6 s_addc_u32 s5, s5, s7 s_load_b32 s3, s[4:5], 0x0 s_waitcnt lgkmcnt(0) s_cmp_eq_u32 s3, -1 s_cbranch_scc1 .LBB0_3 s_clause 0x1 s_load_b32 s8, s[0:1], 0x0 s_load_b128 s[4:7], s[0:1], 0x10 s_mov_b32 s0, 0 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[1:2], null, s2, s8, v[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[3:4], null, s3, s8, v[0:1] v_ashrrev_i32_e32 v2, 31, v1 v_lshlrev_b64 v[0:1], 2, v[1:2] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b64 v[2:3], 2, v[3:4] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v4, vcc_lo, s4, v0 v_add_co_ci_u32_e32 v5, vcc_lo, s5, v1, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v0, vcc_lo, s6, v2 v_add_co_ci_u32_e32 v1, vcc_lo, s7, v3, vcc_lo global_load_b32 v4, v[4:5], off global_load_b32 v3, v[0:1], off .LBB0_2: s_waitcnt vmcnt(0) v_add_f32_e32 v2, v3, v4 global_atomic_cmpswap_b32 v2, v[0:1], v[2:3], off glc s_waitcnt vmcnt(0) v_cmp_eq_u32_e32 vcc_lo, v2, v3 v_mov_b32_e32 v3, v2 s_or_b32 s0, vcc_lo, s0 s_delay_alu instid0(SALU_CYCLE_1) s_and_not1_b32 exec_lo, exec_lo, s0 s_cbranch_execnz .LBB0_2 .LBB0_3: s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z14groupSumKerneliiPiPfS0_ .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 32 .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 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 _Z14groupSumKerneliiPiPfS0_, .Lfunc_end0-_Z14groupSumKerneliiPiPfS0_ .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .offset: 0 .size: 4 .value_kind: by_value - .offset: 4 .size: 4 .value_kind: by_value - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 24 .size: 8 .value_kind: global_buffer .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 32 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z14groupSumKerneliiPiPfS0_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z14groupSumKerneliiPiPfS0_.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_000e2e49_00000000-6_GroupSumKernel.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 _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_ .type _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_, @function _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_: .LFB2051: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movl %edi, 28(%rsp) movl %esi, 24(%rsp) movq %rdx, 16(%rsp) movq %rcx, 8(%rsp) movq %r8, (%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 28(%rsp), %rax movq %rax, 96(%rsp) leaq 24(%rsp), %rax movq %rax, 104(%rsp) leaq 16(%rsp), %rax movq %rax, 112(%rsp) leaq 8(%rsp), %rax movq %rax, 120(%rsp) movq %rsp, %rax movq %rax, 128(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .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 _Z14groupSumKerneliiPiPfS0_(%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 _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_, .-_Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_ .globl _Z14groupSumKerneliiPiPfS0_ .type _Z14groupSumKerneliiPiPfS0_, @function _Z14groupSumKerneliiPiPfS0_: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z41__device_stub__Z14groupSumKerneliiPiPfS0_iiPiPfS0_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z14groupSumKerneliiPiPfS0_, .-_Z14groupSumKerneliiPiPfS0_ .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z14groupSumKerneliiPiPfS0_" .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 _Z14groupSumKerneliiPiPfS0_(%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 "GroupSumKernel.hip" .globl _Z29__device_stub__groupSumKerneliiPiPfS0_ # -- Begin function _Z29__device_stub__groupSumKerneliiPiPfS0_ .p2align 4, 0x90 .type _Z29__device_stub__groupSumKerneliiPiPfS0_,@function _Z29__device_stub__groupSumKerneliiPiPfS0_: # @_Z29__device_stub__groupSumKerneliiPiPfS0_ .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movl %edi, 4(%rsp) movl %esi, (%rsp) movq %rdx, 72(%rsp) movq %rcx, 64(%rsp) movq %r8, 56(%rsp) leaq 4(%rsp), %rax movq %rax, 80(%rsp) movq %rsp, %rax movq %rax, 88(%rsp) leaq 72(%rsp), %rax movq %rax, 96(%rsp) leaq 64(%rsp), %rax movq %rax, 104(%rsp) leaq 56(%rsp), %rax movq %rax, 112(%rsp) leaq 40(%rsp), %rdi leaq 24(%rsp), %rsi leaq 16(%rsp), %rdx leaq 8(%rsp), %rcx callq __hipPopCallConfiguration movq 40(%rsp), %rsi movl 48(%rsp), %edx movq 24(%rsp), %rcx movl 32(%rsp), %r8d leaq 80(%rsp), %r9 movl $_Z14groupSumKerneliiPiPfS0_, %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__groupSumKerneliiPiPfS0_, .Lfunc_end0-_Z29__device_stub__groupSumKerneliiPiPfS0_ .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 $_Z14groupSumKerneliiPiPfS0_, %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 _Z14groupSumKerneliiPiPfS0_,@object # @_Z14groupSumKerneliiPiPfS0_ .section .rodata,"a",@progbits .globl _Z14groupSumKerneliiPiPfS0_ .p2align 3, 0x0 _Z14groupSumKerneliiPiPfS0_: .quad _Z29__device_stub__groupSumKerneliiPiPfS0_ .size _Z14groupSumKerneliiPiPfS0_, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z14groupSumKerneliiPiPfS0_" .size .L__unnamed_1, 28 .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__groupSumKerneliiPiPfS0_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z14groupSumKerneliiPiPfS0_ .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.
/*! * \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the * CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * This class itself is not a proper Caffe layer although it behaves like one to some degree. * * \authors Sadeep Jayasumana, Bernardino Romera-Paredes, Shuai Zheng, Zhizhong Su. * \version 1.0 * \date 2015 * \copyright Torr Vision Group, University of Oxford. * \details If you use this code, please consider citing the paper: * Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, * Chang Huang, Philip H. S. Torr. Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * For more information about CRF-RNN, please visit the project website http://crfasrnn.torr.vision. */ namespace caffe { template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int C, int H, int W, int c, int h, int w) { Dtype value=0; if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[H*W*c+h*W+w]; } return value; } template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w) { Dtype value=0; if( n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[n*C*H*W + c*H*W + h*W + w]; } return value; } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int C, int H, int W, int c, int h, int w, Dtype value) { if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[H*W*c+h*W+w] = value; } } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w, Dtype value) { if(n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[n*C*H*W + c*H*W + h*W + w] = value; } } } // namespace caffe
code for sm_80
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
/*! * \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the * CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * This class itself is not a proper Caffe layer although it behaves like one to some degree. * * \authors Sadeep Jayasumana, Bernardino Romera-Paredes, Shuai Zheng, Zhizhong Su. * \version 1.0 * \date 2015 * \copyright Torr Vision Group, University of Oxford. * \details If you use this code, please consider citing the paper: * Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, * Chang Huang, Philip H. S. Torr. Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * For more information about CRF-RNN, please visit the project website http://crfasrnn.torr.vision. */ namespace caffe { template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int C, int H, int W, int c, int h, int w) { Dtype value=0; if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[H*W*c+h*W+w]; } return value; } template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w) { Dtype value=0; if( n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[n*C*H*W + c*H*W + h*W + w]; } return value; } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int C, int H, int W, int c, int h, int w, Dtype value) { if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[H*W*c+h*W+w] = value; } } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w, Dtype value) { if(n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[n*C*H*W + c*H*W + h*W + w] = value; } } } // namespace caffe
.file "tmpxft_000c1eb3_00000000-6_pixel_access.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2033: .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 .LFE2033: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2056: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2056: .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.
/*! * \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the * CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * This class itself is not a proper Caffe layer although it behaves like one to some degree. * * \authors Sadeep Jayasumana, Bernardino Romera-Paredes, Shuai Zheng, Zhizhong Su. * \version 1.0 * \date 2015 * \copyright Torr Vision Group, University of Oxford. * \details If you use this code, please consider citing the paper: * Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, * Chang Huang, Philip H. S. Torr. Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * For more information about CRF-RNN, please visit the project website http://crfasrnn.torr.vision. */ namespace caffe { template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int C, int H, int W, int c, int h, int w) { Dtype value=0; if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[H*W*c+h*W+w]; } return value; } template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w) { Dtype value=0; if( n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[n*C*H*W + c*H*W + h*W + w]; } return value; } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int C, int H, int W, int c, int h, int w, Dtype value) { if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[H*W*c+h*W+w] = value; } } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w, Dtype value) { if(n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[n*C*H*W + c*H*W + h*W + w] = value; } } } // namespace caffe
#include <hip/hip_runtime.h> /*! * \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the * CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * This class itself is not a proper Caffe layer although it behaves like one to some degree. * * \authors Sadeep Jayasumana, Bernardino Romera-Paredes, Shuai Zheng, Zhizhong Su. * \version 1.0 * \date 2015 * \copyright Torr Vision Group, University of Oxford. * \details If you use this code, please consider citing the paper: * Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, * Chang Huang, Philip H. S. Torr. Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * For more information about CRF-RNN, please visit the project website http://crfasrnn.torr.vision. */ namespace caffe { template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int C, int H, int W, int c, int h, int w) { Dtype value=0; if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[H*W*c+h*W+w]; } return value; } template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w) { Dtype value=0; if( n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[n*C*H*W + c*H*W + h*W + w]; } return value; } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int C, int H, int W, int c, int h, int w, Dtype value) { if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[H*W*c+h*W+w] = value; } } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w, Dtype value) { if(n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[n*C*H*W + c*H*W + h*W + w] = value; } } } // namespace caffe
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> /*! * \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the * CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * This class itself is not a proper Caffe layer although it behaves like one to some degree. * * \authors Sadeep Jayasumana, Bernardino Romera-Paredes, Shuai Zheng, Zhizhong Su. * \version 1.0 * \date 2015 * \copyright Torr Vision Group, University of Oxford. * \details If you use this code, please consider citing the paper: * Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, * Chang Huang, Philip H. S. Torr. Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * For more information about CRF-RNN, please visit the project website http://crfasrnn.torr.vision. */ namespace caffe { template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int C, int H, int W, int c, int h, int w) { Dtype value=0; if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[H*W*c+h*W+w]; } return value; } template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w) { Dtype value=0; if( n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[n*C*H*W + c*H*W + h*W + w]; } return value; } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int C, int H, int W, int c, int h, int w, Dtype value) { if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[H*W*c+h*W+w] = value; } } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w, Dtype value) { if(n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[n*C*H*W + c*H*W + h*W + w] = value; } } } // namespace caffe
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> /*! * \brief A helper class for {@link MultiStageMeanfieldLayer} class, which is the Caffe layer that implements the * CRF-RNN described in the paper: Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * This class itself is not a proper Caffe layer although it behaves like one to some degree. * * \authors Sadeep Jayasumana, Bernardino Romera-Paredes, Shuai Zheng, Zhizhong Su. * \version 1.0 * \date 2015 * \copyright Torr Vision Group, University of Oxford. * \details If you use this code, please consider citing the paper: * Shuai Zheng, Sadeep Jayasumana, Bernardino Romera-Paredes, Vibhav Vineet, Zhizhong Su, Dalong Du, * Chang Huang, Philip H. S. Torr. Conditional Random Fields as Recurrent Neural Networks. IEEE ICCV 2015. * * For more information about CRF-RNN, please visit the project website http://crfasrnn.torr.vision. */ namespace caffe { template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int C, int H, int W, int c, int h, int w) { Dtype value=0; if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[H*W*c+h*W+w]; } return value; } template <typename Dtype> __device__ Dtype get_gpu_pixel(const Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w) { Dtype value=0; if( n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { value = data[n*C*H*W + c*H*W + h*W + w]; } return value; } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int C, int H, int W, int c, int h, int w, Dtype value) { if( c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[H*W*c+h*W+w] = value; } } template <typename Dtype> __device__ void set_gpu_pixel(Dtype* data, int N, int C, int H, int W, int n, int c, int h, int w, Dtype value) { if(n>=0 && n<N && c>=0 && c<C && h>=0 && h<H && w>=0 && w<W) { data[n*C*H*W + c*H*W + h*W + w] = value; } } } // namespace caffe
.text .file "pixel_access.hip" .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_000c1eb3_00000000-6_pixel_access.cudafe1.cpp" .text #APP #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB2033: .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 .LFE2033: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2056: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2056: .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 "pixel_access.hip" .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
// Actually, there are no rounding errors due to results being accumulated in an arbitrary order.. // Therefore EPSILON = 0.0f is OK #define EPSILON 0.001f #define EPSILOND 0.0000001 extern "C" __global__ void compare(float *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabsf(C[myIndex] - C[myIndex + i*iterStep]) > EPSILON) myFaulty++; atomicAdd(faultyElems, myFaulty); } extern "C" __global__ void compareD(double *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabs(C[myIndex] - C[myIndex + i*iterStep]) > EPSILOND) myFaulty++; atomicAdd(faultyElems, myFaulty); }
code for sm_80 Function : compareD .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.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ IMAD.MOV.U32 R6, RZ, RZ, c[0x0][0x170] ; /* 0x00005c00ff067624 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0040*/ IMAD.MOV.U32 R8, RZ, RZ, c[0x0][0x174] ; /* 0x00005d00ff087624 */ /* 0x000fe200078e00ff */ /*0050*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e220000002200 */ /*0060*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fe200078e00ff */ /*0070*/ ISETP.GE.U32.AND P0, PT, R6, 0x2, PT ; /* 0x000000020600780c */ /* 0x000fe40003f06070 */ /*0080*/ S2R R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e640000002500 */ /*0090*/ ISETP.GE.U32.AND.EX P0, PT, R8, RZ, PT, P0 ; /* 0x000000ff0800720c */ /* 0x000fc40003f06100 */ /*00a0*/ S2R R7, SR_TID.X ; /* 0x0000000000077919 */ /* 0x000ea20000002100 */ /*00b0*/ IMAD R0, R0, c[0x0][0x4], R3 ; /* 0x0000010000007a24 */ /* 0x001fc800078e0203 */ /*00c0*/ IMAD R0, R0, c[0x0][0xc], R5 ; /* 0x0000030000007a24 */ /* 0x002fc800078e0205 */ /*00d0*/ IMAD R2, R0, c[0x0][0x0], R7 ; /* 0x0000000000027a24 */ /* 0x004fe400078e0207 */ /*00e0*/ @!P0 BRA 0x660 ; /* 0x0000057000008947 */ /* 0x000fea0003800000 */ /*00f0*/ LEA R4, P0, R2, c[0x0][0x160], 0x3 ; /* 0x0000580002047a11 */ /* 0x000fc800078018ff */ /*0100*/ LEA.HI.X R5, R2, c[0x0][0x164], RZ, 0x3, P0 ; /* 0x0000590002057a11 */ /* 0x000fe400000f1cff */ /*0110*/ IADD3 R0, P0, R6.reuse, -0x2, RZ ; /* 0xfffffffe06007810 */ /* 0x040fe40007f1e0ff */ /*0120*/ IADD3 R6, R6, -0x1, RZ ; /* 0xffffffff06067810 */ /* 0x000fe40007ffe0ff */ /*0130*/ ISETP.GE.U32.AND P1, PT, R0, 0x3, PT ; /* 0x000000030000780c */ /* 0x000fe20003f26070 */ /*0140*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff077624 */ /* 0x000fe200078e00ff */ /*0150*/ LOP3.LUT R0, R6, 0x3, RZ, 0xc0, !PT ; /* 0x0000000306007812 */ /* 0x000fe200078ec0ff */ /*0160*/ LDG.E.64 R4, [R4.64] ; /* 0x0000000604047981 */ /* 0x000f62000c1e1b00 */ /*0170*/ IADD3.X R6, R8, -0x1, RZ, P0, !PT ; /* 0xffffffff08067810 */ /* 0x000fe200007fe4ff */ /*0180*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe20000000000 */ /*0190*/ ISETP.NE.U32.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fe20003f05070 */ /*01a0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*01b0*/ ISETP.GE.U32.AND.EX P1, PT, R6, RZ, PT, P1 ; /* 0x000000ff0600720c */ /* 0x000fe20003f26110 */ /*01c0*/ IMAD R6, R7, c[0x0][0x4], RZ ; /* 0x0000010007067a24 */ /* 0x000fe200078e02ff */ /*01d0*/ ISETP.NE.AND.EX P0, PT, RZ, RZ, PT, P0 ; /* 0x000000ffff00720c */ /* 0x000fe20003f05300 */ /*01e0*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fc400078e00ff */ /*01f0*/ IMAD R6, R6, c[0x0][0xc], RZ ; /* 0x0000030006067a24 */ /* 0x000fc800078e02ff */ /*0200*/ IMAD R19, R6, c[0x0][0x10], RZ ; /* 0x0000040006137a24 */ /* 0x000fc800078e02ff */ /*0210*/ @!P1 BRA 0x500 ; /* 0x000002e000009947 */ /* 0x000fea0003800000 */ /*0220*/ IADD3 R27, P1, R2, R19, RZ ; /* 0x00000013021b7210 */ /* 0x000fe20007f3e0ff */ /*0230*/ IMAD.SHL.U32 R21, R19, 0x8, RZ ; /* 0x0000000813157824 */ /* 0x000fe200078e00ff */ /*0240*/ IADD3 R22, P2, R0, -c[0x0][0x170], RZ ; /* 0x80005c0000167a10 */ /* 0x000fe20007f5e0ff */ /*0250*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fe200078e00ff */ /*0260*/ SHF.R.U32.HI R23, RZ, 0x1d, R19 ; /* 0x0000001dff177819 */ /* 0x000fe20000011613 */ /*0270*/ IMAD.X R6, RZ, RZ, RZ, P1 ; /* 0x000000ffff067224 */ /* 0x000fe200008e06ff */ /*0280*/ LEA R26, P1, R27.reuse, c[0x0][0x160], 0x3 ; /* 0x000058001b1a7a11 */ /* 0x040fe200078218ff */ /*0290*/ IMAD.X R20, RZ, RZ, ~c[0x0][0x174], P2 ; /* 0x80005d00ff147624 */ /* 0x000fe200010e06ff */ /*02a0*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe40000000000 */ /*02b0*/ LEA.HI.X R27, R27, c[0x0][0x164], R6, 0x3, P1 ; /* 0x000059001b1b7a11 */ /* 0x000fe200008f1c06 */ /*02c0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fc60008000000 */ /*02d0*/ IADD3 R24, P1, R21, R26, RZ ; /* 0x0000001a15187210 */ /* 0x000fe20007f3e0ff */ /*02e0*/ LDG.E.64 R12, [R26.64] ; /* 0x000000061a0c7981 */ /* 0x000ea8000c1e1b00 */ /*02f0*/ IMAD.X R25, R23, 0x1, R27, P1 ; /* 0x0000000117197824 */ /* 0x000fe200008e061b */ /*0300*/ IADD3 R16, P1, R21, R24, RZ ; /* 0x0000001815107210 */ /* 0x000fc80007f3e0ff */ /*0310*/ LDG.E.64 R6, [R24.64] ; /* 0x0000000618067981 */ /* 0x000ee2000c1e1b00 */ /*0320*/ IMAD.X R17, R23, 0x1, R25, P1 ; /* 0x0000000117117824 */ /* 0x000fe200008e0619 */ /*0330*/ IADD3 R8, P1, R21, R16, RZ ; /* 0x0000001015087210 */ /* 0x000fc80007f3e0ff */ /*0340*/ LDG.E.64 R10, [R16.64] ; /* 0x00000006100a7981 */ /* 0x000f22000c1e1b00 */ /*0350*/ IMAD.X R9, R23, 0x1, R17, P1 ; /* 0x0000000117097824 */ /* 0x000fca00008e0611 */ /*0360*/ LDG.E.64 R14, [R8.64] ; /* 0x00000006080e7981 */ /* 0x000f22000c1e1b00 */ /*0370*/ UIADD3 UR5, UP0, UR5, 0x4, URZ ; /* 0x0000000405057890 */ /* 0x000fc8000ff1e03f */ /*0380*/ UIADD3.X UR4, URZ, UR4, URZ, UP0, !UPT ; /* 0x000000043f047290 */ /* 0x000fe200087fe43f */ /*0390*/ DADD R12, R4, -R12 ; /* 0x00000000040c7229 */ /* 0x024e0c000000080c */ /*03a0*/ DSETP.GT.AND P1, PT, |R12|, c[0x2][0x0], PT ; /* 0x008000000c00762a */ /* 0x001fc80003f24200 */ /*03b0*/ DADD R6, R4, -R6 ; /* 0x0000000004067229 */ /* 0x008e080000000806 */ /*03c0*/ DADD R10, R4, -R10 ; /* 0x00000000040a7229 */ /* 0x010e48000000080a */ /*03d0*/ DSETP.GT.AND P2, PT, |R6|, c[0x2][0x0], PT ; /* 0x008000000600762a */ /* 0x0010a40003f44200 */ /*03e0*/ IADD3 R6, R18, 0x1, RZ ; /* 0x0000000112067810 */ /* 0x001fe20007ffe0ff */ /*03f0*/ @!P1 IMAD.MOV R6, RZ, RZ, R18 ; /* 0x000000ffff069224 */ /* 0x000fe200078e0212 */ /*0400*/ DSETP.GT.AND P3, PT, |R10|, c[0x2][0x0], PT ; /* 0x008000000a00762a */ /* 0x0021e40003f64200 */ /*0410*/ IADD3 R10, P4, R22, UR5, RZ ; /* 0x00000005160a7c10 */ /* 0x001fe4000ff9e0ff */ /*0420*/ DADD R14, R4, -R14 ; /* 0x00000000040e7229 */ /* 0x000e22000000080e */ /*0430*/ IADD3 R7, R6, 0x1, RZ ; /* 0x0000000106077810 */ /* 0x000fe40007ffe0ff */ /*0440*/ ISETP.NE.U32.AND P1, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fc40003f25070 */ /*0450*/ IADD3.X R10, R20, UR4, RZ, P4, !PT ; /* 0x00000004140a7c10 */ /* 0x000fe2000a7fe4ff */ /*0460*/ @!P2 IMAD.MOV R7, RZ, RZ, R6 ; /* 0x000000ffff07a224 */ /* 0x004fe200078e0206 */ /*0470*/ DSETP.GT.AND P2, PT, |R14|, c[0x2][0x0], PT ; /* 0x008000000e00762a */ /* 0x001e240003f44200 */ /*0480*/ ISETP.NE.AND.EX P1, PT, R10, RZ, PT, P1 ; /* 0x000000ff0a00720c */ /* 0x000fe40003f25310 */ /*0490*/ IADD3 R6, R7, 0x1, RZ ; /* 0x0000000107067810 */ /* 0x000fe20007ffe0ff */ /*04a0*/ @!P3 IMAD.MOV R6, RZ, RZ, R7 ; /* 0x000000ffff06b224 */ /* 0x000fe200078e0207 */ /*04b0*/ IADD3 R26, P3, R21, R8, RZ ; /* 0x00000008151a7210 */ /* 0x000fc80007f7e0ff */ /*04c0*/ IADD3 R18, R6, 0x1, RZ ; /* 0x0000000106127810 */ /* 0x000fe20007ffe0ff */ /*04d0*/ IMAD.X R27, R23, 0x1, R9, P3 ; /* 0x00000001171b7824 */ /* 0x000fc600018e0609 */ /*04e0*/ @!P2 IMAD.MOV R18, RZ, RZ, R6 ; /* 0x000000ffff12a224 */ /* 0x001fe200078e0206 */ /*04f0*/ @P1 BRA 0x2d0 ; /* 0xfffffdd000001947 */ /* 0x000fea000383ffff */ /*0500*/ @!P0 BRA 0x660 ; /* 0x0000015000008947 */ /* 0x000fea0003800000 */ /*0510*/ IMAD.MOV.U32 R3, RZ, RZ, RZ ; /* 0x000000ffff037224 */ /* 0x000fe200078e00ff */ /*0520*/ IADD3 R8, P1, RZ, -R0, RZ ; /* 0x80000000ff087210 */ /* 0x000fe20007f3e0ff */ /*0530*/ IMAD R7, R19.reuse, UR4, RZ ; /* 0x0000000413077c24 */ /* 0x040fe4000f8e02ff */ /*0540*/ IMAD.WIDE.U32 R2, R19, UR5, R2 ; /* 0x0000000513027c25 */ /* 0x000fc8000f8e0002 */ /*0550*/ IMAD.IADD R7, R3, 0x1, R7 ; /* 0x0000000103077824 */ /* 0x000fe200078e0207 */ /*0560*/ LEA R6, P0, R2, c[0x0][0x160], 0x3 ; /* 0x0000580002067a11 */ /* 0x000fe200078018ff */ /*0570*/ IMAD.X R9, RZ, RZ, -0x1, P1 ; /* 0xffffffffff097424 */ /* 0x000fc600008e06ff */ /*0580*/ LEA.HI.X R7, R2, c[0x0][0x164], R7, 0x3, P0 ; /* 0x0000590002077a11 */ /* 0x000fca00000f1c07 */ /*0590*/ LDG.E.64 R2, [R6.64] ; /* 0x0000000606027981 */ /* 0x0000a2000c1e1b00 */ /*05a0*/ IADD3 R8, P0, R8, 0x1, RZ ; /* 0x0000000108087810 */ /* 0x000fe40007f1e0ff */ /*05b0*/ IADD3 R0, R18, 0x1, RZ ; /* 0x0000000112007810 */ /* 0x000fc60007ffe0ff */ /*05c0*/ IMAD.X R9, RZ, RZ, R9, P0 ; /* 0x000000ffff097224 */ /* 0x000fe200000e0609 */ /*05d0*/ ISETP.NE.U32.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe40003f05070 */ /*05e0*/ LEA R6, P2, R19, R6, 0x3 ; /* 0x0000000613067211 */ /* 0x001fe400078418ff */ /*05f0*/ ISETP.NE.AND.EX P0, PT, R9, RZ, PT, P0 ; /* 0x000000ff0900720c */ /* 0x000fe40003f05300 */ /*0600*/ LEA.HI.X R7, R19, R7, RZ, 0x3, P2 ; /* 0x0000000713077211 */ /* 0x000fe200010f1cff */ /*0610*/ DADD R2, R4, -R2 ; /* 0x0000000004027229 */ /* 0x024e0c0000000802 */ /*0620*/ DSETP.GT.AND P1, PT, |R2|, c[0x2][0x0], PT ; /* 0x008000000200762a */ /* 0x001e1c0003f24200 */ /*0630*/ @!P1 IMAD.MOV R0, RZ, RZ, R18 ; /* 0x000000ffff009224 */ /* 0x001fc800078e0212 */ /*0640*/ IMAD.MOV.U32 R18, RZ, RZ, R0 ; /* 0x000000ffff127224 */ /* 0x000fe200078e0000 */ /*0650*/ @P0 BRA 0x590 ; /* 0xffffff3000000947 */ /* 0x000fea000383ffff */ /*0660*/ S2R R0, SR_LANEID ; /* 0x0000000000007919 */ /* 0x000e220000000000 */ /*0670*/ REDUX.SUM UR5, R18 ; /* 0x00000000120573c4 */ /* 0x000e62000000c000 */ /*0680*/ VOTEU.ANY UR4, UPT, PT ; /* 0x0000000000047886 */ /* 0x000fe200038e0100 */ /*0690*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff027624 */ /* 0x000fe200078e00ff */ /*06a0*/ UFLO.U32 UR4, UR4 ; /* 0x00000004000472bd */ /* 0x000fe200080e0000 */ /*06b0*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff037624 */ /* 0x000fca00078e00ff */ /*06c0*/ ISETP.EQ.U32.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x001fe2000bf02070 */ /*06d0*/ IMAD.U32 R5, RZ, RZ, UR5 ; /* 0x00000005ff057e24 */ /* 0x022fd8000f8e00ff */ /*06e0*/ @P0 RED.E.ADD.STRONG.GPU [R2.64], R5 ; /* 0x000000050200098e */ /* 0x000fe2000c10e186 */ /*06f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0700*/ BRA 0x700; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0710*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0720*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0730*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0740*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0750*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0760*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0770*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0780*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0790*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : compare .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.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ IMAD.MOV.U32 R8, RZ, RZ, c[0x0][0x170] ; /* 0x00005c00ff087624 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0040*/ IMAD.MOV.U32 R9, RZ, RZ, c[0x0][0x174] ; /* 0x00005d00ff097624 */ /* 0x000fe200078e00ff */ /*0050*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e220000002200 */ /*0060*/ IMAD.MOV.U32 R6, RZ, RZ, RZ ; /* 0x000000ffff067224 */ /* 0x000fe200078e00ff */ /*0070*/ ISETP.GE.U32.AND P0, PT, R8, 0x2, PT ; /* 0x000000020800780c */ /* 0x000fe40003f06070 */ /*0080*/ S2R R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e640000002500 */ /*0090*/ ISETP.GE.U32.AND.EX P0, PT, R9, RZ, PT, P0 ; /* 0x000000ff0900720c */ /* 0x000fc40003f06100 */ /*00a0*/ S2R R7, SR_TID.X ; /* 0x0000000000077919 */ /* 0x000ea20000002100 */ /*00b0*/ IMAD R0, R0, c[0x0][0x4], R3 ; /* 0x0000010000007a24 */ /* 0x001fc800078e0203 */ /*00c0*/ IMAD R0, R0, c[0x0][0xc], R5 ; /* 0x0000030000007a24 */ /* 0x002fc800078e0205 */ /*00d0*/ IMAD R2, R0, c[0x0][0x0], R7 ; /* 0x0000000000027a24 */ /* 0x004fe400078e0207 */ /*00e0*/ @!P0 BRA 0x690 ; /* 0x000005a000008947 */ /* 0x000fea0003800000 */ /*00f0*/ LEA R4, P0, R2, c[0x0][0x160], 0x2 ; /* 0x0000580002047a11 */ /* 0x000fc800078010ff */ /*0100*/ LEA.HI.X R5, R2, c[0x0][0x164], RZ, 0x2, P0 ; /* 0x0000590002057a11 */ /* 0x000fe400000f14ff */ /*0110*/ IADD3 R6, P0, R8, -0x2, RZ ; /* 0xfffffffe08067810 */ /* 0x000fe20007f1e0ff */ /*0120*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff077624 */ /* 0x000fe200078e00ff */ /*0130*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe20000000000 */ /*0140*/ LDG.E R0, [R4.64] ; /* 0x0000000604007981 */ /* 0x000162000c1e1900 */ /*0150*/ ISETP.GE.U32.AND P1, PT, R6, 0x3, PT ; /* 0x000000030600780c */ /* 0x000fe20003f26070 */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ IADD3.X R6, R9, -0x1, RZ, P0, !PT ; /* 0xffffffff09067810 */ /* 0x000fe400007fe4ff */ /*0180*/ IADD3 R8, R8, -0x1, RZ ; /* 0xffffffff08087810 */ /* 0x000fc40007ffe0ff */ /*0190*/ ISETP.GE.U32.AND.EX P1, PT, R6, RZ, PT, P1 ; /* 0x000000ff0600720c */ /* 0x000fe20003f26110 */ /*01a0*/ IMAD R6, R7, c[0x0][0x4], RZ ; /* 0x0000010007067a24 */ /* 0x000fe200078e02ff */ /*01b0*/ LOP3.LUT R8, R8, 0x3, RZ, 0xc0, !PT ; /* 0x0000000308087812 */ /* 0x000fc600078ec0ff */ /*01c0*/ IMAD R7, R6, c[0x0][0xc], RZ ; /* 0x0000030006077a24 */ /* 0x000fe200078e02ff */ /*01d0*/ ISETP.NE.U32.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe20003f05070 */ /*01e0*/ IMAD.MOV.U32 R6, RZ, RZ, RZ ; /* 0x000000ffff067224 */ /* 0x000fe400078e00ff */ /*01f0*/ IMAD R7, R7, c[0x0][0x10], RZ ; /* 0x0000040007077a24 */ /* 0x000fe200078e02ff */ /*0200*/ ISETP.NE.AND.EX P0, PT, RZ, RZ, PT, P0 ; /* 0x000000ffff00720c */ /* 0x000fc60003f05300 */ /*0210*/ @!P1 BRA 0x510 ; /* 0x000002f000009947 */ /* 0x000ff40003800000 */ /*0220*/ IADD3 R4, P1, R2, R7, RZ ; /* 0x0000000702047210 */ /* 0x001fe20007f3e0ff */ /*0230*/ IMAD.SHL.U32 R9, R7, 0x4, RZ ; /* 0x0000000407097824 */ /* 0x000fe200078e00ff */ /*0240*/ IADD3 R18, P2, R8, -c[0x0][0x170], RZ ; /* 0x80005c0008127a10 */ /* 0x000fe20007f5e0ff */ /*0250*/ IMAD.MOV.U32 R6, RZ, RZ, RZ ; /* 0x000000ffff067224 */ /* 0x000fe200078e00ff */ /*0260*/ SHF.R.U32.HI R15, RZ, 0x1e, R7 ; /* 0x0000001eff0f7819 */ /* 0x000fe20000011607 */ /*0270*/ IMAD.X R5, RZ, RZ, RZ, P1 ; /* 0x000000ffff057224 */ /* 0x000fe200008e06ff */ /*0280*/ LEA R16, P1, R4.reuse, c[0x0][0x160], 0x2 ; /* 0x0000580004107a11 */ /* 0x040fe200078210ff */ /*0290*/ IMAD.X R20, RZ, RZ, ~c[0x0][0x174], P2 ; /* 0x80005d00ff147624 */ /* 0x000fe200010e06ff */ /*02a0*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe40000000000 */ /*02b0*/ LEA.HI.X R4, R4, c[0x0][0x164], R5, 0x2, P1 ; /* 0x0000590004047a11 */ /* 0x000fe200008f1405 */ /*02c0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fc80008000000 */ /*02d0*/ IMAD.MOV.U32 R17, RZ, RZ, R4 ; /* 0x000000ffff117224 */ /* 0x000fe200078e0004 */ /*02e0*/ IADD3 R10, P1, R9, R16, RZ ; /* 0x00000010090a7210 */ /* 0x000fca0007f3e0ff */ /*02f0*/ LDG.E R17, [R16.64] ; /* 0x0000000610117981 */ /* 0x000ea2000c1e1900 */ /*0300*/ IMAD.X R11, R15, 0x1, R4, P1 ; /* 0x000000010f0b7824 */ /* 0x000fe200008e0604 */ /*0310*/ IADD3 R12, P1, R9, R10, RZ ; /* 0x0000000a090c7210 */ /* 0x000fc80007f3e0ff */ /*0320*/ LDG.E R19, [R10.64] ; /* 0x000000060a137981 */ /* 0x0000e2000c1e1900 */ /*0330*/ IMAD.X R13, R15, 0x1, R11, P1 ; /* 0x000000010f0d7824 */ /* 0x000fe200008e060b */ /*0340*/ IADD3 R4, P1, R9, R12, RZ ; /* 0x0000000c09047210 */ /* 0x000fc80007f3e0ff */ /*0350*/ LDG.E R21, [R12.64] ; /* 0x000000060c157981 */ /* 0x000f22000c1e1900 */ /*0360*/ IMAD.X R5, R15, 0x1, R13, P1 ; /* 0x000000010f057824 */ /* 0x000fca00008e060d */ /*0370*/ LDG.E R23, [R4.64] ; /* 0x0000000604177981 */ /* 0x000f22000c1e1900 */ /*0380*/ UIADD3 UR5, UP0, UR5, 0x4, URZ ; /* 0x0000000405057890 */ /* 0x000fc8000ff1e03f */ /*0390*/ UIADD3.X UR4, URZ, UR4, URZ, UP0, !UPT ; /* 0x000000043f047290 */ /* 0x000fe400087fe43f */ /*03a0*/ IADD3 R10, P4, R18, UR5, RZ ; /* 0x00000005120a7c10 */ /* 0x001fc8000ff9e0ff */ /*03b0*/ IADD3.X R11, R20, UR4, RZ, P4, !PT ; /* 0x00000004140b7c10 */ /* 0x000fe2000a7fe4ff */ /*03c0*/ FADD R14, R0, -R17 ; /* 0x80000011000e7221 */ /* 0x024fca0000000000 */ /*03d0*/ FSETP.GT.AND P1, PT, |R14|, 0.0010000000474974513054, PT ; /* 0x3a83126f0e00780b */ /* 0x000fe20003f24200 */ /*03e0*/ FADD R19, R0, -R19 ; /* 0x8000001300137221 */ /* 0x008fe20000000000 */ /*03f0*/ IADD3 R14, R6, 0x1, RZ ; /* 0x00000001060e7810 */ /* 0x000fc80007ffe0ff */ /*0400*/ FSETP.GT.AND P2, PT, |R19|, 0.0010000000474974513054, PT ; /* 0x3a83126f1300780b */ /* 0x000fe20003f44200 */ /*0410*/ FADD R21, R0, -R21 ; /* 0x8000001500157221 */ /* 0x010fca0000000000 */ /*0420*/ FSETP.GT.AND P3, PT, |R21|, 0.0010000000474974513054, PT ; /* 0x3a83126f1500780b */ /* 0x000fe20003f64200 */ /*0430*/ @!P1 IMAD.MOV R14, RZ, RZ, R6 ; /* 0x000000ffff0e9224 */ /* 0x000fe200078e0206 */ /*0440*/ ISETP.NE.U32.AND P1, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fe20003f25070 */ /*0450*/ FADD R23, R0, -R23 ; /* 0x8000001700177221 */ /* 0x000fc60000000000 */ /*0460*/ IADD3 R6, R14, 0x1, RZ ; /* 0x000000010e067810 */ /* 0x000fe20007ffe0ff */ /*0470*/ @!P2 IMAD.MOV R6, RZ, RZ, R14 ; /* 0x000000ffff06a224 */ /* 0x000fe200078e020e */ /*0480*/ ISETP.NE.AND.EX P1, PT, R11, RZ, PT, P1 ; /* 0x000000ff0b00720c */ /* 0x000fe40003f25310 */ /*0490*/ FSETP.GT.AND P2, PT, |R23|, 0.0010000000474974513054, PT ; /* 0x3a83126f1700780b */ /* 0x000fe40003f44200 */ /*04a0*/ IADD3 R10, R6, 0x1, RZ ; /* 0x00000001060a7810 */ /* 0x000fe20007ffe0ff */ /*04b0*/ @!P3 IMAD.MOV R10, RZ, RZ, R6 ; /* 0x000000ffff0ab224 */ /* 0x000fe200078e0206 */ /*04c0*/ IADD3 R16, P3, R9, R4, RZ ; /* 0x0000000409107210 */ /* 0x000fc80007f7e0ff */ /*04d0*/ IADD3 R6, R10, 0x1, RZ ; /* 0x000000010a067810 */ /* 0x000fe20007ffe0ff */ /*04e0*/ IMAD.X R4, R15, 0x1, R5, P3 ; /* 0x000000010f047824 */ /* 0x000fc800018e0605 */ /*04f0*/ @!P2 IMAD.MOV R6, RZ, RZ, R10 ; /* 0x000000ffff06a224 */ /* 0x000fe200078e020a */ /*0500*/ @P1 BRA 0x2d0 ; /* 0xfffffdc000001947 */ /* 0x000fea000383ffff */ /*0510*/ @!P0 BRA 0x690 ; /* 0x0000017000008947 */ /* 0x001fea0003800000 */ /*0520*/ IMAD.MOV.U32 R3, RZ, RZ, RZ ; /* 0x000000ffff037224 */ /* 0x000fe200078e00ff */ /*0530*/ IADD3 R8, P1, RZ, -R8, RZ ; /* 0x80000008ff087210 */ /* 0x000fe20007f3e0ff */ /*0540*/ IMAD R11, R7.reuse, UR4, RZ ; /* 0x00000004070b7c24 */ /* 0x040fe4000f8e02ff */ /*0550*/ IMAD.WIDE.U32 R2, R7, UR5, R2 ; /* 0x0000000507027c25 */ /* 0x000fc8000f8e0002 */ /*0560*/ IMAD.IADD R11, R3, 0x1, R11 ; /* 0x00000001030b7824 */ /* 0x000fe200078e020b */ /*0570*/ LEA R10, P0, R2, c[0x0][0x160], 0x2 ; /* 0x00005800020a7a11 */ /* 0x000fe200078010ff */ /*0580*/ IMAD.X R5, RZ, RZ, -0x1, P1 ; /* 0xffffffffff057424 */ /* 0x000fc600008e06ff */ /*0590*/ LEA.HI.X R11, R2, c[0x0][0x164], R11, 0x2, P0 ; /* 0x00005900020b7a11 */ /* 0x000fca00000f140b */ /*05a0*/ IMAD.MOV.U32 R3, RZ, RZ, R11 ; /* 0x000000ffff037224 */ /* 0x000fe400078e000b */ /*05b0*/ IMAD.MOV.U32 R2, RZ, RZ, R10 ; /* 0x000000ffff027224 */ /* 0x000fca00078e000a */ /*05c0*/ LDG.E R3, [R2.64] ; /* 0x0000000602037981 */ /* 0x000ea2000c1e1900 */ /*05d0*/ IADD3 R8, P0, R8, 0x1, RZ ; /* 0x0000000108087810 */ /* 0x000fe40007f1e0ff */ /*05e0*/ LEA R10, P2, R7, R10, 0x2 ; /* 0x0000000a070a7211 */ /* 0x000fc600078410ff */ /*05f0*/ IMAD.X R5, RZ, RZ, R5, P0 ; /* 0x000000ffff057224 */ /* 0x000fe200000e0605 */ /*0600*/ ISETP.NE.U32.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe40003f05070 */ /*0610*/ LEA.HI.X R11, R7, R11, RZ, 0x2, P2 ; /* 0x0000000b070b7211 */ /* 0x000fe400010f14ff */ /*0620*/ ISETP.NE.AND.EX P0, PT, R5, RZ, PT, P0 ; /* 0x000000ff0500720c */ /* 0x000fe20003f05300 */ /*0630*/ FADD R4, R0, -R3 ; /* 0x8000000300047221 */ /* 0x024fca0000000000 */ /*0640*/ FSETP.GT.AND P1, PT, |R4|, 0.0010000000474974513054, PT ; /* 0x3a83126f0400780b */ /* 0x000fe40003f24200 */ /*0650*/ IADD3 R4, R6, 0x1, RZ ; /* 0x0000000106047810 */ /* 0x000fd60007ffe0ff */ /*0660*/ @!P1 IMAD.MOV R4, RZ, RZ, R6 ; /* 0x000000ffff049224 */ /* 0x000fc800078e0206 */ /*0670*/ IMAD.MOV.U32 R6, RZ, RZ, R4 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0004 */ /*0680*/ @P0 BRA 0x5a0 ; /* 0xffffff1000000947 */ /* 0x000fea000383ffff */ /*0690*/ S2R R0, SR_LANEID ; /* 0x0000000000007919 */ /* 0x020e220000000000 */ /*06a0*/ REDUX.SUM UR5, R6 ; /* 0x00000000060573c4 */ /* 0x000e62000000c000 */ /*06b0*/ VOTEU.ANY UR4, UPT, PT ; /* 0x0000000000047886 */ /* 0x000fe200038e0100 */ /*06c0*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff027624 */ /* 0x000fe200078e00ff */ /*06d0*/ UFLO.U32 UR4, UR4 ; /* 0x00000004000472bd */ /* 0x000fe200080e0000 */ /*06e0*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff037624 */ /* 0x000fca00078e00ff */ /*06f0*/ ISETP.EQ.U32.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x001fe2000bf02070 */ /*0700*/ IMAD.U32 R5, RZ, RZ, UR5 ; /* 0x00000005ff057e24 */ /* 0x002fd8000f8e00ff */ /*0710*/ @P0 RED.E.ADD.STRONG.GPU [R2.64], R5 ; /* 0x000000050200098e */ /* 0x000fe2000c10e186 */ /*0720*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0730*/ BRA 0x730; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0740*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0750*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0760*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0770*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0780*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0790*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
// Actually, there are no rounding errors due to results being accumulated in an arbitrary order.. // Therefore EPSILON = 0.0f is OK #define EPSILON 0.001f #define EPSILOND 0.0000001 extern "C" __global__ void compare(float *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabsf(C[myIndex] - C[myIndex + i*iterStep]) > EPSILON) myFaulty++; atomicAdd(faultyElems, myFaulty); } extern "C" __global__ void compareD(double *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabs(C[myIndex] - C[myIndex + i*iterStep]) > EPSILOND) myFaulty++; atomicAdd(faultyElems, myFaulty); }
.file "tmpxft_00091c21_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 _Z29__device_stub__Z7comparePfPimPfPim .type _Z29__device_stub__Z7comparePfPimPfPim, @function _Z29__device_stub__Z7comparePfPimPfPim: .LFB2051: .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 compare(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z29__device_stub__Z7comparePfPimPfPim, .-_Z29__device_stub__Z7comparePfPimPfPim .globl compare .type compare, @function compare: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z29__device_stub__Z7comparePfPimPfPim addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size compare, .-compare .globl _Z30__device_stub__Z8compareDPdPimPdPim .type _Z30__device_stub__Z8compareDPdPimPdPim, @function _Z30__device_stub__Z8compareDPdPimPdPim: .LFB2053: .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 .L15 .L11: movq 120(%rsp), %rax subq %fs:40, %rax jne .L16 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .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 compareD(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L11 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2053: .size _Z30__device_stub__Z8compareDPdPimPdPim, .-_Z30__device_stub__Z8compareDPdPimPdPim .globl compareD .type compareD, @function compareD: .LFB2054: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z8compareDPdPimPdPim addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2054: .size compareD, .-compareD .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "compareD" .LC1: .string "compare" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2056: .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 compareD(%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 .LC1(%rip), %rdx movq %rdx, %rcx leaq compare(%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 .LFE2056: .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.
// Actually, there are no rounding errors due to results being accumulated in an arbitrary order.. // Therefore EPSILON = 0.0f is OK #define EPSILON 0.001f #define EPSILOND 0.0000001 extern "C" __global__ void compare(float *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabsf(C[myIndex] - C[myIndex + i*iterStep]) > EPSILON) myFaulty++; atomicAdd(faultyElems, myFaulty); } extern "C" __global__ void compareD(double *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabs(C[myIndex] - C[myIndex + i*iterStep]) > EPSILOND) myFaulty++; atomicAdd(faultyElems, myFaulty); }
#include <hip/hip_runtime.h> // Actually, there are no rounding errors due to results being accumulated in an arbitrary order.. // Therefore EPSILON = 0.0f is OK #define EPSILON 0.001f #define EPSILOND 0.0000001 extern "C" __global__ void compare(float *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabsf(C[myIndex] - C[myIndex + i*iterStep]) > EPSILON) myFaulty++; atomicAdd(faultyElems, myFaulty); } extern "C" __global__ void compareD(double *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabs(C[myIndex] - C[myIndex + i*iterStep]) > EPSILOND) myFaulty++; atomicAdd(faultyElems, myFaulty); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> // Actually, there are no rounding errors due to results being accumulated in an arbitrary order.. // Therefore EPSILON = 0.0f is OK #define EPSILON 0.001f #define EPSILOND 0.0000001 extern "C" __global__ void compare(float *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabsf(C[myIndex] - C[myIndex + i*iterStep]) > EPSILON) myFaulty++; atomicAdd(faultyElems, myFaulty); } extern "C" __global__ void compareD(double *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabs(C[myIndex] - C[myIndex + i*iterStep]) > EPSILOND) myFaulty++; atomicAdd(faultyElems, myFaulty); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected compare .globl compare .p2align 8 .type compare,@function compare: s_load_b64 s[2:3], s[0:1], 0x10 v_mov_b32_e32 v2, 0 s_waitcnt lgkmcnt(0) v_cmp_lt_u64_e64 s4, s[2:3], 2 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s4 s_cbranch_vccnz .LBB0_3 s_clause 0x1 s_load_b32 s8, s[0:1], 0x24 s_load_b64 s[4:5], s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 s_load_b64 s[6:7], s[0:1], 0x0 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s9, s8, 16 s_and_b32 s8, s8, 0xffff v_mad_u64_u32 v[2:3], null, s15, s9, v[1:2] s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_mad_u64_u32 v[3:4], null, v2, s4, s[14:15] s_mul_i32 s4, s4, s8 s_mul_i32 s4, s4, s5 s_mov_b32 s5, 0 s_mul_i32 s4, s4, s9 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_lshl_b64 s[4:5], s[4:5], 2 v_mad_u64_u32 v[1:2], null, v3, s8, v[0:1] v_mov_b32_e32 v2, 0 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, s6, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo s_add_u32 s6, s6, s4 s_addc_u32 s7, s7, s5 v_add_co_u32 v0, vcc_lo, s6, v0 global_load_b32 v3, v[2:3], off v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo v_mov_b32_e32 v2, 0 .LBB0_2: global_load_b32 v4, v[0:1], off v_add_co_u32 v0, vcc_lo, v0, s4 v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) s_cmp_eq_u64 s[2:3], 0 s_waitcnt vmcnt(0) v_sub_f32_e32 v4, v3, v4 v_cmp_lt_f32_e64 vcc_lo, 0x3a83126f, |v4| v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo s_cbranch_scc0 .LBB0_2 .LBB0_3: s_mov_b32 s3, exec_lo s_mov_b32 s2, 0 .LBB0_4: s_ctz_i32_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_readlane_b32 s5, v2, s4 s_lshl_b32 s4, 1, s4 s_and_not1_b32 s3, s3, s4 s_delay_alu instid0(VALU_DEP_1) s_add_i32 s2, s2, s5 s_cmp_lg_u32 s3, 0 s_cbranch_scc1 .LBB0_4 v_mbcnt_lo_u32_b32 v0, exec_lo, 0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v0 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB0_7 s_load_b64 s[0:1], s[0:1], 0x8 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 s_waitcnt lgkmcnt(0) global_atomic_add_u32 v0, v1, s[0:1] .LBB0_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel compare .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 compare, .Lfunc_end0-compare .section .AMDGPU.csdata,"",@progbits .text .protected compareD .globl compareD .p2align 8 .type compareD,@function compareD: s_load_b64 s[2:3], s[0:1], 0x10 v_mov_b32_e32 v4, 0 s_waitcnt lgkmcnt(0) v_cmp_lt_u64_e64 s4, s[2:3], 2 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s4 s_cbranch_vccnz .LBB1_3 s_clause 0x1 s_load_b32 s8, s[0:1], 0x24 s_load_b64 s[4:5], s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 s_load_b64 s[6:7], s[0:1], 0x0 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s9, s8, 16 s_and_b32 s8, s8, 0xffff v_mad_u64_u32 v[2:3], null, s15, s9, v[1:2] s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(VALU_DEP_1) v_mad_u64_u32 v[3:4], null, v2, s4, s[14:15] s_mul_i32 s4, s4, s8 v_mov_b32_e32 v4, 0 s_mul_i32 s4, s4, s5 s_mov_b32 s5, 0 s_mul_i32 s4, s4, s9 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2) s_lshl_b64 s[4:5], s[4:5], 3 v_mad_u64_u32 v[1:2], null, v3, s8, v[0:1] v_mov_b32_e32 v2, 0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 3, v[1:2] v_add_co_u32 v0, vcc_lo, s6, v2 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s7, v3, vcc_lo s_add_u32 s6, s6, s4 s_addc_u32 s7, s7, s5 v_add_co_u32 v2, vcc_lo, s6, v2 global_load_b64 v[0:1], v[0:1], off v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo s_mov_b32 s7, 0x3e7ad7f2 s_mov_b32 s6, 0x9abcaf48 .LBB1_2: global_load_b64 v[5:6], v[2:3], off v_add_co_u32 v2, vcc_lo, v2, s4 v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) s_cmp_eq_u64 s[2:3], 0 s_waitcnt vmcnt(0) v_add_f64 v[5:6], v[0:1], -v[5:6] v_cmp_gt_f64_e64 vcc_lo, |v[5:6]|, s[6:7] v_add_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo s_cbranch_scc0 .LBB1_2 .LBB1_3: s_mov_b32 s3, exec_lo s_mov_b32 s2, 0 .LBB1_4: s_ctz_i32_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_readlane_b32 s5, v4, s4 s_lshl_b32 s4, 1, s4 s_and_not1_b32 s3, s3, s4 s_delay_alu instid0(VALU_DEP_1) s_add_i32 s2, s2, s5 s_cmp_lg_u32 s3, 0 s_cbranch_scc1 .LBB1_4 v_mbcnt_lo_u32_b32 v0, exec_lo, 0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v0 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB1_7 s_load_b64 s[0:1], s[0:1], 0x8 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 s_waitcnt lgkmcnt(0) global_atomic_add_u32 v0, v1, s[0:1] .LBB1_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel compareD .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 7 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size compareD, .Lfunc_end1-compareD .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: 8 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: compare .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: compare.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 - .offset: 16 .size: 8 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: compareD .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: compareD.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 7 .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> // Actually, there are no rounding errors due to results being accumulated in an arbitrary order.. // Therefore EPSILON = 0.0f is OK #define EPSILON 0.001f #define EPSILOND 0.0000001 extern "C" __global__ void compare(float *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabsf(C[myIndex] - C[myIndex + i*iterStep]) > EPSILON) myFaulty++; atomicAdd(faultyElems, myFaulty); } extern "C" __global__ void compareD(double *C, int *faultyElems, size_t iters) { size_t iterStep = blockDim.x*blockDim.y*gridDim.x*gridDim.y; size_t myIndex = (blockIdx.y*blockDim.y + threadIdx.y)* // Y gridDim.x*blockDim.x + // W blockIdx.x*blockDim.x + threadIdx.x; // X int myFaulty = 0; for (size_t i = 1; i < iters; ++i) if (fabs(C[myIndex] - C[myIndex + i*iterStep]) > EPSILOND) myFaulty++; atomicAdd(faultyElems, myFaulty); }
.text .file "compare.hip" .globl __device_stub__compare # -- Begin function __device_stub__compare .p2align 4, 0x90 .type __device_stub__compare,@function __device_stub__compare: # @__device_stub__compare .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 $compare, %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 __device_stub__compare, .Lfunc_end0-__device_stub__compare .cfi_endproc # -- End function .globl __device_stub__compareD # -- Begin function __device_stub__compareD .p2align 4, 0x90 .type __device_stub__compareD,@function __device_stub__compareD: # @__device_stub__compareD .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 $compareD, %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_end1: .size __device_stub__compareD, .Lfunc_end1-__device_stub__compareD .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $compare, %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 $compareD, %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_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 compare,@object # @compare .section .rodata,"a",@progbits .globl compare .p2align 3, 0x0 compare: .quad __device_stub__compare .size compare, 8 .type compareD,@object # @compareD .globl compareD .p2align 3, 0x0 compareD: .quad __device_stub__compareD .size compareD, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "compare" .size .L__unnamed_1, 8 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "compareD" .size .L__unnamed_2, 9 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .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 __device_stub__compare .addrsig_sym __device_stub__compareD .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym compare .addrsig_sym compareD .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 : compareD .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.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ IMAD.MOV.U32 R6, RZ, RZ, c[0x0][0x170] ; /* 0x00005c00ff067624 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0040*/ IMAD.MOV.U32 R8, RZ, RZ, c[0x0][0x174] ; /* 0x00005d00ff087624 */ /* 0x000fe200078e00ff */ /*0050*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e220000002200 */ /*0060*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fe200078e00ff */ /*0070*/ ISETP.GE.U32.AND P0, PT, R6, 0x2, PT ; /* 0x000000020600780c */ /* 0x000fe40003f06070 */ /*0080*/ S2R R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e640000002500 */ /*0090*/ ISETP.GE.U32.AND.EX P0, PT, R8, RZ, PT, P0 ; /* 0x000000ff0800720c */ /* 0x000fc40003f06100 */ /*00a0*/ S2R R7, SR_TID.X ; /* 0x0000000000077919 */ /* 0x000ea20000002100 */ /*00b0*/ IMAD R0, R0, c[0x0][0x4], R3 ; /* 0x0000010000007a24 */ /* 0x001fc800078e0203 */ /*00c0*/ IMAD R0, R0, c[0x0][0xc], R5 ; /* 0x0000030000007a24 */ /* 0x002fc800078e0205 */ /*00d0*/ IMAD R2, R0, c[0x0][0x0], R7 ; /* 0x0000000000027a24 */ /* 0x004fe400078e0207 */ /*00e0*/ @!P0 BRA 0x660 ; /* 0x0000057000008947 */ /* 0x000fea0003800000 */ /*00f0*/ LEA R4, P0, R2, c[0x0][0x160], 0x3 ; /* 0x0000580002047a11 */ /* 0x000fc800078018ff */ /*0100*/ LEA.HI.X R5, R2, c[0x0][0x164], RZ, 0x3, P0 ; /* 0x0000590002057a11 */ /* 0x000fe400000f1cff */ /*0110*/ IADD3 R0, P0, R6.reuse, -0x2, RZ ; /* 0xfffffffe06007810 */ /* 0x040fe40007f1e0ff */ /*0120*/ IADD3 R6, R6, -0x1, RZ ; /* 0xffffffff06067810 */ /* 0x000fe40007ffe0ff */ /*0130*/ ISETP.GE.U32.AND P1, PT, R0, 0x3, PT ; /* 0x000000030000780c */ /* 0x000fe20003f26070 */ /*0140*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff077624 */ /* 0x000fe200078e00ff */ /*0150*/ LOP3.LUT R0, R6, 0x3, RZ, 0xc0, !PT ; /* 0x0000000306007812 */ /* 0x000fe200078ec0ff */ /*0160*/ LDG.E.64 R4, [R4.64] ; /* 0x0000000604047981 */ /* 0x000f62000c1e1b00 */ /*0170*/ IADD3.X R6, R8, -0x1, RZ, P0, !PT ; /* 0xffffffff08067810 */ /* 0x000fe200007fe4ff */ /*0180*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe20000000000 */ /*0190*/ ISETP.NE.U32.AND P0, PT, R0, RZ, PT ; /* 0x000000ff0000720c */ /* 0x000fe20003f05070 */ /*01a0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*01b0*/ ISETP.GE.U32.AND.EX P1, PT, R6, RZ, PT, P1 ; /* 0x000000ff0600720c */ /* 0x000fe20003f26110 */ /*01c0*/ IMAD R6, R7, c[0x0][0x4], RZ ; /* 0x0000010007067a24 */ /* 0x000fe200078e02ff */ /*01d0*/ ISETP.NE.AND.EX P0, PT, RZ, RZ, PT, P0 ; /* 0x000000ffff00720c */ /* 0x000fe20003f05300 */ /*01e0*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fc400078e00ff */ /*01f0*/ IMAD R6, R6, c[0x0][0xc], RZ ; /* 0x0000030006067a24 */ /* 0x000fc800078e02ff */ /*0200*/ IMAD R19, R6, c[0x0][0x10], RZ ; /* 0x0000040006137a24 */ /* 0x000fc800078e02ff */ /*0210*/ @!P1 BRA 0x500 ; /* 0x000002e000009947 */ /* 0x000fea0003800000 */ /*0220*/ IADD3 R27, P1, R2, R19, RZ ; /* 0x00000013021b7210 */ /* 0x000fe20007f3e0ff */ /*0230*/ IMAD.SHL.U32 R21, R19, 0x8, RZ ; /* 0x0000000813157824 */ /* 0x000fe200078e00ff */ /*0240*/ IADD3 R22, P2, R0, -c[0x0][0x170], RZ ; /* 0x80005c0000167a10 */ /* 0x000fe20007f5e0ff */ /*0250*/ IMAD.MOV.U32 R18, RZ, RZ, RZ ; /* 0x000000ffff127224 */ /* 0x000fe200078e00ff */ /*0260*/ SHF.R.U32.HI R23, RZ, 0x1d, R19 ; /* 0x0000001dff177819 */ /* 0x000fe20000011613 */ /*0270*/ IMAD.X R6, RZ, RZ, RZ, P1 ; /* 0x000000ffff067224 */ /* 0x000fe200008e06ff */ /*0280*/ LEA R26, P1, R27.reuse, c[0x0][0x160], 0x3 ; /* 0x000058001b1a7a11 */ /* 0x040fe200078218ff */ /*0290*/ IMAD.X R20, RZ, RZ, ~c[0x0][0x174], P2 ; /* 0x80005d00ff147624 */ /* 0x000fe200010e06ff */ /*02a0*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe40000000000 */ /*02b0*/ LEA.HI.X R27, R27, c[0x0][0x164], R6, 0x3, P1 ; /* 0x000059001b1b7a11 */ /* 0x000fe200008f1c06 */ /*02c0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fc60008000000 */ /*02d0*/ IADD3 R24, P1, R21, R26, RZ ; /* 0x0000001a15187210 */ /* 0x000fe20007f3e0ff */ /*02e0*/ LDG.E.64 R12, [R26.64] ; /* 0x000000061a0c7981 */ /* 0x000ea8000c1e1b00 */ /*02f0*/ IMAD.X R25, R23, 0x1, R27, P1 ; /* 0x0000000117197824 */ /* 0x000fe200008e061b */ /*0300*/ IADD3 R16, P1, R21, R24, RZ ; /* 0x0000001815107210 */ /* 0x000fc80007f3e0ff */ /*0310*/ LDG.E.64 R6, [R24.64] ; /* 0x0000000618067981 */ /* 0x000ee2000c1e1b00 */ /*0320*/ IMAD.X R17, R23, 0x1, R25, P1 ; /* 0x0000000117117824 */ /* 0x000fe200008e0619 */ /*0330*/ IADD3 R8, P1, R21, R16, RZ ; /* 0x0000001015087210 */ /* 0x000fc80007f3e0ff */ /*0340*/ LDG.E.64 R10, [R16.64] ; /* 0x00000006100a7981 */ /* 0x000f22000c1e1b00 */ /*0350*/ IMAD.X R9, R23, 0x1, R17, P1 ; /* 0x0000000117097824 */ /* 0x000fca00008e0611 */ /*0360*/ LDG.E.64 R14, [R8.64] ; /* 0x00000006080e7981 */ /* 0x000f22000c1e1b00 */ /*0370*/ UIADD3 UR5, UP0, UR5, 0x4, URZ ; /* 0x0000000405057890 */ /* 0x000fc8000ff1e03f */ /*0380*/ UIADD3.X UR4, URZ, UR4, URZ, UP0, !UPT ; /* 0x000000043f047290 */ /* 0x000fe200087fe43f */ /*0390*/ DADD R12, R4, -R12 ; /* 0x00000000040c7229 */ /* 0x024e0c000000080c */ /*03a0*/ DSETP.GT.AND P1, PT, |R12|, c[0x2][0x0], PT ; /* 0x008000000c00762a */ /* 0x001fc80003f24200 */ /*03b0*/ DADD R6, R4, -R6 ; /* 0x0000000004067229 */ /* 0x008e080000000806 */ /*03c0*/ DADD R10, R4, -R10 ; /* 0x00000000040a7229 */ /* 0x010e48000000080a */ /*03d0*/ DSETP.GT.AND P2, PT, |R6|, c[0x2][0x0], PT ; /* 0x008000000600762a */ /* 0x0010a40003f44200 */ /*03e0*/ IADD3 R6, R18, 0x1, RZ ; /* 0x0000000112067810 */ /* 0x001fe20007ffe0ff */ /*03f0*/ @!P1 IMAD.MOV R6, RZ, RZ, R18 ; /* 0x000000ffff069224 */ /* 0x000fe200078e0212 */ /*0400*/ DSETP.GT.AND P3, PT, |R10|, c[0x2][0x0], PT ; /* 0x008000000a00762a */ /* 0x0021e40003f64200 */ /*0410*/ IADD3 R10, P4, R22, UR5, RZ ; /* 0x00000005160a7c10 */ /* 0x001fe4000ff9e0ff */ /*0420*/ DADD R14, R4, -R14 ; /* 0x00000000040e7229 */ /* 0x000e22000000080e */ /*0430*/ IADD3 R7, R6, 0x1, RZ ; /* 0x0000000106077810 */ /* 0x000fe40007ffe0ff */ /*0440*/ ISETP.NE.U32.AND P1, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fc40003f25070 */ /*0450*/ IADD3.X R10, R20, UR4, RZ, P4, !PT ; /* 0x00000004140a7c10 */ /* 0x000fe2000a7fe4ff */ /*0460*/ @!P2 IMAD.MOV R7, RZ, RZ, R6 ; /* 0x000000ffff07a224 */ /* 0x004fe200078e0206 */ /*0470*/ DSETP.GT.AND P2, PT, |R14|, c[0x2][0x0], PT ; /* 0x008000000e00762a */ /* 0x001e240003f44200 */ /*0480*/ ISETP.NE.AND.EX P1, PT, R10, RZ, PT, P1 ; /* 0x000000ff0a00720c */ /* 0x000fe40003f25310 */ /*0490*/ IADD3 R6, R7, 0x1, RZ ; /* 0x0000000107067810 */ /* 0x000fe20007ffe0ff */ /*04a0*/ @!P3 IMAD.MOV R6, RZ, RZ, R7 ; /* 0x000000ffff06b224 */ /* 0x000fe200078e0207 */ /*04b0*/ IADD3 R26, P3, R21, R8, RZ ; /* 0x00000008151a7210 */ /* 0x000fc80007f7e0ff */ /*04c0*/ IADD3 R18, R6, 0x1, RZ ; /* 0x0000000106127810 */ /* 0x000fe20007ffe0ff */ /*04d0*/ IMAD.X R27, R23, 0x1, R9, P3 ; /* 0x00000001171b7824 */ /* 0x000fc600018e0609 */ /*04e0*/ @!P2 IMAD.MOV R18, RZ, RZ, R6 ; /* 0x000000ffff12a224 */ /* 0x001fe200078e0206 */ /*04f0*/ @P1 BRA 0x2d0 ; /* 0xfffffdd000001947 */ /* 0x000fea000383ffff */ /*0500*/ @!P0 BRA 0x660 ; /* 0x0000015000008947 */ /* 0x000fea0003800000 */ /*0510*/ IMAD.MOV.U32 R3, RZ, RZ, RZ ; /* 0x000000ffff037224 */ /* 0x000fe200078e00ff */ /*0520*/ IADD3 R8, P1, RZ, -R0, RZ ; /* 0x80000000ff087210 */ /* 0x000fe20007f3e0ff */ /*0530*/ IMAD R7, R19.reuse, UR4, RZ ; /* 0x0000000413077c24 */ /* 0x040fe4000f8e02ff */ /*0540*/ IMAD.WIDE.U32 R2, R19, UR5, R2 ; /* 0x0000000513027c25 */ /* 0x000fc8000f8e0002 */ /*0550*/ IMAD.IADD R7, R3, 0x1, R7 ; /* 0x0000000103077824 */ /* 0x000fe200078e0207 */ /*0560*/ LEA R6, P0, R2, c[0x0][0x160], 0x3 ; /* 0x0000580002067a11 */ /* 0x000fe200078018ff */ /*0570*/ IMAD.X R9, RZ, RZ, -0x1, P1 ; /* 0xffffffffff097424 */ /* 0x000fc600008e06ff */ /*0580*/ LEA.HI.X R7, R2, c[0x0][0x164], R7, 0x3, P0 ; /* 0x0000590002077a11 */ /* 0x000fca00000f1c07 */ /*0590*/ LDG.E.64 R2, [R6.64] ; /* 0x0000000606027981 */ /* 0x0000a2000c1e1b00 */ /*05a0*/ IADD3 R8, P0, R8, 0x1, RZ ; /* 0x0000000108087810 */ /* 0x000fe40007f1e0ff */ /*05b0*/ IADD3 R0, R18, 0x1, RZ ; /* 0x0000000112007810 */ /* 0x000fc60007ffe0ff */ /*05c0*/ IMAD.X R9, RZ, RZ, R9, P0 ; /* 0x000000ffff097224 */ /* 0x000fe200000e0609 */ /*05d0*/ ISETP.NE.U32.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe40003f05070 */ /*05e0*/ LEA R6, P2, R19, R6, 0x3 ; /* 0x0000000613067211 */ /* 0x001fe400078418ff */ /*05f0*/ ISETP.NE.AND.EX P0, PT, R9, RZ, PT, P0 ; /* 0x000000ff0900720c */ /* 0x000fe40003f05300 */ /*0600*/ LEA.HI.X R7, R19, R7, RZ, 0x3, P2 ; /* 0x0000000713077211 */ /* 0x000fe200010f1cff */ /*0610*/ DADD R2, R4, -R2 ; /* 0x0000000004027229 */ /* 0x024e0c0000000802 */ /*0620*/ DSETP.GT.AND P1, PT, |R2|, c[0x2][0x0], PT ; /* 0x008000000200762a */ /* 0x001e1c0003f24200 */ /*0630*/ @!P1 IMAD.MOV R0, RZ, RZ, R18 ; /* 0x000000ffff009224 */ /* 0x001fc800078e0212 */ /*0640*/ IMAD.MOV.U32 R18, RZ, RZ, R0 ; /* 0x000000ffff127224 */ /* 0x000fe200078e0000 */ /*0650*/ @P0 BRA 0x590 ; /* 0xffffff3000000947 */ /* 0x000fea000383ffff */ /*0660*/ S2R R0, SR_LANEID ; /* 0x0000000000007919 */ /* 0x000e220000000000 */ /*0670*/ REDUX.SUM UR5, R18 ; /* 0x00000000120573c4 */ /* 0x000e62000000c000 */ /*0680*/ VOTEU.ANY UR4, UPT, PT ; /* 0x0000000000047886 */ /* 0x000fe200038e0100 */ /*0690*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff027624 */ /* 0x000fe200078e00ff */ /*06a0*/ UFLO.U32 UR4, UR4 ; /* 0x00000004000472bd */ /* 0x000fe200080e0000 */ /*06b0*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff037624 */ /* 0x000fca00078e00ff */ /*06c0*/ ISETP.EQ.U32.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x001fe2000bf02070 */ /*06d0*/ IMAD.U32 R5, RZ, RZ, UR5 ; /* 0x00000005ff057e24 */ /* 0x022fd8000f8e00ff */ /*06e0*/ @P0 RED.E.ADD.STRONG.GPU [R2.64], R5 ; /* 0x000000050200098e */ /* 0x000fe2000c10e186 */ /*06f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0700*/ BRA 0x700; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0710*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0720*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0730*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0740*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0750*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0760*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0770*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0780*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0790*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ .......... Function : compare .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.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ IMAD.MOV.U32 R8, RZ, RZ, c[0x0][0x170] ; /* 0x00005c00ff087624 */ /* 0x000fe200078e00ff */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0040*/ IMAD.MOV.U32 R9, RZ, RZ, c[0x0][0x174] ; /* 0x00005d00ff097624 */ /* 0x000fe200078e00ff */ /*0050*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e220000002200 */ /*0060*/ IMAD.MOV.U32 R6, RZ, RZ, RZ ; /* 0x000000ffff067224 */ /* 0x000fe200078e00ff */ /*0070*/ ISETP.GE.U32.AND P0, PT, R8, 0x2, PT ; /* 0x000000020800780c */ /* 0x000fe40003f06070 */ /*0080*/ S2R R5, SR_CTAID.X ; /* 0x0000000000057919 */ /* 0x000e640000002500 */ /*0090*/ ISETP.GE.U32.AND.EX P0, PT, R9, RZ, PT, P0 ; /* 0x000000ff0900720c */ /* 0x000fc40003f06100 */ /*00a0*/ S2R R7, SR_TID.X ; /* 0x0000000000077919 */ /* 0x000ea20000002100 */ /*00b0*/ IMAD R0, R0, c[0x0][0x4], R3 ; /* 0x0000010000007a24 */ /* 0x001fc800078e0203 */ /*00c0*/ IMAD R0, R0, c[0x0][0xc], R5 ; /* 0x0000030000007a24 */ /* 0x002fc800078e0205 */ /*00d0*/ IMAD R2, R0, c[0x0][0x0], R7 ; /* 0x0000000000027a24 */ /* 0x004fe400078e0207 */ /*00e0*/ @!P0 BRA 0x690 ; /* 0x000005a000008947 */ /* 0x000fea0003800000 */ /*00f0*/ LEA R4, P0, R2, c[0x0][0x160], 0x2 ; /* 0x0000580002047a11 */ /* 0x000fc800078010ff */ /*0100*/ LEA.HI.X R5, R2, c[0x0][0x164], RZ, 0x2, P0 ; /* 0x0000590002057a11 */ /* 0x000fe400000f14ff */ /*0110*/ IADD3 R6, P0, R8, -0x2, RZ ; /* 0xfffffffe08067810 */ /* 0x000fe20007f1e0ff */ /*0120*/ IMAD.MOV.U32 R7, RZ, RZ, c[0x0][0x0] ; /* 0x00000000ff077624 */ /* 0x000fe200078e00ff */ /*0130*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe20000000000 */ /*0140*/ LDG.E R0, [R4.64] ; /* 0x0000000604007981 */ /* 0x000162000c1e1900 */ /*0150*/ ISETP.GE.U32.AND P1, PT, R6, 0x3, PT ; /* 0x000000030600780c */ /* 0x000fe20003f26070 */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ IADD3.X R6, R9, -0x1, RZ, P0, !PT ; /* 0xffffffff09067810 */ /* 0x000fe400007fe4ff */ /*0180*/ IADD3 R8, R8, -0x1, RZ ; /* 0xffffffff08087810 */ /* 0x000fc40007ffe0ff */ /*0190*/ ISETP.GE.U32.AND.EX P1, PT, R6, RZ, PT, P1 ; /* 0x000000ff0600720c */ /* 0x000fe20003f26110 */ /*01a0*/ IMAD R6, R7, c[0x0][0x4], RZ ; /* 0x0000010007067a24 */ /* 0x000fe200078e02ff */ /*01b0*/ LOP3.LUT R8, R8, 0x3, RZ, 0xc0, !PT ; /* 0x0000000308087812 */ /* 0x000fc600078ec0ff */ /*01c0*/ IMAD R7, R6, c[0x0][0xc], RZ ; /* 0x0000030006077a24 */ /* 0x000fe200078e02ff */ /*01d0*/ ISETP.NE.U32.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe20003f05070 */ /*01e0*/ IMAD.MOV.U32 R6, RZ, RZ, RZ ; /* 0x000000ffff067224 */ /* 0x000fe400078e00ff */ /*01f0*/ IMAD R7, R7, c[0x0][0x10], RZ ; /* 0x0000040007077a24 */ /* 0x000fe200078e02ff */ /*0200*/ ISETP.NE.AND.EX P0, PT, RZ, RZ, PT, P0 ; /* 0x000000ffff00720c */ /* 0x000fc60003f05300 */ /*0210*/ @!P1 BRA 0x510 ; /* 0x000002f000009947 */ /* 0x000ff40003800000 */ /*0220*/ IADD3 R4, P1, R2, R7, RZ ; /* 0x0000000702047210 */ /* 0x001fe20007f3e0ff */ /*0230*/ IMAD.SHL.U32 R9, R7, 0x4, RZ ; /* 0x0000000407097824 */ /* 0x000fe200078e00ff */ /*0240*/ IADD3 R18, P2, R8, -c[0x0][0x170], RZ ; /* 0x80005c0008127a10 */ /* 0x000fe20007f5e0ff */ /*0250*/ IMAD.MOV.U32 R6, RZ, RZ, RZ ; /* 0x000000ffff067224 */ /* 0x000fe200078e00ff */ /*0260*/ SHF.R.U32.HI R15, RZ, 0x1e, R7 ; /* 0x0000001eff0f7819 */ /* 0x000fe20000011607 */ /*0270*/ IMAD.X R5, RZ, RZ, RZ, P1 ; /* 0x000000ffff057224 */ /* 0x000fe200008e06ff */ /*0280*/ LEA R16, P1, R4.reuse, c[0x0][0x160], 0x2 ; /* 0x0000580004107a11 */ /* 0x040fe200078210ff */ /*0290*/ IMAD.X R20, RZ, RZ, ~c[0x0][0x174], P2 ; /* 0x80005d00ff147624 */ /* 0x000fe200010e06ff */ /*02a0*/ UMOV UR5, 0x1 ; /* 0x0000000100057882 */ /* 0x000fe40000000000 */ /*02b0*/ LEA.HI.X R4, R4, c[0x0][0x164], R5, 0x2, P1 ; /* 0x0000590004047a11 */ /* 0x000fe200008f1405 */ /*02c0*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fc80008000000 */ /*02d0*/ IMAD.MOV.U32 R17, RZ, RZ, R4 ; /* 0x000000ffff117224 */ /* 0x000fe200078e0004 */ /*02e0*/ IADD3 R10, P1, R9, R16, RZ ; /* 0x00000010090a7210 */ /* 0x000fca0007f3e0ff */ /*02f0*/ LDG.E R17, [R16.64] ; /* 0x0000000610117981 */ /* 0x000ea2000c1e1900 */ /*0300*/ IMAD.X R11, R15, 0x1, R4, P1 ; /* 0x000000010f0b7824 */ /* 0x000fe200008e0604 */ /*0310*/ IADD3 R12, P1, R9, R10, RZ ; /* 0x0000000a090c7210 */ /* 0x000fc80007f3e0ff */ /*0320*/ LDG.E R19, [R10.64] ; /* 0x000000060a137981 */ /* 0x0000e2000c1e1900 */ /*0330*/ IMAD.X R13, R15, 0x1, R11, P1 ; /* 0x000000010f0d7824 */ /* 0x000fe200008e060b */ /*0340*/ IADD3 R4, P1, R9, R12, RZ ; /* 0x0000000c09047210 */ /* 0x000fc80007f3e0ff */ /*0350*/ LDG.E R21, [R12.64] ; /* 0x000000060c157981 */ /* 0x000f22000c1e1900 */ /*0360*/ IMAD.X R5, R15, 0x1, R13, P1 ; /* 0x000000010f057824 */ /* 0x000fca00008e060d */ /*0370*/ LDG.E R23, [R4.64] ; /* 0x0000000604177981 */ /* 0x000f22000c1e1900 */ /*0380*/ UIADD3 UR5, UP0, UR5, 0x4, URZ ; /* 0x0000000405057890 */ /* 0x000fc8000ff1e03f */ /*0390*/ UIADD3.X UR4, URZ, UR4, URZ, UP0, !UPT ; /* 0x000000043f047290 */ /* 0x000fe400087fe43f */ /*03a0*/ IADD3 R10, P4, R18, UR5, RZ ; /* 0x00000005120a7c10 */ /* 0x001fc8000ff9e0ff */ /*03b0*/ IADD3.X R11, R20, UR4, RZ, P4, !PT ; /* 0x00000004140b7c10 */ /* 0x000fe2000a7fe4ff */ /*03c0*/ FADD R14, R0, -R17 ; /* 0x80000011000e7221 */ /* 0x024fca0000000000 */ /*03d0*/ FSETP.GT.AND P1, PT, |R14|, 0.0010000000474974513054, PT ; /* 0x3a83126f0e00780b */ /* 0x000fe20003f24200 */ /*03e0*/ FADD R19, R0, -R19 ; /* 0x8000001300137221 */ /* 0x008fe20000000000 */ /*03f0*/ IADD3 R14, R6, 0x1, RZ ; /* 0x00000001060e7810 */ /* 0x000fc80007ffe0ff */ /*0400*/ FSETP.GT.AND P2, PT, |R19|, 0.0010000000474974513054, PT ; /* 0x3a83126f1300780b */ /* 0x000fe20003f44200 */ /*0410*/ FADD R21, R0, -R21 ; /* 0x8000001500157221 */ /* 0x010fca0000000000 */ /*0420*/ FSETP.GT.AND P3, PT, |R21|, 0.0010000000474974513054, PT ; /* 0x3a83126f1500780b */ /* 0x000fe20003f64200 */ /*0430*/ @!P1 IMAD.MOV R14, RZ, RZ, R6 ; /* 0x000000ffff0e9224 */ /* 0x000fe200078e0206 */ /*0440*/ ISETP.NE.U32.AND P1, PT, R10, RZ, PT ; /* 0x000000ff0a00720c */ /* 0x000fe20003f25070 */ /*0450*/ FADD R23, R0, -R23 ; /* 0x8000001700177221 */ /* 0x000fc60000000000 */ /*0460*/ IADD3 R6, R14, 0x1, RZ ; /* 0x000000010e067810 */ /* 0x000fe20007ffe0ff */ /*0470*/ @!P2 IMAD.MOV R6, RZ, RZ, R14 ; /* 0x000000ffff06a224 */ /* 0x000fe200078e020e */ /*0480*/ ISETP.NE.AND.EX P1, PT, R11, RZ, PT, P1 ; /* 0x000000ff0b00720c */ /* 0x000fe40003f25310 */ /*0490*/ FSETP.GT.AND P2, PT, |R23|, 0.0010000000474974513054, PT ; /* 0x3a83126f1700780b */ /* 0x000fe40003f44200 */ /*04a0*/ IADD3 R10, R6, 0x1, RZ ; /* 0x00000001060a7810 */ /* 0x000fe20007ffe0ff */ /*04b0*/ @!P3 IMAD.MOV R10, RZ, RZ, R6 ; /* 0x000000ffff0ab224 */ /* 0x000fe200078e0206 */ /*04c0*/ IADD3 R16, P3, R9, R4, RZ ; /* 0x0000000409107210 */ /* 0x000fc80007f7e0ff */ /*04d0*/ IADD3 R6, R10, 0x1, RZ ; /* 0x000000010a067810 */ /* 0x000fe20007ffe0ff */ /*04e0*/ IMAD.X R4, R15, 0x1, R5, P3 ; /* 0x000000010f047824 */ /* 0x000fc800018e0605 */ /*04f0*/ @!P2 IMAD.MOV R6, RZ, RZ, R10 ; /* 0x000000ffff06a224 */ /* 0x000fe200078e020a */ /*0500*/ @P1 BRA 0x2d0 ; /* 0xfffffdc000001947 */ /* 0x000fea000383ffff */ /*0510*/ @!P0 BRA 0x690 ; /* 0x0000017000008947 */ /* 0x001fea0003800000 */ /*0520*/ IMAD.MOV.U32 R3, RZ, RZ, RZ ; /* 0x000000ffff037224 */ /* 0x000fe200078e00ff */ /*0530*/ IADD3 R8, P1, RZ, -R8, RZ ; /* 0x80000008ff087210 */ /* 0x000fe20007f3e0ff */ /*0540*/ IMAD R11, R7.reuse, UR4, RZ ; /* 0x00000004070b7c24 */ /* 0x040fe4000f8e02ff */ /*0550*/ IMAD.WIDE.U32 R2, R7, UR5, R2 ; /* 0x0000000507027c25 */ /* 0x000fc8000f8e0002 */ /*0560*/ IMAD.IADD R11, R3, 0x1, R11 ; /* 0x00000001030b7824 */ /* 0x000fe200078e020b */ /*0570*/ LEA R10, P0, R2, c[0x0][0x160], 0x2 ; /* 0x00005800020a7a11 */ /* 0x000fe200078010ff */ /*0580*/ IMAD.X R5, RZ, RZ, -0x1, P1 ; /* 0xffffffffff057424 */ /* 0x000fc600008e06ff */ /*0590*/ LEA.HI.X R11, R2, c[0x0][0x164], R11, 0x2, P0 ; /* 0x00005900020b7a11 */ /* 0x000fca00000f140b */ /*05a0*/ IMAD.MOV.U32 R3, RZ, RZ, R11 ; /* 0x000000ffff037224 */ /* 0x000fe400078e000b */ /*05b0*/ IMAD.MOV.U32 R2, RZ, RZ, R10 ; /* 0x000000ffff027224 */ /* 0x000fca00078e000a */ /*05c0*/ LDG.E R3, [R2.64] ; /* 0x0000000602037981 */ /* 0x000ea2000c1e1900 */ /*05d0*/ IADD3 R8, P0, R8, 0x1, RZ ; /* 0x0000000108087810 */ /* 0x000fe40007f1e0ff */ /*05e0*/ LEA R10, P2, R7, R10, 0x2 ; /* 0x0000000a070a7211 */ /* 0x000fc600078410ff */ /*05f0*/ IMAD.X R5, RZ, RZ, R5, P0 ; /* 0x000000ffff057224 */ /* 0x000fe200000e0605 */ /*0600*/ ISETP.NE.U32.AND P0, PT, R8, RZ, PT ; /* 0x000000ff0800720c */ /* 0x000fe40003f05070 */ /*0610*/ LEA.HI.X R11, R7, R11, RZ, 0x2, P2 ; /* 0x0000000b070b7211 */ /* 0x000fe400010f14ff */ /*0620*/ ISETP.NE.AND.EX P0, PT, R5, RZ, PT, P0 ; /* 0x000000ff0500720c */ /* 0x000fe20003f05300 */ /*0630*/ FADD R4, R0, -R3 ; /* 0x8000000300047221 */ /* 0x024fca0000000000 */ /*0640*/ FSETP.GT.AND P1, PT, |R4|, 0.0010000000474974513054, PT ; /* 0x3a83126f0400780b */ /* 0x000fe40003f24200 */ /*0650*/ IADD3 R4, R6, 0x1, RZ ; /* 0x0000000106047810 */ /* 0x000fd60007ffe0ff */ /*0660*/ @!P1 IMAD.MOV R4, RZ, RZ, R6 ; /* 0x000000ffff049224 */ /* 0x000fc800078e0206 */ /*0670*/ IMAD.MOV.U32 R6, RZ, RZ, R4 ; /* 0x000000ffff067224 */ /* 0x000fe200078e0004 */ /*0680*/ @P0 BRA 0x5a0 ; /* 0xffffff1000000947 */ /* 0x000fea000383ffff */ /*0690*/ S2R R0, SR_LANEID ; /* 0x0000000000007919 */ /* 0x020e220000000000 */ /*06a0*/ REDUX.SUM UR5, R6 ; /* 0x00000000060573c4 */ /* 0x000e62000000c000 */ /*06b0*/ VOTEU.ANY UR4, UPT, PT ; /* 0x0000000000047886 */ /* 0x000fe200038e0100 */ /*06c0*/ IMAD.MOV.U32 R2, RZ, RZ, c[0x0][0x168] ; /* 0x00005a00ff027624 */ /* 0x000fe200078e00ff */ /*06d0*/ UFLO.U32 UR4, UR4 ; /* 0x00000004000472bd */ /* 0x000fe200080e0000 */ /*06e0*/ IMAD.MOV.U32 R3, RZ, RZ, c[0x0][0x16c] ; /* 0x00005b00ff037624 */ /* 0x000fca00078e00ff */ /*06f0*/ ISETP.EQ.U32.AND P0, PT, R0, UR4, PT ; /* 0x0000000400007c0c */ /* 0x001fe2000bf02070 */ /*0700*/ IMAD.U32 R5, RZ, RZ, UR5 ; /* 0x00000005ff057e24 */ /* 0x002fd8000f8e00ff */ /*0710*/ @P0 RED.E.ADD.STRONG.GPU [R2.64], R5 ; /* 0x000000050200098e */ /* 0x000fe2000c10e186 */ /*0720*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0730*/ BRA 0x730; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0740*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0750*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0760*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0770*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0780*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0790*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*07f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected compare .globl compare .p2align 8 .type compare,@function compare: s_load_b64 s[2:3], s[0:1], 0x10 v_mov_b32_e32 v2, 0 s_waitcnt lgkmcnt(0) v_cmp_lt_u64_e64 s4, s[2:3], 2 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s4 s_cbranch_vccnz .LBB0_3 s_clause 0x1 s_load_b32 s8, s[0:1], 0x24 s_load_b64 s[4:5], s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 s_load_b64 s[6:7], s[0:1], 0x0 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s9, s8, 16 s_and_b32 s8, s8, 0xffff v_mad_u64_u32 v[2:3], null, s15, s9, v[1:2] s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_mad_u64_u32 v[3:4], null, v2, s4, s[14:15] s_mul_i32 s4, s4, s8 s_mul_i32 s4, s4, s5 s_mov_b32 s5, 0 s_mul_i32 s4, s4, s9 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_lshl_b64 s[4:5], s[4:5], 2 v_mad_u64_u32 v[1:2], null, v3, s8, v[0:1] v_mov_b32_e32 v2, 0 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, s6, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo s_add_u32 s6, s6, s4 s_addc_u32 s7, s7, s5 v_add_co_u32 v0, vcc_lo, s6, v0 global_load_b32 v3, v[2:3], off v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo v_mov_b32_e32 v2, 0 .LBB0_2: global_load_b32 v4, v[0:1], off v_add_co_u32 v0, vcc_lo, v0, s4 v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) s_cmp_eq_u64 s[2:3], 0 s_waitcnt vmcnt(0) v_sub_f32_e32 v4, v3, v4 v_cmp_lt_f32_e64 vcc_lo, 0x3a83126f, |v4| v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo s_cbranch_scc0 .LBB0_2 .LBB0_3: s_mov_b32 s3, exec_lo s_mov_b32 s2, 0 .LBB0_4: s_ctz_i32_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_readlane_b32 s5, v2, s4 s_lshl_b32 s4, 1, s4 s_and_not1_b32 s3, s3, s4 s_delay_alu instid0(VALU_DEP_1) s_add_i32 s2, s2, s5 s_cmp_lg_u32 s3, 0 s_cbranch_scc1 .LBB0_4 v_mbcnt_lo_u32_b32 v0, exec_lo, 0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v0 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB0_7 s_load_b64 s[0:1], s[0:1], 0x8 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 s_waitcnt lgkmcnt(0) global_atomic_add_u32 v0, v1, s[0:1] .LBB0_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel compare .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 compare, .Lfunc_end0-compare .section .AMDGPU.csdata,"",@progbits .text .protected compareD .globl compareD .p2align 8 .type compareD,@function compareD: s_load_b64 s[2:3], s[0:1], 0x10 v_mov_b32_e32 v4, 0 s_waitcnt lgkmcnt(0) v_cmp_lt_u64_e64 s4, s[2:3], 2 s_delay_alu instid0(VALU_DEP_1) s_and_b32 vcc_lo, exec_lo, s4 s_cbranch_vccnz .LBB1_3 s_clause 0x1 s_load_b32 s8, s[0:1], 0x24 s_load_b64 s[4:5], s[0:1], 0x18 v_bfe_u32 v1, v0, 10, 10 s_load_b64 s[6:7], s[0:1], 0x0 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_lshr_b32 s9, s8, 16 s_and_b32 s8, s8, 0xffff v_mad_u64_u32 v[2:3], null, s15, s9, v[1:2] s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(VALU_DEP_1) v_mad_u64_u32 v[3:4], null, v2, s4, s[14:15] s_mul_i32 s4, s4, s8 v_mov_b32_e32 v4, 0 s_mul_i32 s4, s4, s5 s_mov_b32 s5, 0 s_mul_i32 s4, s4, s9 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2) s_lshl_b64 s[4:5], s[4:5], 3 v_mad_u64_u32 v[1:2], null, v3, s8, v[0:1] v_mov_b32_e32 v2, 0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[2:3], 3, v[1:2] v_add_co_u32 v0, vcc_lo, s6, v2 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s7, v3, vcc_lo s_add_u32 s6, s6, s4 s_addc_u32 s7, s7, s5 v_add_co_u32 v2, vcc_lo, s6, v2 global_load_b64 v[0:1], v[0:1], off v_add_co_ci_u32_e32 v3, vcc_lo, s7, v3, vcc_lo s_mov_b32 s7, 0x3e7ad7f2 s_mov_b32 s6, 0x9abcaf48 .LBB1_2: global_load_b64 v[5:6], v[2:3], off v_add_co_u32 v2, vcc_lo, v2, s4 v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo s_add_u32 s2, s2, -1 s_addc_u32 s3, s3, -1 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) s_cmp_eq_u64 s[2:3], 0 s_waitcnt vmcnt(0) v_add_f64 v[5:6], v[0:1], -v[5:6] v_cmp_gt_f64_e64 vcc_lo, |v[5:6]|, s[6:7] v_add_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo s_cbranch_scc0 .LBB1_2 .LBB1_3: s_mov_b32 s3, exec_lo s_mov_b32 s2, 0 .LBB1_4: s_ctz_i32_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_readlane_b32 s5, v4, s4 s_lshl_b32 s4, 1, s4 s_and_not1_b32 s3, s3, s4 s_delay_alu instid0(VALU_DEP_1) s_add_i32 s2, s2, s5 s_cmp_lg_u32 s3, 0 s_cbranch_scc1 .LBB1_4 v_mbcnt_lo_u32_b32 v0, exec_lo, 0 s_mov_b32 s3, exec_lo s_delay_alu instid0(VALU_DEP_1) v_cmpx_eq_u32_e32 0, v0 s_xor_b32 s3, exec_lo, s3 s_cbranch_execz .LBB1_7 s_load_b64 s[0:1], s[0:1], 0x8 v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 s_waitcnt lgkmcnt(0) global_atomic_add_u32 v0, v1, s[0:1] .LBB1_7: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel compareD .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 7 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size compareD, .Lfunc_end1-compareD .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: 8 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: compare .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: compare.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 - .offset: 16 .size: 8 .value_kind: by_value - .offset: 24 .size: 4 .value_kind: hidden_block_count_x - .offset: 28 .size: 4 .value_kind: hidden_block_count_y - .offset: 32 .size: 4 .value_kind: hidden_block_count_z - .offset: 36 .size: 2 .value_kind: hidden_group_size_x - .offset: 38 .size: 2 .value_kind: hidden_group_size_y - .offset: 40 .size: 2 .value_kind: hidden_group_size_z - .offset: 42 .size: 2 .value_kind: hidden_remainder_x - .offset: 44 .size: 2 .value_kind: hidden_remainder_y - .offset: 46 .size: 2 .value_kind: hidden_remainder_z - .offset: 64 .size: 8 .value_kind: hidden_global_offset_x - .offset: 72 .size: 8 .value_kind: hidden_global_offset_y - .offset: 80 .size: 8 .value_kind: hidden_global_offset_z - .offset: 88 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: compareD .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: compareD.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 7 .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_00091c21_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 _Z29__device_stub__Z7comparePfPimPfPim .type _Z29__device_stub__Z7comparePfPimPfPim, @function _Z29__device_stub__Z7comparePfPimPfPim: .LFB2051: .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 compare(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z29__device_stub__Z7comparePfPimPfPim, .-_Z29__device_stub__Z7comparePfPimPfPim .globl compare .type compare, @function compare: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z29__device_stub__Z7comparePfPimPfPim addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size compare, .-compare .globl _Z30__device_stub__Z8compareDPdPimPdPim .type _Z30__device_stub__Z8compareDPdPimPdPim, @function _Z30__device_stub__Z8compareDPdPimPdPim: .LFB2053: .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 .L15 .L11: movq 120(%rsp), %rax subq %fs:40, %rax jne .L16 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .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 compareD(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L11 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2053: .size _Z30__device_stub__Z8compareDPdPimPdPim, .-_Z30__device_stub__Z8compareDPdPimPdPim .globl compareD .type compareD, @function compareD: .LFB2054: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z8compareDPdPimPdPim addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2054: .size compareD, .-compareD .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "compareD" .LC1: .string "compare" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2056: .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 compareD(%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 .LC1(%rip), %rdx movq %rdx, %rcx leaq compare(%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 .LFE2056: .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 "compare.hip" .globl __device_stub__compare # -- Begin function __device_stub__compare .p2align 4, 0x90 .type __device_stub__compare,@function __device_stub__compare: # @__device_stub__compare .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 $compare, %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 __device_stub__compare, .Lfunc_end0-__device_stub__compare .cfi_endproc # -- End function .globl __device_stub__compareD # -- Begin function __device_stub__compareD .p2align 4, 0x90 .type __device_stub__compareD,@function __device_stub__compareD: # @__device_stub__compareD .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 $compareD, %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_end1: .size __device_stub__compareD, .Lfunc_end1-__device_stub__compareD .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function __hip_module_ctor .type __hip_module_ctor,@function __hip_module_ctor: # @__hip_module_ctor .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $32, %rsp .cfi_def_cfa_offset 48 .cfi_offset %rbx, -16 cmpq $0, __hip_gpubin_handle(%rip) jne .LBB2_2 # %bb.1: movl $__hip_fatbin_wrapper, %edi callq __hipRegisterFatBinary movq %rax, __hip_gpubin_handle(%rip) .LBB2_2: movq __hip_gpubin_handle(%rip), %rbx xorps %xmm0, %xmm0 movups %xmm0, 16(%rsp) movups %xmm0, (%rsp) movl $compare, %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 $compareD, %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_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 compare,@object # @compare .section .rodata,"a",@progbits .globl compare .p2align 3, 0x0 compare: .quad __device_stub__compare .size compare, 8 .type compareD,@object # @compareD .globl compareD .p2align 3, 0x0 compareD: .quad __device_stub__compareD .size compareD, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "compare" .size .L__unnamed_1, 8 .type .L__unnamed_2,@object # @1 .L__unnamed_2: .asciz "compareD" .size .L__unnamed_2, 9 .type __hip_fatbin_wrapper,@object # @__hip_fatbin_wrapper .section .hipFatBinSegment,"a",@progbits .p2align 3, 0x0 __hip_fatbin_wrapper: .long 1212764230 # 0x48495046 .long 1 # 0x1 .quad __hip_fatbin .quad 0 .size __hip_fatbin_wrapper, 24 .type __hip_gpubin_handle,@object # @__hip_gpubin_handle .local __hip_gpubin_handle .comm __hip_gpubin_handle,8,8 .section .init_array,"aw",@init_array .p2align 3, 0x0 .quad __hip_module_ctor .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .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 __device_stub__compare .addrsig_sym __device_stub__compareD .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym compare .addrsig_sym compareD .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.
/* Metsai Aleksandros 7723 * metsalex@ece.auth.gr * * Game of life using CUDA. Multiple cells per thread and use of shared memory */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #define THRESHOLD 0.4 #define CELLS_PER_THREAD 2 #define THREADS_PER_BLOCK (500/CELLS_PER_THREAD) struct timeval startwtime, endwtime; double seq_time; __global__ void game_c (int *newer, int *old, int N) { int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD; __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; //Extended Tables __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD; int count; int sum=0; int i=(int) index/N; int j= index%N; int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index for(count=0; count<CELLS_PER_THREAD;count++){ if(i==0){ //top if(j==0){ top[0]= old[N*N-1]; mid[0]= old[N-1]; bot[0]= old[2*N -1]; top[1]= old[N*(N-1)]; mid[1]= old[0]; bot[1]= old[N]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-1)]; mid[lindex+1]= old[0]; bot[lindex+1]= old[N]; top[lindex]= old[N*N -1]; mid[lindex]= old[N-1]; bot[lindex]= old[2*N -1]; }else{ if(lindex==1){ top[lindex-1]= old[N*(N-1) +(j-1)]; mid[lindex-1]= old[j-1]; bot[lindex-1]= old[N+(j-1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; }else if(lindex==(lsize)){ top[lindex+1]= old[N*(N-1) +(j+1)]; mid[lindex+1]= old[j+1]; bot[lindex+1]= old[N+ (j+1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N +j]; }else{ top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; } } }else if(i==(N-1)){ //bottom if(j==0){ top[0]= old[N*(N-1) -1]; mid[0]= old[N*N -1]; bot[0]= old[N-1]; top[1]= old[N*(N-2)]; mid[1]= old[N*(N-1)]; bot[1]= old[0]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-2)]; mid[lindex+1]= old[N*(N-1)]; bot[lindex+1]= old[0]; top[lindex]= old[N*(N-1) -1]; mid[lindex]= old[N*N -1]; bot[lindex]= old[N-1]; }else{ // !! if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[j-1]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; } } }else if(j==0){ //left top[0]= old[(i-1)*N +(N-1)]; mid[0]= old[i*N +(N-1)]; bot[0]= old[(i+1)*N +(N-1)]; top[1]= old[(i-1)*N]; mid[1]= old[i*N]; bot[1]= old[(i+1)*N]; }else if(j==(N-1)){ //right top[lindex+1]= old[(i-1)*N]; mid[lindex+1]= old[i*N]; bot[lindex+1]= old[(i+1)*N]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ //general case if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[(i+1)*N +(j-1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(i+1)*N +(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; } } lindex++; j++; } //Restore values j=index%N; lindex=threadIdx.x*CELLS_PER_THREAD +1; __syncthreads(); for(count=0; count<CELLS_PER_THREAD; count++){ sum= top[lindex-1] +top[lindex]+top[lindex+1] +mid[lindex-1] +mid[lindex+1] +bot[lindex-1] +bot[lindex] +bot[lindex+1]; switch(sum){ case 3: newer[i*N + j] = 1; break; case 2: newer[i*N + j] = old[i*N + j]; break; default: newer[i*N + j] = 0; } lindex++; j++; } } void read_from_file(int *X, char *filename, int N); void save_table(int *X, int N); int main(){ int *table; int* newer; int* old; int *temp; int blocks, t, N, count; printf("Set the number of generations\n"); scanf("%d", &t); printf("Set N (table size = NxN)\n"); scanf("%d", &N); int size=N*N*sizeof(int); /* Insert table here */ char filename[20]; sprintf(filename, "table%dx%d.bin", N, N); printf("Reading %dx%d table from file %s\n", N, N, filename); table = (int *)malloc(N*N*sizeof(int)); read_from_file(table, filename, N); printf("This is kernel c\n"); printf("The game will be played for %d generations N=%d\n", t, N); //!!!Start Timer!!! gettimeofday (&startwtime, NULL); //Allocate space of new and old in device cudaMalloc(&newer, size); cudaMalloc(&old, size); //copy table cudaMemcpy(old, table, size, cudaMemcpyHostToDevice); blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD); //Play game for t generations for(count=0;count<t;count++){ game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N); cudaThreadSynchronize(); //swap pointers temp=old; old=newer; newer=temp; } //copy back table cudaMemcpy(table, old, size, cudaMemcpyDeviceToHost); //!!!End Timer!!! gettimeofday (&endwtime, NULL); seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec); printf("Cuda clock time = %f\n", seq_time); save_table(table, N); cudaFree(newer); cudaFree(old); free(table); return(0); } void read_from_file(int *X, char *filename, int N){ FILE *fp = fopen(filename, "r+"); int size = fread(X, sizeof(int), N*N, fp); printf("elements: %d\n", size); fclose(fp); } void save_table(int *X, int N){ FILE *fp; char filename[20]; sprintf(filename, "cuda_c_table%dx%d.bin", N, N); printf("Saving table in file %s\n", filename); fp = fopen(filename, "w+"); fwrite(X, sizeof(int), N*N, fp); fclose(fp); }
.file "tmpxft_000b9a8d_00000000-6_CUDA_gameoflife_impl3.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 .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "r+" .LC1: .string "elements: %d\n" .text .globl _Z14read_from_filePiPci .type _Z14read_from_filePiPci, @function _Z14read_from_filePiPci: .LFB2058: .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 movq %rdi, %r12 movq %rsi, %rdi movl %edx, %ebx leaq .LC0(%rip), %rsi call fopen@PLT movq %rax, %rbp imull %ebx, %ebx movslq %ebx, %rcx movq %rax, %r8 movl $4, %edx movq $-1, %rsi movq %r12, %rdi call __fread_chk@PLT movl %eax, %edx leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq %rbp, %rdi call fclose@PLT popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z14read_from_filePiPci, .-_Z14read_from_filePiPci .section .rodata.str1.1 .LC2: .string "cuda_c_table%dx%d.bin" .LC3: .string "Saving table in file %s\n" .LC4: .string "w+" .text .globl _Z10save_tablePii .type _Z10save_tablePii, @function _Z10save_tablePii: .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 $32, %rsp .cfi_def_cfa_offset 64 movq %rdi, %r12 movl %esi, %ebx movq %fs:40, %rax movq %rax, 24(%rsp) xorl %eax, %eax movq %rsp, %rbp movl %esi, %r9d movl %esi, %r8d leaq .LC2(%rip), %rcx movl $20, %edx movl $2, %esi movq %rbp, %rdi call __sprintf_chk@PLT movq %rbp, %rdx leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq .LC4(%rip), %rsi movq %rbp, %rdi call fopen@PLT movq %rax, %rbp imull %ebx, %ebx movslq %ebx, %rdx movq %rax, %rcx movl $4, %esi movq %r12, %rdi call fwrite@PLT movq %rbp, %rdi call fclose@PLT movq 24(%rsp), %rax subq %fs:40, %rax jne .L8 addq $32, %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 .L8: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2059: .size _Z10save_tablePii, .-_Z10save_tablePii .globl _Z28__device_stub__Z6game_cPiS_iPiS_i .type _Z28__device_stub__Z6game_cPiS_iPiS_i, @function _Z28__device_stub__Z6game_cPiS_iPiS_i: .LFB2084: .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 .L13 .L9: movq 120(%rsp), %rax subq %fs:40, %rax jne .L14 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L13: .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 _Z6game_cPiS_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L9 .L14: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z28__device_stub__Z6game_cPiS_iPiS_i, .-_Z28__device_stub__Z6game_cPiS_iPiS_i .globl _Z6game_cPiS_i .type _Z6game_cPiS_i, @function _Z6game_cPiS_i: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z28__device_stub__Z6game_cPiS_iPiS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z6game_cPiS_i, .-_Z6game_cPiS_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC5: .string "Set the number of generations\n" .section .rodata.str1.1 .LC6: .string "%d" .LC7: .string "Set N (table size = NxN)\n" .LC8: .string "table%dx%d.bin" .section .rodata.str1.8 .align 8 .LC9: .string "Reading %dx%d table from file %s\n" .section .rodata.str1.1 .LC10: .string "This is kernel c\n" .section .rodata.str1.8 .align 8 .LC11: .string "The game will be played for %d generations N=%d\n" .section .rodata.str1.1 .LC13: .string "Cuda clock time = %f\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $88, %rsp .cfi_def_cfa_offset 128 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq .LC5(%rip), %rsi movl $2, %edi call __printf_chk@PLT movq %rsp, %rsi leaq .LC6(%rip), %rbx movq %rbx, %rdi movl $0, %eax call __isoc23_scanf@PLT leaq .LC7(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 4(%rsp), %rsi movq %rbx, %rdi movl $0, %eax call __isoc23_scanf@PLT movl 4(%rsp), %r12d leaq 48(%rsp), %rbx movl %r12d, %r9d movl %r12d, %r8d leaq .LC8(%rip), %rcx movl $20, %edx movl $2, %esi movq %rbx, %rdi movl $0, %eax call __sprintf_chk@PLT movl 4(%rsp), %edx movq %rbx, %r8 movl %edx, %ecx leaq .LC9(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl 4(%rsp), %ebp movl %ebp, %edi imull %ebp, %edi movslq %edi, %rdi salq $2, %rdi call malloc@PLT movq %rax, %r13 movl %ebp, %edx movq %rbx, %rsi movq %rax, %rdi call _Z14read_from_filePiPci leaq .LC10(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl 4(%rsp), %ecx movl (%rsp), %edx leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $0, %esi leaq startwtime(%rip), %rdi call gettimeofday@PLT imull %r12d, %r12d sall $2, %r12d movslq %r12d, %r12 leaq 8(%rsp), %rdi movq %r12, %rsi call cudaMalloc@PLT leaq 16(%rsp), %rdi movq %r12, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r12, %rdx movq %r13, %rsi movq 16(%rsp), %rdi call cudaMemcpy@PLT movl 4(%rsp), %eax imull %eax, %eax movslq %eax, %rbp imulq $274877907, %rbp, %rbp sarq $37, %rbp sarl $31, %eax subl %eax, %ebp cmpl $0, (%rsp) jle .L18 movl $0, %ebx jmp .L20 .L19: call cudaThreadSynchronize@PLT movq 16(%rsp), %rax movq 8(%rsp), %rdx movq %rdx, 16(%rsp) movq %rax, 8(%rsp) addl $1, %ebx cmpl %ebx, (%rsp) jle .L18 .L20: movl $250, 36(%rsp) movl $1, 40(%rsp) movl %ebp, 24(%rsp) movl $1, 28(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax jne .L19 movl 4(%rsp), %edx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z28__device_stub__Z6game_cPiS_iPiS_i jmp .L19 .L18: movl $2, %ecx movq %r12, %rdx movq 16(%rsp), %rsi movq %r13, %rdi call cudaMemcpy@PLT movl $0, %esi leaq endwtime(%rip), %rdi call gettimeofday@PLT movq 8+endwtime(%rip), %rax subq 8+startwtime(%rip), %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 divsd .LC12(%rip), %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq endwtime(%rip), %xmm1 addsd %xmm1, %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq startwtime(%rip), %xmm1 subsd %xmm1, %xmm0 movsd %xmm0, seq_time(%rip) leaq .LC13(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl 4(%rsp), %esi movq %r13, %rdi call _Z10save_tablePii movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq %r13, %rdi call free@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L24 movl $0, %eax addq $88, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L24: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC14: .string "_Z6game_cPiS_i" .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 .LC14(%rip), %rdx movq %rdx, %rcx leaq _Z6game_cPiS_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 .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 .globl seq_time .bss .align 8 .type seq_time, @object .size seq_time, 8 seq_time: .zero 8 .globl endwtime .align 16 .type endwtime, @object .size endwtime, 16 endwtime: .zero 16 .globl startwtime .align 16 .type startwtime, @object .size startwtime, 16 startwtime: .zero 16 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC12: .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.
/* Metsai Aleksandros 7723 * metsalex@ece.auth.gr * * Game of life using CUDA. Multiple cells per thread and use of shared memory */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #define THRESHOLD 0.4 #define CELLS_PER_THREAD 2 #define THREADS_PER_BLOCK (500/CELLS_PER_THREAD) struct timeval startwtime, endwtime; double seq_time; __global__ void game_c (int *newer, int *old, int N) { int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD; __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; //Extended Tables __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD; int count; int sum=0; int i=(int) index/N; int j= index%N; int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index for(count=0; count<CELLS_PER_THREAD;count++){ if(i==0){ //top if(j==0){ top[0]= old[N*N-1]; mid[0]= old[N-1]; bot[0]= old[2*N -1]; top[1]= old[N*(N-1)]; mid[1]= old[0]; bot[1]= old[N]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-1)]; mid[lindex+1]= old[0]; bot[lindex+1]= old[N]; top[lindex]= old[N*N -1]; mid[lindex]= old[N-1]; bot[lindex]= old[2*N -1]; }else{ if(lindex==1){ top[lindex-1]= old[N*(N-1) +(j-1)]; mid[lindex-1]= old[j-1]; bot[lindex-1]= old[N+(j-1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; }else if(lindex==(lsize)){ top[lindex+1]= old[N*(N-1) +(j+1)]; mid[lindex+1]= old[j+1]; bot[lindex+1]= old[N+ (j+1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N +j]; }else{ top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; } } }else if(i==(N-1)){ //bottom if(j==0){ top[0]= old[N*(N-1) -1]; mid[0]= old[N*N -1]; bot[0]= old[N-1]; top[1]= old[N*(N-2)]; mid[1]= old[N*(N-1)]; bot[1]= old[0]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-2)]; mid[lindex+1]= old[N*(N-1)]; bot[lindex+1]= old[0]; top[lindex]= old[N*(N-1) -1]; mid[lindex]= old[N*N -1]; bot[lindex]= old[N-1]; }else{ // !! if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[j-1]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; } } }else if(j==0){ //left top[0]= old[(i-1)*N +(N-1)]; mid[0]= old[i*N +(N-1)]; bot[0]= old[(i+1)*N +(N-1)]; top[1]= old[(i-1)*N]; mid[1]= old[i*N]; bot[1]= old[(i+1)*N]; }else if(j==(N-1)){ //right top[lindex+1]= old[(i-1)*N]; mid[lindex+1]= old[i*N]; bot[lindex+1]= old[(i+1)*N]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ //general case if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[(i+1)*N +(j-1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(i+1)*N +(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; } } lindex++; j++; } //Restore values j=index%N; lindex=threadIdx.x*CELLS_PER_THREAD +1; __syncthreads(); for(count=0; count<CELLS_PER_THREAD; count++){ sum= top[lindex-1] +top[lindex]+top[lindex+1] +mid[lindex-1] +mid[lindex+1] +bot[lindex-1] +bot[lindex] +bot[lindex+1]; switch(sum){ case 3: newer[i*N + j] = 1; break; case 2: newer[i*N + j] = old[i*N + j]; break; default: newer[i*N + j] = 0; } lindex++; j++; } } void read_from_file(int *X, char *filename, int N); void save_table(int *X, int N); int main(){ int *table; int* newer; int* old; int *temp; int blocks, t, N, count; printf("Set the number of generations\n"); scanf("%d", &t); printf("Set N (table size = NxN)\n"); scanf("%d", &N); int size=N*N*sizeof(int); /* Insert table here */ char filename[20]; sprintf(filename, "table%dx%d.bin", N, N); printf("Reading %dx%d table from file %s\n", N, N, filename); table = (int *)malloc(N*N*sizeof(int)); read_from_file(table, filename, N); printf("This is kernel c\n"); printf("The game will be played for %d generations N=%d\n", t, N); //!!!Start Timer!!! gettimeofday (&startwtime, NULL); //Allocate space of new and old in device cudaMalloc(&newer, size); cudaMalloc(&old, size); //copy table cudaMemcpy(old, table, size, cudaMemcpyHostToDevice); blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD); //Play game for t generations for(count=0;count<t;count++){ game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N); cudaThreadSynchronize(); //swap pointers temp=old; old=newer; newer=temp; } //copy back table cudaMemcpy(table, old, size, cudaMemcpyDeviceToHost); //!!!End Timer!!! gettimeofday (&endwtime, NULL); seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec); printf("Cuda clock time = %f\n", seq_time); save_table(table, N); cudaFree(newer); cudaFree(old); free(table); return(0); } void read_from_file(int *X, char *filename, int N){ FILE *fp = fopen(filename, "r+"); int size = fread(X, sizeof(int), N*N, fp); printf("elements: %d\n", size); fclose(fp); } void save_table(int *X, int N){ FILE *fp; char filename[20]; sprintf(filename, "cuda_c_table%dx%d.bin", N, N); printf("Saving table in file %s\n", filename); fp = fopen(filename, "w+"); fwrite(X, sizeof(int), N*N, fp); fclose(fp); }
/* Metsai Aleksandros 7723 * metsalex@ece.auth.gr * * Game of life using CUDA. Multiple cells per thread and use of shared memory */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #define THRESHOLD 0.4 #define CELLS_PER_THREAD 2 #define THREADS_PER_BLOCK (500/CELLS_PER_THREAD) struct timeval startwtime, endwtime; double seq_time; __global__ void game_c (int *newer, int *old, int N) { int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD; __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; //Extended Tables __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD; int count; int sum=0; int i=(int) index/N; int j= index%N; int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index for(count=0; count<CELLS_PER_THREAD;count++){ if(i==0){ //top if(j==0){ top[0]= old[N*N-1]; mid[0]= old[N-1]; bot[0]= old[2*N -1]; top[1]= old[N*(N-1)]; mid[1]= old[0]; bot[1]= old[N]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-1)]; mid[lindex+1]= old[0]; bot[lindex+1]= old[N]; top[lindex]= old[N*N -1]; mid[lindex]= old[N-1]; bot[lindex]= old[2*N -1]; }else{ if(lindex==1){ top[lindex-1]= old[N*(N-1) +(j-1)]; mid[lindex-1]= old[j-1]; bot[lindex-1]= old[N+(j-1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; }else if(lindex==(lsize)){ top[lindex+1]= old[N*(N-1) +(j+1)]; mid[lindex+1]= old[j+1]; bot[lindex+1]= old[N+ (j+1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N +j]; }else{ top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; } } }else if(i==(N-1)){ //bottom if(j==0){ top[0]= old[N*(N-1) -1]; mid[0]= old[N*N -1]; bot[0]= old[N-1]; top[1]= old[N*(N-2)]; mid[1]= old[N*(N-1)]; bot[1]= old[0]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-2)]; mid[lindex+1]= old[N*(N-1)]; bot[lindex+1]= old[0]; top[lindex]= old[N*(N-1) -1]; mid[lindex]= old[N*N -1]; bot[lindex]= old[N-1]; }else{ // !! if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[j-1]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; } } }else if(j==0){ //left top[0]= old[(i-1)*N +(N-1)]; mid[0]= old[i*N +(N-1)]; bot[0]= old[(i+1)*N +(N-1)]; top[1]= old[(i-1)*N]; mid[1]= old[i*N]; bot[1]= old[(i+1)*N]; }else if(j==(N-1)){ //right top[lindex+1]= old[(i-1)*N]; mid[lindex+1]= old[i*N]; bot[lindex+1]= old[(i+1)*N]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ //general case if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[(i+1)*N +(j-1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(i+1)*N +(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; } } lindex++; j++; } //Restore values j=index%N; lindex=threadIdx.x*CELLS_PER_THREAD +1; __syncthreads(); for(count=0; count<CELLS_PER_THREAD; count++){ sum= top[lindex-1] +top[lindex]+top[lindex+1] +mid[lindex-1] +mid[lindex+1] +bot[lindex-1] +bot[lindex] +bot[lindex+1]; switch(sum){ case 3: newer[i*N + j] = 1; break; case 2: newer[i*N + j] = old[i*N + j]; break; default: newer[i*N + j] = 0; } lindex++; j++; } } void read_from_file(int *X, char *filename, int N); void save_table(int *X, int N); int main(){ int *table; int* newer; int* old; int *temp; int blocks, t, N, count; printf("Set the number of generations\n"); scanf("%d", &t); printf("Set N (table size = NxN)\n"); scanf("%d", &N); int size=N*N*sizeof(int); /* Insert table here */ char filename[20]; sprintf(filename, "table%dx%d.bin", N, N); printf("Reading %dx%d table from file %s\n", N, N, filename); table = (int *)malloc(N*N*sizeof(int)); read_from_file(table, filename, N); printf("This is kernel c\n"); printf("The game will be played for %d generations N=%d\n", t, N); //!!!Start Timer!!! gettimeofday (&startwtime, NULL); //Allocate space of new and old in device hipMalloc(&newer, size); hipMalloc(&old, size); //copy table hipMemcpy(old, table, size, hipMemcpyHostToDevice); blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD); //Play game for t generations for(count=0;count<t;count++){ game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N); hipDeviceSynchronize(); //swap pointers temp=old; old=newer; newer=temp; } //copy back table hipMemcpy(table, old, size, hipMemcpyDeviceToHost); //!!!End Timer!!! gettimeofday (&endwtime, NULL); seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec); printf("Cuda clock time = %f\n", seq_time); save_table(table, N); hipFree(newer); hipFree(old); free(table); return(0); } void read_from_file(int *X, char *filename, int N){ FILE *fp = fopen(filename, "r+"); int size = fread(X, sizeof(int), N*N, fp); printf("elements: %d\n", size); fclose(fp); } void save_table(int *X, int N){ FILE *fp; char filename[20]; sprintf(filename, "cuda_c_table%dx%d.bin", N, N); printf("Saving table in file %s\n", filename); fp = fopen(filename, "w+"); fwrite(X, sizeof(int), N*N, fp); fclose(fp); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
/* Metsai Aleksandros 7723 * metsalex@ece.auth.gr * * Game of life using CUDA. Multiple cells per thread and use of shared memory */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #define THRESHOLD 0.4 #define CELLS_PER_THREAD 2 #define THREADS_PER_BLOCK (500/CELLS_PER_THREAD) struct timeval startwtime, endwtime; double seq_time; __global__ void game_c (int *newer, int *old, int N) { int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD; __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; //Extended Tables __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD; int count; int sum=0; int i=(int) index/N; int j= index%N; int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index for(count=0; count<CELLS_PER_THREAD;count++){ if(i==0){ //top if(j==0){ top[0]= old[N*N-1]; mid[0]= old[N-1]; bot[0]= old[2*N -1]; top[1]= old[N*(N-1)]; mid[1]= old[0]; bot[1]= old[N]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-1)]; mid[lindex+1]= old[0]; bot[lindex+1]= old[N]; top[lindex]= old[N*N -1]; mid[lindex]= old[N-1]; bot[lindex]= old[2*N -1]; }else{ if(lindex==1){ top[lindex-1]= old[N*(N-1) +(j-1)]; mid[lindex-1]= old[j-1]; bot[lindex-1]= old[N+(j-1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; }else if(lindex==(lsize)){ top[lindex+1]= old[N*(N-1) +(j+1)]; mid[lindex+1]= old[j+1]; bot[lindex+1]= old[N+ (j+1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N +j]; }else{ top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; } } }else if(i==(N-1)){ //bottom if(j==0){ top[0]= old[N*(N-1) -1]; mid[0]= old[N*N -1]; bot[0]= old[N-1]; top[1]= old[N*(N-2)]; mid[1]= old[N*(N-1)]; bot[1]= old[0]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-2)]; mid[lindex+1]= old[N*(N-1)]; bot[lindex+1]= old[0]; top[lindex]= old[N*(N-1) -1]; mid[lindex]= old[N*N -1]; bot[lindex]= old[N-1]; }else{ // !! if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[j-1]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; } } }else if(j==0){ //left top[0]= old[(i-1)*N +(N-1)]; mid[0]= old[i*N +(N-1)]; bot[0]= old[(i+1)*N +(N-1)]; top[1]= old[(i-1)*N]; mid[1]= old[i*N]; bot[1]= old[(i+1)*N]; }else if(j==(N-1)){ //right top[lindex+1]= old[(i-1)*N]; mid[lindex+1]= old[i*N]; bot[lindex+1]= old[(i+1)*N]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ //general case if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[(i+1)*N +(j-1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(i+1)*N +(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; } } lindex++; j++; } //Restore values j=index%N; lindex=threadIdx.x*CELLS_PER_THREAD +1; __syncthreads(); for(count=0; count<CELLS_PER_THREAD; count++){ sum= top[lindex-1] +top[lindex]+top[lindex+1] +mid[lindex-1] +mid[lindex+1] +bot[lindex-1] +bot[lindex] +bot[lindex+1]; switch(sum){ case 3: newer[i*N + j] = 1; break; case 2: newer[i*N + j] = old[i*N + j]; break; default: newer[i*N + j] = 0; } lindex++; j++; } } void read_from_file(int *X, char *filename, int N); void save_table(int *X, int N); int main(){ int *table; int* newer; int* old; int *temp; int blocks, t, N, count; printf("Set the number of generations\n"); scanf("%d", &t); printf("Set N (table size = NxN)\n"); scanf("%d", &N); int size=N*N*sizeof(int); /* Insert table here */ char filename[20]; sprintf(filename, "table%dx%d.bin", N, N); printf("Reading %dx%d table from file %s\n", N, N, filename); table = (int *)malloc(N*N*sizeof(int)); read_from_file(table, filename, N); printf("This is kernel c\n"); printf("The game will be played for %d generations N=%d\n", t, N); //!!!Start Timer!!! gettimeofday (&startwtime, NULL); //Allocate space of new and old in device hipMalloc(&newer, size); hipMalloc(&old, size); //copy table hipMemcpy(old, table, size, hipMemcpyHostToDevice); blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD); //Play game for t generations for(count=0;count<t;count++){ game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N); hipDeviceSynchronize(); //swap pointers temp=old; old=newer; newer=temp; } //copy back table hipMemcpy(table, old, size, hipMemcpyDeviceToHost); //!!!End Timer!!! gettimeofday (&endwtime, NULL); seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec); printf("Cuda clock time = %f\n", seq_time); save_table(table, N); hipFree(newer); hipFree(old); free(table); return(0); } void read_from_file(int *X, char *filename, int N){ FILE *fp = fopen(filename, "r+"); int size = fread(X, sizeof(int), N*N, fp); printf("elements: %d\n", size); fclose(fp); } void save_table(int *X, int N){ FILE *fp; char filename[20]; sprintf(filename, "cuda_c_table%dx%d.bin", N, N); printf("Saving table in file %s\n", filename); fp = fopen(filename, "w+"); fwrite(X, sizeof(int), N*N, fp); fclose(fp); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6game_cPiS_i .globl _Z6game_cPiS_i .p2align 8 .type _Z6game_cPiS_i,@function _Z6game_cPiS_i: s_clause 0x2 s_load_b32 s18, s[0:1], 0x10 s_load_b32 s2, s[0:1], 0x24 s_load_b64 s[6:7], s[0:1], 0x8 s_mov_b32 s5, 0 v_lshl_or_b32 v22, v0, 1, 1 v_lshl_or_b32 v23, v0, 3, 4 s_movk_i32 s30, 0x400 v_mov_b32_e32 v28, 0 s_waitcnt lgkmcnt(0) s_ashr_i32 s14, s18, 31 s_and_b32 s2, s2, 0xffff s_add_i32 s3, s18, s14 s_ashr_i32 s19, s18, 31 s_xor_b32 s16, s3, s14 s_mul_i32 s4, s18, s18 v_cvt_f32_u32_e32 v1, s16 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_rcp_iflag_f32_e32 v1, v1 s_waitcnt_depctr 0xfff v_mul_f32_e32 v1, 0x4f7ffffe, v1 v_cvt_u32_f32_e32 v4, v1 v_mad_u64_u32 v[2:3], null, s15, s2, v[0:1] s_sub_i32 s2, 0, s16 s_add_u32 s24, s6, -4 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_2) v_mul_lo_u32 v3, s2, v4 s_addc_u32 s25, s7, -1 s_add_i32 s2, s18, -2 s_add_i32 s20, s18, -1 v_lshlrev_b32_e32 v1, 1, v2 v_bfe_i32 v2, v2, 30, 1 s_mul_i32 s2, s2, s18 s_mul_i32 s10, s20, s18 v_mul_hi_u32 v3, v4, v3 s_ashr_i32 s3, s2, 31 v_add_nc_u32_e32 v5, v1, v2 s_lshl_b64 s[2:3], s[2:3], 2 v_subrev_nc_u32_e32 v24, s18, v1 s_add_u32 s8, s6, s2 s_addc_u32 s9, s7, s3 v_xor_b32_e32 v5, v5, v2 v_add_nc_u32_e32 v3, v4, v3 v_xor_b32_e32 v2, s14, v2 s_ashr_i32 s11, s10, 31 v_add_nc_u32_e32 v25, s18, v1 s_lshl_b64 s[2:3], s[10:11], 2 v_mul_hi_u32 v3, v5, v3 s_add_u32 s10, s6, s2 s_addc_u32 s11, s7, s3 s_lshl_b64 s[2:3], s[4:5], 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) s_add_u32 s12, s24, s2 s_addc_u32 s13, s25, s3 s_ashr_i32 s21, s20, 31 v_mul_lo_u32 v4, v3, s16 s_lshl_b64 s[2:3], s[20:21], 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) s_add_u32 s14, s6, s2 s_addc_u32 s15, s7, s3 s_lshl_b64 s[2:3], s[18:19], 2 v_sub_nc_u32_e32 v4, v5, v4 v_add_nc_u32_e32 v5, 1, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_subrev_nc_u32_e32 v6, s16, v4 v_cmp_le_u32_e32 vcc_lo, s16, v4 v_dual_cndmask_b32 v3, v3, v5 :: v_dual_cndmask_b32 v4, v4, v6 v_add_nc_u32_e32 v6, s18, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v5, 1, v3 v_cmp_le_u32_e32 vcc_lo, s16, v4 s_add_u32 s16, s6, s2 s_addc_u32 s17, s7, s3 s_lshl_b32 s2, s18, 1 v_cndmask_b32_e32 v3, v3, v5, vcc_lo s_ashr_i32 s3, s2, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_lshl_b64 s[22:23], s[2:3], 2 v_xor_b32_e32 v3, v3, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_sub_nc_u32_e32 v5, v3, v2 v_sub_nc_u32_e32 v2, v2, v3 v_xad_u32 v8, v3, -1, v6 v_add_nc_u32_e32 v7, -1, v5 v_mul_lo_u32 v4, v5, s18 s_delay_alu instid0(VALU_DEP_4) v_mul_lo_u32 v9, s18, v2 v_cmp_ne_u32_e32 vcc_lo, 0, v5 v_cmp_ne_u32_e64 s2, s20, v5 v_mul_lo_u32 v6, v7, s18 v_mad_u64_u32 v[2:3], null, s18, v8, v[1:2] v_add_nc_u32_e32 v8, s18, v4 v_ashrrev_i32_e32 v5, 31, v4 v_sub_nc_u32_e32 v3, v1, v4 v_add_nc_u32_e32 v10, s20, v4 v_ashrrev_i32_e32 v7, 31, v6 v_add3_u32 v26, v9, s18, v1 v_lshlrev_b64 v[12:13], 2, v[4:5] v_ashrrev_i32_e32 v9, 31, v8 v_ashrrev_i32_e32 v4, 31, v3 v_add_nc_u32_e32 v14, s20, v6 v_lshlrev_b64 v[6:7], 2, v[6:7] v_ashrrev_i32_e32 v11, 31, v10 v_add_nc_u32_e32 v16, s20, v8 v_xad_u32 v27, v1, -1, v8 v_lshlrev_b64 v[8:9], 2, v[8:9] v_lshlrev_b64 v[18:19], 2, v[3:4] v_add_co_u32 v4, s3, s6, v12 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v5, s3, s7, v13, s3 v_lshlrev_b64 v[10:11], 2, v[10:11] v_add_co_u32 v6, s3, s6, v6 v_ashrrev_i32_e32 v15, 31, v14 v_add_co_ci_u32_e64 v7, s3, s7, v7, s3 v_add_co_u32 v8, s3, s6, v8 v_ashrrev_i32_e32 v17, 31, v16 v_add_co_ci_u32_e64 v9, s3, s7, v9, s3 v_lshlrev_b64 v[14:15], 2, v[14:15] v_add_co_u32 v10, s3, s6, v10 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v11, s3, s7, v11, s3 v_lshlrev_b64 v[16:17], 2, v[16:17] v_add_co_u32 v12, s3, s6, v18 v_add_co_ci_u32_e64 v13, s3, s7, v19, s3 v_add_co_u32 v14, s3, s6, v14 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v15, s3, s7, v15, s3 v_add_co_u32 v16, s3, s6, v16 v_add_co_ci_u32_e64 v17, s3, s7, v17, s3 s_add_u32 s18, s24, s22 s_addc_u32 s19, s25, s23 s_branch .LBB0_3 .LBB0_1: s_or_b32 exec_lo, exec_lo, s3 .LBB0_2: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1) s_or_b32 exec_lo, exec_lo, s4 v_add_co_u32 v12, s3, v12, 4 v_add_nc_u32_e32 v23, 4, v23 v_add_co_ci_u32_e64 v13, s3, 0, v13, s3 s_add_i32 s5, s5, 1 s_cmp_eq_u32 s5, 1 s_cbranch_scc0 .LBB0_64 .LBB0_3: v_add_nc_u32_e32 v19, s5, v3 v_add_nc_u32_e32 v18, s5, v22 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_cmp_ne_u32_e64 s3, 0, v19 s_and_saveexec_b32 s4, vcc_lo s_xor_b32 s20, exec_lo, s4 s_cbranch_execz .LBB0_45 s_and_saveexec_b32 s4, s2 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s21, exec_lo, s4 s_cbranch_execz .LBB0_24 s_and_saveexec_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s22, exec_lo, s4 s_cbranch_execz .LBB0_21 s_mov_b32 s23, exec_lo v_cmpx_ne_u32_e64 s5, v27 s_xor_b32 s23, exec_lo, s23 s_cbranch_execz .LBB0_18 s_mov_b32 s24, 0 s_mov_b32 s26, 0 s_mov_b32 s25, exec_lo v_cmpx_lt_i32_e32 0x1f3, v18 s_xor_b32 s25, exec_lo, s25 s_cbranch_execz .LBB0_11 s_mov_b32 s27, -1 s_mov_b32 s26, exec_lo v_cmpx_eq_u32_e32 0x1f4, v18 s_cbranch_execz .LBB0_10 v_add_nc_u32_e32 v18, s5, v24 v_add_nc_u32_e32 v20, s5, v1 v_add_nc_u32_e32 v29, s5, v25 s_movk_i32 s27, 0xc00 s_movk_i32 s28, 0x400 v_add_nc_u32_e32 v30, 1, v18 v_add_nc_u32_e32 v32, 1, v20 v_add_nc_u32_e32 v34, 1, v29 v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v31, 31, v30 v_ashrrev_i32_e32 v33, 31, v32 v_ashrrev_i32_e32 v35, 31, v34 v_lshlrev_b64 v[18:19], 2, v[18:19] v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[30:31], 2, v[30:31] v_lshlrev_b64 v[32:33], 2, v[32:33] v_lshlrev_b64 v[34:35], 2, v[34:35] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v36, s4, s6, v30 v_add_co_ci_u32_e64 v37, s4, s7, v31, s4 s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_3) | instid1(VALU_DEP_1) v_add_co_u32 v31, s4, s6, v32 v_ashrrev_i32_e32 v30, 31, v29 v_add_co_ci_u32_e64 v32, s4, s7, v33, s4 v_add_co_u32 v33, s4, s6, v34 v_add_co_ci_u32_e64 v34, s4, s7, v35, s4 v_add_co_u32 v18, s4, s6, v18 v_lshlrev_b64 v[29:30], 2, v[29:30] v_add_co_ci_u32_e64 v19, s4, s7, v19, s4 v_add_co_u32 v20, s4, s6, v20 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_ci_u32_e64 v21, s4, s7, v21, s4 v_add_co_u32 v29, s4, s6, v29 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_clause 0x5 global_load_b32 v35, v[36:37], off global_load_b32 v31, v[31:32], off global_load_b32 v32, v[33:34], off global_load_b32 v18, v[18:19], off global_load_b32 v19, v[20:21], off global_load_b32 v20, v[29:30], off s_movk_i32 s4, 0x1400 v_add_nc_u32_e32 v29, s27, v28 v_add_nc_u32_e32 v21, s4, v28 v_add_nc_u32_e32 v30, s28, v28 s_xor_b32 s27, exec_lo, -1 s_waitcnt vmcnt(2) ds_store_2addr_b32 v21, v18, v35 offset0:228 offset1:229 s_waitcnt vmcnt(1) ds_store_2addr_b32 v29, v19, v31 offset0:236 offset1:237 s_waitcnt vmcnt(0) ds_store_2addr_b32 v30, v20, v32 offset0:244 offset1:245 .LBB0_10: s_or_b32 exec_lo, exec_lo, s26 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 s26, s27, exec_lo .LBB0_11: s_and_not1_saveexec_b32 s25, s25 v_cmp_ne_u32_e64 s4, 1, v18 s_and_not1_b32 s26, s26, exec_lo s_mov_b32 s24, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s4, s4, exec_lo s_or_b32 s26, s26, s4 s_or_b32 exec_lo, exec_lo, s25 s_and_saveexec_b32 s4, s26 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s25, exec_lo, s4 s_cbranch_execz .LBB0_15 v_add_nc_u32_e32 v18, s5, v24 v_add_nc_u32_e32 v20, s5, v1 v_add_nc_u32_e32 v29, s5, v25 s_and_not1_b32 s24, s24, exec_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v21, 31, v20 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v30, 31, v29 v_lshlrev_b64 v[18:19], 2, v[18:19] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[29:30], 2, v[29:30] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v18, s4, s6, v18 v_add_co_ci_u32_e64 v19, s4, s7, v19, s4 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v20, s4, s6, v20 v_add_co_ci_u32_e64 v21, s4, s7, v21, s4 v_add_co_u32 v29, s4, s6, v29 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_clause 0x2 global_load_b32 v18, v[18:19], off global_load_b32 v19, v[20:21], off global_load_b32 v20, v[29:30], off s_waitcnt vmcnt(2) ds_store_b32 v23, v18 offset:4032 s_waitcnt vmcnt(1) ds_store_b32 v23, v19 offset:2016 s_waitcnt vmcnt(0) ds_store_b32 v23, v20 .LBB0_15: s_or_b32 exec_lo, exec_lo, s25 s_and_saveexec_b32 s25, s24 s_cbranch_execz .LBB0_17 v_add_nc_u32_e32 v18, s5, v24 v_add_nc_u32_e32 v20, s5, v1 v_add_nc_u32_e32 v29, s5, v25 s_movk_i32 s24, 0x400 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_nc_u32_e32 v30, -1, v18 v_add_nc_u32_e32 v32, -1, v20 s_delay_alu instid0(VALU_DEP_3) v_add_nc_u32_e32 v34, -1, v29 v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v31, 31, v30 v_ashrrev_i32_e32 v33, 31, v32 v_ashrrev_i32_e32 v35, 31, v34 v_lshlrev_b64 v[18:19], 2, v[18:19] v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[30:31], 2, v[30:31] v_lshlrev_b64 v[32:33], 2, v[32:33] v_lshlrev_b64 v[34:35], 2, v[34:35] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v36, s4, s6, v30 v_add_co_ci_u32_e64 v37, s4, s7, v31, s4 s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_3) | instid1(VALU_DEP_1) v_add_co_u32 v31, s4, s6, v32 v_ashrrev_i32_e32 v30, 31, v29 v_add_co_ci_u32_e64 v32, s4, s7, v33, s4 v_add_co_u32 v33, s4, s6, v34 v_add_co_ci_u32_e64 v34, s4, s7, v35, s4 v_add_co_u32 v18, s4, s6, v18 v_lshlrev_b64 v[29:30], 2, v[29:30] v_add_co_ci_u32_e64 v19, s4, s7, v19, s4 v_add_co_u32 v20, s4, s6, v20 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_ci_u32_e64 v21, s4, s7, v21, s4 v_add_co_u32 v29, s4, s6, v29 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_clause 0x5 global_load_b32 v35, v[36:37], off global_load_b32 v31, v[31:32], off global_load_b32 v32, v[33:34], off global_load_b32 v18, v[18:19], off global_load_b32 v19, v[20:21], off global_load_b32 v20, v[29:30], off s_movk_i32 s4, 0xc00 v_add_nc_u32_e32 v29, s24, v28 v_add_nc_u32_e32 v21, s4, v28 s_waitcnt vmcnt(2) ds_store_2addr_b32 v21, v35, v18 offset0:240 offset1:241 s_waitcnt vmcnt(1) ds_store_2addr_b32 v29, v31, v19 offset0:248 offset1:249 s_waitcnt vmcnt(0) ds_store_2addr_b32 v28, v32, v20 offset1:1 .LBB0_17: s_or_b32 exec_lo, exec_lo, s25 .LBB0_18: s_and_not1_saveexec_b32 s23, s23 s_cbranch_execz .LBB0_20 v_add_nc_u32_e32 v18, s5, v24 v_add_nc_u32_e32 v20, s5, v1 v_add_nc_u32_e32 v29, s5, v25 s_movk_i32 s24, 0x400 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v21, 31, v20 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_ashrrev_i32_e32 v30, 31, v29 v_lshlrev_b64 v[18:19], 2, v[18:19] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[29:30], 2, v[29:30] s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v18, s4, s6, v18 v_add_co_ci_u32_e64 v19, s4, s7, v19, s4 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v20, s4, s6, v20 v_add_co_ci_u32_e64 v21, s4, s7, v21, s4 v_add_co_u32 v29, s4, s6, v29 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_clause 0x5 global_load_b32 v31, v[6:7], off global_load_b32 v32, v[4:5], off global_load_b32 v33, v[8:9], off global_load_b32 v18, v[18:19], off global_load_b32 v19, v[20:21], off global_load_b32 v20, v[29:30], off s_movk_i32 s4, 0xc00 v_add_nc_u32_e32 v29, s24, v23 v_add_nc_u32_e32 v21, s4, v23 s_waitcnt vmcnt(2) ds_store_2addr_b32 v21, v18, v31 offset0:240 offset1:241 s_waitcnt vmcnt(1) ds_store_2addr_b32 v29, v19, v32 offset0:248 offset1:249 s_waitcnt vmcnt(0) ds_store_2addr_b32 v23, v20, v33 offset1:1 .LBB0_20: s_or_b32 exec_lo, exec_lo, s23 .LBB0_21: s_and_not1_saveexec_b32 s4, s22 s_cbranch_execz .LBB0_23 s_clause 0x5 global_load_b32 v18, v[14:15], off global_load_b32 v19, v[10:11], off global_load_b32 v20, v[16:17], off global_load_b32 v21, v[6:7], off global_load_b32 v29, v[4:5], off global_load_b32 v30, v[8:9], off s_movk_i32 s22, 0xc00 s_movk_i32 s23, 0x400 v_add_nc_u32_e32 v31, s22, v28 v_add_nc_u32_e32 v32, s23, v28 s_waitcnt vmcnt(2) ds_store_2addr_b32 v31, v18, v21 offset0:240 offset1:241 s_waitcnt vmcnt(1) ds_store_2addr_b32 v32, v19, v29 offset0:248 offset1:249 s_waitcnt vmcnt(0) ds_store_2addr_b32 v28, v20, v30 offset1:1 .LBB0_23: s_or_b32 exec_lo, exec_lo, s4 .LBB0_24: s_and_not1_saveexec_b32 s21, s21 s_cbranch_execz .LBB0_44 s_and_saveexec_b32 s4, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s22, exec_lo, s4 s_cbranch_execz .LBB0_41 s_mov_b32 s23, exec_lo v_cmpx_ne_u32_e64 s5, v27 s_xor_b32 s23, exec_lo, s23 s_cbranch_execz .LBB0_38 s_mov_b32 s24, 0 s_mov_b32 s26, 0 s_mov_b32 s25, exec_lo v_cmpx_lt_i32_e32 0x1f3, v18 s_xor_b32 s25, exec_lo, s25 s_cbranch_execz .LBB0_31 s_mov_b32 s27, -1 s_mov_b32 s26, exec_lo v_cmpx_eq_u32_e32 0x1f4, v18 s_cbranch_execz .LBB0_30 v_add_nc_u32_e32 v18, s5, v24 v_add_nc_u32_e32 v20, s5, v1 v_add3_u32 v31, v3, s5, 1 s_movk_i32 s27, 0xc00 s_movk_i32 s28, 0x400 v_add_nc_u32_e32 v29, 1, v18 v_add_nc_u32_e32 v33, 1, v20 v_ashrrev_i32_e32 v32, 31, v31 v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v30, 31, v29 v_ashrrev_i32_e32 v34, 31, v33 v_lshlrev_b64 v[31:32], 2, v[31:32] v_lshlrev_b64 v[18:19], 2, v[18:19] v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[29:30], 2, v[29:30] v_lshlrev_b64 v[33:34], 2, v[33:34] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v29, s4, s6, v29 v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v33, s4, s6, v33 v_add_co_ci_u32_e64 v34, s4, s7, v34, s4 v_add_co_u32 v31, s4, s6, v31 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v32, s4, s7, v32, s4 v_add_co_u32 v18, s4, s6, v18 v_add_co_ci_u32_e64 v19, s4, s7, v19, s4 v_add_co_u32 v20, s4, s6, v20 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v21, s4, s7, v21, s4 s_clause 0x4 global_load_b32 v29, v[29:30], off global_load_b32 v30, v[33:34], off global_load_b32 v31, v[31:32], off global_load_b32 v18, v[18:19], off global_load_b32 v19, v[20:21], off global_load_b32 v20, v[12:13], off s_movk_i32 s4, 0x1400 v_add_nc_u32_e32 v32, s27, v28 v_add_nc_u32_e32 v21, s4, v28 v_add_nc_u32_e32 v33, s28, v28 s_xor_b32 s27, exec_lo, -1 s_waitcnt vmcnt(2) ds_store_2addr_b32 v21, v18, v29 offset0:228 offset1:229 s_waitcnt vmcnt(1) ds_store_2addr_b32 v32, v19, v30 offset0:236 offset1:237 s_waitcnt vmcnt(0) ds_store_2addr_b32 v33, v20, v31 offset0:244 offset1:245 .LBB0_30: s_or_b32 exec_lo, exec_lo, s26 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 s26, s27, exec_lo .LBB0_31: s_and_not1_saveexec_b32 s25, s25 v_cmp_ne_u32_e64 s4, 1, v18 s_and_not1_b32 s26, s26, exec_lo s_mov_b32 s24, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s4, s4, exec_lo s_or_b32 s26, s26, s4 s_or_b32 exec_lo, exec_lo, s25 v_add_nc_u32_e32 v20, s5, v24 v_add_nc_u32_e32 v18, s5, v1 s_and_saveexec_b32 s4, s26 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s25, exec_lo, s4 s_cbranch_execz .LBB0_35 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v19, 31, v18 s_and_not1_b32 s24, s24, exec_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[29:30], 2, v[20:21] v_lshlrev_b64 v[31:32], 2, v[18:19] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v29, s4, s6, v29 v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v31, s4, s6, v31 v_add_co_ci_u32_e64 v32, s4, s7, v32, s4 s_clause 0x1 global_load_b32 v19, v[29:30], off global_load_b32 v21, v[31:32], off global_load_b32 v29, v[12:13], off s_waitcnt vmcnt(2) ds_store_b32 v23, v19 offset:4032 s_waitcnt vmcnt(1) ds_store_b32 v23, v21 offset:2016 s_waitcnt vmcnt(0) ds_store_b32 v23, v29 .LBB0_35: s_or_b32 exec_lo, exec_lo, s25 s_and_saveexec_b32 s25, s24 s_cbranch_execz .LBB0_37 v_add_nc_u32_e32 v29, -1, v20 v_add_nc_u32_e32 v31, -1, v18 v_add3_u32 v33, v3, s5, -1 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v30, 31, v29 v_ashrrev_i32_e32 v32, 31, v31 v_ashrrev_i32_e32 v34, 31, v33 v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[18:19], 2, v[18:19] v_lshlrev_b64 v[29:30], 2, v[29:30] v_lshlrev_b64 v[31:32], 2, v[31:32] v_lshlrev_b64 v[33:34], 2, v[33:34] s_movk_i32 s24, 0x400 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v29, s4, s6, v29 v_add_co_ci_u32_e64 v30, s4, s7, v30, s4 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v31, s4, s6, v31 v_add_co_ci_u32_e64 v32, s4, s7, v32, s4 v_add_co_u32 v33, s4, s6, v33 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v34, s4, s7, v34, s4 v_add_co_u32 v20, s4, s6, v20 v_add_co_ci_u32_e64 v21, s4, s7, v21, s4 v_add_co_u32 v18, s4, s6, v18 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v19, s4, s7, v19, s4 s_clause 0x4 global_load_b32 v29, v[29:30], off global_load_b32 v30, v[31:32], off global_load_b32 v31, v[33:34], off global_load_b32 v20, v[20:21], off global_load_b32 v18, v[18:19], off global_load_b32 v19, v[12:13], off s_movk_i32 s4, 0xc00 v_add_nc_u32_e32 v32, s24, v28 v_add_nc_u32_e32 v21, s4, v28 s_waitcnt vmcnt(2) ds_store_2addr_b32 v21, v29, v20 offset0:240 offset1:241 s_waitcnt vmcnt(1) ds_store_2addr_b32 v32, v30, v18 offset0:248 offset1:249 s_waitcnt vmcnt(0) ds_store_2addr_b32 v28, v31, v19 offset1:1 .LBB0_37: s_or_b32 exec_lo, exec_lo, s25 .LBB0_38: s_and_not1_saveexec_b32 s4, s23 s_cbranch_execz .LBB0_40 s_add_u32 s24, s10, -4 s_addc_u32 s25, s11, -1 s_movk_i32 s29, 0xc00 s_clause 0x5 s_load_b32 s23, s[24:25], 0x0 s_load_b32 s24, s[8:9], 0x0 s_load_b32 s25, s[12:13], 0x0 s_load_b32 s26, s[10:11], 0x0 s_load_b32 s27, s[14:15], 0x0 s_load_b32 s28, s[6:7], 0x0 v_add_nc_u32_e32 v18, s29, v23 v_add_nc_u32_e32 v19, s30, v23 s_waitcnt lgkmcnt(0) v_dual_mov_b32 v31, s23 :: v_dual_mov_b32 v20, s24 v_mov_b32_e32 v29, s25 v_dual_mov_b32 v21, s26 :: v_dual_mov_b32 v32, s27 v_mov_b32_e32 v30, s28 ds_store_2addr_b32 v19, v29, v21 offset0:248 offset1:249 ds_store_2addr_b32 v18, v31, v20 offset0:240 offset1:241 ds_store_2addr_b32 v23, v32, v30 offset1:1 .LBB0_40: s_or_b32 exec_lo, exec_lo, s4 .LBB0_41: s_and_not1_saveexec_b32 s4, s22 s_cbranch_execz .LBB0_43 s_add_u32 s22, s10, -4 s_addc_u32 s23, s11, -1 s_clause 0x5 s_load_b32 s24, s[12:13], 0x0 s_load_b32 s25, s[14:15], 0x0 s_load_b32 s22, s[22:23], 0x0 s_load_b32 s23, s[10:11], 0x0 s_load_b32 s26, s[8:9], 0x0 s_load_b32 s27, s[6:7], 0x0 s_movk_i32 s28, 0xc00 s_movk_i32 s29, 0x400 v_add_nc_u32_e32 v18, s28, v28 s_waitcnt lgkmcnt(0) v_dual_mov_b32 v20, s24 :: v_dual_add_nc_u32 v19, s29, v28 v_mov_b32_e32 v21, s25 v_mov_b32_e32 v29, s22 v_dual_mov_b32 v31, s23 :: v_dual_mov_b32 v30, s26 v_mov_b32_e32 v32, s27 ds_store_2addr_b32 v18, v29, v30 offset0:240 offset1:241 ds_store_2addr_b32 v19, v20, v31 offset0:248 offset1:249 ds_store_2addr_b32 v28, v21, v32 offset1:1 .LBB0_43: s_or_b32 exec_lo, exec_lo, s4 .LBB0_44: s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 exec_lo, exec_lo, s21 .LBB0_45: s_and_not1_saveexec_b32 s4, s20 s_cbranch_execz .LBB0_2 s_and_saveexec_b32 s20, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s20, exec_lo, s20 s_cbranch_execz .LBB0_62 s_mov_b32 s21, exec_lo v_cmpx_ne_u32_e64 s5, v27 s_xor_b32 s21, exec_lo, s21 s_cbranch_execz .LBB0_59 s_mov_b32 s22, 0 s_mov_b32 s24, 0 s_mov_b32 s23, exec_lo v_cmpx_lt_i32_e32 0x1f3, v18 s_xor_b32 s23, exec_lo, s23 s_cbranch_execz .LBB0_52 s_mov_b32 s25, -1 s_mov_b32 s24, exec_lo v_cmpx_eq_u32_e32 0x1f4, v18 s_cbranch_execz .LBB0_51 v_add_nc_u32_e32 v18, s5, v2 v_add3_u32 v29, v3, s5, 1 v_add_nc_u32_e32 v20, s5, v26 s_movk_i32 s25, 0xc00 s_movk_i32 s26, 0x400 v_add_nc_u32_e32 v31, 1, v18 v_ashrrev_i32_e32 v30, 31, v29 v_add_nc_u32_e32 v33, 1, v20 v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v32, 31, v31 v_lshlrev_b64 v[29:30], 2, v[29:30] v_ashrrev_i32_e32 v34, 31, v33 v_lshlrev_b64 v[18:19], 2, v[18:19] v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[31:32], 2, v[31:32] s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[33:34], 2, v[33:34] v_add_co_u32 v29, s3, s6, v29 v_add_co_ci_u32_e64 v30, s3, s7, v30, s3 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v31, s3, s6, v31 v_add_co_ci_u32_e64 v32, s3, s7, v32, s3 v_add_co_u32 v33, s3, s6, v33 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v34, s3, s7, v34, s3 v_add_co_u32 v18, s3, s6, v18 v_add_co_ci_u32_e64 v19, s3, s7, v19, s3 v_add_co_u32 v20, s3, s6, v20 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v21, s3, s7, v21, s3 s_clause 0x3 global_load_b32 v31, v[31:32], off global_load_b32 v29, v[29:30], off global_load_b32 v30, v[33:34], off global_load_b32 v18, v[18:19], off global_load_b32 v19, v[12:13], off global_load_b32 v20, v[20:21], off s_movk_i32 s3, 0x1400 v_add_nc_u32_e32 v32, s25, v28 v_add_nc_u32_e32 v21, s3, v28 v_add_nc_u32_e32 v33, s26, v28 s_xor_b32 s25, exec_lo, -1 s_waitcnt vmcnt(2) ds_store_2addr_b32 v21, v18, v31 offset0:228 offset1:229 s_waitcnt vmcnt(1) ds_store_2addr_b32 v32, v19, v29 offset0:236 offset1:237 s_waitcnt vmcnt(0) ds_store_2addr_b32 v33, v20, v30 offset0:244 offset1:245 .LBB0_51: s_or_b32 exec_lo, exec_lo, s24 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 s24, s25, exec_lo .LBB0_52: s_and_not1_saveexec_b32 s23, s23 v_cmp_ne_u32_e64 s3, 1, v18 s_and_not1_b32 s24, s24, exec_lo s_mov_b32 s22, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s3, s3, exec_lo s_or_b32 s24, s24, s3 s_or_b32 exec_lo, exec_lo, s23 v_add_nc_u32_e32 v20, s5, v2 v_add_nc_u32_e32 v18, s5, v26 s_and_saveexec_b32 s3, s24 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s23, exec_lo, s3 s_cbranch_execz .LBB0_56 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v19, 31, v18 s_and_not1_b32 s22, s22, exec_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[29:30], 2, v[20:21] v_lshlrev_b64 v[31:32], 2, v[18:19] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v29, s3, s6, v29 v_add_co_ci_u32_e64 v30, s3, s7, v30, s3 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v31, s3, s6, v31 v_add_co_ci_u32_e64 v32, s3, s7, v32, s3 global_load_b32 v19, v[29:30], off global_load_b32 v21, v[12:13], off global_load_b32 v29, v[31:32], off s_waitcnt vmcnt(2) ds_store_b32 v23, v19 offset:4032 s_waitcnt vmcnt(1) ds_store_b32 v23, v21 offset:2016 s_waitcnt vmcnt(0) ds_store_b32 v23, v29 .LBB0_56: s_or_b32 exec_lo, exec_lo, s23 s_and_saveexec_b32 s23, s22 s_cbranch_execz .LBB0_58 v_add_nc_u32_e32 v29, -1, v20 v_add3_u32 v31, v3, s5, -1 v_add_nc_u32_e32 v33, -1, v18 v_ashrrev_i32_e32 v21, 31, v20 v_ashrrev_i32_e32 v19, 31, v18 v_ashrrev_i32_e32 v30, 31, v29 v_ashrrev_i32_e32 v32, 31, v31 v_ashrrev_i32_e32 v34, 31, v33 v_lshlrev_b64 v[20:21], 2, v[20:21] v_lshlrev_b64 v[18:19], 2, v[18:19] v_lshlrev_b64 v[29:30], 2, v[29:30] v_lshlrev_b64 v[31:32], 2, v[31:32] v_lshlrev_b64 v[33:34], 2, v[33:34] s_movk_i32 s22, 0x400 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v29, s3, s6, v29 v_add_co_ci_u32_e64 v30, s3, s7, v30, s3 s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v31, s3, s6, v31 v_add_co_ci_u32_e64 v32, s3, s7, v32, s3 v_add_co_u32 v33, s3, s6, v33 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v34, s3, s7, v34, s3 v_add_co_u32 v20, s3, s6, v20 v_add_co_ci_u32_e64 v21, s3, s7, v21, s3 v_add_co_u32 v18, s3, s6, v18 s_delay_alu instid0(VALU_DEP_1) v_add_co_ci_u32_e64 v19, s3, s7, v19, s3 s_clause 0x3 global_load_b32 v29, v[29:30], off global_load_b32 v30, v[31:32], off global_load_b32 v31, v[33:34], off global_load_b32 v20, v[20:21], off global_load_b32 v21, v[12:13], off global_load_b32 v18, v[18:19], off s_movk_i32 s3, 0xc00 v_add_nc_u32_e32 v32, s22, v28 v_add_nc_u32_e32 v19, s3, v28 s_waitcnt vmcnt(2) ds_store_2addr_b32 v19, v29, v20 offset0:240 offset1:241 s_waitcnt vmcnt(1) ds_store_2addr_b32 v32, v30, v21 offset0:248 offset1:249 s_waitcnt vmcnt(0) ds_store_2addr_b32 v28, v31, v18 offset1:1 .LBB0_58: s_or_b32 exec_lo, exec_lo, s23 .LBB0_59: s_and_not1_saveexec_b32 s3, s21 s_cbranch_execz .LBB0_61 s_clause 0x5 s_load_b32 s21, s[10:11], 0x0 s_load_b32 s22, s[6:7], 0x0 s_load_b32 s23, s[16:17], 0x0 s_load_b32 s24, s[12:13], 0x0 s_load_b32 s25, s[14:15], 0x0 s_load_b32 s26, s[18:19], 0x0 s_movk_i32 s27, 0xc00 s_movk_i32 s28, 0x400 v_add_nc_u32_e32 v18, s27, v23 s_waitcnt lgkmcnt(0) v_dual_mov_b32 v20, s21 :: v_dual_add_nc_u32 v19, s28, v23 v_mov_b32_e32 v21, s22 v_dual_mov_b32 v29, s23 :: v_dual_mov_b32 v30, s24 v_dual_mov_b32 v31, s25 :: v_dual_mov_b32 v32, s26 ds_store_2addr_b32 v18, v30, v20 offset0:240 offset1:241 ds_store_2addr_b32 v19, v31, v21 offset0:248 offset1:249 ds_store_2addr_b32 v23, v32, v29 offset1:1 .LBB0_61: s_or_b32 exec_lo, exec_lo, s3 .LBB0_62: s_and_not1_saveexec_b32 s3, s20 s_cbranch_execz .LBB0_1 s_clause 0x5 s_load_b32 s20, s[12:13], 0x0 s_load_b32 s21, s[14:15], 0x0 s_load_b32 s22, s[18:19], 0x0 s_load_b32 s23, s[10:11], 0x0 s_load_b32 s24, s[16:17], 0x0 s_load_b32 s25, s[6:7], 0x0 s_movk_i32 s26, 0xc00 s_movk_i32 s27, 0x400 v_add_nc_u32_e32 v18, s26, v28 s_waitcnt lgkmcnt(0) v_dual_mov_b32 v20, s20 :: v_dual_add_nc_u32 v19, s27, v28 v_mov_b32_e32 v21, s21 v_dual_mov_b32 v29, s22 :: v_dual_mov_b32 v30, s23 v_dual_mov_b32 v32, s24 :: v_dual_mov_b32 v31, s25 ds_store_2addr_b32 v18, v20, v30 offset0:240 offset1:241 ds_store_2addr_b32 v19, v21, v31 offset0:248 offset1:249 ds_store_2addr_b32 v28, v29, v32 offset1:1 s_branch .LBB0_1 .LBB0_64: s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b32_e32 v0, 3, v0 s_mov_b32 s2, 0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv s_branch .LBB0_66 .LBB0_65: s_or_b32 exec_lo, exec_lo, s4 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) v_lshlrev_b64 v[2:3], 2, v[3:4] v_add_nc_u32_e32 v1, 1, v1 s_add_i32 s2, s2, 4 s_cmp_eq_u32 s2, 4 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v2, vcc_lo, s0, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo s_waitcnt vmcnt(0) global_store_b32 v[2:3], v5, off s_cbranch_scc0 .LBB0_76 .LBB0_66: v_add_nc_u32_e32 v8, s2, v0 s_movk_i32 s3, 0xc00 s_mov_b32 s5, 0 s_mov_b32 s8, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_add_nc_u32_e32 v2, s3, v8 s_movk_i32 s3, 0x400 v_add_nc_u32_e32 v4, s3, v8 s_mov_b32 s3, 0 ds_load_2addr_b32 v[2:3], v2 offset0:240 offset1:241 ds_load_2addr_b32 v[4:5], v4 offset0:248 offset1:250 ds_load_b32 v9, v8 offset:4040 ds_load_2addr_b32 v[6:7], v8 offset1:1 ds_load_b32 v8, v8 offset:8 s_waitcnt lgkmcnt(4) v_add_nc_u32_e32 v2, v3, v2 s_waitcnt lgkmcnt(2) s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_add3_u32 v2, v2, v9, v4 s_waitcnt lgkmcnt(1) v_add3_u32 v2, v2, v5, v6 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add3_u32 v2, v2, v7, v8 v_cmpx_lt_i32_e32 2, v2 s_xor_b32 s8, exec_lo, s8 s_cbranch_execz .LBB0_70 s_mov_b32 s9, -1 s_mov_b32 s5, exec_lo v_cmpx_eq_u32_e32 3, v2 v_ashrrev_i32_e32 v2, 31, v1 s_mov_b32 s4, 1 s_xor_b32 s9, exec_lo, -1 s_delay_alu instid0(VALU_DEP_1) v_dual_mov_b32 v4, v2 :: v_dual_mov_b32 v3, v1 s_or_b32 exec_lo, exec_lo, s5 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 s5, s9, exec_lo .LBB0_70: s_and_not1_saveexec_b32 s8, s8 v_cmp_ne_u32_e32 vcc_lo, 2, v2 s_and_not1_b32 s5, s5, exec_lo s_mov_b32 s3, exec_lo s_and_b32 s9, vcc_lo, exec_lo s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 s5, s5, s9 s_or_b32 exec_lo, exec_lo, s8 v_mov_b32_e32 v5, s4 v_ashrrev_i32_e32 v2, 31, v1 s_and_saveexec_b32 s4, s5 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s4, exec_lo, s4 s_delay_alu instid0(VALU_DEP_1) v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v4, v2 v_mov_b32_e32 v3, v1 s_and_not1_b32 s3, s3, exec_lo s_or_b32 exec_lo, exec_lo, s4 s_and_saveexec_b32 s4, s3 s_cbranch_execz .LBB0_65 v_lshlrev_b64 v[3:4], 2, v[1:2] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v3, vcc_lo, s6, v3 v_add_co_ci_u32_e32 v4, vcc_lo, s7, v4, vcc_lo global_load_b32 v5, v[3:4], off v_dual_mov_b32 v4, v2 :: v_dual_mov_b32 v3, v1 s_branch .LBB0_65 .LBB0_76: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6game_cPiS_i .amdhsa_group_segment_fixed_size 6040 .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 38 .amdhsa_next_free_sgpr 31 .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 _Z6game_cPiS_i, .Lfunc_end0-_Z6game_cPiS_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: 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: 6040 .kernarg_segment_align: 8 .kernarg_segment_size: 280 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z6game_cPiS_i .private_segment_fixed_size: 0 .sgpr_count: 33 .sgpr_spill_count: 0 .symbol: _Z6game_cPiS_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 38 .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.
/* Metsai Aleksandros 7723 * metsalex@ece.auth.gr * * Game of life using CUDA. Multiple cells per thread and use of shared memory */ #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #define THRESHOLD 0.4 #define CELLS_PER_THREAD 2 #define THREADS_PER_BLOCK (500/CELLS_PER_THREAD) struct timeval startwtime, endwtime; double seq_time; __global__ void game_c (int *newer, int *old, int N) { int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD; __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; //Extended Tables __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2]; int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD; int count; int sum=0; int i=(int) index/N; int j= index%N; int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index for(count=0; count<CELLS_PER_THREAD;count++){ if(i==0){ //top if(j==0){ top[0]= old[N*N-1]; mid[0]= old[N-1]; bot[0]= old[2*N -1]; top[1]= old[N*(N-1)]; mid[1]= old[0]; bot[1]= old[N]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-1)]; mid[lindex+1]= old[0]; bot[lindex+1]= old[N]; top[lindex]= old[N*N -1]; mid[lindex]= old[N-1]; bot[lindex]= old[2*N -1]; }else{ if(lindex==1){ top[lindex-1]= old[N*(N-1) +(j-1)]; mid[lindex-1]= old[j-1]; bot[lindex-1]= old[N+(j-1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; }else if(lindex==(lsize)){ top[lindex+1]= old[N*(N-1) +(j+1)]; mid[lindex+1]= old[j+1]; bot[lindex+1]= old[N+ (j+1)]; top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N +j]; }else{ top[lindex]= old[N*(N-1) +j]; mid[lindex]= old[j]; bot[lindex]= old[N+j]; } } }else if(i==(N-1)){ //bottom if(j==0){ top[0]= old[N*(N-1) -1]; mid[0]= old[N*N -1]; bot[0]= old[N-1]; top[1]= old[N*(N-2)]; mid[1]= old[N*(N-1)]; bot[1]= old[0]; }else if(j==(N-1)){ top[lindex+1]= old[N*(N-2)]; mid[lindex+1]= old[N*(N-1)]; bot[lindex+1]= old[0]; top[lindex]= old[N*(N-1) -1]; mid[lindex]= old[N*N -1]; bot[lindex]= old[N-1]; }else{ // !! if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[j-1]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[j]; } } }else if(j==0){ //left top[0]= old[(i-1)*N +(N-1)]; mid[0]= old[i*N +(N-1)]; bot[0]= old[(i+1)*N +(N-1)]; top[1]= old[(i-1)*N]; mid[1]= old[i*N]; bot[1]= old[(i+1)*N]; }else if(j==(N-1)){ //right top[lindex+1]= old[(i-1)*N]; mid[lindex+1]= old[i*N]; bot[lindex+1]= old[(i+1)*N]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ //general case if(lindex==1){ top[lindex-1]= old[(i-1)*N +(j-1)]; mid[lindex-1]= old[i*N +(j-1)]; bot[lindex-1]= old[(i+1)*N +(j-1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else if(lindex==(lsize)){ top[lindex+1]= old[(i-1)*N +(j+1)]; mid[lindex+1]= old[i*N +(j+1)]; bot[lindex+1]= old[(i+1)*N +(j+1)]; top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; }else{ top[lindex]= old[(i-1)*N +j]; mid[lindex]= old[i*N +j]; bot[lindex]= old[(i+1)*N +j]; } } lindex++; j++; } //Restore values j=index%N; lindex=threadIdx.x*CELLS_PER_THREAD +1; __syncthreads(); for(count=0; count<CELLS_PER_THREAD; count++){ sum= top[lindex-1] +top[lindex]+top[lindex+1] +mid[lindex-1] +mid[lindex+1] +bot[lindex-1] +bot[lindex] +bot[lindex+1]; switch(sum){ case 3: newer[i*N + j] = 1; break; case 2: newer[i*N + j] = old[i*N + j]; break; default: newer[i*N + j] = 0; } lindex++; j++; } } void read_from_file(int *X, char *filename, int N); void save_table(int *X, int N); int main(){ int *table; int* newer; int* old; int *temp; int blocks, t, N, count; printf("Set the number of generations\n"); scanf("%d", &t); printf("Set N (table size = NxN)\n"); scanf("%d", &N); int size=N*N*sizeof(int); /* Insert table here */ char filename[20]; sprintf(filename, "table%dx%d.bin", N, N); printf("Reading %dx%d table from file %s\n", N, N, filename); table = (int *)malloc(N*N*sizeof(int)); read_from_file(table, filename, N); printf("This is kernel c\n"); printf("The game will be played for %d generations N=%d\n", t, N); //!!!Start Timer!!! gettimeofday (&startwtime, NULL); //Allocate space of new and old in device hipMalloc(&newer, size); hipMalloc(&old, size); //copy table hipMemcpy(old, table, size, hipMemcpyHostToDevice); blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD); //Play game for t generations for(count=0;count<t;count++){ game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N); hipDeviceSynchronize(); //swap pointers temp=old; old=newer; newer=temp; } //copy back table hipMemcpy(table, old, size, hipMemcpyDeviceToHost); //!!!End Timer!!! gettimeofday (&endwtime, NULL); seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6 + endwtime.tv_sec - startwtime.tv_sec); printf("Cuda clock time = %f\n", seq_time); save_table(table, N); hipFree(newer); hipFree(old); free(table); return(0); } void read_from_file(int *X, char *filename, int N){ FILE *fp = fopen(filename, "r+"); int size = fread(X, sizeof(int), N*N, fp); printf("elements: %d\n", size); fclose(fp); } void save_table(int *X, int N){ FILE *fp; char filename[20]; sprintf(filename, "cuda_c_table%dx%d.bin", N, N); printf("Saving table in file %s\n", filename); fp = fopen(filename, "w+"); fwrite(X, sizeof(int), N*N, fp); fclose(fp); }
.text .file "CUDA_gameoflife_impl3.hip" .globl _Z21__device_stub__game_cPiS_i # -- Begin function _Z21__device_stub__game_cPiS_i .p2align 4, 0x90 .type _Z21__device_stub__game_cPiS_i,@function _Z21__device_stub__game_cPiS_i: # @_Z21__device_stub__game_cPiS_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 $_Z6game_cPiS_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 _Z21__device_stub__game_cPiS_i, .Lfunc_end0-_Z21__device_stub__game_cPiS_i .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI1_0: .quad 0x412e848000000000 # double 1.0E+6 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $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 $.Lstr, %edi callq puts@PLT xorl %ebp, %ebp leaq 4(%rsp), %rsi movl $.L.str.1, %edi xorl %eax, %eax callq __isoc23_scanf movl $.Lstr.1, %edi callq puts@PLT movq %rsp, %rsi movl $.L.str.1, %edi xorl %eax, %eax callq __isoc23_scanf movl (%rsp), %ecx movl %ecx, %r15d imull %ecx, %r15d shll $2, %r15d leaq 144(%rsp), %rbx movl $.L.str.3, %esi movq %rbx, %rdi movl %ecx, %edx xorl %eax, %eax callq sprintf movl (%rsp), %edx movl $.L.str.4, %edi movl %edx, %esi movq %rbx, %rcx xorl %eax, %eax callq printf movl (%rsp), %r14d imull %r14d, %r14d leaq (,%r14,4), %rdi callq malloc movq %rax, %r12 movl $.L.str.8, %esi movq %rbx, %rdi callq fopen movq %rax, %rbx movl $4, %esi movq %r12, %rdi movq %r14, %rdx movq %rax, %rcx callq fread movl $.L.str.9, %edi movl %eax, %esi xorl %eax, %eax callq printf movq %rbx, %rdi callq fclose movl $.Lstr.2, %edi callq puts@PLT movl 4(%rsp), %esi movl (%rsp), %edx movl $.L.str.6, %edi xorl %eax, %eax callq printf movl $startwtime, %edi xorl %esi, %esi callq gettimeofday movslq %r15d, %rbx leaq 16(%rsp), %rdi movq %rbx, %rsi callq hipMalloc leaq 8(%rsp), %rdi movq %rbx, %rsi callq hipMalloc movq 8(%rsp), %rdi movq %r12, 40(%rsp) # 8-byte Spill movq %r12, %rsi movq %rbx, 32(%rsp) # 8-byte Spill movq %rbx, %rdx movl $1, %ecx callq hipMemcpy cmpl $0, 4(%rsp) jle .LBB1_5 # %bb.1: # %.lr.ph movabsq $4294967296, %r15 # imm = 0x100000000 movl (%rsp), %eax imull %eax, %eax imulq $274877907, %rax, %r12 # imm = 0x10624DD3 shrq $37, %r12 orq %r15, %r12 addq $250, %r15 leaq 56(%rsp), %rbx leaq 48(%rsp), %r14 leaq 112(%rsp), %r13 jmp .LBB1_2 .p2align 4, 0x90 .LBB1_4: # in Loop: Header=BB1_2 Depth=1 callq hipDeviceSynchronize movq 8(%rsp), %rax movq 16(%rsp), %rcx movq %rcx, 8(%rsp) movq %rax, 16(%rsp) incl %ebp cmpl 4(%rsp), %ebp jge .LBB1_5 .LBB1_2: # =>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_4 # %bb.3: # in Loop: Header=BB1_2 Depth=1 movq 16(%rsp), %rax movq 8(%rsp), %rcx movl (%rsp), %edx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movl %edx, 28(%rsp) leaq 104(%rsp), %rax movq %rax, 112(%rsp) leaq 96(%rsp), %rax movq %rax, 120(%rsp) leaq 28(%rsp), %rax movq %rax, 128(%rsp) leaq 80(%rsp), %rdi leaq 64(%rsp), %rsi movq %rbx, %rdx movq %r14, %rcx callq __hipPopCallConfiguration movq 80(%rsp), %rsi movl 88(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d movl $_Z6game_cPiS_i, %edi movq %r13, %r9 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 jmp .LBB1_4 .LBB1_5: # %._crit_edge movq 8(%rsp), %rsi movq 40(%rsp), %r15 # 8-byte Reload movq %r15, %rdi movq 32(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy movl $endwtime, %edi xorl %esi, %esi callq gettimeofday movq endwtime+8(%rip), %rax subq startwtime+8(%rip), %rax cvtsi2sd %rax, %xmm1 divsd .LCPI1_0(%rip), %xmm1 cvtsi2sdq endwtime(%rip), %xmm0 addsd %xmm1, %xmm0 xorps %xmm1, %xmm1 cvtsi2sdq startwtime(%rip), %xmm1 subsd %xmm1, %xmm0 movsd %xmm0, seq_time(%rip) movl $.L.str.7, %edi movb $1, %al callq printf movl (%rsp), %ebx leaq 112(%rsp), %r14 movl $.L.str.10, %esi movq %r14, %rdi movl %ebx, %edx movl %ebx, %ecx xorl %eax, %eax callq sprintf movl $.L.str.11, %edi movq %r14, %rsi xorl %eax, %eax callq printf movl $.L.str.12, %esi movq %r14, %rdi callq fopen movq %rax, %r14 imull %ebx, %ebx movl $4, %esi movq %r15, %rdi movq %rbx, %rdx movq %rax, %rcx callq fwrite movq %r14, %rdi callq fclose movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq %r15, %rdi callq free 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 .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .globl _Z14read_from_filePiPci # -- Begin function _Z14read_from_filePiPci .p2align 4, 0x90 .type _Z14read_from_filePiPci,@function _Z14read_from_filePiPci: # @_Z14read_from_filePiPci .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl %edx, %ebx movq %rsi, %rax movq %rdi, %r14 movl $.L.str.8, %esi movq %rax, %rdi callq fopen movq %rax, %r15 imull %ebx, %ebx movl $4, %esi movq %r14, %rdi movq %rbx, %rdx movq %rax, %rcx callq fread movl $.L.str.9, %edi movl %eax, %esi xorl %eax, %eax callq printf movq %r15, %rdi popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 jmp fclose # TAILCALL .Lfunc_end2: .size _Z14read_from_filePiPci, .Lfunc_end2-_Z14read_from_filePiPci .cfi_endproc # -- End function .globl _Z10save_tablePii # -- Begin function _Z10save_tablePii .p2align 4, 0x90 .type _Z10save_tablePii,@function _Z10save_tablePii: # @_Z10save_tablePii .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 subq $32, %rsp .cfi_def_cfa_offset 64 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl %esi, %ebx movq %rdi, %r14 movq %rsp, %r15 movl $.L.str.10, %esi movq %r15, %rdi movl %ebx, %edx movl %ebx, %ecx xorl %eax, %eax callq sprintf movl $.L.str.11, %edi movq %r15, %rsi xorl %eax, %eax callq printf movl $.L.str.12, %esi movq %r15, %rdi callq fopen movq %rax, %r15 imull %ebx, %ebx movl $4, %esi movq %r14, %rdi movq %rbx, %rdx movq %rax, %rcx callq fwrite movq %r15, %rdi callq fclose addq $32, %rsp .cfi_def_cfa_offset 32 popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size _Z10save_tablePii, .Lfunc_end3-_Z10save_tablePii .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 $_Z6game_cPiS_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_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 startwtime,@object # @startwtime .bss .globl startwtime .p2align 3, 0x0 startwtime: .zero 16 .size startwtime, 16 .type endwtime,@object # @endwtime .globl endwtime .p2align 3, 0x0 endwtime: .zero 16 .size endwtime, 16 .type seq_time,@object # @seq_time .globl seq_time .p2align 3, 0x0 seq_time: .quad 0x0000000000000000 # double 0 .size seq_time, 8 .type _Z6game_cPiS_i,@object # @_Z6game_cPiS_i .section .rodata,"a",@progbits .globl _Z6game_cPiS_i .p2align 3, 0x0 _Z6game_cPiS_i: .quad _Z21__device_stub__game_cPiS_i .size _Z6game_cPiS_i, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "%d" .size .L.str.1, 3 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "table%dx%d.bin" .size .L.str.3, 15 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "Reading %dx%d table from file %s\n" .size .L.str.4, 34 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "The game will be played for %d generations N=%d\n" .size .L.str.6, 49 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "Cuda clock time = %f\n" .size .L.str.7, 22 .type .L.str.8,@object # @.str.8 .L.str.8: .asciz "r+" .size .L.str.8, 3 .type .L.str.9,@object # @.str.9 .L.str.9: .asciz "elements: %d\n" .size .L.str.9, 14 .type .L.str.10,@object # @.str.10 .L.str.10: .asciz "cuda_c_table%dx%d.bin" .size .L.str.10, 22 .type .L.str.11,@object # @.str.11 .L.str.11: .asciz "Saving table in file %s\n" .size .L.str.11, 25 .type .L.str.12,@object # @.str.12 .L.str.12: .asciz "w+" .size .L.str.12, 3 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6game_cPiS_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 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Set the number of generations" .size .Lstr, 30 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Set N (table size = NxN)" .size .Lstr.1, 25 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "This is kernel c" .size .Lstr.2, 17 .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__game_cPiS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym startwtime .addrsig_sym endwtime .addrsig_sym _Z6game_cPiS_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_000b9a8d_00000000-6_CUDA_gameoflife_impl3.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 .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "r+" .LC1: .string "elements: %d\n" .text .globl _Z14read_from_filePiPci .type _Z14read_from_filePiPci, @function _Z14read_from_filePiPci: .LFB2058: .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 movq %rdi, %r12 movq %rsi, %rdi movl %edx, %ebx leaq .LC0(%rip), %rsi call fopen@PLT movq %rax, %rbp imull %ebx, %ebx movslq %ebx, %rcx movq %rax, %r8 movl $4, %edx movq $-1, %rsi movq %r12, %rdi call __fread_chk@PLT movl %eax, %edx leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq %rbp, %rdi call fclose@PLT popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z14read_from_filePiPci, .-_Z14read_from_filePiPci .section .rodata.str1.1 .LC2: .string "cuda_c_table%dx%d.bin" .LC3: .string "Saving table in file %s\n" .LC4: .string "w+" .text .globl _Z10save_tablePii .type _Z10save_tablePii, @function _Z10save_tablePii: .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 $32, %rsp .cfi_def_cfa_offset 64 movq %rdi, %r12 movl %esi, %ebx movq %fs:40, %rax movq %rax, 24(%rsp) xorl %eax, %eax movq %rsp, %rbp movl %esi, %r9d movl %esi, %r8d leaq .LC2(%rip), %rcx movl $20, %edx movl $2, %esi movq %rbp, %rdi call __sprintf_chk@PLT movq %rbp, %rdx leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq .LC4(%rip), %rsi movq %rbp, %rdi call fopen@PLT movq %rax, %rbp imull %ebx, %ebx movslq %ebx, %rdx movq %rax, %rcx movl $4, %esi movq %r12, %rdi call fwrite@PLT movq %rbp, %rdi call fclose@PLT movq 24(%rsp), %rax subq %fs:40, %rax jne .L8 addq $32, %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 .L8: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2059: .size _Z10save_tablePii, .-_Z10save_tablePii .globl _Z28__device_stub__Z6game_cPiS_iPiS_i .type _Z28__device_stub__Z6game_cPiS_iPiS_i, @function _Z28__device_stub__Z6game_cPiS_iPiS_i: .LFB2084: .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 .L13 .L9: movq 120(%rsp), %rax subq %fs:40, %rax jne .L14 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L13: .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 _Z6game_cPiS_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L9 .L14: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _Z28__device_stub__Z6game_cPiS_iPiS_i, .-_Z28__device_stub__Z6game_cPiS_iPiS_i .globl _Z6game_cPiS_i .type _Z6game_cPiS_i, @function _Z6game_cPiS_i: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z28__device_stub__Z6game_cPiS_iPiS_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _Z6game_cPiS_i, .-_Z6game_cPiS_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC5: .string "Set the number of generations\n" .section .rodata.str1.1 .LC6: .string "%d" .LC7: .string "Set N (table size = NxN)\n" .LC8: .string "table%dx%d.bin" .section .rodata.str1.8 .align 8 .LC9: .string "Reading %dx%d table from file %s\n" .section .rodata.str1.1 .LC10: .string "This is kernel c\n" .section .rodata.str1.8 .align 8 .LC11: .string "The game will be played for %d generations N=%d\n" .section .rodata.str1.1 .LC13: .string "Cuda clock time = %f\n" .text .globl main .type main, @function main: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $88, %rsp .cfi_def_cfa_offset 128 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq .LC5(%rip), %rsi movl $2, %edi call __printf_chk@PLT movq %rsp, %rsi leaq .LC6(%rip), %rbx movq %rbx, %rdi movl $0, %eax call __isoc23_scanf@PLT leaq .LC7(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 4(%rsp), %rsi movq %rbx, %rdi movl $0, %eax call __isoc23_scanf@PLT movl 4(%rsp), %r12d leaq 48(%rsp), %rbx movl %r12d, %r9d movl %r12d, %r8d leaq .LC8(%rip), %rcx movl $20, %edx movl $2, %esi movq %rbx, %rdi movl $0, %eax call __sprintf_chk@PLT movl 4(%rsp), %edx movq %rbx, %r8 movl %edx, %ecx leaq .LC9(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl 4(%rsp), %ebp movl %ebp, %edi imull %ebp, %edi movslq %edi, %rdi salq $2, %rdi call malloc@PLT movq %rax, %r13 movl %ebp, %edx movq %rbx, %rsi movq %rax, %rdi call _Z14read_from_filePiPci leaq .LC10(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl 4(%rsp), %ecx movl (%rsp), %edx leaq .LC11(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $0, %esi leaq startwtime(%rip), %rdi call gettimeofday@PLT imull %r12d, %r12d sall $2, %r12d movslq %r12d, %r12 leaq 8(%rsp), %rdi movq %r12, %rsi call cudaMalloc@PLT leaq 16(%rsp), %rdi movq %r12, %rsi call cudaMalloc@PLT movl $1, %ecx movq %r12, %rdx movq %r13, %rsi movq 16(%rsp), %rdi call cudaMemcpy@PLT movl 4(%rsp), %eax imull %eax, %eax movslq %eax, %rbp imulq $274877907, %rbp, %rbp sarq $37, %rbp sarl $31, %eax subl %eax, %ebp cmpl $0, (%rsp) jle .L18 movl $0, %ebx jmp .L20 .L19: call cudaThreadSynchronize@PLT movq 16(%rsp), %rax movq 8(%rsp), %rdx movq %rdx, 16(%rsp) movq %rax, 8(%rsp) addl $1, %ebx cmpl %ebx, (%rsp) jle .L18 .L20: movl $250, 36(%rsp) movl $1, 40(%rsp) movl %ebp, 24(%rsp) movl $1, 28(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax jne .L19 movl 4(%rsp), %edx movq 16(%rsp), %rsi movq 8(%rsp), %rdi call _Z28__device_stub__Z6game_cPiS_iPiS_i jmp .L19 .L18: movl $2, %ecx movq %r12, %rdx movq 16(%rsp), %rsi movq %r13, %rdi call cudaMemcpy@PLT movl $0, %esi leaq endwtime(%rip), %rdi call gettimeofday@PLT movq 8+endwtime(%rip), %rax subq 8+startwtime(%rip), %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 divsd .LC12(%rip), %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq endwtime(%rip), %xmm1 addsd %xmm1, %xmm0 pxor %xmm1, %xmm1 cvtsi2sdq startwtime(%rip), %xmm1 subsd %xmm1, %xmm0 movsd %xmm0, seq_time(%rip) leaq .LC13(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl 4(%rsp), %esi movq %r13, %rdi call _Z10save_tablePii movq 8(%rsp), %rdi call cudaFree@PLT movq 16(%rsp), %rdi call cudaFree@PLT movq %r13, %rdi call free@PLT movq 72(%rsp), %rax subq %fs:40, %rax jne .L24 movl $0, %eax addq $88, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L24: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size main, .-main .section .rodata.str1.1 .LC14: .string "_Z6game_cPiS_i" .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 .LC14(%rip), %rdx movq %rdx, %rcx leaq _Z6game_cPiS_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 .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 .globl seq_time .bss .align 8 .type seq_time, @object .size seq_time, 8 seq_time: .zero 8 .globl endwtime .align 16 .type endwtime, @object .size endwtime, 16 endwtime: .zero 16 .globl startwtime .align 16 .type startwtime, @object .size startwtime, 16 startwtime: .zero 16 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC12: .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 "CUDA_gameoflife_impl3.hip" .globl _Z21__device_stub__game_cPiS_i # -- Begin function _Z21__device_stub__game_cPiS_i .p2align 4, 0x90 .type _Z21__device_stub__game_cPiS_i,@function _Z21__device_stub__game_cPiS_i: # @_Z21__device_stub__game_cPiS_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 $_Z6game_cPiS_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 _Z21__device_stub__game_cPiS_i, .Lfunc_end0-_Z21__device_stub__game_cPiS_i .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI1_0: .quad 0x412e848000000000 # double 1.0E+6 .text .globl main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: pushq %rbp .cfi_def_cfa_offset 16 pushq %r15 .cfi_def_cfa_offset 24 pushq %r14 .cfi_def_cfa_offset 32 pushq %r13 .cfi_def_cfa_offset 40 pushq %r12 .cfi_def_cfa_offset 48 pushq %rbx .cfi_def_cfa_offset 56 subq $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 $.Lstr, %edi callq puts@PLT xorl %ebp, %ebp leaq 4(%rsp), %rsi movl $.L.str.1, %edi xorl %eax, %eax callq __isoc23_scanf movl $.Lstr.1, %edi callq puts@PLT movq %rsp, %rsi movl $.L.str.1, %edi xorl %eax, %eax callq __isoc23_scanf movl (%rsp), %ecx movl %ecx, %r15d imull %ecx, %r15d shll $2, %r15d leaq 144(%rsp), %rbx movl $.L.str.3, %esi movq %rbx, %rdi movl %ecx, %edx xorl %eax, %eax callq sprintf movl (%rsp), %edx movl $.L.str.4, %edi movl %edx, %esi movq %rbx, %rcx xorl %eax, %eax callq printf movl (%rsp), %r14d imull %r14d, %r14d leaq (,%r14,4), %rdi callq malloc movq %rax, %r12 movl $.L.str.8, %esi movq %rbx, %rdi callq fopen movq %rax, %rbx movl $4, %esi movq %r12, %rdi movq %r14, %rdx movq %rax, %rcx callq fread movl $.L.str.9, %edi movl %eax, %esi xorl %eax, %eax callq printf movq %rbx, %rdi callq fclose movl $.Lstr.2, %edi callq puts@PLT movl 4(%rsp), %esi movl (%rsp), %edx movl $.L.str.6, %edi xorl %eax, %eax callq printf movl $startwtime, %edi xorl %esi, %esi callq gettimeofday movslq %r15d, %rbx leaq 16(%rsp), %rdi movq %rbx, %rsi callq hipMalloc leaq 8(%rsp), %rdi movq %rbx, %rsi callq hipMalloc movq 8(%rsp), %rdi movq %r12, 40(%rsp) # 8-byte Spill movq %r12, %rsi movq %rbx, 32(%rsp) # 8-byte Spill movq %rbx, %rdx movl $1, %ecx callq hipMemcpy cmpl $0, 4(%rsp) jle .LBB1_5 # %bb.1: # %.lr.ph movabsq $4294967296, %r15 # imm = 0x100000000 movl (%rsp), %eax imull %eax, %eax imulq $274877907, %rax, %r12 # imm = 0x10624DD3 shrq $37, %r12 orq %r15, %r12 addq $250, %r15 leaq 56(%rsp), %rbx leaq 48(%rsp), %r14 leaq 112(%rsp), %r13 jmp .LBB1_2 .p2align 4, 0x90 .LBB1_4: # in Loop: Header=BB1_2 Depth=1 callq hipDeviceSynchronize movq 8(%rsp), %rax movq 16(%rsp), %rcx movq %rcx, 8(%rsp) movq %rax, 16(%rsp) incl %ebp cmpl 4(%rsp), %ebp jge .LBB1_5 .LBB1_2: # =>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_4 # %bb.3: # in Loop: Header=BB1_2 Depth=1 movq 16(%rsp), %rax movq 8(%rsp), %rcx movl (%rsp), %edx movq %rax, 104(%rsp) movq %rcx, 96(%rsp) movl %edx, 28(%rsp) leaq 104(%rsp), %rax movq %rax, 112(%rsp) leaq 96(%rsp), %rax movq %rax, 120(%rsp) leaq 28(%rsp), %rax movq %rax, 128(%rsp) leaq 80(%rsp), %rdi leaq 64(%rsp), %rsi movq %rbx, %rdx movq %r14, %rcx callq __hipPopCallConfiguration movq 80(%rsp), %rsi movl 88(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d movl $_Z6game_cPiS_i, %edi movq %r13, %r9 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 jmp .LBB1_4 .LBB1_5: # %._crit_edge movq 8(%rsp), %rsi movq 40(%rsp), %r15 # 8-byte Reload movq %r15, %rdi movq 32(%rsp), %rdx # 8-byte Reload movl $2, %ecx callq hipMemcpy movl $endwtime, %edi xorl %esi, %esi callq gettimeofday movq endwtime+8(%rip), %rax subq startwtime+8(%rip), %rax cvtsi2sd %rax, %xmm1 divsd .LCPI1_0(%rip), %xmm1 cvtsi2sdq endwtime(%rip), %xmm0 addsd %xmm1, %xmm0 xorps %xmm1, %xmm1 cvtsi2sdq startwtime(%rip), %xmm1 subsd %xmm1, %xmm0 movsd %xmm0, seq_time(%rip) movl $.L.str.7, %edi movb $1, %al callq printf movl (%rsp), %ebx leaq 112(%rsp), %r14 movl $.L.str.10, %esi movq %r14, %rdi movl %ebx, %edx movl %ebx, %ecx xorl %eax, %eax callq sprintf movl $.L.str.11, %edi movq %r14, %rsi xorl %eax, %eax callq printf movl $.L.str.12, %esi movq %r14, %rdi callq fopen movq %rax, %r14 imull %ebx, %ebx movl $4, %esi movq %r15, %rdi movq %rbx, %rdx movq %rax, %rcx callq fwrite movq %r14, %rdi callq fclose movq 16(%rsp), %rdi callq hipFree movq 8(%rsp), %rdi callq hipFree movq %r15, %rdi callq free 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 .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .globl _Z14read_from_filePiPci # -- Begin function _Z14read_from_filePiPci .p2align 4, 0x90 .type _Z14read_from_filePiPci,@function _Z14read_from_filePiPci: # @_Z14read_from_filePiPci .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl %edx, %ebx movq %rsi, %rax movq %rdi, %r14 movl $.L.str.8, %esi movq %rax, %rdi callq fopen movq %rax, %r15 imull %ebx, %ebx movl $4, %esi movq %r14, %rdi movq %rbx, %rdx movq %rax, %rcx callq fread movl $.L.str.9, %edi movl %eax, %esi xorl %eax, %eax callq printf movq %r15, %rdi popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 jmp fclose # TAILCALL .Lfunc_end2: .size _Z14read_from_filePiPci, .Lfunc_end2-_Z14read_from_filePiPci .cfi_endproc # -- End function .globl _Z10save_tablePii # -- Begin function _Z10save_tablePii .p2align 4, 0x90 .type _Z10save_tablePii,@function _Z10save_tablePii: # @_Z10save_tablePii .cfi_startproc # %bb.0: pushq %r15 .cfi_def_cfa_offset 16 pushq %r14 .cfi_def_cfa_offset 24 pushq %rbx .cfi_def_cfa_offset 32 subq $32, %rsp .cfi_def_cfa_offset 64 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl %esi, %ebx movq %rdi, %r14 movq %rsp, %r15 movl $.L.str.10, %esi movq %r15, %rdi movl %ebx, %edx movl %ebx, %ecx xorl %eax, %eax callq sprintf movl $.L.str.11, %edi movq %r15, %rsi xorl %eax, %eax callq printf movl $.L.str.12, %esi movq %r15, %rdi callq fopen movq %rax, %r15 imull %ebx, %ebx movl $4, %esi movq %r14, %rdi movq %rbx, %rdx movq %rax, %rcx callq fwrite movq %r15, %rdi callq fclose addq $32, %rsp .cfi_def_cfa_offset 32 popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end3: .size _Z10save_tablePii, .Lfunc_end3-_Z10save_tablePii .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 $_Z6game_cPiS_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_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 startwtime,@object # @startwtime .bss .globl startwtime .p2align 3, 0x0 startwtime: .zero 16 .size startwtime, 16 .type endwtime,@object # @endwtime .globl endwtime .p2align 3, 0x0 endwtime: .zero 16 .size endwtime, 16 .type seq_time,@object # @seq_time .globl seq_time .p2align 3, 0x0 seq_time: .quad 0x0000000000000000 # double 0 .size seq_time, 8 .type _Z6game_cPiS_i,@object # @_Z6game_cPiS_i .section .rodata,"a",@progbits .globl _Z6game_cPiS_i .p2align 3, 0x0 _Z6game_cPiS_i: .quad _Z21__device_stub__game_cPiS_i .size _Z6game_cPiS_i, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "%d" .size .L.str.1, 3 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "table%dx%d.bin" .size .L.str.3, 15 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "Reading %dx%d table from file %s\n" .size .L.str.4, 34 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "The game will be played for %d generations N=%d\n" .size .L.str.6, 49 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "Cuda clock time = %f\n" .size .L.str.7, 22 .type .L.str.8,@object # @.str.8 .L.str.8: .asciz "r+" .size .L.str.8, 3 .type .L.str.9,@object # @.str.9 .L.str.9: .asciz "elements: %d\n" .size .L.str.9, 14 .type .L.str.10,@object # @.str.10 .L.str.10: .asciz "cuda_c_table%dx%d.bin" .size .L.str.10, 22 .type .L.str.11,@object # @.str.11 .L.str.11: .asciz "Saving table in file %s\n" .size .L.str.11, 25 .type .L.str.12,@object # @.str.12 .L.str.12: .asciz "w+" .size .L.str.12, 3 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6game_cPiS_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 .type .Lstr,@object # @str .section .rodata.str1.1,"aMS",@progbits,1 .Lstr: .asciz "Set the number of generations" .size .Lstr, 30 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Set N (table size = NxN)" .size .Lstr.1, 25 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "This is kernel c" .size .Lstr.2, 17 .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__game_cPiS_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym startwtime .addrsig_sym endwtime .addrsig_sym _Z6game_cPiS_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 <stdio.h> #include <cuda.h> #include <cuda_runtime_api.h> int getMaxThreads( const int max_regs_per_thread, int cuda_device) { cudaDeviceProp d; cudaGetDeviceProperties(&d, cuda_device); return d.regsPerBlock / max_regs_per_thread; }
code for sm_80
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <stdio.h> #include <cuda.h> #include <cuda_runtime_api.h> int getMaxThreads( const int max_regs_per_thread, int cuda_device) { cudaDeviceProp d; cudaGetDeviceProperties(&d, cuda_device); return d.regsPerBlock / max_regs_per_thread; }
.file "tmpxft_00192f4f_00000000-6_cuda_resources.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 _Z13getMaxThreadsii .type _Z13getMaxThreadsii, @function _Z13getMaxThreadsii: .LFB2057: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $1040, %rsp .cfi_def_cfa_offset 1056 movl %edi, %ebx movq %fs:40, %rax movq %rax, 1032(%rsp) xorl %eax, %eax movq %rsp, %rdi call cudaGetDeviceProperties_v2@PLT movl 304(%rsp), %eax cltd idivl %ebx movq 1032(%rsp), %rdx subq %fs:40, %rdx jne .L6 addq $1040, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L6: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size _Z13getMaxThreadsii, .-_Z13getMaxThreadsii .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <stdio.h> #include <cuda.h> #include <cuda_runtime_api.h> int getMaxThreads( const int max_regs_per_thread, int cuda_device) { cudaDeviceProp d; cudaGetDeviceProperties(&d, cuda_device); return d.regsPerBlock / max_regs_per_thread; }
#include <stdio.h> #include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> int getMaxThreads( const int max_regs_per_thread, int cuda_device) { hipDeviceProp_t d; hipGetDeviceProperties(&d, cuda_device); return d.regsPerBlock / max_regs_per_thread; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <stdio.h> #include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> int getMaxThreads( const int max_regs_per_thread, int cuda_device) { hipDeviceProp_t d; hipGetDeviceProperties(&d, cuda_device); return d.regsPerBlock / max_regs_per_thread; }
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <stdio.h> #include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> int getMaxThreads( const int max_regs_per_thread, int cuda_device) { hipDeviceProp_t d; hipGetDeviceProperties(&d, cuda_device); return d.regsPerBlock / max_regs_per_thread; }
.text .file "cuda_resources.hip" .globl _Z13getMaxThreadsii # -- Begin function _Z13getMaxThreadsii .p2align 4, 0x90 .type _Z13getMaxThreadsii,@function _Z13getMaxThreadsii: # @_Z13getMaxThreadsii .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $1472, %rsp # imm = 0x5C0 .cfi_def_cfa_offset 1488 .cfi_offset %rbx, -16 movl %edi, %ebx movq %rsp, %rdi callq hipGetDevicePropertiesR0600 movl 304(%rsp), %eax cltd idivl %ebx addq $1472, %rsp # imm = 0x5C0 .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z13getMaxThreadsii, .Lfunc_end0-_Z13getMaxThreadsii .cfi_endproc # -- End function .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting from CUDA device assembly to AMD device assembly.
code for sm_80
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting from CUDA host assembly to AMD host assembly.
.file "tmpxft_00192f4f_00000000-6_cuda_resources.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 _Z13getMaxThreadsii .type _Z13getMaxThreadsii, @function _Z13getMaxThreadsii: .LFB2057: .cfi_startproc endbr64 pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 subq $1040, %rsp .cfi_def_cfa_offset 1056 movl %edi, %ebx movq %fs:40, %rax movq %rax, 1032(%rsp) xorl %eax, %eax movq %rsp, %rdi call cudaGetDeviceProperties_v2@PLT movl 304(%rsp), %eax cltd idivl %ebx movq 1032(%rsp), %rdx subq %fs:40, %rdx jne .L6 addq $1040, %rsp .cfi_remember_state .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 ret .L6: .cfi_restore_state call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size _Z13getMaxThreadsii, .-_Z13getMaxThreadsii .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
.text .file "cuda_resources.hip" .globl _Z13getMaxThreadsii # -- Begin function _Z13getMaxThreadsii .p2align 4, 0x90 .type _Z13getMaxThreadsii,@function _Z13getMaxThreadsii: # @_Z13getMaxThreadsii .cfi_startproc # %bb.0: pushq %rbx .cfi_def_cfa_offset 16 subq $1472, %rsp # imm = 0x5C0 .cfi_def_cfa_offset 1488 .cfi_offset %rbx, -16 movl %edi, %ebx movq %rsp, %rdi callq hipGetDevicePropertiesR0600 movl 304(%rsp), %eax cltd idivl %ebx addq $1472, %rsp # imm = 0x5C0 .cfi_def_cfa_offset 16 popq %rbx .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size _Z13getMaxThreadsii, .Lfunc_end0-_Z13getMaxThreadsii .cfi_endproc # -- End function .type __hip_cuid_,@object # @__hip_cuid_ .bss .globl __hip_cuid_ __hip_cuid_: .byte 0 # 0x0 .size __hip_cuid_, 1 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __global__ void back(double *h_out_d, double *weights_out_d, double *weights_h_d, double *weights_in_d, double *outputs_d, double *deltas_h_d, double *deltas_h_new_d, double *deltas_o_d, double *weights_in_delta_d, double *weights_out_delta_d, double *weights_h_delta_d, int height, int inputs, int outputs, int layers, double *training_in_d, double *training_out_d, int sample){ int i, j; int tix = threadIdx.x; int tiy = threadIdx.y + sample; int h_offset = tiy * layers * height; int w_o_d_offset = tiy * outputs * height; int w_h_d_offset = tiy * (layers-1) * height * height; int w_i_d_offset = tiy * inputs * height; int d_h_offset = tiy * height; double delta_sum, temp; /*__shared__ double h_out_ds[H_LAYERS*H_HEIGHT]; __shared__ double weights_h_ds[(H_LAYERS-1)*H_HEIGHT*H_HEIGHT]; __shared__ double deltas_h_ds[H_HEIGHT]; __shared__ double deltas_h_new_ds[H_HEIGHT]; for(i=0;i<layers;i++) h_out_ds[tix*height+i] = h_out_d[tix*height+i]; for(i=0;i<layers-1;i++){ for(j=0;j<height;j++) weights_h_ds[i*height*height + tix*height + j] = weights_h_d[i*height*height + tix*height + j]; } deltas_h_ds[tix] = deltas_h_d[tix]; deltas_h_new_ds[tix] = deltas_h_new_d[tix]; __syncthreads(); */ //output layer if(tix < outputs){ deltas_o_d[tiy * outputs + tix] = (outputs_d[tiy * outputs + tix] - training_out_d[tiy]); for(i = 0; i < height; i++){ weights_out_delta_d[w_o_d_offset + (tix * height) + i] = deltas_o_d[tiy * outputs + tix] * h_out_d[h_offset + (layers-1)*height+i]; } } __syncthreads(); //hidden layer //layer connected to output delta_sum = 0; for(i = 0; i < outputs; i++){ delta_sum += weights_out_d[tix + (i * height)] * deltas_o_d[tiy * outputs + i]; } temp = h_out_d[h_offset + (layers-1)*height + tix]; deltas_h_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i = 0; i < height; i++){ weights_h_delta_d[w_h_d_offset + (layers-2)*height*height + (tix * height) + i] = deltas_h_d[d_h_offset + tix] * h_out_d[h_offset + (layers-2)*height+i]; } __syncthreads(); //each hidden layer not connected to input/hidden output layer for(i = layers - 2; i > 0; i--){ delta_sum = 0; for(j = 0; j < height; j++){ delta_sum += weights_h_d[i*height*height + j*height + tix] * deltas_h_d[d_h_offset + j]; } temp = h_out_d[h_offset + i*height + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(j = 0; j < height; j++){ weights_h_delta_d[w_h_d_offset + (i-1)*height*height + (tix * height) + j] = (deltas_h_new_d[d_h_offset + tix] * h_out_d[h_offset + (i-1)*height+j]); } __syncthreads(); //change pointers to simulate copying memory deltas_h_d[d_h_offset + tix] = deltas_h_new_d[d_h_offset + tix]; __syncthreads(); } //Layer connected to inputs delta_sum = 0; for(i=0; i<height; i++){ delta_sum += weights_h_d[i*height + tix] * deltas_h_d[d_h_offset + i]; } temp = h_out_d[h_offset + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i=0; i<inputs; i++){ weights_in_delta_d[w_i_d_offset + tix*inputs+i] = (deltas_h_new_d[d_h_offset + tix] * training_in_d[tiy * inputs + i]); } __syncthreads(); }
.file "tmpxft_000ace3e_00000000-6_back.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 _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .type _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, @function _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: .LFB2051: .cfi_startproc endbr64 subq $344, %rsp .cfi_def_cfa_offset 352 movq %rdi, 104(%rsp) movq %rsi, 96(%rsp) movq %rdx, 88(%rsp) movq %rcx, 80(%rsp) movq %r8, 72(%rsp) movq %r9, 64(%rsp) movq 352(%rsp), %rax movq %rax, 56(%rsp) movq 360(%rsp), %rax movq %rax, 48(%rsp) movq 368(%rsp), %rax movq %rax, 40(%rsp) movq 376(%rsp), %rax movq %rax, 32(%rsp) movq 384(%rsp), %rax movq %rax, 24(%rsp) movq 424(%rsp), %rax movq %rax, 16(%rsp) movq 432(%rsp), %rax movq %rax, 8(%rsp) movq %fs:40, %rax movq %rax, 328(%rsp) xorl %eax, %eax leaq 104(%rsp), %rax movq %rax, 176(%rsp) leaq 96(%rsp), %rax movq %rax, 184(%rsp) leaq 88(%rsp), %rax movq %rax, 192(%rsp) leaq 80(%rsp), %rax movq %rax, 200(%rsp) leaq 72(%rsp), %rax movq %rax, 208(%rsp) leaq 64(%rsp), %rax movq %rax, 216(%rsp) leaq 56(%rsp), %rax movq %rax, 224(%rsp) leaq 48(%rsp), %rax movq %rax, 232(%rsp) leaq 40(%rsp), %rax movq %rax, 240(%rsp) leaq 32(%rsp), %rax movq %rax, 248(%rsp) leaq 24(%rsp), %rax movq %rax, 256(%rsp) leaq 392(%rsp), %rax movq %rax, 264(%rsp) leaq 400(%rsp), %rax movq %rax, 272(%rsp) leaq 408(%rsp), %rax movq %rax, 280(%rsp) leaq 416(%rsp), %rax movq %rax, 288(%rsp) leaq 16(%rsp), %rax movq %rax, 296(%rsp) leaq 8(%rsp), %rax movq %rax, 304(%rsp) leaq 440(%rsp), %rax movq %rax, 312(%rsp) movl $1, 128(%rsp) movl $1, 132(%rsp) movl $1, 136(%rsp) movl $1, 140(%rsp) movl $1, 144(%rsp) movl $1, 148(%rsp) leaq 120(%rsp), %rcx leaq 112(%rsp), %rdx leaq 140(%rsp), %rsi leaq 128(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 328(%rsp), %rax subq %fs:40, %rax jne .L8 addq $344, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 120(%rsp) .cfi_def_cfa_offset 360 pushq 120(%rsp) .cfi_def_cfa_offset 368 leaq 192(%rsp), %r9 movq 156(%rsp), %rcx movl 164(%rsp), %r8d movq 144(%rsp), %rsi movl 152(%rsp), %edx leaq _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 352 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .-_Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .globl _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .type _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, @function _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 24 pushq 104(%rsp) .cfi_def_cfa_offset 32 pushq 104(%rsp) .cfi_def_cfa_offset 40 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 48 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 56 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 64 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 72 pushq 104(%rsp) .cfi_def_cfa_offset 80 pushq 104(%rsp) .cfi_def_cfa_offset 88 pushq 104(%rsp) .cfi_def_cfa_offset 96 pushq 104(%rsp) .cfi_def_cfa_offset 104 pushq 104(%rsp) .cfi_def_cfa_offset 112 call _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i addq $104, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .-_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_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 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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 .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 back(double *h_out_d, double *weights_out_d, double *weights_h_d, double *weights_in_d, double *outputs_d, double *deltas_h_d, double *deltas_h_new_d, double *deltas_o_d, double *weights_in_delta_d, double *weights_out_delta_d, double *weights_h_delta_d, int height, int inputs, int outputs, int layers, double *training_in_d, double *training_out_d, int sample){ int i, j; int tix = threadIdx.x; int tiy = threadIdx.y + sample; int h_offset = tiy * layers * height; int w_o_d_offset = tiy * outputs * height; int w_h_d_offset = tiy * (layers-1) * height * height; int w_i_d_offset = tiy * inputs * height; int d_h_offset = tiy * height; double delta_sum, temp; /*__shared__ double h_out_ds[H_LAYERS*H_HEIGHT]; __shared__ double weights_h_ds[(H_LAYERS-1)*H_HEIGHT*H_HEIGHT]; __shared__ double deltas_h_ds[H_HEIGHT]; __shared__ double deltas_h_new_ds[H_HEIGHT]; for(i=0;i<layers;i++) h_out_ds[tix*height+i] = h_out_d[tix*height+i]; for(i=0;i<layers-1;i++){ for(j=0;j<height;j++) weights_h_ds[i*height*height + tix*height + j] = weights_h_d[i*height*height + tix*height + j]; } deltas_h_ds[tix] = deltas_h_d[tix]; deltas_h_new_ds[tix] = deltas_h_new_d[tix]; __syncthreads(); */ //output layer if(tix < outputs){ deltas_o_d[tiy * outputs + tix] = (outputs_d[tiy * outputs + tix] - training_out_d[tiy]); for(i = 0; i < height; i++){ weights_out_delta_d[w_o_d_offset + (tix * height) + i] = deltas_o_d[tiy * outputs + tix] * h_out_d[h_offset + (layers-1)*height+i]; } } __syncthreads(); //hidden layer //layer connected to output delta_sum = 0; for(i = 0; i < outputs; i++){ delta_sum += weights_out_d[tix + (i * height)] * deltas_o_d[tiy * outputs + i]; } temp = h_out_d[h_offset + (layers-1)*height + tix]; deltas_h_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i = 0; i < height; i++){ weights_h_delta_d[w_h_d_offset + (layers-2)*height*height + (tix * height) + i] = deltas_h_d[d_h_offset + tix] * h_out_d[h_offset + (layers-2)*height+i]; } __syncthreads(); //each hidden layer not connected to input/hidden output layer for(i = layers - 2; i > 0; i--){ delta_sum = 0; for(j = 0; j < height; j++){ delta_sum += weights_h_d[i*height*height + j*height + tix] * deltas_h_d[d_h_offset + j]; } temp = h_out_d[h_offset + i*height + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(j = 0; j < height; j++){ weights_h_delta_d[w_h_d_offset + (i-1)*height*height + (tix * height) + j] = (deltas_h_new_d[d_h_offset + tix] * h_out_d[h_offset + (i-1)*height+j]); } __syncthreads(); //change pointers to simulate copying memory deltas_h_d[d_h_offset + tix] = deltas_h_new_d[d_h_offset + tix]; __syncthreads(); } //Layer connected to inputs delta_sum = 0; for(i=0; i<height; i++){ delta_sum += weights_h_d[i*height + tix] * deltas_h_d[d_h_offset + i]; } temp = h_out_d[h_offset + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i=0; i<inputs; i++){ weights_in_delta_d[w_i_d_offset + tix*inputs+i] = (deltas_h_new_d[d_h_offset + tix] * training_in_d[tiy * inputs + i]); } __syncthreads(); }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void back(double *h_out_d, double *weights_out_d, double *weights_h_d, double *weights_in_d, double *outputs_d, double *deltas_h_d, double *deltas_h_new_d, double *deltas_o_d, double *weights_in_delta_d, double *weights_out_delta_d, double *weights_h_delta_d, int height, int inputs, int outputs, int layers, double *training_in_d, double *training_out_d, int sample){ int i, j; int tix = threadIdx.x; int tiy = threadIdx.y + sample; int h_offset = tiy * layers * height; int w_o_d_offset = tiy * outputs * height; int w_h_d_offset = tiy * (layers-1) * height * height; int w_i_d_offset = tiy * inputs * height; int d_h_offset = tiy * height; double delta_sum, temp; /*__shared__ double h_out_ds[H_LAYERS*H_HEIGHT]; __shared__ double weights_h_ds[(H_LAYERS-1)*H_HEIGHT*H_HEIGHT]; __shared__ double deltas_h_ds[H_HEIGHT]; __shared__ double deltas_h_new_ds[H_HEIGHT]; for(i=0;i<layers;i++) h_out_ds[tix*height+i] = h_out_d[tix*height+i]; for(i=0;i<layers-1;i++){ for(j=0;j<height;j++) weights_h_ds[i*height*height + tix*height + j] = weights_h_d[i*height*height + tix*height + j]; } deltas_h_ds[tix] = deltas_h_d[tix]; deltas_h_new_ds[tix] = deltas_h_new_d[tix]; __syncthreads(); */ //output layer if(tix < outputs){ deltas_o_d[tiy * outputs + tix] = (outputs_d[tiy * outputs + tix] - training_out_d[tiy]); for(i = 0; i < height; i++){ weights_out_delta_d[w_o_d_offset + (tix * height) + i] = deltas_o_d[tiy * outputs + tix] * h_out_d[h_offset + (layers-1)*height+i]; } } __syncthreads(); //hidden layer //layer connected to output delta_sum = 0; for(i = 0; i < outputs; i++){ delta_sum += weights_out_d[tix + (i * height)] * deltas_o_d[tiy * outputs + i]; } temp = h_out_d[h_offset + (layers-1)*height + tix]; deltas_h_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i = 0; i < height; i++){ weights_h_delta_d[w_h_d_offset + (layers-2)*height*height + (tix * height) + i] = deltas_h_d[d_h_offset + tix] * h_out_d[h_offset + (layers-2)*height+i]; } __syncthreads(); //each hidden layer not connected to input/hidden output layer for(i = layers - 2; i > 0; i--){ delta_sum = 0; for(j = 0; j < height; j++){ delta_sum += weights_h_d[i*height*height + j*height + tix] * deltas_h_d[d_h_offset + j]; } temp = h_out_d[h_offset + i*height + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(j = 0; j < height; j++){ weights_h_delta_d[w_h_d_offset + (i-1)*height*height + (tix * height) + j] = (deltas_h_new_d[d_h_offset + tix] * h_out_d[h_offset + (i-1)*height+j]); } __syncthreads(); //change pointers to simulate copying memory deltas_h_d[d_h_offset + tix] = deltas_h_new_d[d_h_offset + tix]; __syncthreads(); } //Layer connected to inputs delta_sum = 0; for(i=0; i<height; i++){ delta_sum += weights_h_d[i*height + tix] * deltas_h_d[d_h_offset + i]; } temp = h_out_d[h_offset + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i=0; i<inputs; i++){ weights_in_delta_d[w_i_d_offset + tix*inputs+i] = (deltas_h_new_d[d_h_offset + tix] * training_in_d[tiy * inputs + i]); } __syncthreads(); }
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 back(double *h_out_d, double *weights_out_d, double *weights_h_d, double *weights_in_d, double *outputs_d, double *deltas_h_d, double *deltas_h_new_d, double *deltas_o_d, double *weights_in_delta_d, double *weights_out_delta_d, double *weights_h_delta_d, int height, int inputs, int outputs, int layers, double *training_in_d, double *training_out_d, int sample){ int i, j; int tix = threadIdx.x; int tiy = threadIdx.y + sample; int h_offset = tiy * layers * height; int w_o_d_offset = tiy * outputs * height; int w_h_d_offset = tiy * (layers-1) * height * height; int w_i_d_offset = tiy * inputs * height; int d_h_offset = tiy * height; double delta_sum, temp; /*__shared__ double h_out_ds[H_LAYERS*H_HEIGHT]; __shared__ double weights_h_ds[(H_LAYERS-1)*H_HEIGHT*H_HEIGHT]; __shared__ double deltas_h_ds[H_HEIGHT]; __shared__ double deltas_h_new_ds[H_HEIGHT]; for(i=0;i<layers;i++) h_out_ds[tix*height+i] = h_out_d[tix*height+i]; for(i=0;i<layers-1;i++){ for(j=0;j<height;j++) weights_h_ds[i*height*height + tix*height + j] = weights_h_d[i*height*height + tix*height + j]; } deltas_h_ds[tix] = deltas_h_d[tix]; deltas_h_new_ds[tix] = deltas_h_new_d[tix]; __syncthreads(); */ //output layer if(tix < outputs){ deltas_o_d[tiy * outputs + tix] = (outputs_d[tiy * outputs + tix] - training_out_d[tiy]); for(i = 0; i < height; i++){ weights_out_delta_d[w_o_d_offset + (tix * height) + i] = deltas_o_d[tiy * outputs + tix] * h_out_d[h_offset + (layers-1)*height+i]; } } __syncthreads(); //hidden layer //layer connected to output delta_sum = 0; for(i = 0; i < outputs; i++){ delta_sum += weights_out_d[tix + (i * height)] * deltas_o_d[tiy * outputs + i]; } temp = h_out_d[h_offset + (layers-1)*height + tix]; deltas_h_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i = 0; i < height; i++){ weights_h_delta_d[w_h_d_offset + (layers-2)*height*height + (tix * height) + i] = deltas_h_d[d_h_offset + tix] * h_out_d[h_offset + (layers-2)*height+i]; } __syncthreads(); //each hidden layer not connected to input/hidden output layer for(i = layers - 2; i > 0; i--){ delta_sum = 0; for(j = 0; j < height; j++){ delta_sum += weights_h_d[i*height*height + j*height + tix] * deltas_h_d[d_h_offset + j]; } temp = h_out_d[h_offset + i*height + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(j = 0; j < height; j++){ weights_h_delta_d[w_h_d_offset + (i-1)*height*height + (tix * height) + j] = (deltas_h_new_d[d_h_offset + tix] * h_out_d[h_offset + (i-1)*height+j]); } __syncthreads(); //change pointers to simulate copying memory deltas_h_d[d_h_offset + tix] = deltas_h_new_d[d_h_offset + tix]; __syncthreads(); } //Layer connected to inputs delta_sum = 0; for(i=0; i<height; i++){ delta_sum += weights_h_d[i*height + tix] * deltas_h_d[d_h_offset + i]; } temp = h_out_d[h_offset + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i=0; i<inputs; i++){ weights_in_delta_d[w_i_d_offset + tix*inputs+i] = (deltas_h_new_d[d_h_offset + tix] * training_in_d[tiy * inputs + i]); } __syncthreads(); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .globl _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .p2align 8 .type _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i,@function _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: s_clause 0x4 s_load_b32 s3, s[0:1], 0x78 s_load_b64 s[6:7], s[0:1], 0x60 s_load_b64 s[4:5], s[0:1], 0x0 s_load_b64 s[8:9], s[0:1], 0x38 s_load_b32 s2, s[0:1], 0x58 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v1, s3, v1 s_add_i32 s16, s7, -1 s_mov_b32 s3, exec_lo v_mul_lo_u32 v23, v1, s7 v_mul_lo_u32 v3, v1, s6 v_cmpx_gt_i32_e64 s6, v0 s_cbranch_execz .LBB0_4 s_clause 0x1 s_load_b64 s[10:11], s[0:1], 0x20 s_load_b64 s[12:13], s[0:1], 0x70 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v6, v3, v0 v_ashrrev_i32_e32 v2, 31, v1 s_cmp_lt_i32 s2, 1 v_ashrrev_i32_e32 v7, 31, v6 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3) v_lshlrev_b64 v[4:5], 3, v[6:7] v_lshlrev_b64 v[7:8], 3, v[1:2] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v9, vcc_lo, s10, v4 v_add_co_ci_u32_e32 v10, vcc_lo, s11, v5, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v7, vcc_lo, s12, v7 v_add_co_ci_u32_e32 v8, vcc_lo, s13, v8, vcc_lo v_add_co_u32 v4, vcc_lo, s8, v4 global_load_b64 v[9:10], v[9:10], off global_load_b64 v[7:8], v[7:8], off v_add_co_ci_u32_e32 v5, vcc_lo, s9, v5, vcc_lo s_waitcnt vmcnt(0) v_add_f64 v[7:8], v[9:10], -v[7:8] global_store_b64 v[4:5], v[7:8], off s_cbranch_scc1 .LBB0_4 v_add_nc_u32_e32 v2, s16, v23 s_load_b64 s[10:11], s[0:1], 0x48 v_mul_lo_u32 v6, v6, s2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_mul_lo_u32 v8, v2, s2 v_ashrrev_i32_e32 v7, 31, v6 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v9, 31, v8 v_lshlrev_b64 v[6:7], 3, v[6:7] s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_lshlrev_b64 v[8:9], 3, v[8:9] s_waitcnt lgkmcnt(0) v_add_co_u32 v6, vcc_lo, s10, v6 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_ci_u32_e32 v7, vcc_lo, s11, v7, vcc_lo v_add_co_u32 v8, vcc_lo, s4, v8 s_delay_alu instid0(VALU_DEP_4) v_add_co_ci_u32_e32 v9, vcc_lo, s5, v9, vcc_lo s_mov_b32 s10, s2 .p2align 6 .LBB0_3: global_load_b64 v[10:11], v[4:5], off global_load_b64 v[12:13], v[8:9], off v_add_co_u32 v8, vcc_lo, v8, 8 v_add_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo s_add_i32 s10, s10, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s10, 0 s_waitcnt vmcnt(0) v_mul_f64 v[10:11], v[10:11], v[12:13] global_store_b64 v[6:7], v[10:11], off v_add_co_u32 v6, vcc_lo, v6, 8 v_add_co_ci_u32_e32 v7, vcc_lo, 0, v7, vcc_lo s_cbranch_scc1 .LBB0_3 .LBB0_4: s_or_b32 exec_lo, exec_lo, s3 s_cmp_lt_i32 s6, 1 s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv s_cbranch_scc1 .LBB0_7 s_load_b64 s[10:11], s[0:1], 0x8 v_ashrrev_i32_e32 v4, 31, v3 v_lshlrev_b32_e32 v6, 3, v0 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3) v_lshlrev_b64 v[4:5], 3, v[3:4] v_mov_b32_e32 v2, 0 v_mov_b32_e32 v3, 0 v_add_co_u32 v4, vcc_lo, s8, v4 s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v5, vcc_lo, s9, v5, vcc_lo s_waitcnt lgkmcnt(0) v_add_co_u32 v6, s3, s10, v6 v_add_co_ci_u32_e64 v7, null, s11, 0, s3 s_ashr_i32 s3, s2, 31 s_delay_alu instid0(SALU_CYCLE_1) s_lshl_b64 s[8:9], s[2:3], 3 .LBB0_6: global_load_b64 v[8:9], v[6:7], off global_load_b64 v[10:11], v[4:5], off v_add_co_u32 v4, vcc_lo, v4, 8 v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo v_add_co_u32 v6, vcc_lo, v6, s8 v_add_co_ci_u32_e32 v7, vcc_lo, s9, v7, vcc_lo s_add_i32 s6, s6, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s6, 0 s_waitcnt vmcnt(0) v_fma_f64 v[2:3], v[8:9], v[10:11], v[2:3] s_cbranch_scc1 .LBB0_6 s_branch .LBB0_8 .LBB0_7: v_mov_b32_e32 v2, 0 v_mov_b32_e32 v3, 0 .LBB0_8: v_add_nc_u32_e32 v6, s16, v23 s_clause 0x1 s_load_b64 s[8:9], s[0:1], 0x28 s_load_b64 s[12:13], s[0:1], 0x50 v_mul_lo_u32 v24, v23, s2 s_cmp_lt_i32 s2, 1 v_mad_u64_u32 v[4:5], null, v6, s2, v[0:1] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v5, 31, v4 v_lshlrev_b64 v[4:5], 3, v[4:5] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v4, vcc_lo, s4, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s5, v5, vcc_lo global_load_b64 v[4:5], v[4:5], off s_waitcnt vmcnt(0) v_add_f64 v[6:7], -v[4:5], 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f64 v[4:5], v[4:5], v[6:7] v_mul_f64 v[8:9], v[2:3], v[4:5] v_mul_lo_u32 v4, v1, s2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v2, v4, v0 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[6:7], 3, v[2:3] s_waitcnt lgkmcnt(0) v_add_co_u32 v6, vcc_lo, s8, v6 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v7, vcc_lo, s9, v7, vcc_lo global_store_b64 v[6:7], v[8:9], off s_cbranch_scc1 .LBB0_11 v_mul_lo_u32 v5, v4, s16 s_add_i32 s3, s7, -2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_mul_i32 s3, s3, s2 v_add_nc_u32_e32 v10, s3, v24 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_add3_u32 v5, s3, v0, v5 s_mov_b32 s3, s2 v_ashrrev_i32_e32 v11, 31, v10 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_mul_lo_u32 v8, v5, s2 v_lshlrev_b64 v[10:11], 3, v[10:11] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v9, 31, v8 v_lshlrev_b64 v[8:9], 3, v[8:9] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v8, vcc_lo, s12, v8 v_add_co_ci_u32_e32 v9, vcc_lo, s13, v9, vcc_lo v_add_co_u32 v10, vcc_lo, s4, v10 v_add_co_ci_u32_e32 v11, vcc_lo, s5, v11, vcc_lo .p2align 6 .LBB0_10: global_load_b64 v[12:13], v[6:7], off global_load_b64 v[14:15], v[10:11], off v_add_co_u32 v10, vcc_lo, v10, 8 v_add_co_ci_u32_e32 v11, vcc_lo, 0, v11, vcc_lo s_add_i32 s3, s3, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s3, 0 s_waitcnt vmcnt(0) v_mul_f64 v[12:13], v[12:13], v[14:15] global_store_b64 v[8:9], v[12:13], off v_add_co_u32 v8, vcc_lo, v8, 8 v_add_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo s_cbranch_scc1 .LBB0_10 .LBB0_11: s_clause 0x1 s_load_b64 s[14:15], s[0:1], 0x10 s_load_b64 s[10:11], s[0:1], 0x30 v_ashrrev_i32_e32 v5, 31, v4 s_cmp_lt_i32 s7, 3 s_waitcnt lgkmcnt(0) s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv s_cbranch_scc1 .LBB0_20 v_mul_lo_u32 v8, v1, s16 v_lshlrev_b64 v[11:12], 3, v[2:3] v_lshlrev_b64 v[15:16], 3, v[4:5] v_add3_u32 v10, v23, s7, -3 s_add_i32 s6, s7, -2 s_mul_i32 s3, s2, s2 s_cmp_gt_i32 s2, 0 v_add_co_u32 v11, vcc_lo, s10, v11 v_add3_u32 v8, s7, v8, -3 v_add_co_ci_u32_e32 v12, vcc_lo, s11, v12, vcc_lo v_add_co_u32 v15, vcc_lo, s8, v15 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_4) v_mad_u64_u32 v[13:14], null, s2, v8, v[0:1] v_mad_u64_u32 v[8:9], null, s3, s6, v[0:1] v_mul_lo_u32 v9, s2, v10 v_add_co_ci_u32_e32 v16, vcc_lo, s9, v16, vcc_lo s_cselect_b32 s7, -1, 0 v_mul_lo_u32 v13, s2, v13 s_branch .LBB0_14 .LBB0_13: s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv global_load_b64 v[17:18], v[11:12], off v_subrev_nc_u32_e32 v8, s3, v8 v_subrev_nc_u32_e32 v13, s3, v13 v_subrev_nc_u32_e32 v9, s2, v9 s_add_i32 s16, s6, -1 s_cmp_lt_i32 s6, 2 s_mov_b32 s6, s16 s_waitcnt vmcnt(0) global_store_b64 v[6:7], v[17:18], off s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv s_cbranch_scc1 .LBB0_20 .LBB0_14: v_mov_b32_e32 v17, 0 v_mov_b32_e32 v18, 0 s_and_not1_b32 vcc_lo, exec_lo, s7 s_cbranch_vccnz .LBB0_17 v_mov_b32_e32 v19, v8 v_dual_mov_b32 v22, v16 :: v_dual_mov_b32 v21, v15 s_mov_b32 s16, s2 .p2align 6 .LBB0_16: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_ashrrev_i32_e32 v20, 31, v19 s_add_i32 s16, s16, -1 s_cmp_lg_u32 s16, 0 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_lshlrev_b64 v[25:26], 3, v[19:20] v_add_nc_u32_e32 v19, s2, v19 v_add_co_u32 v25, vcc_lo, s14, v25 s_delay_alu instid0(VALU_DEP_3) v_add_co_ci_u32_e32 v26, vcc_lo, s15, v26, vcc_lo global_load_b64 v[27:28], v[21:22], off global_load_b64 v[25:26], v[25:26], off v_add_co_u32 v21, vcc_lo, v21, 8 v_add_co_ci_u32_e32 v22, vcc_lo, 0, v22, vcc_lo s_waitcnt vmcnt(0) v_fma_f64 v[17:18], v[25:26], v[27:28], v[17:18] s_cbranch_scc1 .LBB0_16 .LBB0_17: v_add_nc_u32_e32 v10, s6, v23 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[19:20], null, v10, s2, v[0:1] v_ashrrev_i32_e32 v20, 31, v19 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_lshlrev_b64 v[19:20], 3, v[19:20] v_add_co_u32 v19, vcc_lo, s4, v19 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1) v_add_co_ci_u32_e32 v20, vcc_lo, s5, v20, vcc_lo s_and_not1_b32 vcc_lo, exec_lo, s7 global_load_b64 v[19:20], v[19:20], off s_waitcnt vmcnt(0) v_add_f64 v[21:22], -v[19:20], 1.0 v_mul_f64 v[19:20], v[19:20], v[21:22] s_delay_alu instid0(VALU_DEP_1) v_mul_f64 v[17:18], v[17:18], v[19:20] global_store_b64 v[11:12], v[17:18], off s_cbranch_vccnz .LBB0_13 v_ashrrev_i32_e32 v14, 31, v13 v_ashrrev_i32_e32 v10, 31, v9 s_mov_b32 s16, s2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[17:18], 3, v[13:14] v_lshlrev_b64 v[19:20], 3, v[9:10] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v17, vcc_lo, s12, v17 v_add_co_ci_u32_e32 v18, vcc_lo, s13, v18, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v19, vcc_lo, s4, v19 v_add_co_ci_u32_e32 v20, vcc_lo, s5, v20, vcc_lo .p2align 6 .LBB0_19: global_load_b64 v[21:22], v[11:12], off global_load_b64 v[25:26], v[19:20], off v_add_co_u32 v19, vcc_lo, v19, 8 v_add_co_ci_u32_e32 v20, vcc_lo, 0, v20, vcc_lo s_add_i32 s16, s16, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s16, 0 s_waitcnt vmcnt(0) v_mul_f64 v[21:22], v[21:22], v[25:26] global_store_b64 v[17:18], v[21:22], off v_add_co_u32 v17, vcc_lo, v17, 8 v_add_co_ci_u32_e32 v18, vcc_lo, 0, v18, vcc_lo s_cbranch_scc1 .LBB0_19 s_branch .LBB0_13 .LBB0_20: s_cmp_lt_i32 s2, 1 s_cbranch_scc1 .LBB0_23 v_lshlrev_b64 v[8:9], 3, v[4:5] v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v7, 0 v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v6, v0 s_mov_b32 s3, s2 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v8, vcc_lo, s8, v8 v_add_co_ci_u32_e32 v9, vcc_lo, s9, v9, vcc_lo .p2align 6 .LBB0_22: s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) v_lshlrev_b64 v[10:11], 3, v[6:7] v_add_nc_u32_e32 v6, s2, v6 s_add_i32 s3, s3, -1 s_cmp_lg_u32 s3, 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v10, vcc_lo, s14, v10 v_add_co_ci_u32_e32 v11, vcc_lo, s15, v11, vcc_lo global_load_b64 v[12:13], v[8:9], off global_load_b64 v[10:11], v[10:11], off v_add_co_u32 v8, vcc_lo, v8, 8 v_add_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo s_waitcnt vmcnt(0) v_fma_f64 v[4:5], v[10:11], v[12:13], v[4:5] s_cbranch_scc1 .LBB0_22 s_branch .LBB0_24 .LBB0_23: v_mov_b32_e32 v4, 0 v_mov_b32_e32 v5, 0 .LBB0_24: v_add_nc_u32_e32 v6, v24, v0 s_load_b32 s3, s[0:1], 0x5c v_lshlrev_b64 v[2:3], 3, v[2:3] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v7, 31, v6 v_lshlrev_b64 v[6:7], 3, v[6:7] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v6, vcc_lo, s4, v6 v_add_co_ci_u32_e32 v7, vcc_lo, s5, v7, vcc_lo v_add_co_u32 v2, vcc_lo, s10, v2 v_add_co_ci_u32_e32 v3, vcc_lo, s11, v3, vcc_lo global_load_b64 v[6:7], v[6:7], off s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s3, 1 s_waitcnt vmcnt(0) v_add_f64 v[8:9], -v[6:7], 1.0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f64 v[6:7], v[6:7], v[8:9] v_mul_f64 v[4:5], v[4:5], v[6:7] global_store_b64 v[2:3], v[4:5], off s_cbranch_scc1 .LBB0_27 v_mul_lo_u32 v4, v1, s3 v_mul_lo_u32 v0, v0, s3 s_clause 0x1 s_load_b64 s[4:5], s[0:1], 0x40 s_load_b64 s[0:1], s[0:1], 0x68 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v5, 31, v4 v_mad_u64_u32 v[6:7], null, v4, s2, v[0:1] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[4:5], 3, v[4:5] v_ashrrev_i32_e32 v7, 31, v6 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_lshlrev_b64 v[0:1], 3, v[6:7] s_waitcnt lgkmcnt(0) v_add_co_u32 v0, vcc_lo, s4, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo v_add_co_u32 v4, vcc_lo, s0, v4 v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo .p2align 6 .LBB0_26: global_load_b64 v[6:7], v[2:3], off global_load_b64 v[8:9], v[4:5], off v_add_co_u32 v4, vcc_lo, v4, 8 v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo s_add_i32 s3, s3, -1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_lg_u32 s3, 0 s_waitcnt vmcnt(0) v_mul_f64 v[6:7], v[6:7], v[8:9] global_store_b64 v[0:1], v[6:7], off v_add_co_u32 v0, vcc_lo, v0, 8 v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo s_cbranch_scc1 .LBB0_26 .LBB0_27: s_waitcnt_vscnt null, 0x0 s_barrier buffer_gl0_inv s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 124 .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 1 .amdhsa_next_free_vgpr 29 .amdhsa_next_free_sgpr 17 .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 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .Lfunc_end0-_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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 - .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 - .address_space: global .offset: 64 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 72 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 80 .size: 8 .value_kind: global_buffer - .offset: 88 .size: 4 .value_kind: by_value - .offset: 92 .size: 4 .value_kind: by_value - .offset: 96 .size: 4 .value_kind: by_value - .offset: 100 .size: 4 .value_kind: by_value - .address_space: global .offset: 104 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 112 .size: 8 .value_kind: global_buffer - .offset: 120 .size: 4 .value_kind: by_value .group_segment_fixed_size: 0 .kernarg_segment_align: 8 .kernarg_segment_size: 124 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .private_segment_fixed_size: 0 .sgpr_count: 19 .sgpr_spill_count: 0 .symbol: _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 29 .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 back(double *h_out_d, double *weights_out_d, double *weights_h_d, double *weights_in_d, double *outputs_d, double *deltas_h_d, double *deltas_h_new_d, double *deltas_o_d, double *weights_in_delta_d, double *weights_out_delta_d, double *weights_h_delta_d, int height, int inputs, int outputs, int layers, double *training_in_d, double *training_out_d, int sample){ int i, j; int tix = threadIdx.x; int tiy = threadIdx.y + sample; int h_offset = tiy * layers * height; int w_o_d_offset = tiy * outputs * height; int w_h_d_offset = tiy * (layers-1) * height * height; int w_i_d_offset = tiy * inputs * height; int d_h_offset = tiy * height; double delta_sum, temp; /*__shared__ double h_out_ds[H_LAYERS*H_HEIGHT]; __shared__ double weights_h_ds[(H_LAYERS-1)*H_HEIGHT*H_HEIGHT]; __shared__ double deltas_h_ds[H_HEIGHT]; __shared__ double deltas_h_new_ds[H_HEIGHT]; for(i=0;i<layers;i++) h_out_ds[tix*height+i] = h_out_d[tix*height+i]; for(i=0;i<layers-1;i++){ for(j=0;j<height;j++) weights_h_ds[i*height*height + tix*height + j] = weights_h_d[i*height*height + tix*height + j]; } deltas_h_ds[tix] = deltas_h_d[tix]; deltas_h_new_ds[tix] = deltas_h_new_d[tix]; __syncthreads(); */ //output layer if(tix < outputs){ deltas_o_d[tiy * outputs + tix] = (outputs_d[tiy * outputs + tix] - training_out_d[tiy]); for(i = 0; i < height; i++){ weights_out_delta_d[w_o_d_offset + (tix * height) + i] = deltas_o_d[tiy * outputs + tix] * h_out_d[h_offset + (layers-1)*height+i]; } } __syncthreads(); //hidden layer //layer connected to output delta_sum = 0; for(i = 0; i < outputs; i++){ delta_sum += weights_out_d[tix + (i * height)] * deltas_o_d[tiy * outputs + i]; } temp = h_out_d[h_offset + (layers-1)*height + tix]; deltas_h_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i = 0; i < height; i++){ weights_h_delta_d[w_h_d_offset + (layers-2)*height*height + (tix * height) + i] = deltas_h_d[d_h_offset + tix] * h_out_d[h_offset + (layers-2)*height+i]; } __syncthreads(); //each hidden layer not connected to input/hidden output layer for(i = layers - 2; i > 0; i--){ delta_sum = 0; for(j = 0; j < height; j++){ delta_sum += weights_h_d[i*height*height + j*height + tix] * deltas_h_d[d_h_offset + j]; } temp = h_out_d[h_offset + i*height + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(j = 0; j < height; j++){ weights_h_delta_d[w_h_d_offset + (i-1)*height*height + (tix * height) + j] = (deltas_h_new_d[d_h_offset + tix] * h_out_d[h_offset + (i-1)*height+j]); } __syncthreads(); //change pointers to simulate copying memory deltas_h_d[d_h_offset + tix] = deltas_h_new_d[d_h_offset + tix]; __syncthreads(); } //Layer connected to inputs delta_sum = 0; for(i=0; i<height; i++){ delta_sum += weights_h_d[i*height + tix] * deltas_h_d[d_h_offset + i]; } temp = h_out_d[h_offset + tix]; deltas_h_new_d[d_h_offset + tix] = temp * (1 - temp) * delta_sum; for(i=0; i<inputs; i++){ weights_in_delta_d[w_i_d_offset + tix*inputs+i] = (deltas_h_new_d[d_h_offset + tix] * training_in_d[tiy * inputs + i]); } __syncthreads(); }
.text .file "back.hip" .globl _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i # -- Begin function _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .p2align 4, 0x90 .type _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i,@function _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: # @_Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .cfi_startproc # %bb.0: subq $248, %rsp .cfi_def_cfa_offset 256 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movq %rcx, 64(%rsp) movq %r8, 56(%rsp) movq %r9, 48(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 64(%rsp), %rax movq %rax, 120(%rsp) leaq 56(%rsp), %rax movq %rax, 128(%rsp) leaq 48(%rsp), %rax movq %rax, 136(%rsp) leaq 256(%rsp), %rax movq %rax, 144(%rsp) leaq 264(%rsp), %rax movq %rax, 152(%rsp) leaq 272(%rsp), %rax movq %rax, 160(%rsp) leaq 280(%rsp), %rax movq %rax, 168(%rsp) leaq 288(%rsp), %rax movq %rax, 176(%rsp) leaq 296(%rsp), %rax movq %rax, 184(%rsp) leaq 304(%rsp), %rax movq %rax, 192(%rsp) leaq 312(%rsp), %rax movq %rax, 200(%rsp) leaq 320(%rsp), %rax movq %rax, 208(%rsp) leaq 328(%rsp), %rax movq %rax, 216(%rsp) leaq 336(%rsp), %rax movq %rax, 224(%rsp) leaq 344(%rsp), %rax movq %rax, 232(%rsp) 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 96(%rsp), %r9 movl $_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $264, %rsp # imm = 0x108 .cfi_adjust_cfa_offset -264 retq .Lfunc_end0: .size _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .Lfunc_end0-_Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_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 $_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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_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 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i,@object # @_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .section .rodata,"a",@progbits .globl _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .p2align 3, 0x0 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: .quad _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .size _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i" .size .L__unnamed_1, 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 .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__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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_000ace3e_00000000-6_back.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 _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .type _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, @function _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: .LFB2051: .cfi_startproc endbr64 subq $344, %rsp .cfi_def_cfa_offset 352 movq %rdi, 104(%rsp) movq %rsi, 96(%rsp) movq %rdx, 88(%rsp) movq %rcx, 80(%rsp) movq %r8, 72(%rsp) movq %r9, 64(%rsp) movq 352(%rsp), %rax movq %rax, 56(%rsp) movq 360(%rsp), %rax movq %rax, 48(%rsp) movq 368(%rsp), %rax movq %rax, 40(%rsp) movq 376(%rsp), %rax movq %rax, 32(%rsp) movq 384(%rsp), %rax movq %rax, 24(%rsp) movq 424(%rsp), %rax movq %rax, 16(%rsp) movq 432(%rsp), %rax movq %rax, 8(%rsp) movq %fs:40, %rax movq %rax, 328(%rsp) xorl %eax, %eax leaq 104(%rsp), %rax movq %rax, 176(%rsp) leaq 96(%rsp), %rax movq %rax, 184(%rsp) leaq 88(%rsp), %rax movq %rax, 192(%rsp) leaq 80(%rsp), %rax movq %rax, 200(%rsp) leaq 72(%rsp), %rax movq %rax, 208(%rsp) leaq 64(%rsp), %rax movq %rax, 216(%rsp) leaq 56(%rsp), %rax movq %rax, 224(%rsp) leaq 48(%rsp), %rax movq %rax, 232(%rsp) leaq 40(%rsp), %rax movq %rax, 240(%rsp) leaq 32(%rsp), %rax movq %rax, 248(%rsp) leaq 24(%rsp), %rax movq %rax, 256(%rsp) leaq 392(%rsp), %rax movq %rax, 264(%rsp) leaq 400(%rsp), %rax movq %rax, 272(%rsp) leaq 408(%rsp), %rax movq %rax, 280(%rsp) leaq 416(%rsp), %rax movq %rax, 288(%rsp) leaq 16(%rsp), %rax movq %rax, 296(%rsp) leaq 8(%rsp), %rax movq %rax, 304(%rsp) leaq 440(%rsp), %rax movq %rax, 312(%rsp) movl $1, 128(%rsp) movl $1, 132(%rsp) movl $1, 136(%rsp) movl $1, 140(%rsp) movl $1, 144(%rsp) movl $1, 148(%rsp) leaq 120(%rsp), %rcx leaq 112(%rsp), %rdx leaq 140(%rsp), %rsi leaq 128(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L7 .L3: movq 328(%rsp), %rax subq %fs:40, %rax jne .L8 addq $344, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L7: .cfi_restore_state pushq 120(%rsp) .cfi_def_cfa_offset 360 pushq 120(%rsp) .cfi_def_cfa_offset 368 leaq 192(%rsp), %r9 movq 156(%rsp), %rcx movl 164(%rsp), %r8d movq 144(%rsp), %rsi movl 152(%rsp), %edx leaq _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 352 jmp .L3 .L8: call __stack_chk_fail@PLT .cfi_endproc .LFE2051: .size _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .-_Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .globl _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .type _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, @function _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 24 pushq 104(%rsp) .cfi_def_cfa_offset 32 pushq 104(%rsp) .cfi_def_cfa_offset 40 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 48 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 56 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 64 movl 104(%rsp), %eax pushq %rax .cfi_def_cfa_offset 72 pushq 104(%rsp) .cfi_def_cfa_offset 80 pushq 104(%rsp) .cfi_def_cfa_offset 88 pushq 104(%rsp) .cfi_def_cfa_offset 96 pushq 104(%rsp) .cfi_def_cfa_offset 104 pushq 104(%rsp) .cfi_def_cfa_offset 112 call _Z52__device_stub__Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_iPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i addq $104, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .-_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_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 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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 .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 "back.hip" .globl _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i # -- Begin function _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .p2align 4, 0x90 .type _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i,@function _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: # @_Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .cfi_startproc # %bb.0: subq $248, %rsp .cfi_def_cfa_offset 256 movq %rdi, 88(%rsp) movq %rsi, 80(%rsp) movq %rdx, 72(%rsp) movq %rcx, 64(%rsp) movq %r8, 56(%rsp) movq %r9, 48(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 72(%rsp), %rax movq %rax, 112(%rsp) leaq 64(%rsp), %rax movq %rax, 120(%rsp) leaq 56(%rsp), %rax movq %rax, 128(%rsp) leaq 48(%rsp), %rax movq %rax, 136(%rsp) leaq 256(%rsp), %rax movq %rax, 144(%rsp) leaq 264(%rsp), %rax movq %rax, 152(%rsp) leaq 272(%rsp), %rax movq %rax, 160(%rsp) leaq 280(%rsp), %rax movq %rax, 168(%rsp) leaq 288(%rsp), %rax movq %rax, 176(%rsp) leaq 296(%rsp), %rax movq %rax, 184(%rsp) leaq 304(%rsp), %rax movq %rax, 192(%rsp) leaq 312(%rsp), %rax movq %rax, 200(%rsp) leaq 320(%rsp), %rax movq %rax, 208(%rsp) leaq 328(%rsp), %rax movq %rax, 216(%rsp) leaq 336(%rsp), %rax movq %rax, 224(%rsp) leaq 344(%rsp), %rax movq %rax, 232(%rsp) 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 96(%rsp), %r9 movl $_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $264, %rsp # imm = 0x108 .cfi_adjust_cfa_offset -264 retq .Lfunc_end0: .size _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, .Lfunc_end0-_Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_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 $_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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_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 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i,@object # @_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .section .rodata,"a",@progbits .globl _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .p2align 3, 0x0 _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i: .quad _Z19__device_stub__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .size _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i" .size .L__unnamed_1, 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 .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__backPdS_S_S_S_S_S_S_S_S_S_iiiiS_S_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z4backPdS_S_S_S_S_S_S_S_S_S_iiiiS_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 HIP/AMD source code.
#include <string> #include <iostream> #include <cstdlib> #include <fstream> #include <cmath> #include <iomanip> #include <cstring> #include <chrono> #define mu 0 #define pi 3.141 #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) // useful MACRO to check for errors using namespace std; static void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { cout<<cudaGetErrorString( err )<<" in "<< file <<" at line "<< line; } } struct Pixel {float r, g, b; }; __global__ void convolution_gpu_x(const Pixel *in, Pixel *mid, const float *K, const int width, const int height, const int k, const int N) { int indx = threadIdx.x + blockIdx.x * blockDim.x; // calculate the thread index int row = indx / width; // calculate my row row++; // inc by 1 so that it doesnt have 0 if(indx < N && indx <= ((row*width)-k)) // only enter if indx is less than N and { // width -k for each row float temp1=0, temp2=0, temp3=0; // declare temps for(int ref = 0; ref<k; ref++) // loop through ref for K { int findx = indx + ref; temp1 += K[ref] * in[findx].r; // cal K[0]*in[0] + K[1]*in[1] ... and so on temp2 += K[ref] * in[findx].g; // do for r, g and b temp3 += K[ref] * in[findx].b; // store in temp variables } mid[indx].r = temp1; // put it in indermidiate image mid[indx].g = temp2; mid[indx].b = temp3; } /* __syncthreads() // sync threads doesnt provide barrier for all threads if(indx < N-((k-1)*width)) //&& indx <= ((row*width)-k)) { float temp1=0, temp2=0, temp3=0; for(int ref = 0; ref<k; ref++) { temp1 += K[ref] * mid[indx+(ref*width)].r; temp2 += K[ref] * mid[indx+(ref*width)].g; temp3 += K[ref] * mid[indx+(ref*width)].b; } out[indx].r = temp1; out[indx].g = temp2; out[indx].b = temp3; } */ } __global__ void convolution_gpu_y(const Pixel *mid, Pixel *out, const float *K, const int width, const int height, const int k, const int N) { int indx = threadIdx.x + blockIdx.x * blockDim.x; // calc index int row = indx / width; // calc row row++; /* if(indx < N && indx <= ((row*width)-k)) { float temp1=0, temp2=0, temp3=0; for(int ref = 0; ref<k; ref++) { temp1 += K[ref] * in[indx+ref].r; temp2 += K[ref] * in[indx+ref].g; temp3 += K[ref] * in[indx+ref].b; } mid[indx].r = temp1; mid[indx].g = temp2; mid[indx].b = temp3; } __syncthreads(); */ if(indx < N-((k-1)*width) && indx <= ((row*width)-k)) // proceed only if my thread is not below height - k or beyond width -k { float temp1=0, temp2=0, temp3=0; // declare temps for(int ref = 0; ref<k; ref++) // loop to loop through K and mid image columns { int findx = indx + (ref*width); temp1 += K[ref] * mid[findx].r; // calc K[0]*mid[0] + K[1]*mid[1] + ... so on temp2 += K[ref] * mid[findx].g; // mid is indexed column wise temp3 += K[ref] * mid[findx].b; // if width is 5 it will go like mid[0], mid[5], mid[10] } out[indx].r = temp1; // store back the temps to output out[indx].g = temp2; out[indx].b = temp3; } } int main(int argc, char* argv[]) { if(argc !=3) //Checking if there are 3 arguments { cout<<"Please enter 3 arguments"<<endl; //returns this message if 3 arguments not present cout<<"USAGE:./executable image_file_name.ppm kernal_size "<<endl; return 1; } string filename = argv[1]; // stores the ppm image name to filename int sigma = atoi(argv[2]); // stores the second argument to sigma /***************************READ FILE*****************************************/ ifstream file(filename.c_str(), ios::binary); string type; // string to store file type eg. P6 string comment; // string to store comments in file string dustbin; // unused dustin variable to discard comments file >> type; // read file type file >> comment; // read next word after type while(comment.compare(0,1,"#") == 0) // see if first character is a # { getline(file,dustbin); // then read the entire line file >> comment; // read the next word } int width, height, range; // variables to store the width, height and range width = stoi(comment); // value after comment store it in width file >> height >> range; // continue reading for height and range int N = height*width; // N to store total number of pixels availanle cout << endl; cout << "Type : " << type << endl; // display the headers cout << "height : " << height << endl; cout << "width : " << width << endl; cout << "range : " << range << endl; cout << "N : " << N << endl << endl; size_t buffer_size = 3 * height * width * sizeof(unsigned char) + 1; // calulate the size of buffer needed to allocate unsigned char *buffer = new unsigned char[buffer_size]; // allocate pointer for the buffer file.read((char *)buffer, N*3+1); // read the data into buffer using the pointer file.close(); // close the file size_t pixel_size = height * width * sizeof(Pixel) + 1; // calculate size of pixel adding 1 to be on safer side Pixel *pixel_in = new Pixel[pixel_size]; // allocate pointer's to store input, mid image and output image Pixel *pixel_mid = new Pixel[pixel_size]; Pixel *pixel_out = new Pixel[pixel_size]; memset(pixel_in, 0, pixel_size); // initalize everything to 0 memset(pixel_mid, 0, pixel_size); memset(pixel_out, 0, pixel_size); for (int i=0; i<N; i++) // store the rgb values in pixel data type { pixel_in[i].r = buffer[i*3+1]; pixel_in[i].g = buffer[i*3+2]; pixel_in[i].b = buffer[i*3+3]; } delete[] buffer; // i dont need the buffer anymore /*****************************CREATE KERNEL***********************************/ double coeff; // declare variable to store coefficient coeff = 1/sqrt(2*sigma*sigma*pi); // calculate the coefficient cout << "coefficient is : " << coeff << endl << endl; // display the coefficient value int k = 6 * sigma; // calculate number of elements in kernel and store it in coeff if(k%2==0) k++; // if k is even, increment by 1 int k_half = k/2; // calculate half of k float* K = new float[k]; // create a pointer to kernel K float sum = 0; // declare temp variable sum for(int i=-k_half; i<=k_half; i++) // loop over from -k/2 to +k/2 { K[i+k_half]=coeff*exp(-(((i-mu)*(i-mu))/(2*sigma*sigma))); // calcuate K[i] and ofset the index to store in positive values // cout << "k["<<i+k_half<<"] :" << K[i+k_half]<<endl; // uncomment this print statement to check the values of K sum += K[i+k_half]; // add it to temp variable sum } // cout<<"SUM : " << sum << endl; // display the sum of K use this to normalize K to 1 // cout <<"---------------------------------------------" << endl; // cout <<"NORMALIZED K" << endl; // cout <<"---------------------------------------------" << endl; // uncomment these lines to see the sum float sum2 = 0; for(int i=-k_half; i<=k_half; i++) { K[i+k_half]/=sum; // normalize K using sum // cout << "k["<<i+k_half<<"] :" << K[i+k_half]<<endl; // uncomment this print statement to check the values of normalized K sum2+=K[i+k_half]; // store in sum 2 } // cout << "\nSUM after normalizing : " << sum2 << endl; // display sum after normalizing. uncommnet to check /**************************CONVOLUTION ROW WISE*******************************/ chrono::high_resolution_clock::time_point start,stop; // initialize the timers start = chrono::high_resolution_clock::now(); // record the start point float temp1, temp2, temp3; // declare 3 temp variables for rgb for(int j=0; j<height; j++) // loop till the end height { int ofset = j*width; for(int i=0; i<=width-k; i++) // stops at width so that ref can fill rest of image width { int indx = i+ofset; temp1 = 0, temp2 = 0, temp3 = 0; // inialize the temps to 0 after each width loop for(int ref=0; ref<k; ref++ ) { int findx = indx + ref; // findx gives [(i+j*width)+ref] temp1 += K[ref] * pixel_in[findx].r; // calc K[0] * input[0] + K[1] * input[1] ... and so on temp2 += K[ref] * pixel_in[findx].g; // do it for r, g and b temp3 += K[ref] * pixel_in[findx].b; // and store in temp variables } pixel_mid[indx].r = temp1; // copy the values to the intermediate image. pixel_mid[indx].g = temp2; pixel_mid[indx].b = temp3; } } /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF MID IMAGE for(int i=0; i<N; i++) { if(i%20 == 0) cout << endl; cout << pixel_mid[i].r << " "<< pixel_mid[i].g << " "<< pixel_mid[i].b << " "; } cout << endl; */ /***********************CONVOLUTION COLUMN WISE******************************/ for(int j=0; j<=height-k; j++) // stops at a hight so that ref can fill rest of image height { int ofset = j*width; for(int i=0; i<=width-k; i++) // loop through width. dont loop at the end k-1. { int indx = i+ofset; temp1 = 0; temp2 = 0 ; temp3 = 0; // inialize the temps to 0 after each width loop for(int ref=0; ref<k; ref++ ) { int findx = indx+(ref*width); // findx gives [(i+j*width)+(ref*width)] temp1 += K[ref] * pixel_mid[findx].r; // cal K[0] * mid[0] + K[1] * mid[1] + .. so on temp2 += K[ref] * pixel_mid[findx].g; // mid[0], mid[1], mid[2] .. is all along column wise temp3 += K[ref] * pixel_mid[findx].b; // if width is 5 the indexing is like mid[0], mid[5], mid[10] } pixel_out[indx].r = temp1; // store it to the output image pixel_out[indx].g = temp2; pixel_out[indx].b = temp3; } } stop = chrono::high_resolution_clock::now(); // record the stop point chrono::milliseconds cpu_time; // declare d to store time in milliseconds cpu_time = chrono::duration_cast<chrono::milliseconds>(stop - start); // calculate stop - start gives the time taken cout << "cpu time taken : " << cpu_time.count() << " ms" << endl; // display the time in ms /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF OUTPUT IMAGE for(int i=0; i<N; i++) { if(i%20 == 0) cout << endl; cout << pixel_out[i].r << " "<<pixel_out[i].g << " "<<pixel_out[i].b << " "; } cout << endl; */ /******************************WRITE FILE*************************************/ ofstream wfile("output_image_cpu.ppm", ios::binary); // create or open a file in binary mode to store the output image wfile << type << endl; // write file type wfile << width << " " << height << endl << range << endl; // write the width, height and range unsigned char *out_buffer = new unsigned char[buffer_size]; // create a pointer to buffer to write easily. doesn't work if i write directly for(int i = 0; i < N; i++) // store the output values in the buffer { out_buffer[i*3+0] = (unsigned char)pixel_out[i].r; out_buffer[i*3+1] = (unsigned char)pixel_out[i].g; out_buffer[i*3+2] = (unsigned char)pixel_out[i].b; } /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF OUTPUT BUFFEER for(int i=0; i<N*3; i++) { if(i%(3*20) == 0) cout << endl; cout << (int)out_buffer[i] << " "; } cout << endl; */ wfile.write(reinterpret_cast<char *>(&out_buffer[0]), N*3); // write the values in the buffer to the the file wfile.close(); // close the file cout << "\ndone writing cpu image" << endl << endl; delete[] out_buffer; // delete the buffer to free up space /******************************GPU KERNAL*************************************/ cudaDeviceProp prop; HANDLE_ERROR(cudaGetDeviceProperties(&prop,0)); // store the gpu properties in prop Pixel *pixel_gpu_in, *pixel_gpu_mid, *pixel_gpu_out; // declare gpu pointers float *K_gpu; HANDLE_ERROR(cudaMalloc(&pixel_gpu_in , pixel_size)); // allocate memory on gpu HANDLE_ERROR(cudaMalloc(&pixel_gpu_mid, pixel_size)); HANDLE_ERROR(cudaMalloc(&pixel_gpu_out, pixel_size)); HANDLE_ERROR(cudaMalloc(&K_gpu, k*sizeof(float))); HANDLE_ERROR(cudaMemset(pixel_gpu_in , 0, pixel_size)); // set the memory to 0 HANDLE_ERROR(cudaMemset(pixel_gpu_mid, 0, pixel_size)); HANDLE_ERROR(cudaMemset(pixel_gpu_out, 0, pixel_size)); HANDLE_ERROR(cudaMemset(K_gpu, 0, k*sizeof(float))); memset(pixel_out, 0, height*width*sizeof(Pixel)); // reuse pixel_out by setting it to 0 HANDLE_ERROR(cudaMemcpy(pixel_gpu_in, pixel_in, pixel_size, cudaMemcpyHostToDevice)); // copy the cpu_input to gpu_input HANDLE_ERROR(cudaMemcpy(K_gpu, K, k*sizeof(float), cudaMemcpyHostToDevice)); // copy cpu_K to gpu_K int blockDim = prop.maxThreadsDim[0]; // use max threads per block int gridDim = N / blockDim + 1; // calulate max blocks based on N and blockDim cout << "blockDim : " << blockDim << endl; // display threads per block, num of blocks, total number od threads cout << "gridDim : " << gridDim << endl; cout << "Num threads : "<< blockDim * gridDim << endl << endl; cudaEvent_t begin, end; // 2 events to record time cudaEventCreate(&begin); // create the 2 event cudaEventCreate(&end); cudaEventRecord(begin); // send the start event to stream // I am using 2 seperate kernel because syncthread() only syncs threads within blocks so I was getting wrong results. // LAUNCH THE KERNEL TO PERFORM CONVOLUTION ALONG X AXIS convolution_gpu_x<<<gridDim, blockDim>>>(pixel_gpu_in, pixel_gpu_mid, K_gpu, width, height, k, N); HANDLE_ERROR(cudaMemcpy(pixel_mid, pixel_gpu_mid, pixel_size, cudaMemcpyDeviceToHost)); // copy back the intermidiate image // LAUNCH THE KERNEL TO PERFORM CONVOLUTION ALONG Y AXIS convolution_gpu_y<<<gridDim, blockDim>>>(pixel_gpu_mid, pixel_gpu_out, K_gpu, width, height, k, N); cudaEventRecord(end); // send the stop event to stream cudaEventSynchronize(end); // wait till end occurs float gpu_time = 0; // declare a variable to store time in milliseconds cudaEventElapsedTime(&gpu_time, begin, end); // store the time cout << "gpu time taken : " << gpu_time <<" ms includes one data copy back to the host" << endl << endl; // output gpu time float speedup = (float)cpu_time.count() / (float)gpu_time; cout <<"*********************************************************" << endl; cout <<"Speed up of GPU over CPU : " << speedup << " times" << endl; // display the speedup cout <<"*********************************************************" << endl; HANDLE_ERROR(cudaMemcpy(pixel_out, pixel_gpu_out, pixel_size, cudaMemcpyDeviceToHost)); // copy back the final output /* // UNCOMMENT THIS BLOCK TO CHECK FINAL VALUES for(int i=0; i<N; i++) { if(i%(20) == 0) cout << endl; cout << pixel_out[i].b << " "; } cout << endl; */ /******************************WRITE FILE*************************************/ ofstream gfile("output_image_gpu.ppm", ios::binary); // Same as writing in cpu. just different filename gfile << type << endl; gfile << width << " " << height << endl << range << endl; unsigned char *gpu_buffer = new unsigned char[buffer_size]; for(int i = 0; i < N; i++) { gpu_buffer[i*3+0] = (unsigned char)pixel_out[i].r; gpu_buffer[i*3+1] = (unsigned char)pixel_out[i].g; gpu_buffer[i*3+2] = (unsigned char)pixel_out[i].b; } /* for(int i=0; i<N*3; i++) { if(i%(3*20) == 0) cout << endl; cout << (float)gpu_buffer[i] << " "; } cout << endl; */ gfile.write(reinterpret_cast<char *>(&gpu_buffer[0]), N*3); gfile.close(); cout << "\ndone writing gpu image" << endl << endl; delete[] pixel_in, pixel_mid, pixel_out, gpu_buffer; // release the memory delete[] K, K_gpu; return 0; }
#include <hip/hip_runtime.h> #include <string> #include <iostream> #include <cstdlib> #include <fstream> #include <cmath> #include <iomanip> #include <cstring> #include <chrono> #define mu 0 #define pi 3.141 #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) // useful MACRO to check for errors using namespace std; static void HandleError( hipError_t err, const char *file, int line ) { if (err != hipSuccess) { cout<<hipGetErrorString( err )<<" in "<< file <<" at line "<< line; } } struct Pixel {float r, g, b; }; __global__ void convolution_gpu_x(const Pixel *in, Pixel *mid, const float *K, const int width, const int height, const int k, const int N) { int indx = threadIdx.x + blockIdx.x * blockDim.x; // calculate the thread index int row = indx / width; // calculate my row row++; // inc by 1 so that it doesnt have 0 if(indx < N && indx <= ((row*width)-k)) // only enter if indx is less than N and { // width -k for each row float temp1=0, temp2=0, temp3=0; // declare temps for(int ref = 0; ref<k; ref++) // loop through ref for K { int findx = indx + ref; temp1 += K[ref] * in[findx].r; // cal K[0]*in[0] + K[1]*in[1] ... and so on temp2 += K[ref] * in[findx].g; // do for r, g and b temp3 += K[ref] * in[findx].b; // store in temp variables } mid[indx].r = temp1; // put it in indermidiate image mid[indx].g = temp2; mid[indx].b = temp3; } /* __syncthreads() // sync threads doesnt provide barrier for all threads if(indx < N-((k-1)*width)) //&& indx <= ((row*width)-k)) { float temp1=0, temp2=0, temp3=0; for(int ref = 0; ref<k; ref++) { temp1 += K[ref] * mid[indx+(ref*width)].r; temp2 += K[ref] * mid[indx+(ref*width)].g; temp3 += K[ref] * mid[indx+(ref*width)].b; } out[indx].r = temp1; out[indx].g = temp2; out[indx].b = temp3; } */ } __global__ void convolution_gpu_y(const Pixel *mid, Pixel *out, const float *K, const int width, const int height, const int k, const int N) { int indx = threadIdx.x + blockIdx.x * blockDim.x; // calc index int row = indx / width; // calc row row++; /* if(indx < N && indx <= ((row*width)-k)) { float temp1=0, temp2=0, temp3=0; for(int ref = 0; ref<k; ref++) { temp1 += K[ref] * in[indx+ref].r; temp2 += K[ref] * in[indx+ref].g; temp3 += K[ref] * in[indx+ref].b; } mid[indx].r = temp1; mid[indx].g = temp2; mid[indx].b = temp3; } __syncthreads(); */ if(indx < N-((k-1)*width) && indx <= ((row*width)-k)) // proceed only if my thread is not below height - k or beyond width -k { float temp1=0, temp2=0, temp3=0; // declare temps for(int ref = 0; ref<k; ref++) // loop to loop through K and mid image columns { int findx = indx + (ref*width); temp1 += K[ref] * mid[findx].r; // calc K[0]*mid[0] + K[1]*mid[1] + ... so on temp2 += K[ref] * mid[findx].g; // mid is indexed column wise temp3 += K[ref] * mid[findx].b; // if width is 5 it will go like mid[0], mid[5], mid[10] } out[indx].r = temp1; // store back the temps to output out[indx].g = temp2; out[indx].b = temp3; } } int main(int argc, char* argv[]) { if(argc !=3) //Checking if there are 3 arguments { cout<<"Please enter 3 arguments"<<endl; //returns this message if 3 arguments not present cout<<"USAGE:./executable image_file_name.ppm kernal_size "<<endl; return 1; } string filename = argv[1]; // stores the ppm image name to filename int sigma = atoi(argv[2]); // stores the second argument to sigma /***************************READ FILE*****************************************/ ifstream file(filename.c_str(), ios::binary); string type; // string to store file type eg. P6 string comment; // string to store comments in file string dustbin; // unused dustin variable to discard comments file >> type; // read file type file >> comment; // read next word after type while(comment.compare(0,1,"#") == 0) // see if first character is a # { getline(file,dustbin); // then read the entire line file >> comment; // read the next word } int width, height, range; // variables to store the width, height and range width = stoi(comment); // value after comment store it in width file >> height >> range; // continue reading for height and range int N = height*width; // N to store total number of pixels availanle cout << endl; cout << "Type : " << type << endl; // display the headers cout << "height : " << height << endl; cout << "width : " << width << endl; cout << "range : " << range << endl; cout << "N : " << N << endl << endl; size_t buffer_size = 3 * height * width * sizeof(unsigned char) + 1; // calulate the size of buffer needed to allocate unsigned char *buffer = new unsigned char[buffer_size]; // allocate pointer for the buffer file.read((char *)buffer, N*3+1); // read the data into buffer using the pointer file.close(); // close the file size_t pixel_size = height * width * sizeof(Pixel) + 1; // calculate size of pixel adding 1 to be on safer side Pixel *pixel_in = new Pixel[pixel_size]; // allocate pointer's to store input, mid image and output image Pixel *pixel_mid = new Pixel[pixel_size]; Pixel *pixel_out = new Pixel[pixel_size]; memset(pixel_in, 0, pixel_size); // initalize everything to 0 memset(pixel_mid, 0, pixel_size); memset(pixel_out, 0, pixel_size); for (int i=0; i<N; i++) // store the rgb values in pixel data type { pixel_in[i].r = buffer[i*3+1]; pixel_in[i].g = buffer[i*3+2]; pixel_in[i].b = buffer[i*3+3]; } delete[] buffer; // i dont need the buffer anymore /*****************************CREATE KERNEL***********************************/ double coeff; // declare variable to store coefficient coeff = 1/sqrt(2*sigma*sigma*pi); // calculate the coefficient cout << "coefficient is : " << coeff << endl << endl; // display the coefficient value int k = 6 * sigma; // calculate number of elements in kernel and store it in coeff if(k%2==0) k++; // if k is even, increment by 1 int k_half = k/2; // calculate half of k float* K = new float[k]; // create a pointer to kernel K float sum = 0; // declare temp variable sum for(int i=-k_half; i<=k_half; i++) // loop over from -k/2 to +k/2 { K[i+k_half]=coeff*exp(-(((i-mu)*(i-mu))/(2*sigma*sigma))); // calcuate K[i] and ofset the index to store in positive values // cout << "k["<<i+k_half<<"] :" << K[i+k_half]<<endl; // uncomment this print statement to check the values of K sum += K[i+k_half]; // add it to temp variable sum } // cout<<"SUM : " << sum << endl; // display the sum of K use this to normalize K to 1 // cout <<"---------------------------------------------" << endl; // cout <<"NORMALIZED K" << endl; // cout <<"---------------------------------------------" << endl; // uncomment these lines to see the sum float sum2 = 0; for(int i=-k_half; i<=k_half; i++) { K[i+k_half]/=sum; // normalize K using sum // cout << "k["<<i+k_half<<"] :" << K[i+k_half]<<endl; // uncomment this print statement to check the values of normalized K sum2+=K[i+k_half]; // store in sum 2 } // cout << "\nSUM after normalizing : " << sum2 << endl; // display sum after normalizing. uncommnet to check /**************************CONVOLUTION ROW WISE*******************************/ chrono::high_resolution_clock::time_point start,stop; // initialize the timers start = chrono::high_resolution_clock::now(); // record the start point float temp1, temp2, temp3; // declare 3 temp variables for rgb for(int j=0; j<height; j++) // loop till the end height { int ofset = j*width; for(int i=0; i<=width-k; i++) // stops at width so that ref can fill rest of image width { int indx = i+ofset; temp1 = 0, temp2 = 0, temp3 = 0; // inialize the temps to 0 after each width loop for(int ref=0; ref<k; ref++ ) { int findx = indx + ref; // findx gives [(i+j*width)+ref] temp1 += K[ref] * pixel_in[findx].r; // calc K[0] * input[0] + K[1] * input[1] ... and so on temp2 += K[ref] * pixel_in[findx].g; // do it for r, g and b temp3 += K[ref] * pixel_in[findx].b; // and store in temp variables } pixel_mid[indx].r = temp1; // copy the values to the intermediate image. pixel_mid[indx].g = temp2; pixel_mid[indx].b = temp3; } } /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF MID IMAGE for(int i=0; i<N; i++) { if(i%20 == 0) cout << endl; cout << pixel_mid[i].r << " "<< pixel_mid[i].g << " "<< pixel_mid[i].b << " "; } cout << endl; */ /***********************CONVOLUTION COLUMN WISE******************************/ for(int j=0; j<=height-k; j++) // stops at a hight so that ref can fill rest of image height { int ofset = j*width; for(int i=0; i<=width-k; i++) // loop through width. dont loop at the end k-1. { int indx = i+ofset; temp1 = 0; temp2 = 0 ; temp3 = 0; // inialize the temps to 0 after each width loop for(int ref=0; ref<k; ref++ ) { int findx = indx+(ref*width); // findx gives [(i+j*width)+(ref*width)] temp1 += K[ref] * pixel_mid[findx].r; // cal K[0] * mid[0] + K[1] * mid[1] + .. so on temp2 += K[ref] * pixel_mid[findx].g; // mid[0], mid[1], mid[2] .. is all along column wise temp3 += K[ref] * pixel_mid[findx].b; // if width is 5 the indexing is like mid[0], mid[5], mid[10] } pixel_out[indx].r = temp1; // store it to the output image pixel_out[indx].g = temp2; pixel_out[indx].b = temp3; } } stop = chrono::high_resolution_clock::now(); // record the stop point chrono::milliseconds cpu_time; // declare d to store time in milliseconds cpu_time = chrono::duration_cast<chrono::milliseconds>(stop - start); // calculate stop - start gives the time taken cout << "cpu time taken : " << cpu_time.count() << " ms" << endl; // display the time in ms /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF OUTPUT IMAGE for(int i=0; i<N; i++) { if(i%20 == 0) cout << endl; cout << pixel_out[i].r << " "<<pixel_out[i].g << " "<<pixel_out[i].b << " "; } cout << endl; */ /******************************WRITE FILE*************************************/ ofstream wfile("output_image_cpu.ppm", ios::binary); // create or open a file in binary mode to store the output image wfile << type << endl; // write file type wfile << width << " " << height << endl << range << endl; // write the width, height and range unsigned char *out_buffer = new unsigned char[buffer_size]; // create a pointer to buffer to write easily. doesn't work if i write directly for(int i = 0; i < N; i++) // store the output values in the buffer { out_buffer[i*3+0] = (unsigned char)pixel_out[i].r; out_buffer[i*3+1] = (unsigned char)pixel_out[i].g; out_buffer[i*3+2] = (unsigned char)pixel_out[i].b; } /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF OUTPUT BUFFEER for(int i=0; i<N*3; i++) { if(i%(3*20) == 0) cout << endl; cout << (int)out_buffer[i] << " "; } cout << endl; */ wfile.write(reinterpret_cast<char *>(&out_buffer[0]), N*3); // write the values in the buffer to the the file wfile.close(); // close the file cout << "\ndone writing cpu image" << endl << endl; delete[] out_buffer; // delete the buffer to free up space /******************************GPU KERNAL*************************************/ hipDeviceProp_t prop; HANDLE_ERROR(hipGetDeviceProperties(&prop,0)); // store the gpu properties in prop Pixel *pixel_gpu_in, *pixel_gpu_mid, *pixel_gpu_out; // declare gpu pointers float *K_gpu; HANDLE_ERROR(hipMalloc(&pixel_gpu_in , pixel_size)); // allocate memory on gpu HANDLE_ERROR(hipMalloc(&pixel_gpu_mid, pixel_size)); HANDLE_ERROR(hipMalloc(&pixel_gpu_out, pixel_size)); HANDLE_ERROR(hipMalloc(&K_gpu, k*sizeof(float))); HANDLE_ERROR(hipMemset(pixel_gpu_in , 0, pixel_size)); // set the memory to 0 HANDLE_ERROR(hipMemset(pixel_gpu_mid, 0, pixel_size)); HANDLE_ERROR(hipMemset(pixel_gpu_out, 0, pixel_size)); HANDLE_ERROR(hipMemset(K_gpu, 0, k*sizeof(float))); memset(pixel_out, 0, height*width*sizeof(Pixel)); // reuse pixel_out by setting it to 0 HANDLE_ERROR(hipMemcpy(pixel_gpu_in, pixel_in, pixel_size, hipMemcpyHostToDevice)); // copy the cpu_input to gpu_input HANDLE_ERROR(hipMemcpy(K_gpu, K, k*sizeof(float), hipMemcpyHostToDevice)); // copy cpu_K to gpu_K int blockDim = prop.maxThreadsDim[0]; // use max threads per block int gridDim = N / blockDim + 1; // calulate max blocks based on N and blockDim cout << "blockDim : " << blockDim << endl; // display threads per block, num of blocks, total number od threads cout << "gridDim : " << gridDim << endl; cout << "Num threads : "<< blockDim * gridDim << endl << endl; hipEvent_t begin, end; // 2 events to record time hipEventCreate(&begin); // create the 2 event hipEventCreate(&end); hipEventRecord(begin); // send the start event to stream // I am using 2 seperate kernel because syncthread() only syncs threads within blocks so I was getting wrong results. // LAUNCH THE KERNEL TO PERFORM CONVOLUTION ALONG X AXIS convolution_gpu_x<<<gridDim, blockDim>>>(pixel_gpu_in, pixel_gpu_mid, K_gpu, width, height, k, N); HANDLE_ERROR(hipMemcpy(pixel_mid, pixel_gpu_mid, pixel_size, hipMemcpyDeviceToHost)); // copy back the intermidiate image // LAUNCH THE KERNEL TO PERFORM CONVOLUTION ALONG Y AXIS convolution_gpu_y<<<gridDim, blockDim>>>(pixel_gpu_mid, pixel_gpu_out, K_gpu, width, height, k, N); hipEventRecord(end); // send the stop event to stream hipEventSynchronize(end); // wait till end occurs float gpu_time = 0; // declare a variable to store time in milliseconds hipEventElapsedTime(&gpu_time, begin, end); // store the time cout << "gpu time taken : " << gpu_time <<" ms includes one data copy back to the host" << endl << endl; // output gpu time float speedup = (float)cpu_time.count() / (float)gpu_time; cout <<"*********************************************************" << endl; cout <<"Speed up of GPU over CPU : " << speedup << " times" << endl; // display the speedup cout <<"*********************************************************" << endl; HANDLE_ERROR(hipMemcpy(pixel_out, pixel_gpu_out, pixel_size, hipMemcpyDeviceToHost)); // copy back the final output /* // UNCOMMENT THIS BLOCK TO CHECK FINAL VALUES for(int i=0; i<N; i++) { if(i%(20) == 0) cout << endl; cout << pixel_out[i].b << " "; } cout << endl; */ /******************************WRITE FILE*************************************/ ofstream gfile("output_image_gpu.ppm", ios::binary); // Same as writing in cpu. just different filename gfile << type << endl; gfile << width << " " << height << endl << range << endl; unsigned char *gpu_buffer = new unsigned char[buffer_size]; for(int i = 0; i < N; i++) { gpu_buffer[i*3+0] = (unsigned char)pixel_out[i].r; gpu_buffer[i*3+1] = (unsigned char)pixel_out[i].g; gpu_buffer[i*3+2] = (unsigned char)pixel_out[i].b; } /* for(int i=0; i<N*3; i++) { if(i%(3*20) == 0) cout << endl; cout << (float)gpu_buffer[i] << " "; } cout << endl; */ gfile.write(reinterpret_cast<char *>(&gpu_buffer[0]), N*3); gfile.close(); cout << "\ndone writing gpu image" << endl << endl; delete[] pixel_in, pixel_mid, pixel_out, gpu_buffer; // release the memory delete[] K, K_gpu; return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <string> #include <iostream> #include <cstdlib> #include <fstream> #include <cmath> #include <iomanip> #include <cstring> #include <chrono> #define mu 0 #define pi 3.141 #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) // useful MACRO to check for errors using namespace std; static void HandleError( hipError_t err, const char *file, int line ) { if (err != hipSuccess) { cout<<hipGetErrorString( err )<<" in "<< file <<" at line "<< line; } } struct Pixel {float r, g, b; }; __global__ void convolution_gpu_x(const Pixel *in, Pixel *mid, const float *K, const int width, const int height, const int k, const int N) { int indx = threadIdx.x + blockIdx.x * blockDim.x; // calculate the thread index int row = indx / width; // calculate my row row++; // inc by 1 so that it doesnt have 0 if(indx < N && indx <= ((row*width)-k)) // only enter if indx is less than N and { // width -k for each row float temp1=0, temp2=0, temp3=0; // declare temps for(int ref = 0; ref<k; ref++) // loop through ref for K { int findx = indx + ref; temp1 += K[ref] * in[findx].r; // cal K[0]*in[0] + K[1]*in[1] ... and so on temp2 += K[ref] * in[findx].g; // do for r, g and b temp3 += K[ref] * in[findx].b; // store in temp variables } mid[indx].r = temp1; // put it in indermidiate image mid[indx].g = temp2; mid[indx].b = temp3; } /* __syncthreads() // sync threads doesnt provide barrier for all threads if(indx < N-((k-1)*width)) //&& indx <= ((row*width)-k)) { float temp1=0, temp2=0, temp3=0; for(int ref = 0; ref<k; ref++) { temp1 += K[ref] * mid[indx+(ref*width)].r; temp2 += K[ref] * mid[indx+(ref*width)].g; temp3 += K[ref] * mid[indx+(ref*width)].b; } out[indx].r = temp1; out[indx].g = temp2; out[indx].b = temp3; } */ } __global__ void convolution_gpu_y(const Pixel *mid, Pixel *out, const float *K, const int width, const int height, const int k, const int N) { int indx = threadIdx.x + blockIdx.x * blockDim.x; // calc index int row = indx / width; // calc row row++; /* if(indx < N && indx <= ((row*width)-k)) { float temp1=0, temp2=0, temp3=0; for(int ref = 0; ref<k; ref++) { temp1 += K[ref] * in[indx+ref].r; temp2 += K[ref] * in[indx+ref].g; temp3 += K[ref] * in[indx+ref].b; } mid[indx].r = temp1; mid[indx].g = temp2; mid[indx].b = temp3; } __syncthreads(); */ if(indx < N-((k-1)*width) && indx <= ((row*width)-k)) // proceed only if my thread is not below height - k or beyond width -k { float temp1=0, temp2=0, temp3=0; // declare temps for(int ref = 0; ref<k; ref++) // loop to loop through K and mid image columns { int findx = indx + (ref*width); temp1 += K[ref] * mid[findx].r; // calc K[0]*mid[0] + K[1]*mid[1] + ... so on temp2 += K[ref] * mid[findx].g; // mid is indexed column wise temp3 += K[ref] * mid[findx].b; // if width is 5 it will go like mid[0], mid[5], mid[10] } out[indx].r = temp1; // store back the temps to output out[indx].g = temp2; out[indx].b = temp3; } } int main(int argc, char* argv[]) { if(argc !=3) //Checking if there are 3 arguments { cout<<"Please enter 3 arguments"<<endl; //returns this message if 3 arguments not present cout<<"USAGE:./executable image_file_name.ppm kernal_size "<<endl; return 1; } string filename = argv[1]; // stores the ppm image name to filename int sigma = atoi(argv[2]); // stores the second argument to sigma /***************************READ FILE*****************************************/ ifstream file(filename.c_str(), ios::binary); string type; // string to store file type eg. P6 string comment; // string to store comments in file string dustbin; // unused dustin variable to discard comments file >> type; // read file type file >> comment; // read next word after type while(comment.compare(0,1,"#") == 0) // see if first character is a # { getline(file,dustbin); // then read the entire line file >> comment; // read the next word } int width, height, range; // variables to store the width, height and range width = stoi(comment); // value after comment store it in width file >> height >> range; // continue reading for height and range int N = height*width; // N to store total number of pixels availanle cout << endl; cout << "Type : " << type << endl; // display the headers cout << "height : " << height << endl; cout << "width : " << width << endl; cout << "range : " << range << endl; cout << "N : " << N << endl << endl; size_t buffer_size = 3 * height * width * sizeof(unsigned char) + 1; // calulate the size of buffer needed to allocate unsigned char *buffer = new unsigned char[buffer_size]; // allocate pointer for the buffer file.read((char *)buffer, N*3+1); // read the data into buffer using the pointer file.close(); // close the file size_t pixel_size = height * width * sizeof(Pixel) + 1; // calculate size of pixel adding 1 to be on safer side Pixel *pixel_in = new Pixel[pixel_size]; // allocate pointer's to store input, mid image and output image Pixel *pixel_mid = new Pixel[pixel_size]; Pixel *pixel_out = new Pixel[pixel_size]; memset(pixel_in, 0, pixel_size); // initalize everything to 0 memset(pixel_mid, 0, pixel_size); memset(pixel_out, 0, pixel_size); for (int i=0; i<N; i++) // store the rgb values in pixel data type { pixel_in[i].r = buffer[i*3+1]; pixel_in[i].g = buffer[i*3+2]; pixel_in[i].b = buffer[i*3+3]; } delete[] buffer; // i dont need the buffer anymore /*****************************CREATE KERNEL***********************************/ double coeff; // declare variable to store coefficient coeff = 1/sqrt(2*sigma*sigma*pi); // calculate the coefficient cout << "coefficient is : " << coeff << endl << endl; // display the coefficient value int k = 6 * sigma; // calculate number of elements in kernel and store it in coeff if(k%2==0) k++; // if k is even, increment by 1 int k_half = k/2; // calculate half of k float* K = new float[k]; // create a pointer to kernel K float sum = 0; // declare temp variable sum for(int i=-k_half; i<=k_half; i++) // loop over from -k/2 to +k/2 { K[i+k_half]=coeff*exp(-(((i-mu)*(i-mu))/(2*sigma*sigma))); // calcuate K[i] and ofset the index to store in positive values // cout << "k["<<i+k_half<<"] :" << K[i+k_half]<<endl; // uncomment this print statement to check the values of K sum += K[i+k_half]; // add it to temp variable sum } // cout<<"SUM : " << sum << endl; // display the sum of K use this to normalize K to 1 // cout <<"---------------------------------------------" << endl; // cout <<"NORMALIZED K" << endl; // cout <<"---------------------------------------------" << endl; // uncomment these lines to see the sum float sum2 = 0; for(int i=-k_half; i<=k_half; i++) { K[i+k_half]/=sum; // normalize K using sum // cout << "k["<<i+k_half<<"] :" << K[i+k_half]<<endl; // uncomment this print statement to check the values of normalized K sum2+=K[i+k_half]; // store in sum 2 } // cout << "\nSUM after normalizing : " << sum2 << endl; // display sum after normalizing. uncommnet to check /**************************CONVOLUTION ROW WISE*******************************/ chrono::high_resolution_clock::time_point start,stop; // initialize the timers start = chrono::high_resolution_clock::now(); // record the start point float temp1, temp2, temp3; // declare 3 temp variables for rgb for(int j=0; j<height; j++) // loop till the end height { int ofset = j*width; for(int i=0; i<=width-k; i++) // stops at width so that ref can fill rest of image width { int indx = i+ofset; temp1 = 0, temp2 = 0, temp3 = 0; // inialize the temps to 0 after each width loop for(int ref=0; ref<k; ref++ ) { int findx = indx + ref; // findx gives [(i+j*width)+ref] temp1 += K[ref] * pixel_in[findx].r; // calc K[0] * input[0] + K[1] * input[1] ... and so on temp2 += K[ref] * pixel_in[findx].g; // do it for r, g and b temp3 += K[ref] * pixel_in[findx].b; // and store in temp variables } pixel_mid[indx].r = temp1; // copy the values to the intermediate image. pixel_mid[indx].g = temp2; pixel_mid[indx].b = temp3; } } /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF MID IMAGE for(int i=0; i<N; i++) { if(i%20 == 0) cout << endl; cout << pixel_mid[i].r << " "<< pixel_mid[i].g << " "<< pixel_mid[i].b << " "; } cout << endl; */ /***********************CONVOLUTION COLUMN WISE******************************/ for(int j=0; j<=height-k; j++) // stops at a hight so that ref can fill rest of image height { int ofset = j*width; for(int i=0; i<=width-k; i++) // loop through width. dont loop at the end k-1. { int indx = i+ofset; temp1 = 0; temp2 = 0 ; temp3 = 0; // inialize the temps to 0 after each width loop for(int ref=0; ref<k; ref++ ) { int findx = indx+(ref*width); // findx gives [(i+j*width)+(ref*width)] temp1 += K[ref] * pixel_mid[findx].r; // cal K[0] * mid[0] + K[1] * mid[1] + .. so on temp2 += K[ref] * pixel_mid[findx].g; // mid[0], mid[1], mid[2] .. is all along column wise temp3 += K[ref] * pixel_mid[findx].b; // if width is 5 the indexing is like mid[0], mid[5], mid[10] } pixel_out[indx].r = temp1; // store it to the output image pixel_out[indx].g = temp2; pixel_out[indx].b = temp3; } } stop = chrono::high_resolution_clock::now(); // record the stop point chrono::milliseconds cpu_time; // declare d to store time in milliseconds cpu_time = chrono::duration_cast<chrono::milliseconds>(stop - start); // calculate stop - start gives the time taken cout << "cpu time taken : " << cpu_time.count() << " ms" << endl; // display the time in ms /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF OUTPUT IMAGE for(int i=0; i<N; i++) { if(i%20 == 0) cout << endl; cout << pixel_out[i].r << " "<<pixel_out[i].g << " "<<pixel_out[i].b << " "; } cout << endl; */ /******************************WRITE FILE*************************************/ ofstream wfile("output_image_cpu.ppm", ios::binary); // create or open a file in binary mode to store the output image wfile << type << endl; // write file type wfile << width << " " << height << endl << range << endl; // write the width, height and range unsigned char *out_buffer = new unsigned char[buffer_size]; // create a pointer to buffer to write easily. doesn't work if i write directly for(int i = 0; i < N; i++) // store the output values in the buffer { out_buffer[i*3+0] = (unsigned char)pixel_out[i].r; out_buffer[i*3+1] = (unsigned char)pixel_out[i].g; out_buffer[i*3+2] = (unsigned char)pixel_out[i].b; } /* // UNCOMMENT THIS BLOCK TO CHECK VALUES OF OUTPUT BUFFEER for(int i=0; i<N*3; i++) { if(i%(3*20) == 0) cout << endl; cout << (int)out_buffer[i] << " "; } cout << endl; */ wfile.write(reinterpret_cast<char *>(&out_buffer[0]), N*3); // write the values in the buffer to the the file wfile.close(); // close the file cout << "\ndone writing cpu image" << endl << endl; delete[] out_buffer; // delete the buffer to free up space /******************************GPU KERNAL*************************************/ hipDeviceProp_t prop; HANDLE_ERROR(hipGetDeviceProperties(&prop,0)); // store the gpu properties in prop Pixel *pixel_gpu_in, *pixel_gpu_mid, *pixel_gpu_out; // declare gpu pointers float *K_gpu; HANDLE_ERROR(hipMalloc(&pixel_gpu_in , pixel_size)); // allocate memory on gpu HANDLE_ERROR(hipMalloc(&pixel_gpu_mid, pixel_size)); HANDLE_ERROR(hipMalloc(&pixel_gpu_out, pixel_size)); HANDLE_ERROR(hipMalloc(&K_gpu, k*sizeof(float))); HANDLE_ERROR(hipMemset(pixel_gpu_in , 0, pixel_size)); // set the memory to 0 HANDLE_ERROR(hipMemset(pixel_gpu_mid, 0, pixel_size)); HANDLE_ERROR(hipMemset(pixel_gpu_out, 0, pixel_size)); HANDLE_ERROR(hipMemset(K_gpu, 0, k*sizeof(float))); memset(pixel_out, 0, height*width*sizeof(Pixel)); // reuse pixel_out by setting it to 0 HANDLE_ERROR(hipMemcpy(pixel_gpu_in, pixel_in, pixel_size, hipMemcpyHostToDevice)); // copy the cpu_input to gpu_input HANDLE_ERROR(hipMemcpy(K_gpu, K, k*sizeof(float), hipMemcpyHostToDevice)); // copy cpu_K to gpu_K int blockDim = prop.maxThreadsDim[0]; // use max threads per block int gridDim = N / blockDim + 1; // calulate max blocks based on N and blockDim cout << "blockDim : " << blockDim << endl; // display threads per block, num of blocks, total number od threads cout << "gridDim : " << gridDim << endl; cout << "Num threads : "<< blockDim * gridDim << endl << endl; hipEvent_t begin, end; // 2 events to record time hipEventCreate(&begin); // create the 2 event hipEventCreate(&end); hipEventRecord(begin); // send the start event to stream // I am using 2 seperate kernel because syncthread() only syncs threads within blocks so I was getting wrong results. // LAUNCH THE KERNEL TO PERFORM CONVOLUTION ALONG X AXIS convolution_gpu_x<<<gridDim, blockDim>>>(pixel_gpu_in, pixel_gpu_mid, K_gpu, width, height, k, N); HANDLE_ERROR(hipMemcpy(pixel_mid, pixel_gpu_mid, pixel_size, hipMemcpyDeviceToHost)); // copy back the intermidiate image // LAUNCH THE KERNEL TO PERFORM CONVOLUTION ALONG Y AXIS convolution_gpu_y<<<gridDim, blockDim>>>(pixel_gpu_mid, pixel_gpu_out, K_gpu, width, height, k, N); hipEventRecord(end); // send the stop event to stream hipEventSynchronize(end); // wait till end occurs float gpu_time = 0; // declare a variable to store time in milliseconds hipEventElapsedTime(&gpu_time, begin, end); // store the time cout << "gpu time taken : " << gpu_time <<" ms includes one data copy back to the host" << endl << endl; // output gpu time float speedup = (float)cpu_time.count() / (float)gpu_time; cout <<"*********************************************************" << endl; cout <<"Speed up of GPU over CPU : " << speedup << " times" << endl; // display the speedup cout <<"*********************************************************" << endl; HANDLE_ERROR(hipMemcpy(pixel_out, pixel_gpu_out, pixel_size, hipMemcpyDeviceToHost)); // copy back the final output /* // UNCOMMENT THIS BLOCK TO CHECK FINAL VALUES for(int i=0; i<N; i++) { if(i%(20) == 0) cout << endl; cout << pixel_out[i].b << " "; } cout << endl; */ /******************************WRITE FILE*************************************/ ofstream gfile("output_image_gpu.ppm", ios::binary); // Same as writing in cpu. just different filename gfile << type << endl; gfile << width << " " << height << endl << range << endl; unsigned char *gpu_buffer = new unsigned char[buffer_size]; for(int i = 0; i < N; i++) { gpu_buffer[i*3+0] = (unsigned char)pixel_out[i].r; gpu_buffer[i*3+1] = (unsigned char)pixel_out[i].g; gpu_buffer[i*3+2] = (unsigned char)pixel_out[i].b; } /* for(int i=0; i<N*3; i++) { if(i%(3*20) == 0) cout << endl; cout << (float)gpu_buffer[i] << " "; } cout << endl; */ gfile.write(reinterpret_cast<char *>(&gpu_buffer[0]), N*3); gfile.close(); cout << "\ndone writing gpu image" << endl << endl; delete[] pixel_in, pixel_mid, pixel_out, gpu_buffer; // release the memory delete[] K, K_gpu; return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z17convolution_gpu_xPK5PixelPS_PKfiiii .globl _Z17convolution_gpu_xPK5PixelPS_PKfiiii .p2align 8 .type _Z17convolution_gpu_xPK5PixelPS_PKfiiii,@function _Z17convolution_gpu_xPK5PixelPS_PKfiiii: s_clause 0x1 s_load_b32 s2, s[0:1], 0x34 s_load_b32 s3, s[0:1], 0x24 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[3:4], null, s15, s2, v[0:1] s_mov_b32 s2, exec_lo v_cmpx_gt_i32_e64 s3, v3 s_cbranch_execz .LBB0_6 s_clause 0x1 s_load_b32 s2, s[0:1], 0x18 s_load_b32 s6, s[0:1], 0x20 v_ashrrev_i32_e32 v2, 31, v3 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v4, v3, v2 v_xor_b32_e32 v4, v4, v2 s_waitcnt lgkmcnt(0) s_ashr_i32 s3, s2, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1) s_add_i32 s4, s2, s3 v_xor_b32_e32 v2, s3, v2 s_xor_b32 s4, s4, s3 v_cvt_f32_u32_e32 v0, s4 s_sub_i32 s5, 0, s4 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1) v_rcp_iflag_f32_e32 v0, v0 s_waitcnt_depctr 0xfff v_mul_f32_e32 v0, 0x4f7ffffe, v0 v_cvt_u32_f32_e32 v0, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_lo_u32 v1, s5, v0 v_mul_hi_u32 v1, v0, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v0, v0, v1 v_mul_hi_u32 v0, v4, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_lo_u32 v1, v0, s4 v_sub_nc_u32_e32 v1, v4, v1 v_add_nc_u32_e32 v4, 1, v0 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_subrev_nc_u32_e32 v5, s4, v1 v_cmp_le_u32_e32 vcc_lo, s4, v1 v_dual_cndmask_b32 v1, v1, v5 :: v_dual_cndmask_b32 v0, v0, v4 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_cmp_le_u32_e32 vcc_lo, s4, v1 v_add_nc_u32_e32 v4, 1, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cndmask_b32_e32 v0, v0, v4, vcc_lo v_xor_b32_e32 v0, v0, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_sub_nc_u32_e32 v2, v0, v2 v_mad_u64_u32 v[0:1], null, s2, v2, s[2:3] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_subrev_nc_u32_e32 v0, s6, v0 v_cmp_le_i32_e32 vcc_lo, v3, v0 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_6 v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v1, 0 v_mov_b32_e32 v0, 0 s_cmp_lt_i32 s6, 1 s_cbranch_scc1 .LBB0_5 s_clause 0x1 s_load_b64 s[2:3], s[0:1], 0x0 s_load_b64 s[4:5], s[0:1], 0x10 v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v1, 0 v_mov_b32_e32 v4, v3 v_mov_b32_e32 v0, 0 .LBB0_4: s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) v_mad_i64_i32 v[5:6], null, v4, 12, s[2:3] s_load_b32 s7, s[4:5], 0x0 s_add_i32 s6, s6, -1 s_add_u32 s4, s4, 4 s_addc_u32 s5, s5, 0 s_cmp_eq_u32 s6, 0 global_load_b96 v[5:7], v[5:6], off s_waitcnt vmcnt(0) lgkmcnt(0) v_dual_fmac_f32 v1, s7, v6 :: v_dual_add_nc_u32 v4, 1, v4 v_fmac_f32_e32 v0, s7, v5 v_fmac_f32_e32 v2, s7, v7 s_cbranch_scc0 .LBB0_4 .LBB0_5: s_load_b64 s[0:1], s[0:1], 0x8 s_waitcnt lgkmcnt(0) v_mad_i64_i32 v[4:5], null, v3, 12, s[0:1] global_store_b96 v[4:5], v[0:2], off .LBB0_6: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z17convolution_gpu_xPK5PixelPS_PKfiiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 296 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z17convolution_gpu_xPK5PixelPS_PKfiiii, .Lfunc_end0-_Z17convolution_gpu_xPK5PixelPS_PKfiiii .section .AMDGPU.csdata,"",@progbits .text .protected _Z17convolution_gpu_yPK5PixelPS_PKfiiii .globl _Z17convolution_gpu_yPK5PixelPS_PKfiiii .p2align 8 .type _Z17convolution_gpu_yPK5PixelPS_PKfiiii,@function _Z17convolution_gpu_yPK5PixelPS_PKfiiii: s_clause 0x2 s_load_b32 s5, s[0:1], 0x34 s_load_b64 s[2:3], s[0:1], 0x20 s_load_b32 s4, s[0:1], 0x18 s_waitcnt lgkmcnt(0) s_and_b32 s5, s5, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) v_mad_u64_u32 v[3:4], null, s15, s5, v[0:1] s_add_i32 s5, s2, -1 s_mul_i32 s5, s5, s4 s_delay_alu instid0(SALU_CYCLE_1) s_sub_i32 s3, s3, s5 s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1) v_cmp_gt_i32_e32 vcc_lo, s3, v3 s_and_saveexec_b32 s3, vcc_lo s_cbranch_execz .LBB1_6 s_ashr_i32 s3, s4, 31 v_ashrrev_i32_e32 v2, 31, v3 s_add_i32 s5, s4, s3 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) s_xor_b32 s5, s5, s3 v_add_nc_u32_e32 v4, v3, v2 v_cvt_f32_u32_e32 v0, s5 s_sub_i32 s6, 0, s5 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_xor_b32_e32 v4, v4, v2 v_rcp_iflag_f32_e32 v0, v0 v_xor_b32_e32 v2, s3, v2 s_waitcnt_depctr 0xfff v_mul_f32_e32 v0, 0x4f7ffffe, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cvt_u32_f32_e32 v0, v0 v_mul_lo_u32 v1, s6, v0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_hi_u32 v1, v0, v1 v_add_nc_u32_e32 v0, v0, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_hi_u32 v0, v4, v0 v_mul_lo_u32 v1, v0, s5 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_sub_nc_u32_e32 v1, v4, v1 v_add_nc_u32_e32 v4, 1, v0 v_subrev_nc_u32_e32 v5, s5, v1 v_cmp_le_u32_e32 vcc_lo, s5, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_dual_cndmask_b32 v1, v1, v5 :: v_dual_cndmask_b32 v0, v0, v4 v_cmp_le_u32_e32 vcc_lo, s5, v1 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_nc_u32_e32 v4, 1, v0 v_cndmask_b32_e32 v0, v0, v4, vcc_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_xor_b32_e32 v0, v0, v2 v_sub_nc_u32_e32 v2, v0, v2 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, s4, v2, s[4:5] v_subrev_nc_u32_e32 v0, s2, v0 s_delay_alu instid0(VALU_DEP_1) v_cmp_le_i32_e32 vcc_lo, v3, v0 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB1_6 v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v1, 0 v_mov_b32_e32 v0, 0 s_cmp_lt_i32 s2, 1 s_cbranch_scc1 .LBB1_5 s_clause 0x1 s_load_b64 s[6:7], s[0:1], 0x0 s_load_b64 s[8:9], s[0:1], 0x10 v_dual_mov_b32 v2, 0 :: v_dual_mov_b32 v1, 0 v_mov_b32_e32 v4, v3 v_mov_b32_e32 v0, 0 .LBB1_4: s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) v_mad_i64_i32 v[5:6], null, v4, 12, s[6:7] s_load_b32 s3, s[8:9], 0x0 s_add_i32 s2, s2, -1 s_add_u32 s8, s8, 4 s_addc_u32 s9, s9, 0 s_cmp_eq_u32 s2, 0 global_load_b96 v[5:7], v[5:6], off s_waitcnt vmcnt(0) lgkmcnt(0) v_dual_fmac_f32 v1, s3, v6 :: v_dual_add_nc_u32 v4, s4, v4 v_fmac_f32_e32 v0, s3, v5 v_fmac_f32_e32 v2, s3, v7 s_cbranch_scc0 .LBB1_4 .LBB1_5: s_load_b64 s[0:1], s[0:1], 0x8 s_waitcnt lgkmcnt(0) v_mad_i64_i32 v[4:5], null, v3, 12, s[0:1] global_store_b96 v[4:5], v[0:2], off .LBB1_6: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z17convolution_gpu_yPK5PixelPS_PKfiiii .amdhsa_group_segment_fixed_size 0 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 296 .amdhsa_user_sgpr_count 15 .amdhsa_user_sgpr_dispatch_ptr 0 .amdhsa_user_sgpr_queue_ptr 0 .amdhsa_user_sgpr_kernarg_segment_ptr 1 .amdhsa_user_sgpr_dispatch_id 0 .amdhsa_user_sgpr_private_segment_size 0 .amdhsa_wavefront_size32 1 .amdhsa_uses_dynamic_stack 0 .amdhsa_enable_private_segment 0 .amdhsa_system_sgpr_workgroup_id_x 1 .amdhsa_system_sgpr_workgroup_id_y 0 .amdhsa_system_sgpr_workgroup_id_z 0 .amdhsa_system_sgpr_workgroup_info 0 .amdhsa_system_vgpr_workitem_id 0 .amdhsa_next_free_vgpr 8 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end1: .size _Z17convolution_gpu_yPK5PixelPS_PKfiiii, .Lfunc_end1-_Z17convolution_gpu_yPK5PixelPS_PKfiiii .section .AMDGPU.csdata,"",@progbits .text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgpu_metadata --- amdhsa.kernels: - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: by_value - .offset: 36 .size: 4 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: 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: _Z17convolution_gpu_xPK5PixelPS_PKfiiii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z17convolution_gpu_xPK5PixelPS_PKfiiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 - .args: - .address_space: global .offset: 0 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 8 .size: 8 .value_kind: global_buffer - .address_space: global .offset: 16 .size: 8 .value_kind: global_buffer - .offset: 24 .size: 4 .value_kind: by_value - .offset: 28 .size: 4 .value_kind: by_value - .offset: 32 .size: 4 .value_kind: by_value - .offset: 36 .size: 4 .value_kind: by_value - .offset: 40 .size: 4 .value_kind: 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: _Z17convolution_gpu_yPK5PixelPS_PKfiiii .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z17convolution_gpu_yPK5PixelPS_PKfiiii.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 8 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
// Corresponding header file: /include/mirror_ops.h #include <cuda_runtime.h> #include <stdio.h> /* Mirror operations */ __global__ void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; if ( col >= numCols || row >= numRows ) { return; } if(!vertical) { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = thread_x; int thread_y_new = numRows-thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; } else { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = numCols-thread_x; int thread_y_new = thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; // linear data store in global memory } } uchar4* mirror_ops(uchar4 *d_inputImageRGBA, size_t numRows, size_t numCols, bool vertical) { //Set reasonable block size (i.e., number of threads per block) const dim3 blockSize(4,4,1); //Calculate Grid SIze int a=numCols/blockSize.x, b=numRows/blockSize.y; const dim3 gridSize(a+1,b+1,1); const size_t numPixels = numRows * numCols; uchar4 *d_outputImageRGBA; cudaMalloc(&d_outputImageRGBA, sizeof(uchar4) * numPixels); //Call mirror kernel. mirror<<<gridSize, blockSize>>>(d_inputImageRGBA, d_outputImageRGBA, numRows, numCols, vertical); cudaDeviceSynchronize(); //Initialize memory on host for output uchar4* uchar4* h_out; h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels); //copy output from device to host cudaMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, cudaMemcpyDeviceToHost); //cleanup memory on device cudaFree(d_inputImageRGBA); cudaFree(d_outputImageRGBA); //return h_out return h_out; }
code for sm_80 Function : _Z6mirrorPK6uchar4PS_iib .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e280000002100 */ /*0030*/ S2R R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000e680000002600 */ /*0040*/ S2R R2, SR_TID.Y ; /* 0x0000000000027919 */ /* 0x000e620000002200 */ /*0050*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0203 */ /*0060*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x174], PT ; /* 0x00005d0000007a0c */ /* 0x000fe20003f06270 */ /*0070*/ IMAD R5, R5, c[0x0][0x4], R2 ; /* 0x0000010005057a24 */ /* 0x002fca00078e0202 */ /*0080*/ ISETP.GE.OR P0, PT, R5, c[0x0][0x170], P0 ; /* 0x00005c0005007a0c */ /* 0x000fda0000706670 */ /*0090*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00a0*/ ULDC.S8 UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe20000000200 */ /*00b0*/ HFMA2.MMA R4, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff047435 */ /* 0x000fe200000001ff */ /*00c0*/ ISETP.NE.AND P0, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf05270 */ /*00d0*/ IMAD R2, R5, c[0x0][0x174], R0 ; /* 0x00005d0005027a24 */ /* 0x000fe200078e0200 */ /*00e0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fce0000000a00 */ /*00f0*/ IMAD.WIDE R2, R2, R4, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x000fc800078e0204 */ /*0100*/ @!P0 BRA 0x170 ; /* 0x0000006000008947 */ /* 0x000fea0003800000 */ /*0110*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*0120*/ IADD3 R0, -R0, c[0x0][0x174], RZ ; /* 0x00005d0000007a10 */ /* 0x000fca0007ffe1ff */ /*0130*/ IMAD R5, R5, c[0x0][0x174], R0 ; /* 0x00005d0005057a24 */ /* 0x000fc800078e0200 */ /*0140*/ IMAD.WIDE R4, R5, R4, c[0x0][0x168] ; /* 0x00005a0005047625 */ /* 0x000fca00078e0204 */ /*0150*/ STG.E [R4.64], R3 ; /* 0x0000000304007986 */ /* 0x004fe2000c101904 */ /*0160*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0170*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*0180*/ IADD3 R5, -R5, c[0x0][0x170], RZ ; /* 0x00005c0005057a10 */ /* 0x000fca0007ffe1ff */ /*0190*/ IMAD R5, R5, c[0x0][0x174], R0 ; /* 0x00005d0005057a24 */ /* 0x000fc800078e0200 */ /*01a0*/ IMAD.WIDE R4, R5, R4, c[0x0][0x168] ; /* 0x00005a0005047625 */ /* 0x000fca00078e0204 */ /*01b0*/ STG.E [R4.64], R3 ; /* 0x0000000304007986 */ /* 0x004fe2000c101904 */ /*01c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01d0*/ BRA 0x1d0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0200*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0210*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0220*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0230*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0240*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
// Corresponding header file: /include/mirror_ops.h #include <cuda_runtime.h> #include <stdio.h> /* Mirror operations */ __global__ void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; if ( col >= numCols || row >= numRows ) { return; } if(!vertical) { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = thread_x; int thread_y_new = numRows-thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; } else { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = numCols-thread_x; int thread_y_new = thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; // linear data store in global memory } } uchar4* mirror_ops(uchar4 *d_inputImageRGBA, size_t numRows, size_t numCols, bool vertical) { //Set reasonable block size (i.e., number of threads per block) const dim3 blockSize(4,4,1); //Calculate Grid SIze int a=numCols/blockSize.x, b=numRows/blockSize.y; const dim3 gridSize(a+1,b+1,1); const size_t numPixels = numRows * numCols; uchar4 *d_outputImageRGBA; cudaMalloc(&d_outputImageRGBA, sizeof(uchar4) * numPixels); //Call mirror kernel. mirror<<<gridSize, blockSize>>>(d_inputImageRGBA, d_outputImageRGBA, numRows, numCols, vertical); cudaDeviceSynchronize(); //Initialize memory on host for output uchar4* uchar4* h_out; h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels); //copy output from device to host cudaMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, cudaMemcpyDeviceToHost); //cleanup memory on device cudaFree(d_inputImageRGBA); cudaFree(d_outputImageRGBA); //return h_out return h_out; }
.file "tmpxft_000d421e_00000000-6_mirror_ops.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 _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib .type _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib, @function _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib: .LFB2082: .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) movb %r8b, 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 12(%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 .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 _Z6mirrorPK6uchar4PS_iib(%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 _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib, .-_Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib .globl _Z6mirrorPK6uchar4PS_iib .type _Z6mirrorPK6uchar4PS_iib, @function _Z6mirrorPK6uchar4PS_iib: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movzbl %r8b, %r8d call _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z6mirrorPK6uchar4PS_iib, .-_Z6mirrorPK6uchar4PS_iib .globl _Z10mirror_opsP6uchar4mmb .type _Z10mirror_opsP6uchar4mmb, @function _Z10mirror_opsP6uchar4mmb: .LFB2057: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $48, %rsp .cfi_def_cfa_offset 96 movq %rdi, %r13 movq %rsi, %rbp movq %rdx, %r12 movl %ecx, %r14d movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax movl $1, 24(%rsp) movq %rdx, %rax shrq $2, %rax addl $1, %eax movl %eax, 28(%rsp) movq %rsi, %rax shrq $2, %rax addl $1, %eax movl %eax, 32(%rsp) movl $1, 36(%rsp) movq %rdx, %rbx imulq %rsi, %rbx salq $2, %rbx leaq 8(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT movl $4, 16(%rsp) movl $4, 20(%rsp) movl 24(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 16(%rsp), %rdx movq 28(%rsp), %rdi movl 36(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L15 .L12: call cudaDeviceSynchronize@PLT movq %rbx, %rdi call malloc@PLT movq %rax, %rbp movl $2, %ecx movq %rbx, %rdx movq 8(%rsp), %rsi movq %rax, %rdi call cudaMemcpy@PLT movq %r13, %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rax subq %fs:40, %rax jne .L16 movq %rbp, %rax addq $48, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L15: .cfi_restore_state movzbl %r14b, %r8d movl %r12d, %ecx movl %ebp, %edx movq 8(%rsp), %rsi movq %r13, %rdi call _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib jmp .L12 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size _Z10mirror_opsP6uchar4mmb, .-_Z10mirror_opsP6uchar4mmb .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z6mirrorPK6uchar4PS_iib" .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 .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z6mirrorPK6uchar4PS_iib(%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.
// Corresponding header file: /include/mirror_ops.h #include <cuda_runtime.h> #include <stdio.h> /* Mirror operations */ __global__ void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; if ( col >= numCols || row >= numRows ) { return; } if(!vertical) { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = thread_x; int thread_y_new = numRows-thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; } else { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = numCols-thread_x; int thread_y_new = thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; // linear data store in global memory } } uchar4* mirror_ops(uchar4 *d_inputImageRGBA, size_t numRows, size_t numCols, bool vertical) { //Set reasonable block size (i.e., number of threads per block) const dim3 blockSize(4,4,1); //Calculate Grid SIze int a=numCols/blockSize.x, b=numRows/blockSize.y; const dim3 gridSize(a+1,b+1,1); const size_t numPixels = numRows * numCols; uchar4 *d_outputImageRGBA; cudaMalloc(&d_outputImageRGBA, sizeof(uchar4) * numPixels); //Call mirror kernel. mirror<<<gridSize, blockSize>>>(d_inputImageRGBA, d_outputImageRGBA, numRows, numCols, vertical); cudaDeviceSynchronize(); //Initialize memory on host for output uchar4* uchar4* h_out; h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels); //copy output from device to host cudaMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, cudaMemcpyDeviceToHost); //cleanup memory on device cudaFree(d_inputImageRGBA); cudaFree(d_outputImageRGBA); //return h_out return h_out; }
// Corresponding header file: /include/mirror_ops.h #include <hip/hip_runtime.h> #include <stdio.h> /* Mirror operations */ __global__ void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; if ( col >= numCols || row >= numRows ) { return; } if(!vertical) { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = thread_x; int thread_y_new = numRows-thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; } else { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = numCols-thread_x; int thread_y_new = thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; // linear data store in global memory } } uchar4* mirror_ops(uchar4 *d_inputImageRGBA, size_t numRows, size_t numCols, bool vertical) { //Set reasonable block size (i.e., number of threads per block) const dim3 blockSize(4,4,1); //Calculate Grid SIze int a=numCols/blockSize.x, b=numRows/blockSize.y; const dim3 gridSize(a+1,b+1,1); const size_t numPixels = numRows * numCols; uchar4 *d_outputImageRGBA; hipMalloc(&d_outputImageRGBA, sizeof(uchar4) * numPixels); //Call mirror kernel. mirror<<<gridSize, blockSize>>>(d_inputImageRGBA, d_outputImageRGBA, numRows, numCols, vertical); hipDeviceSynchronize(); //Initialize memory on host for output uchar4* uchar4* h_out; h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels); //copy output from device to host hipMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, hipMemcpyDeviceToHost); //cleanup memory on device hipFree(d_inputImageRGBA); hipFree(d_outputImageRGBA); //return h_out return h_out; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
// Corresponding header file: /include/mirror_ops.h #include <hip/hip_runtime.h> #include <stdio.h> /* Mirror operations */ __global__ void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; if ( col >= numCols || row >= numRows ) { return; } if(!vertical) { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = thread_x; int thread_y_new = numRows-thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; } else { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = numCols-thread_x; int thread_y_new = thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; // linear data store in global memory } } uchar4* mirror_ops(uchar4 *d_inputImageRGBA, size_t numRows, size_t numCols, bool vertical) { //Set reasonable block size (i.e., number of threads per block) const dim3 blockSize(4,4,1); //Calculate Grid SIze int a=numCols/blockSize.x, b=numRows/blockSize.y; const dim3 gridSize(a+1,b+1,1); const size_t numPixels = numRows * numCols; uchar4 *d_outputImageRGBA; hipMalloc(&d_outputImageRGBA, sizeof(uchar4) * numPixels); //Call mirror kernel. mirror<<<gridSize, blockSize>>>(d_inputImageRGBA, d_outputImageRGBA, numRows, numCols, vertical); hipDeviceSynchronize(); //Initialize memory on host for output uchar4* uchar4* h_out; h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels); //copy output from device to host hipMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, hipMemcpyDeviceToHost); //cleanup memory on device hipFree(d_inputImageRGBA); hipFree(d_outputImageRGBA); //return h_out return h_out; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .globl _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .p2align 8 .type _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib,@function _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib: s_clause 0x1 s_load_b32 s5, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x14 v_and_b32_e32 v3, 0x3ff, v0 s_add_u32 s2, s0, 32 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s5, s5, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s14, s5, v[3:4] s_mov_b32 s5, exec_lo v_cmpx_gt_i32_e64 s4, v1 s_cbranch_execz .LBB0_8 s_load_b32 s3, s[2:3], 0xc s_load_b32 s2, s[0:1], 0x10 v_bfe_u32 v0, v0, 10, 10 s_waitcnt lgkmcnt(0) s_lshr_b32 s3, s3, 16 s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1) v_mad_u64_u32 v[4:5], null, s15, s3, v[0:1] s_delay_alu instid0(VALU_DEP_1) v_cmp_gt_i32_e32 vcc_lo, s2, v4 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_8 s_load_b32 s3, s[0:1], 0x18 s_waitcnt lgkmcnt(0) s_bitcmp1_b32 s3, 0 s_cselect_b32 s3, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 vcc_lo, exec_lo, s3 s_cbranch_vccnz .LBB0_4 v_sub_nc_u32_e32 v0, s2, v4 s_mov_b32 s2, 0 s_delay_alu instid0(VALU_DEP_1) v_mad_u64_u32 v[2:3], null, v0, s4, v[1:2] s_branch .LBB0_5 .LBB0_4: s_mov_b32 s2, -1 .LBB0_5: v_mul_lo_u32 v0, v4, s4 s_and_not1_b32 vcc_lo, exec_lo, s2 s_cbranch_vccnz .LBB0_7 v_sub_nc_u32_e32 v2, s4, v1 s_delay_alu instid0(VALU_DEP_1) v_add_nc_u32_e32 v2, v2, v0 .LBB0_7: s_load_b128 s[0:3], s[0:1], 0x0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v0, v0, v1 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[0:1], 2, v[0:1] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_load_b32 v4, v[0:1], off v_lshlrev_b64 v[0:1], 2, v[2:3] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_waitcnt vmcnt(0) global_store_b32 v[0:1], v4, off .LBB0_8: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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 _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, .Lfunc_end0-_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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: 1 .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: _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib.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.
// Corresponding header file: /include/mirror_ops.h #include <hip/hip_runtime.h> #include <stdio.h> /* Mirror operations */ __global__ void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; if ( col >= numCols || row >= numRows ) { return; } if(!vertical) { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = thread_x; int thread_y_new = numRows-thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; } else { int thread_x = blockDim.x * blockIdx.x + threadIdx.x; int thread_y = blockDim.y * blockIdx.y + threadIdx.y; int thread_x_new = numCols-thread_x; int thread_y_new = thread_y; int myId = thread_y * numCols + thread_x; int myId_new = thread_y_new * numCols + thread_x_new; outputChannel[myId_new] = inputChannel[myId]; // linear data store in global memory } } uchar4* mirror_ops(uchar4 *d_inputImageRGBA, size_t numRows, size_t numCols, bool vertical) { //Set reasonable block size (i.e., number of threads per block) const dim3 blockSize(4,4,1); //Calculate Grid SIze int a=numCols/blockSize.x, b=numRows/blockSize.y; const dim3 gridSize(a+1,b+1,1); const size_t numPixels = numRows * numCols; uchar4 *d_outputImageRGBA; hipMalloc(&d_outputImageRGBA, sizeof(uchar4) * numPixels); //Call mirror kernel. mirror<<<gridSize, blockSize>>>(d_inputImageRGBA, d_outputImageRGBA, numRows, numCols, vertical); hipDeviceSynchronize(); //Initialize memory on host for output uchar4* uchar4* h_out; h_out = (uchar4*)malloc(sizeof(uchar4) * numPixels); //copy output from device to host hipMemcpy(h_out, d_outputImageRGBA, sizeof(uchar4) * numPixels, hipMemcpyDeviceToHost); //cleanup memory on device hipFree(d_inputImageRGBA); hipFree(d_outputImageRGBA); //return h_out return h_out; }
.text .file "mirror_ops.hip" .globl _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib # -- Begin function _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .p2align 4, 0x90 .type _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib,@function _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib: # @_Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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) movb %r8b, 7(%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 7(%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 $_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, %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__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, .Lfunc_end0-_Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .cfi_endproc # -- End function .globl _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb # -- Begin function _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb .p2align 4, 0x90 .type _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb,@function _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb: # @_Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb .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 %ecx, %ebp movq %rdx, %r15 movq %rsi, %r12 movq %rdi, %rbx movq %rdx, %rax shrq $2, %rax incl %eax movq %rsi, %rcx andq $-4, %rcx shlq $30, %rcx orq %rax, %rcx movabsq $4294967296, %r13 # imm = 0x100000000 addq %rcx, %r13 movq %rsi, %r14 imulq %rdx, %r14 shlq $2, %r14 leaq 16(%rsp), %rdi movq %r14, %rsi callq hipMalloc movabsq $17179869188, %rdx # imm = 0x400000004 movq %r13, %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_2 # %bb.1: movq 16(%rsp), %rax movq %rbx, 88(%rsp) movq %rax, 80(%rsp) movl %r12d, 28(%rsp) movl %r15d, 24(%rsp) movb %bpl, 15(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 28(%rsp), %rax movq %rax, 112(%rsp) leaq 24(%rsp), %rax movq %rax, 120(%rsp) leaq 15(%rsp), %rax movq %rax, 128(%rsp) leaq 64(%rsp), %rdi leaq 48(%rsp), %rsi leaq 40(%rsp), %rdx leaq 32(%rsp), %rcx callq __hipPopCallConfiguration movq 64(%rsp), %rsi movl 72(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, %edi pushq 32(%rsp) .cfi_adjust_cfa_offset 8 pushq 48(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_2: callq hipDeviceSynchronize movq %r14, %rdi callq malloc movq %rax, %r15 movq 16(%rsp), %rsi movq %rax, %rdi movq %r14, %rdx movl $2, %ecx callq hipMemcpy movq %rbx, %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree movq %r15, %rax 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 .Lfunc_end1: .size _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb, .Lfunc_end1-_Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb .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 $_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, %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 _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib,@object # @_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .section .rodata,"a",@progbits .globl _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .p2align 3, 0x0 _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib: .quad _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .size _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib" .size .L__unnamed_1, 43 .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__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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 : _Z6mirrorPK6uchar4PS_iib .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.X ; /* 0x0000000000007919 */ /* 0x000e280000002500 */ /*0020*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e280000002100 */ /*0030*/ S2R R5, SR_CTAID.Y ; /* 0x0000000000057919 */ /* 0x000e680000002600 */ /*0040*/ S2R R2, SR_TID.Y ; /* 0x0000000000027919 */ /* 0x000e620000002200 */ /*0050*/ IMAD R0, R0, c[0x0][0x0], R3 ; /* 0x0000000000007a24 */ /* 0x001fca00078e0203 */ /*0060*/ ISETP.GE.AND P0, PT, R0, c[0x0][0x174], PT ; /* 0x00005d0000007a0c */ /* 0x000fe20003f06270 */ /*0070*/ IMAD R5, R5, c[0x0][0x4], R2 ; /* 0x0000010005057a24 */ /* 0x002fca00078e0202 */ /*0080*/ ISETP.GE.OR P0, PT, R5, c[0x0][0x170], P0 ; /* 0x00005c0005007a0c */ /* 0x000fda0000706670 */ /*0090*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*00a0*/ ULDC.S8 UR4, c[0x0][0x178] ; /* 0x00005e0000047ab9 */ /* 0x000fe20000000200 */ /*00b0*/ HFMA2.MMA R4, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff047435 */ /* 0x000fe200000001ff */ /*00c0*/ ISETP.NE.AND P0, PT, RZ, UR4, PT ; /* 0x00000004ff007c0c */ /* 0x000fe2000bf05270 */ /*00d0*/ IMAD R2, R5, c[0x0][0x174], R0 ; /* 0x00005d0005027a24 */ /* 0x000fe200078e0200 */ /*00e0*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fce0000000a00 */ /*00f0*/ IMAD.WIDE R2, R2, R4, c[0x0][0x160] ; /* 0x0000580002027625 */ /* 0x000fc800078e0204 */ /*0100*/ @!P0 BRA 0x170 ; /* 0x0000006000008947 */ /* 0x000fea0003800000 */ /*0110*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*0120*/ IADD3 R0, -R0, c[0x0][0x174], RZ ; /* 0x00005d0000007a10 */ /* 0x000fca0007ffe1ff */ /*0130*/ IMAD R5, R5, c[0x0][0x174], R0 ; /* 0x00005d0005057a24 */ /* 0x000fc800078e0200 */ /*0140*/ IMAD.WIDE R4, R5, R4, c[0x0][0x168] ; /* 0x00005a0005047625 */ /* 0x000fca00078e0204 */ /*0150*/ STG.E [R4.64], R3 ; /* 0x0000000304007986 */ /* 0x004fe2000c101904 */ /*0160*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0170*/ LDG.E R3, [R2.64] ; /* 0x0000000402037981 */ /* 0x000ea2000c1e1900 */ /*0180*/ IADD3 R5, -R5, c[0x0][0x170], RZ ; /* 0x00005c0005057a10 */ /* 0x000fca0007ffe1ff */ /*0190*/ IMAD R5, R5, c[0x0][0x174], R0 ; /* 0x00005d0005057a24 */ /* 0x000fc800078e0200 */ /*01a0*/ IMAD.WIDE R4, R5, R4, c[0x0][0x168] ; /* 0x00005a0005047625 */ /* 0x000fca00078e0204 */ /*01b0*/ STG.E [R4.64], R3 ; /* 0x0000000304007986 */ /* 0x004fe2000c101904 */ /*01c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*01d0*/ BRA 0x1d0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0200*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0210*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0220*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0230*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0240*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0250*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0260*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0270*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .globl _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .p2align 8 .type _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib,@function _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib: s_clause 0x1 s_load_b32 s5, s[0:1], 0x2c s_load_b32 s4, s[0:1], 0x14 v_and_b32_e32 v3, 0x3ff, v0 s_add_u32 s2, s0, 32 s_addc_u32 s3, s1, 0 s_waitcnt lgkmcnt(0) s_and_b32 s5, s5, 0xffff s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_mad_u64_u32 v[1:2], null, s14, s5, v[3:4] s_mov_b32 s5, exec_lo v_cmpx_gt_i32_e64 s4, v1 s_cbranch_execz .LBB0_8 s_load_b32 s3, s[2:3], 0xc s_load_b32 s2, s[0:1], 0x10 v_bfe_u32 v0, v0, 10, 10 s_waitcnt lgkmcnt(0) s_lshr_b32 s3, s3, 16 s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1) v_mad_u64_u32 v[4:5], null, s15, s3, v[0:1] s_delay_alu instid0(VALU_DEP_1) v_cmp_gt_i32_e32 vcc_lo, s2, v4 s_and_b32 exec_lo, exec_lo, vcc_lo s_cbranch_execz .LBB0_8 s_load_b32 s3, s[0:1], 0x18 s_waitcnt lgkmcnt(0) s_bitcmp1_b32 s3, 0 s_cselect_b32 s3, -1, 0 s_delay_alu instid0(SALU_CYCLE_1) s_and_b32 vcc_lo, exec_lo, s3 s_cbranch_vccnz .LBB0_4 v_sub_nc_u32_e32 v0, s2, v4 s_mov_b32 s2, 0 s_delay_alu instid0(VALU_DEP_1) v_mad_u64_u32 v[2:3], null, v0, s4, v[1:2] s_branch .LBB0_5 .LBB0_4: s_mov_b32 s2, -1 .LBB0_5: v_mul_lo_u32 v0, v4, s4 s_and_not1_b32 vcc_lo, exec_lo, s2 s_cbranch_vccnz .LBB0_7 v_sub_nc_u32_e32 v2, s4, v1 s_delay_alu instid0(VALU_DEP_1) v_add_nc_u32_e32 v2, v2, v0 .LBB0_7: s_load_b128 s[0:3], s[0:1], 0x0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_nc_u32_e32 v0, v0, v1 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v1, 31, v0 v_lshlrev_b64 v[0:1], 2, v[0:1] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo global_load_b32 v4, v[0:1], off v_lshlrev_b64 v[0:1], 2, v[2:3] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s2, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo s_waitcnt vmcnt(0) global_store_b32 v[0:1], v4, off .LBB0_8: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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 _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, .Lfunc_end0-_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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: 1 .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: _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib.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_000d421e_00000000-6_mirror_ops.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 _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib .type _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib, @function _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib: .LFB2082: .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) movb %r8b, 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 12(%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 .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 _Z6mirrorPK6uchar4PS_iib(%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 _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib, .-_Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib .globl _Z6mirrorPK6uchar4PS_iib .type _Z6mirrorPK6uchar4PS_iib, @function _Z6mirrorPK6uchar4PS_iib: .LFB2083: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movzbl %r8b, %r8d call _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2083: .size _Z6mirrorPK6uchar4PS_iib, .-_Z6mirrorPK6uchar4PS_iib .globl _Z10mirror_opsP6uchar4mmb .type _Z10mirror_opsP6uchar4mmb, @function _Z10mirror_opsP6uchar4mmb: .LFB2057: .cfi_startproc endbr64 pushq %r14 .cfi_def_cfa_offset 16 .cfi_offset 14, -16 pushq %r13 .cfi_def_cfa_offset 24 .cfi_offset 13, -24 pushq %r12 .cfi_def_cfa_offset 32 .cfi_offset 12, -32 pushq %rbp .cfi_def_cfa_offset 40 .cfi_offset 6, -40 pushq %rbx .cfi_def_cfa_offset 48 .cfi_offset 3, -48 subq $48, %rsp .cfi_def_cfa_offset 96 movq %rdi, %r13 movq %rsi, %rbp movq %rdx, %r12 movl %ecx, %r14d movq %fs:40, %rax movq %rax, 40(%rsp) xorl %eax, %eax movl $1, 24(%rsp) movq %rdx, %rax shrq $2, %rax addl $1, %eax movl %eax, 28(%rsp) movq %rsi, %rax shrq $2, %rax addl $1, %eax movl %eax, 32(%rsp) movl $1, 36(%rsp) movq %rdx, %rbx imulq %rsi, %rbx salq $2, %rbx leaq 8(%rsp), %rdi movq %rbx, %rsi call cudaMalloc@PLT movl $4, 16(%rsp) movl $4, 20(%rsp) movl 24(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 16(%rsp), %rdx movq 28(%rsp), %rdi movl 36(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L15 .L12: call cudaDeviceSynchronize@PLT movq %rbx, %rdi call malloc@PLT movq %rax, %rbp movl $2, %ecx movq %rbx, %rdx movq 8(%rsp), %rsi movq %rax, %rdi call cudaMemcpy@PLT movq %r13, %rdi call cudaFree@PLT movq 8(%rsp), %rdi call cudaFree@PLT movq 40(%rsp), %rax subq %fs:40, %rax jne .L16 movq %rbp, %rax addq $48, %rsp .cfi_remember_state .cfi_def_cfa_offset 48 popq %rbx .cfi_def_cfa_offset 40 popq %rbp .cfi_def_cfa_offset 32 popq %r12 .cfi_def_cfa_offset 24 popq %r13 .cfi_def_cfa_offset 16 popq %r14 .cfi_def_cfa_offset 8 ret .L15: .cfi_restore_state movzbl %r14b, %r8d movl %r12d, %ecx movl %ebp, %edx movq 8(%rsp), %rsi movq %r13, %rdi call _Z38__device_stub__Z6mirrorPK6uchar4PS_iibPK6uchar4PS_iib jmp .L12 .L16: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size _Z10mirror_opsP6uchar4mmb, .-_Z10mirror_opsP6uchar4mmb .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z6mirrorPK6uchar4PS_iib" .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 .LC0(%rip), %rdx movq %rdx, %rcx leaq _Z6mirrorPK6uchar4PS_iib(%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 "mirror_ops.hip" .globl _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib # -- Begin function _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .p2align 4, 0x90 .type _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib,@function _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib: # @_Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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) movb %r8b, 7(%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 7(%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 $_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, %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__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, .Lfunc_end0-_Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .cfi_endproc # -- End function .globl _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb # -- Begin function _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb .p2align 4, 0x90 .type _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb,@function _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb: # @_Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb .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 %ecx, %ebp movq %rdx, %r15 movq %rsi, %r12 movq %rdi, %rbx movq %rdx, %rax shrq $2, %rax incl %eax movq %rsi, %rcx andq $-4, %rcx shlq $30, %rcx orq %rax, %rcx movabsq $4294967296, %r13 # imm = 0x100000000 addq %rcx, %r13 movq %rsi, %r14 imulq %rdx, %r14 shlq $2, %r14 leaq 16(%rsp), %rdi movq %r14, %rsi callq hipMalloc movabsq $17179869188, %rdx # imm = 0x400000004 movq %r13, %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_2 # %bb.1: movq 16(%rsp), %rax movq %rbx, 88(%rsp) movq %rax, 80(%rsp) movl %r12d, 28(%rsp) movl %r15d, 24(%rsp) movb %bpl, 15(%rsp) leaq 88(%rsp), %rax movq %rax, 96(%rsp) leaq 80(%rsp), %rax movq %rax, 104(%rsp) leaq 28(%rsp), %rax movq %rax, 112(%rsp) leaq 24(%rsp), %rax movq %rax, 120(%rsp) leaq 15(%rsp), %rax movq %rax, 128(%rsp) leaq 64(%rsp), %rdi leaq 48(%rsp), %rsi leaq 40(%rsp), %rdx leaq 32(%rsp), %rcx callq __hipPopCallConfiguration movq 64(%rsp), %rsi movl 72(%rsp), %edx movq 48(%rsp), %rcx movl 56(%rsp), %r8d leaq 96(%rsp), %r9 movl $_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, %edi pushq 32(%rsp) .cfi_adjust_cfa_offset 8 pushq 48(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_2: callq hipDeviceSynchronize movq %r14, %rdi callq malloc movq %rax, %r15 movq 16(%rsp), %rsi movq %rax, %rdi movq %r14, %rdx movl $2, %ecx callq hipMemcpy movq %rbx, %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree movq %r15, %rax 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 .Lfunc_end1: .size _Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb, .Lfunc_end1-_Z10mirror_opsP15HIP_vector_typeIhLj4EEmmb .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 $_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, %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 _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib,@object # @_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .section .rodata,"a",@progbits .globl _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .p2align 3, 0x0 _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib: .quad _Z21__device_stub__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .size _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib" .size .L__unnamed_1, 43 .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__mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6mirrorPK15HIP_vector_typeIhLj4EEPS0_iib .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 <math.h> #include <iostream> #include <cuda.h> float *a, *b; // host data float *c, *c2; // results __global__ void vecAdd(float *A,float *B,float *C,int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; // Limit thread execution more than its limit incase it will stop buffer overflow. if(i<N){ C[i] = A[i] + B[i]; } } void vecAdd_h(float *A1,float *B1, float *C1, float N) { for(int i=0;i<N;i++) C1[i] = A1[i] + B1[i]; } int main(int argc,char **argv) { printf("Begin \n"); int n=10000000; int nBytes = n*sizeof(float); int block_size, block_no; a = (float *)malloc(nBytes); b = (float *)malloc(nBytes); c = (float *)malloc(nBytes); c2 = (float *)malloc(nBytes); float *a_d,*b_d,*c_d; block_size=1000; block_no = n/block_size; dim3 threadPerBlock(block_size,1,1); dim3 dimBlock(block_no,1,1); for(int i = 0; i < n; i++ ) { a[i] = sin(i)*sin(i); b[i] = cos(i)*cos(i); } printf("Allocating device memory on host..\n"); cudaMalloc((void **)&a_d,nBytes); cudaMalloc((void **)&b_d,nBytes); cudaMalloc((void **)&c_d,nBytes); printf("Copying to device..\n"); cudaMemcpy(a_d,a,nBytes,cudaMemcpyHostToDevice); cudaMemcpy(b_d,b,nBytes,cudaMemcpyHostToDevice); clock_t start_d=clock(); printf("Doing GPU Vector add\n"); vecAdd<<<dimBlock,threadPerBlock>>>(a_d,b_d,c_d,n); cudaThreadSynchronize(); clock_t end_d = clock(); clock_t start_h = clock(); printf("Doing CPU Vector add\n"); vecAdd_h(a,b,c2,n); clock_t end_h = clock(); double time_d = (double)(end_d-start_d)/CLOCKS_PER_SEC; double time_h = (double)(end_h-start_h)/CLOCKS_PER_SEC; int cpy_C=cudaMemcpy(c,c_d,nBytes,cudaMemcpyDeviceToHost); printf("%d\n",cpy_C); printf("Number of elements: %d GPU Time: %f CPU Time: %f\n",n,time_d,time_h); for (int i=0; i<3;i++){ printf("%f\n", c[i]); } for (int i=0; i<3;i++){ printf("%f\n", c2[i]); } cudaFree(a_d); cudaFree(b_d); cudaFree(c_d); return 0; }
code for sm_80 Function : _Z6vecAddPfS_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_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 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 */ /* 0x000fc800078e0207 */ /*00d0*/ FADD R9, R4, R3 ; /* 0x0000000304097221 */ /* 0x004fca0000000000 */ /*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.
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <cuda.h> float *a, *b; // host data float *c, *c2; // results __global__ void vecAdd(float *A,float *B,float *C,int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; // Limit thread execution more than its limit incase it will stop buffer overflow. if(i<N){ C[i] = A[i] + B[i]; } } void vecAdd_h(float *A1,float *B1, float *C1, float N) { for(int i=0;i<N;i++) C1[i] = A1[i] + B1[i]; } int main(int argc,char **argv) { printf("Begin \n"); int n=10000000; int nBytes = n*sizeof(float); int block_size, block_no; a = (float *)malloc(nBytes); b = (float *)malloc(nBytes); c = (float *)malloc(nBytes); c2 = (float *)malloc(nBytes); float *a_d,*b_d,*c_d; block_size=1000; block_no = n/block_size; dim3 threadPerBlock(block_size,1,1); dim3 dimBlock(block_no,1,1); for(int i = 0; i < n; i++ ) { a[i] = sin(i)*sin(i); b[i] = cos(i)*cos(i); } printf("Allocating device memory on host..\n"); cudaMalloc((void **)&a_d,nBytes); cudaMalloc((void **)&b_d,nBytes); cudaMalloc((void **)&c_d,nBytes); printf("Copying to device..\n"); cudaMemcpy(a_d,a,nBytes,cudaMemcpyHostToDevice); cudaMemcpy(b_d,b,nBytes,cudaMemcpyHostToDevice); clock_t start_d=clock(); printf("Doing GPU Vector add\n"); vecAdd<<<dimBlock,threadPerBlock>>>(a_d,b_d,c_d,n); cudaThreadSynchronize(); clock_t end_d = clock(); clock_t start_h = clock(); printf("Doing CPU Vector add\n"); vecAdd_h(a,b,c2,n); clock_t end_h = clock(); double time_d = (double)(end_d-start_d)/CLOCKS_PER_SEC; double time_h = (double)(end_h-start_h)/CLOCKS_PER_SEC; int cpy_C=cudaMemcpy(c,c_d,nBytes,cudaMemcpyDeviceToHost); printf("%d\n",cpy_C); printf("Number of elements: %d GPU Time: %f CPU Time: %f\n",n,time_d,time_h); for (int i=0; i<3;i++){ printf("%f\n", c[i]); } for (int i=0; i<3;i++){ printf("%f\n", c2[i]); } cudaFree(a_d); cudaFree(b_d); cudaFree(c_d); return 0; }
.file "tmpxft_00155326_00000000-6_vecadd.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3673: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3673: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z8vecAdd_hPfS_S_f .type _Z8vecAdd_hPfS_S_f, @function _Z8vecAdd_hPfS_S_f: .LFB3669: .cfi_startproc endbr64 movl $1, %eax pxor %xmm1, %xmm1 comiss %xmm1, %xmm0 jbe .L3 .L6: movss -4(%rdi,%rax,4), %xmm1 addss -4(%rsi,%rax,4), %xmm1 movss %xmm1, -4(%rdx,%rax,4) pxor %xmm1, %xmm1 cvtsi2ssl %eax, %xmm1 addq $1, %rax comiss %xmm1, %xmm0 ja .L6 .L3: ret .cfi_endproc .LFE3669: .size _Z8vecAdd_hPfS_S_f, .-_Z8vecAdd_hPfS_S_f .globl _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i .type _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i, @function _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i: .LFB3695: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movl %ecx, 4(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 4(%rsp), %rax movq %rax, 120(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L14 .L10: movq 136(%rsp), %rax subq %fs:40, %rax jne .L15 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L14: .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 _Z6vecAddPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L10 .L15: call __stack_chk_fail@PLT .cfi_endproc .LFE3695: .size _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i, .-_Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i .globl _Z6vecAddPfS_S_i .type _Z6vecAddPfS_S_i, @function _Z6vecAddPfS_S_i: .LFB3696: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3696: .size _Z6vecAddPfS_S_i, .-_Z6vecAddPfS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "Begin \n" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC2: .string "Allocating device memory on host..\n" .section .rodata.str1.1 .LC3: .string "Copying to device..\n" .LC4: .string "Doing GPU Vector add\n" .LC5: .string "Doing CPU Vector add\n" .LC8: .string "%d\n" .section .rodata.str1.8 .align 8 .LC9: .string "Number of elements: %d GPU Time: %f CPU Time: %f\n" .section .rodata.str1.1 .LC10: .string "%f\n" .text .globl main .type main, @function main: .LFB3670: .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 $80, %rsp .cfi_def_cfa_offset 112 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq .LC1(%rip), %rsi movl $2, %edi call __printf_chk@PLT movl $40000000, %edi call malloc@PLT movq %rax, a(%rip) movl $40000000, %edi call malloc@PLT movq %rax, b(%rip) movl $40000000, %edi call malloc@PLT movq %rax, c(%rip) movl $40000000, %edi call malloc@PLT movq %rax, c2(%rip) movl $1000, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $10000, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $0, %ebx leaq 8(%rsp), %rbp .L19: movq %rsp, %rsi pxor %xmm0, %xmm0 cvtsi2sdl %ebx, %xmm0 movq %rbp, %rdi call sincos@PLT movsd (%rsp), %xmm0 movsd 8(%rsp), %xmm1 mulsd %xmm1, %xmm1 cvtsd2ss %xmm1, %xmm1 movq a(%rip), %rax movss %xmm1, (%rax,%rbx,4) mulsd %xmm0, %xmm0 cvtsd2ss %xmm0, %xmm0 movq b(%rip), %rax movss %xmm0, (%rax,%rbx,4) addq $1, %rbx cmpq $10000000, %rbx jne .L19 leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 24(%rsp), %rdi movl $40000000, %esi call cudaMalloc@PLT leaq 32(%rsp), %rdi movl $40000000, %esi call cudaMalloc@PLT leaq 40(%rsp), %rdi movl $40000000, %esi call cudaMalloc@PLT leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %ecx movl $40000000, %edx movq a(%rip), %rsi movq 24(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $40000000, %edx movq b(%rip), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT call clock@PLT movq %rax, %r12 leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@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 .L28 .L20: call cudaThreadSynchronize@PLT call clock@PLT movq %rax, %rbx call clock@PLT movq %rax, %rbp leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movss .LC6(%rip), %xmm0 movq c2(%rip), %rdx movq b(%rip), %rsi movq a(%rip), %rdi call _Z8vecAdd_hPfS_S_f call clock@PLT subq %r12, %rbx pxor %xmm1, %xmm1 cvtsi2sdq %rbx, %xmm1 movsd .LC7(%rip), %xmm0 divsd %xmm0, %xmm1 movq %xmm1, %rbx subq %rbp, %rax pxor %xmm1, %xmm1 cvtsi2sdq %rax, %xmm1 divsd %xmm0, %xmm1 movq %xmm1, %rbp movl $2, %ecx movl $40000000, %edx movq 40(%rsp), %rsi movq c(%rip), %rdi call cudaMemcpy@PLT movl %eax, %edx leaq .LC8(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq %rbp, %xmm1 movq %rbx, %xmm0 movl $10000000, %edx leaq .LC9(%rip), %rsi movl $2, %edi movl $2, %eax call __printf_chk@PLT movl $0, %ebx leaq .LC10(%rip), %rbp .L21: movq c(%rip), %rax pxor %xmm0, %xmm0 cvtss2sd (%rax,%rbx), %xmm0 movq %rbp, %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT addq $4, %rbx cmpq $12, %rbx jne .L21 movl $0, %ebx leaq .LC10(%rip), %rbp .L22: movq c2(%rip), %rax pxor %xmm0, %xmm0 cvtss2sd (%rax,%rbx), %xmm0 movq %rbp, %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT addq $4, %rbx cmpq $12, %rbx jne .L22 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 .L29 movl $0, %eax addq $80, %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 .L28: .cfi_restore_state movl $10000000, %ecx movq 40(%rsp), %rdx movq 32(%rsp), %rsi movq 24(%rsp), %rdi call _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i jmp .L20 .L29: call __stack_chk_fail@PLT .cfi_endproc .LFE3670: .size main, .-main .section .rodata.str1.1 .LC11: .string "_Z6vecAddPfS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3698: .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 _Z6vecAddPfS_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 .LFE3698: .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 c2 .bss .align 8 .type c2, @object .size c2, 8 c2: .zero 8 .globl c .align 8 .type c, @object .size c, 8 c: .zero 8 .globl b .align 8 .type b, @object .size b, 8 b: .zero 8 .globl a .align 8 .type a, @object .size a, 8 a: .zero 8 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC6: .long 1259902592 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC7: .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 <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <cuda.h> float *a, *b; // host data float *c, *c2; // results __global__ void vecAdd(float *A,float *B,float *C,int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; // Limit thread execution more than its limit incase it will stop buffer overflow. if(i<N){ C[i] = A[i] + B[i]; } } void vecAdd_h(float *A1,float *B1, float *C1, float N) { for(int i=0;i<N;i++) C1[i] = A1[i] + B1[i]; } int main(int argc,char **argv) { printf("Begin \n"); int n=10000000; int nBytes = n*sizeof(float); int block_size, block_no; a = (float *)malloc(nBytes); b = (float *)malloc(nBytes); c = (float *)malloc(nBytes); c2 = (float *)malloc(nBytes); float *a_d,*b_d,*c_d; block_size=1000; block_no = n/block_size; dim3 threadPerBlock(block_size,1,1); dim3 dimBlock(block_no,1,1); for(int i = 0; i < n; i++ ) { a[i] = sin(i)*sin(i); b[i] = cos(i)*cos(i); } printf("Allocating device memory on host..\n"); cudaMalloc((void **)&a_d,nBytes); cudaMalloc((void **)&b_d,nBytes); cudaMalloc((void **)&c_d,nBytes); printf("Copying to device..\n"); cudaMemcpy(a_d,a,nBytes,cudaMemcpyHostToDevice); cudaMemcpy(b_d,b,nBytes,cudaMemcpyHostToDevice); clock_t start_d=clock(); printf("Doing GPU Vector add\n"); vecAdd<<<dimBlock,threadPerBlock>>>(a_d,b_d,c_d,n); cudaThreadSynchronize(); clock_t end_d = clock(); clock_t start_h = clock(); printf("Doing CPU Vector add\n"); vecAdd_h(a,b,c2,n); clock_t end_h = clock(); double time_d = (double)(end_d-start_d)/CLOCKS_PER_SEC; double time_h = (double)(end_h-start_h)/CLOCKS_PER_SEC; int cpy_C=cudaMemcpy(c,c_d,nBytes,cudaMemcpyDeviceToHost); printf("%d\n",cpy_C); printf("Number of elements: %d GPU Time: %f CPU Time: %f\n",n,time_d,time_h); for (int i=0; i<3;i++){ printf("%f\n", c[i]); } for (int i=0; i<3;i++){ printf("%f\n", c2[i]); } cudaFree(a_d); cudaFree(b_d); cudaFree(c_d); return 0; }
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <hip/hip_runtime.h> float *a, *b; // host data float *c, *c2; // results __global__ void vecAdd(float *A,float *B,float *C,int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; // Limit thread execution more than its limit incase it will stop buffer overflow. if(i<N){ C[i] = A[i] + B[i]; } } void vecAdd_h(float *A1,float *B1, float *C1, float N) { for(int i=0;i<N;i++) C1[i] = A1[i] + B1[i]; } int main(int argc,char **argv) { printf("Begin \n"); int n=10000000; int nBytes = n*sizeof(float); int block_size, block_no; a = (float *)malloc(nBytes); b = (float *)malloc(nBytes); c = (float *)malloc(nBytes); c2 = (float *)malloc(nBytes); float *a_d,*b_d,*c_d; block_size=1000; block_no = n/block_size; dim3 threadPerBlock(block_size,1,1); dim3 dimBlock(block_no,1,1); for(int i = 0; i < n; i++ ) { a[i] = sin(i)*sin(i); b[i] = cos(i)*cos(i); } printf("Allocating device memory on host..\n"); hipMalloc((void **)&a_d,nBytes); hipMalloc((void **)&b_d,nBytes); hipMalloc((void **)&c_d,nBytes); printf("Copying to device..\n"); hipMemcpy(a_d,a,nBytes,hipMemcpyHostToDevice); hipMemcpy(b_d,b,nBytes,hipMemcpyHostToDevice); clock_t start_d=clock(); printf("Doing GPU Vector add\n"); vecAdd<<<dimBlock,threadPerBlock>>>(a_d,b_d,c_d,n); hipDeviceSynchronize(); clock_t end_d = clock(); clock_t start_h = clock(); printf("Doing CPU Vector add\n"); vecAdd_h(a,b,c2,n); clock_t end_h = clock(); double time_d = (double)(end_d-start_d)/CLOCKS_PER_SEC; double time_h = (double)(end_h-start_h)/CLOCKS_PER_SEC; int cpy_C=hipMemcpy(c,c_d,nBytes,hipMemcpyDeviceToHost); printf("%d\n",cpy_C); printf("Number of elements: %d GPU Time: %f CPU Time: %f\n",n,time_d,time_h); for (int i=0; i<3;i++){ printf("%f\n", c[i]); } for (int i=0; i<3;i++){ printf("%f\n", c2[i]); } hipFree(a_d); hipFree(b_d); hipFree(c_d); 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 <math.h> #include <iostream> #include <hip/hip_runtime.h> float *a, *b; // host data float *c, *c2; // results __global__ void vecAdd(float *A,float *B,float *C,int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; // Limit thread execution more than its limit incase it will stop buffer overflow. if(i<N){ C[i] = A[i] + B[i]; } } void vecAdd_h(float *A1,float *B1, float *C1, float N) { for(int i=0;i<N;i++) C1[i] = A1[i] + B1[i]; } int main(int argc,char **argv) { printf("Begin \n"); int n=10000000; int nBytes = n*sizeof(float); int block_size, block_no; a = (float *)malloc(nBytes); b = (float *)malloc(nBytes); c = (float *)malloc(nBytes); c2 = (float *)malloc(nBytes); float *a_d,*b_d,*c_d; block_size=1000; block_no = n/block_size; dim3 threadPerBlock(block_size,1,1); dim3 dimBlock(block_no,1,1); for(int i = 0; i < n; i++ ) { a[i] = sin(i)*sin(i); b[i] = cos(i)*cos(i); } printf("Allocating device memory on host..\n"); hipMalloc((void **)&a_d,nBytes); hipMalloc((void **)&b_d,nBytes); hipMalloc((void **)&c_d,nBytes); printf("Copying to device..\n"); hipMemcpy(a_d,a,nBytes,hipMemcpyHostToDevice); hipMemcpy(b_d,b,nBytes,hipMemcpyHostToDevice); clock_t start_d=clock(); printf("Doing GPU Vector add\n"); vecAdd<<<dimBlock,threadPerBlock>>>(a_d,b_d,c_d,n); hipDeviceSynchronize(); clock_t end_d = clock(); clock_t start_h = clock(); printf("Doing CPU Vector add\n"); vecAdd_h(a,b,c2,n); clock_t end_h = clock(); double time_d = (double)(end_d-start_d)/CLOCKS_PER_SEC; double time_h = (double)(end_h-start_h)/CLOCKS_PER_SEC; int cpy_C=hipMemcpy(c,c_d,nBytes,hipMemcpyDeviceToHost); printf("%d\n",cpy_C); printf("Number of elements: %d GPU Time: %f CPU Time: %f\n",n,time_d,time_h); for (int i=0; i<3;i++){ printf("%f\n", c[i]); } for (int i=0; i<3;i++){ printf("%f\n", c2[i]); } hipFree(a_d); hipFree(b_d); hipFree(c_d); return 0; }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z6vecAddPfS_S_i .globl _Z6vecAddPfS_S_i .p2align 8 .type _Z6vecAddPfS_S_i,@function _Z6vecAddPfS_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_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 _Z6vecAddPfS_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 _Z6vecAddPfS_S_i, .Lfunc_end0-_Z6vecAddPfS_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: _Z6vecAddPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6vecAddPfS_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.
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <hip/hip_runtime.h> float *a, *b; // host data float *c, *c2; // results __global__ void vecAdd(float *A,float *B,float *C,int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; // Limit thread execution more than its limit incase it will stop buffer overflow. if(i<N){ C[i] = A[i] + B[i]; } } void vecAdd_h(float *A1,float *B1, float *C1, float N) { for(int i=0;i<N;i++) C1[i] = A1[i] + B1[i]; } int main(int argc,char **argv) { printf("Begin \n"); int n=10000000; int nBytes = n*sizeof(float); int block_size, block_no; a = (float *)malloc(nBytes); b = (float *)malloc(nBytes); c = (float *)malloc(nBytes); c2 = (float *)malloc(nBytes); float *a_d,*b_d,*c_d; block_size=1000; block_no = n/block_size; dim3 threadPerBlock(block_size,1,1); dim3 dimBlock(block_no,1,1); for(int i = 0; i < n; i++ ) { a[i] = sin(i)*sin(i); b[i] = cos(i)*cos(i); } printf("Allocating device memory on host..\n"); hipMalloc((void **)&a_d,nBytes); hipMalloc((void **)&b_d,nBytes); hipMalloc((void **)&c_d,nBytes); printf("Copying to device..\n"); hipMemcpy(a_d,a,nBytes,hipMemcpyHostToDevice); hipMemcpy(b_d,b,nBytes,hipMemcpyHostToDevice); clock_t start_d=clock(); printf("Doing GPU Vector add\n"); vecAdd<<<dimBlock,threadPerBlock>>>(a_d,b_d,c_d,n); hipDeviceSynchronize(); clock_t end_d = clock(); clock_t start_h = clock(); printf("Doing CPU Vector add\n"); vecAdd_h(a,b,c2,n); clock_t end_h = clock(); double time_d = (double)(end_d-start_d)/CLOCKS_PER_SEC; double time_h = (double)(end_h-start_h)/CLOCKS_PER_SEC; int cpy_C=hipMemcpy(c,c_d,nBytes,hipMemcpyDeviceToHost); printf("%d\n",cpy_C); printf("Number of elements: %d GPU Time: %f CPU Time: %f\n",n,time_d,time_h); for (int i=0; i<3;i++){ printf("%f\n", c[i]); } for (int i=0; i<3;i++){ printf("%f\n", c2[i]); } hipFree(a_d); hipFree(b_d); hipFree(c_d); return 0; }
.text .file "vecadd.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z21__device_stub__vecAddPfS_S_i # -- Begin function _Z21__device_stub__vecAddPfS_S_i .p2align 4, 0x90 .type _Z21__device_stub__vecAddPfS_S_i,@function _Z21__device_stub__vecAddPfS_S_i: # @_Z21__device_stub__vecAddPfS_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 $_Z6vecAddPfS_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 _Z21__device_stub__vecAddPfS_S_i, .Lfunc_end0-_Z21__device_stub__vecAddPfS_S_i .cfi_endproc # -- End function .globl _Z8vecAdd_hPfS_S_f # -- Begin function _Z8vecAdd_hPfS_S_f .p2align 4, 0x90 .type _Z8vecAdd_hPfS_S_f,@function _Z8vecAdd_hPfS_S_f: # @_Z8vecAdd_hPfS_S_f .cfi_startproc # %bb.0: xorps %xmm1, %xmm1 ucomiss %xmm1, %xmm0 jbe .LBB1_3 # %bb.1: # %.lr.ph.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 movss (%rdi,%rax,4), %xmm1 # xmm1 = mem[0],zero,zero,zero addss (%rsi,%rax,4), %xmm1 movss %xmm1, (%rdx,%rax,4) incq %rax xorps %xmm1, %xmm1 cvtsi2ss %eax, %xmm1 ucomiss %xmm1, %xmm0 ja .LBB1_2 .LBB1_3: # %._crit_edge retq .Lfunc_end1: .size _Z8vecAdd_hPfS_S_f, .Lfunc_end1-_Z8vecAdd_hPfS_S_f .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI2_0: .quad 0x412e848000000000 # double 1.0E+6 .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 %rbx .cfi_def_cfa_offset 32 subq $160, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $.Lstr, %edi callq puts@PLT movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, a(%rip) movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, b(%rip) movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, c(%rip) movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, c2(%rip) xorl %ebx, %ebx .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 xorps %xmm0, %xmm0 cvtsi2sd %ebx, %xmm0 movsd %xmm0, 16(%rsp) # 8-byte Spill callq sin movsd %xmm0, 8(%rsp) # 8-byte Spill movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero callq sin mulsd 8(%rsp), %xmm0 # 8-byte Folded Reload cvtsd2ss %xmm0, %xmm0 movq a(%rip), %rax movss %xmm0, (%rax,%rbx,4) movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero callq cos movsd %xmm0, 8(%rsp) # 8-byte Spill movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero callq cos mulsd 8(%rsp), %xmm0 # 8-byte Folded Reload cvtsd2ss %xmm0, %xmm0 movq b(%rip), %rax movss %xmm0, (%rax,%rbx,4) incq %rbx cmpq $10000000, %rbx # imm = 0x989680 jne .LBB2_1 # %bb.2: movl $.Lstr.1, %edi callq puts@PLT leaq 40(%rsp), %rdi movl $40000000, %esi # imm = 0x2625A00 callq hipMalloc leaq 32(%rsp), %rdi movl $40000000, %esi # imm = 0x2625A00 callq hipMalloc leaq 24(%rsp), %rdi movl $40000000, %esi # imm = 0x2625A00 callq hipMalloc movl $.Lstr.2, %edi callq puts@PLT movq 40(%rsp), %rdi movq a(%rip), %rsi movl $40000000, %edx # imm = 0x2625A00 movl $1, %ecx callq hipMemcpy movq 32(%rsp), %rdi movq b(%rip), %rsi movl $40000000, %edx # imm = 0x2625A00 movl $1, %ecx callq hipMemcpy callq clock movq %rax, %rbx movl $.Lstr.3, %edi callq puts@PLT movabsq $4294968296, %rdx # imm = 0x1000003E8 leaq 9000(%rdx), %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_4 # %bb.3: movq 40(%rsp), %rax movq 32(%rsp), %rcx movq 24(%rsp), %rdx movq %rax, 120(%rsp) movq %rcx, 112(%rsp) movq %rdx, 104(%rsp) movl $10000000, 52(%rsp) # imm = 0x989680 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 52(%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 $_Z6vecAddPfS_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_4: callq hipDeviceSynchronize callq clock movq %rax, %r15 callq clock movq %rax, %r14 movl $.Lstr.4, %edi callq puts@PLT movq a(%rip), %rax movq b(%rip), %rcx xorl %edx, %edx movq c2(%rip), %rsi .p2align 4, 0x90 .LBB2_5: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 movss (%rax,%rdx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rcx,%rdx,4), %xmm0 movss %xmm0, (%rsi,%rdx,4) incq %rdx cmpq $10000000, %rdx # imm = 0x989680 jne .LBB2_5 # %bb.6: # %_Z8vecAdd_hPfS_S_f.exit callq clock subq %rbx, %r15 cvtsi2sd %r15, %xmm1 movsd .LCPI2_0(%rip), %xmm0 # xmm0 = mem[0],zero subq %r14, %rax cvtsi2sd %rax, %xmm2 divsd %xmm0, %xmm1 movsd %xmm1, 16(%rsp) # 8-byte Spill divsd %xmm0, %xmm2 movsd %xmm2, 8(%rsp) # 8-byte Spill movq c(%rip), %rdi movq 24(%rsp), %rsi movl $40000000, %edx # imm = 0x2625A00 movl $2, %ecx callq hipMemcpy xorl %ebx, %ebx movl $.L.str.5, %edi movl %eax, %esi xorl %eax, %eax callq printf movl $.L.str.6, %edi movl $10000000, %esi # imm = 0x989680 movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero movsd 8(%rsp), %xmm1 # 8-byte Reload # xmm1 = mem[0],zero movb $2, %al callq printf .p2align 4, 0x90 .LBB2_7: # =>This Inner Loop Header: Depth=1 movq c(%rip), %rax movss (%rax,%rbx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.7, %edi movb $1, %al callq printf incq %rbx cmpq $3, %rbx jne .LBB2_7 # %bb.8: # %.preheader.preheader xorl %ebx, %ebx .p2align 4, 0x90 .LBB2_9: # %.preheader # =>This Inner Loop Header: Depth=1 movq c2(%rip), %rax movss (%rax,%rbx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.7, %edi movb $1, %al callq printf incq %rbx cmpq $3, %rbx jne .LBB2_9 # %bb.10: movq 40(%rsp), %rdi callq hipFree movq 32(%rsp), %rdi callq hipFree movq 24(%rsp), %rdi callq hipFree xorl %eax, %eax addq $160, %rsp .cfi_def_cfa_offset 32 popq %rbx .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 $_Z6vecAddPfS_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 a,@object # @a .bss .globl a .p2align 3, 0x0 a: .quad 0 .size a, 8 .type b,@object # @b .globl b .p2align 3, 0x0 b: .quad 0 .size b, 8 .type c,@object # @c .globl c .p2align 3, 0x0 c: .quad 0 .size c, 8 .type c2,@object # @c2 .globl c2 .p2align 3, 0x0 c2: .quad 0 .size c2, 8 .type _Z6vecAddPfS_S_i,@object # @_Z6vecAddPfS_S_i .section .rodata,"a",@progbits .globl _Z6vecAddPfS_S_i .p2align 3, 0x0 _Z6vecAddPfS_S_i: .quad _Z21__device_stub__vecAddPfS_S_i .size _Z6vecAddPfS_S_i, 8 .type .L.str.5,@object # @.str.5 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.5: .asciz "%d\n" .size .L.str.5, 4 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "Number of elements: %d GPU Time: %f CPU Time: %f\n" .size .L.str.6, 50 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "%f\n" .size .L.str.7, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6vecAddPfS_S_i" .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 "Begin " .size .Lstr, 7 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Allocating device memory on host.." .size .Lstr.1, 35 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "Copying to device.." .size .Lstr.2, 20 .type .Lstr.3,@object # @str.3 .Lstr.3: .asciz "Doing GPU Vector add" .size .Lstr.3, 21 .type .Lstr.4,@object # @str.4 .Lstr.4: .asciz "Doing CPU Vector add" .size .Lstr.4, 21 .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_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6vecAddPfS_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 : _Z6vecAddPfS_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_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 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 */ /* 0x000fc800078e0207 */ /*00d0*/ FADD R9, R4, R3 ; /* 0x0000000304097221 */ /* 0x004fca0000000000 */ /*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 _Z6vecAddPfS_S_i .globl _Z6vecAddPfS_S_i .p2align 8 .type _Z6vecAddPfS_S_i,@function _Z6vecAddPfS_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_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 _Z6vecAddPfS_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 _Z6vecAddPfS_S_i, .Lfunc_end0-_Z6vecAddPfS_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: _Z6vecAddPfS_S_i .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z6vecAddPfS_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_00155326_00000000-6_vecadd.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3673: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3673: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z8vecAdd_hPfS_S_f .type _Z8vecAdd_hPfS_S_f, @function _Z8vecAdd_hPfS_S_f: .LFB3669: .cfi_startproc endbr64 movl $1, %eax pxor %xmm1, %xmm1 comiss %xmm1, %xmm0 jbe .L3 .L6: movss -4(%rdi,%rax,4), %xmm1 addss -4(%rsi,%rax,4), %xmm1 movss %xmm1, -4(%rdx,%rax,4) pxor %xmm1, %xmm1 cvtsi2ssl %eax, %xmm1 addq $1, %rax comiss %xmm1, %xmm0 ja .L6 .L3: ret .cfi_endproc .LFE3669: .size _Z8vecAdd_hPfS_S_f, .-_Z8vecAdd_hPfS_S_f .globl _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i .type _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i, @function _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i: .LFB3695: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%rsp) movq %rdx, 8(%rsp) movl %ecx, 4(%rsp) movq %fs:40, %rax movq %rax, 136(%rsp) xorl %eax, %eax leaq 24(%rsp), %rax movq %rax, 96(%rsp) leaq 16(%rsp), %rax movq %rax, 104(%rsp) leaq 8(%rsp), %rax movq %rax, 112(%rsp) leaq 4(%rsp), %rax movq %rax, 120(%rsp) movl $1, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $1, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) leaq 40(%rsp), %rcx leaq 32(%rsp), %rdx leaq 60(%rsp), %rsi leaq 48(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L14 .L10: movq 136(%rsp), %rax subq %fs:40, %rax jne .L15 addq $152, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L14: .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 _Z6vecAddPfS_S_i(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 160 jmp .L10 .L15: call __stack_chk_fail@PLT .cfi_endproc .LFE3695: .size _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i, .-_Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i .globl _Z6vecAddPfS_S_i .type _Z6vecAddPfS_S_i, @function _Z6vecAddPfS_S_i: .LFB3696: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3696: .size _Z6vecAddPfS_S_i, .-_Z6vecAddPfS_S_i .section .rodata.str1.1,"aMS",@progbits,1 .LC1: .string "Begin \n" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC2: .string "Allocating device memory on host..\n" .section .rodata.str1.1 .LC3: .string "Copying to device..\n" .LC4: .string "Doing GPU Vector add\n" .LC5: .string "Doing CPU Vector add\n" .LC8: .string "%d\n" .section .rodata.str1.8 .align 8 .LC9: .string "Number of elements: %d GPU Time: %f CPU Time: %f\n" .section .rodata.str1.1 .LC10: .string "%f\n" .text .globl main .type main, @function main: .LFB3670: .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 $80, %rsp .cfi_def_cfa_offset 112 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq .LC1(%rip), %rsi movl $2, %edi call __printf_chk@PLT movl $40000000, %edi call malloc@PLT movq %rax, a(%rip) movl $40000000, %edi call malloc@PLT movq %rax, b(%rip) movl $40000000, %edi call malloc@PLT movq %rax, c(%rip) movl $40000000, %edi call malloc@PLT movq %rax, c2(%rip) movl $1000, 48(%rsp) movl $1, 52(%rsp) movl $1, 56(%rsp) movl $10000, 60(%rsp) movl $1, 64(%rsp) movl $1, 68(%rsp) movl $0, %ebx leaq 8(%rsp), %rbp .L19: movq %rsp, %rsi pxor %xmm0, %xmm0 cvtsi2sdl %ebx, %xmm0 movq %rbp, %rdi call sincos@PLT movsd (%rsp), %xmm0 movsd 8(%rsp), %xmm1 mulsd %xmm1, %xmm1 cvtsd2ss %xmm1, %xmm1 movq a(%rip), %rax movss %xmm1, (%rax,%rbx,4) mulsd %xmm0, %xmm0 cvtsd2ss %xmm0, %xmm0 movq b(%rip), %rax movss %xmm0, (%rax,%rbx,4) addq $1, %rbx cmpq $10000000, %rbx jne .L19 leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 24(%rsp), %rdi movl $40000000, %esi call cudaMalloc@PLT leaq 32(%rsp), %rdi movl $40000000, %esi call cudaMalloc@PLT leaq 40(%rsp), %rdi movl $40000000, %esi call cudaMalloc@PLT leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movl $1, %ecx movl $40000000, %edx movq a(%rip), %rsi movq 24(%rsp), %rdi call cudaMemcpy@PLT movl $1, %ecx movl $40000000, %edx movq b(%rip), %rsi movq 32(%rsp), %rdi call cudaMemcpy@PLT call clock@PLT movq %rax, %r12 leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@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 .L28 .L20: call cudaThreadSynchronize@PLT call clock@PLT movq %rax, %rbx call clock@PLT movq %rax, %rbp leaq .LC5(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movss .LC6(%rip), %xmm0 movq c2(%rip), %rdx movq b(%rip), %rsi movq a(%rip), %rdi call _Z8vecAdd_hPfS_S_f call clock@PLT subq %r12, %rbx pxor %xmm1, %xmm1 cvtsi2sdq %rbx, %xmm1 movsd .LC7(%rip), %xmm0 divsd %xmm0, %xmm1 movq %xmm1, %rbx subq %rbp, %rax pxor %xmm1, %xmm1 cvtsi2sdq %rax, %xmm1 divsd %xmm0, %xmm1 movq %xmm1, %rbp movl $2, %ecx movl $40000000, %edx movq 40(%rsp), %rsi movq c(%rip), %rdi call cudaMemcpy@PLT movl %eax, %edx leaq .LC8(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT movq %rbp, %xmm1 movq %rbx, %xmm0 movl $10000000, %edx leaq .LC9(%rip), %rsi movl $2, %edi movl $2, %eax call __printf_chk@PLT movl $0, %ebx leaq .LC10(%rip), %rbp .L21: movq c(%rip), %rax pxor %xmm0, %xmm0 cvtss2sd (%rax,%rbx), %xmm0 movq %rbp, %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT addq $4, %rbx cmpq $12, %rbx jne .L21 movl $0, %ebx leaq .LC10(%rip), %rbp .L22: movq c2(%rip), %rax pxor %xmm0, %xmm0 cvtss2sd (%rax,%rbx), %xmm0 movq %rbp, %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT addq $4, %rbx cmpq $12, %rbx jne .L22 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 .L29 movl $0, %eax addq $80, %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 .L28: .cfi_restore_state movl $10000000, %ecx movq 40(%rsp), %rdx movq 32(%rsp), %rsi movq 24(%rsp), %rdi call _Z30__device_stub__Z6vecAddPfS_S_iPfS_S_i jmp .L20 .L29: call __stack_chk_fail@PLT .cfi_endproc .LFE3670: .size main, .-main .section .rodata.str1.1 .LC11: .string "_Z6vecAddPfS_S_i" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3698: .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 _Z6vecAddPfS_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 .LFE3698: .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 c2 .bss .align 8 .type c2, @object .size c2, 8 c2: .zero 8 .globl c .align 8 .type c, @object .size c, 8 c: .zero 8 .globl b .align 8 .type b, @object .size b, 8 b: .zero 8 .globl a .align 8 .type a, @object .size a, 8 a: .zero 8 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC6: .long 1259902592 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC7: .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 "vecadd.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z21__device_stub__vecAddPfS_S_i # -- Begin function _Z21__device_stub__vecAddPfS_S_i .p2align 4, 0x90 .type _Z21__device_stub__vecAddPfS_S_i,@function _Z21__device_stub__vecAddPfS_S_i: # @_Z21__device_stub__vecAddPfS_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 $_Z6vecAddPfS_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 _Z21__device_stub__vecAddPfS_S_i, .Lfunc_end0-_Z21__device_stub__vecAddPfS_S_i .cfi_endproc # -- End function .globl _Z8vecAdd_hPfS_S_f # -- Begin function _Z8vecAdd_hPfS_S_f .p2align 4, 0x90 .type _Z8vecAdd_hPfS_S_f,@function _Z8vecAdd_hPfS_S_f: # @_Z8vecAdd_hPfS_S_f .cfi_startproc # %bb.0: xorps %xmm1, %xmm1 ucomiss %xmm1, %xmm0 jbe .LBB1_3 # %bb.1: # %.lr.ph.preheader xorl %eax, %eax .p2align 4, 0x90 .LBB1_2: # %.lr.ph # =>This Inner Loop Header: Depth=1 movss (%rdi,%rax,4), %xmm1 # xmm1 = mem[0],zero,zero,zero addss (%rsi,%rax,4), %xmm1 movss %xmm1, (%rdx,%rax,4) incq %rax xorps %xmm1, %xmm1 cvtsi2ss %eax, %xmm1 ucomiss %xmm1, %xmm0 ja .LBB1_2 .LBB1_3: # %._crit_edge retq .Lfunc_end1: .size _Z8vecAdd_hPfS_S_f, .Lfunc_end1-_Z8vecAdd_hPfS_S_f .cfi_endproc # -- End function .section .rodata.cst8,"aM",@progbits,8 .p2align 3, 0x0 # -- Begin function main .LCPI2_0: .quad 0x412e848000000000 # double 1.0E+6 .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 %rbx .cfi_def_cfa_offset 32 subq $160, %rsp .cfi_def_cfa_offset 192 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 movl $.Lstr, %edi callq puts@PLT movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, a(%rip) movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, b(%rip) movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, c(%rip) movl $40000000, %edi # imm = 0x2625A00 callq malloc movq %rax, c2(%rip) xorl %ebx, %ebx .p2align 4, 0x90 .LBB2_1: # =>This Inner Loop Header: Depth=1 xorps %xmm0, %xmm0 cvtsi2sd %ebx, %xmm0 movsd %xmm0, 16(%rsp) # 8-byte Spill callq sin movsd %xmm0, 8(%rsp) # 8-byte Spill movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero callq sin mulsd 8(%rsp), %xmm0 # 8-byte Folded Reload cvtsd2ss %xmm0, %xmm0 movq a(%rip), %rax movss %xmm0, (%rax,%rbx,4) movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero callq cos movsd %xmm0, 8(%rsp) # 8-byte Spill movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero callq cos mulsd 8(%rsp), %xmm0 # 8-byte Folded Reload cvtsd2ss %xmm0, %xmm0 movq b(%rip), %rax movss %xmm0, (%rax,%rbx,4) incq %rbx cmpq $10000000, %rbx # imm = 0x989680 jne .LBB2_1 # %bb.2: movl $.Lstr.1, %edi callq puts@PLT leaq 40(%rsp), %rdi movl $40000000, %esi # imm = 0x2625A00 callq hipMalloc leaq 32(%rsp), %rdi movl $40000000, %esi # imm = 0x2625A00 callq hipMalloc leaq 24(%rsp), %rdi movl $40000000, %esi # imm = 0x2625A00 callq hipMalloc movl $.Lstr.2, %edi callq puts@PLT movq 40(%rsp), %rdi movq a(%rip), %rsi movl $40000000, %edx # imm = 0x2625A00 movl $1, %ecx callq hipMemcpy movq 32(%rsp), %rdi movq b(%rip), %rsi movl $40000000, %edx # imm = 0x2625A00 movl $1, %ecx callq hipMemcpy callq clock movq %rax, %rbx movl $.Lstr.3, %edi callq puts@PLT movabsq $4294968296, %rdx # imm = 0x1000003E8 leaq 9000(%rdx), %rdi movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB2_4 # %bb.3: movq 40(%rsp), %rax movq 32(%rsp), %rcx movq 24(%rsp), %rdx movq %rax, 120(%rsp) movq %rcx, 112(%rsp) movq %rdx, 104(%rsp) movl $10000000, 52(%rsp) # imm = 0x989680 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 52(%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 $_Z6vecAddPfS_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_4: callq hipDeviceSynchronize callq clock movq %rax, %r15 callq clock movq %rax, %r14 movl $.Lstr.4, %edi callq puts@PLT movq a(%rip), %rax movq b(%rip), %rcx xorl %edx, %edx movq c2(%rip), %rsi .p2align 4, 0x90 .LBB2_5: # %.lr.ph.i # =>This Inner Loop Header: Depth=1 movss (%rax,%rdx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero addss (%rcx,%rdx,4), %xmm0 movss %xmm0, (%rsi,%rdx,4) incq %rdx cmpq $10000000, %rdx # imm = 0x989680 jne .LBB2_5 # %bb.6: # %_Z8vecAdd_hPfS_S_f.exit callq clock subq %rbx, %r15 cvtsi2sd %r15, %xmm1 movsd .LCPI2_0(%rip), %xmm0 # xmm0 = mem[0],zero subq %r14, %rax cvtsi2sd %rax, %xmm2 divsd %xmm0, %xmm1 movsd %xmm1, 16(%rsp) # 8-byte Spill divsd %xmm0, %xmm2 movsd %xmm2, 8(%rsp) # 8-byte Spill movq c(%rip), %rdi movq 24(%rsp), %rsi movl $40000000, %edx # imm = 0x2625A00 movl $2, %ecx callq hipMemcpy xorl %ebx, %ebx movl $.L.str.5, %edi movl %eax, %esi xorl %eax, %eax callq printf movl $.L.str.6, %edi movl $10000000, %esi # imm = 0x989680 movsd 16(%rsp), %xmm0 # 8-byte Reload # xmm0 = mem[0],zero movsd 8(%rsp), %xmm1 # 8-byte Reload # xmm1 = mem[0],zero movb $2, %al callq printf .p2align 4, 0x90 .LBB2_7: # =>This Inner Loop Header: Depth=1 movq c(%rip), %rax movss (%rax,%rbx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.7, %edi movb $1, %al callq printf incq %rbx cmpq $3, %rbx jne .LBB2_7 # %bb.8: # %.preheader.preheader xorl %ebx, %ebx .p2align 4, 0x90 .LBB2_9: # %.preheader # =>This Inner Loop Header: Depth=1 movq c2(%rip), %rax movss (%rax,%rbx,4), %xmm0 # xmm0 = mem[0],zero,zero,zero cvtss2sd %xmm0, %xmm0 movl $.L.str.7, %edi movb $1, %al callq printf incq %rbx cmpq $3, %rbx jne .LBB2_9 # %bb.10: movq 40(%rsp), %rdi callq hipFree movq 32(%rsp), %rdi callq hipFree movq 24(%rsp), %rdi callq hipFree xorl %eax, %eax addq $160, %rsp .cfi_def_cfa_offset 32 popq %rbx .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 $_Z6vecAddPfS_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 a,@object # @a .bss .globl a .p2align 3, 0x0 a: .quad 0 .size a, 8 .type b,@object # @b .globl b .p2align 3, 0x0 b: .quad 0 .size b, 8 .type c,@object # @c .globl c .p2align 3, 0x0 c: .quad 0 .size c, 8 .type c2,@object # @c2 .globl c2 .p2align 3, 0x0 c2: .quad 0 .size c2, 8 .type _Z6vecAddPfS_S_i,@object # @_Z6vecAddPfS_S_i .section .rodata,"a",@progbits .globl _Z6vecAddPfS_S_i .p2align 3, 0x0 _Z6vecAddPfS_S_i: .quad _Z21__device_stub__vecAddPfS_S_i .size _Z6vecAddPfS_S_i, 8 .type .L.str.5,@object # @.str.5 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.5: .asciz "%d\n" .size .L.str.5, 4 .type .L.str.6,@object # @.str.6 .L.str.6: .asciz "Number of elements: %d GPU Time: %f CPU Time: %f\n" .size .L.str.6, 50 .type .L.str.7,@object # @.str.7 .L.str.7: .asciz "%f\n" .size .L.str.7, 4 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z6vecAddPfS_S_i" .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 "Begin " .size .Lstr, 7 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "Allocating device memory on host.." .size .Lstr.1, 35 .type .Lstr.2,@object # @str.2 .Lstr.2: .asciz "Copying to device.." .size .Lstr.2, 20 .type .Lstr.3,@object # @str.3 .Lstr.3: .asciz "Doing GPU Vector add" .size .Lstr.3, 21 .type .Lstr.4,@object # @str.4 .Lstr.4: .asciz "Doing CPU Vector add" .size .Lstr.4, 21 .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_i .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z6vecAddPfS_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 <iostream> #include <stdio.h> #include <cuda_runtime.h> #define MIN(a, b) (a<b?a:b) #define BLOCK_SIZE 32 struct Matrix { int height; int width; int *el; int stride; __host__ __device__ Matrix(int height, int width, int stride ): height(height), width(width),stride(stride){} __host__ __device__ Matrix(const Matrix &a): height(a.height), width(a.width),el(a.el),stride(a.stride){} __device__ float getElement(int row, int col){ return el[row * stride + col]; } __host__ __device__ void operator =(const Matrix &a){height = a.height; width = a.width; el = a.el; stride = a.stride;} __device__ void setElement(int row, int col, int val){ el[row * stride + col] = val; } __device__ Matrix cutMatrix(int row, int col){ Matrix tmp(BLOCK_SIZE, BLOCK_SIZE, stride); tmp.el = &el[stride * BLOCK_SIZE * row + BLOCK_SIZE * col]; return tmp; } __host__ void writeOut(){ for(int i = 0; i < height; i++){ std::cout<<"| "; for(int j = 0; j < width; j++){ std::cout<<el[i * width + j]<<" "; } std::cout<<"|"<<std::endl; } std::cout<<"\n"; } }; __global__ void MatrixMulKernel(Matrix a,Matrix b, Matrix c) { int cutRow = blockIdx.y ; int cutCol = blockIdx.x; int fRow = blockIdx.y * blockDim.y + threadIdx.y; int fCol = blockIdx.x * blockDim.x + threadIdx.x; int row = threadIdx.y; int col = threadIdx.x; int temp = 0; Matrix cutMatC = c.cutMatrix(cutRow, cutCol); for( int v = 0; v < ((a.width + BLOCK_SIZE - 1)/BLOCK_SIZE); ++v){ Matrix cutMatA = a.cutMatrix(cutRow, v); //cut input matrix vector which can fit inside block Matrix cutMatB = b.cutMatrix(v, cutCol); __shared__ int A[BLOCK_SIZE][BLOCK_SIZE]; //Matrix wchich can share memory between threads __shared__ int B[BLOCK_SIZE][BLOCK_SIZE]; if((row < a.height) && ((col + v * BLOCK_SIZE) < a.width)){ A[row][col] = cutMatA.getElement(row, col); } else{ A[row][col] = 0; } if((col < b.width) && ((row + v * BLOCK_SIZE) < b.height)){ B[row][col] = cutMatB.getElement(row, col); } else{ B[row][col] = 0; } __syncthreads(); //make sure that every metrix is filled for (int i = 0; i < BLOCK_SIZE; ++i){ temp += A[row][i] * B[i][col]; } __syncthreads(); } if(fRow < c.height && fCol < c.width) c.setElement(fRow, fCol, temp); } int main(){ int N = 37; Matrix a(N, N, N), g(N, N, N), ag(N, N, N); cudaError_t err = cudaSuccess; dim3 threadsPerBlock(BLOCK_SIZE,BLOCK_SIZE); dim3 blocksPerGrid((N + BLOCK_SIZE - 1) / BLOCK_SIZE ,(N + BLOCK_SIZE - 1) / BLOCK_SIZE ); cudaMallocManaged(&a.el,N * N * sizeof(int)); cudaMallocManaged(&g.el, N * N * sizeof(int)); cudaMallocManaged(&ag.el, N * N * sizeof(int)); for(int i = 0; i < N; i++){ for(int j = 0; j<N; j++){ a.el[i*N+j] = 1; g.el[i*N+j] = 2; } } MatrixMulKernel<<<blocksPerGrid, threadsPerBlock>>>( a, g, ag); cudaDeviceSynchronize(); if (err != cudaSuccess){ fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", cudaGetErrorString(err)); exit(EXIT_FAILURE); } //a.writeOut(); //g.writeOut(); ag.writeOut(); cudaFree(a.el); cudaFree(g.el); cudaFree(ag.el); }
code for sm_80 Function : _Z15MatrixMulKernel6MatrixS_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 R9, SR_CTAID.X ; /* 0x0000000000097919 */ /* 0x000e220000002500 */ /*0020*/ MOV R4, c[0x0][0x164] ; /* 0x0000590000047a02 */ /* 0x000fe20000000f00 */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0040*/ HFMA2.MMA R23, -RZ, RZ, 0, 0 ; /* 0x00000000ff177435 */ /* 0x000fe200000001ff */ /*0050*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e220000002100 */ /*0060*/ ISETP.GE.AND P1, PT, R4, 0x1, PT ; /* 0x000000010400780c */ /* 0x000fc60003f26270 */ /*0070*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e680000002600 */ /*0080*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e620000002200 */ /*0090*/ IMAD R20, R9, c[0x0][0x0], R0 ; /* 0x0000000009147a24 */ /* 0x001fca00078e0200 */ /*00a0*/ ISETP.GE.AND P0, PT, R20, c[0x0][0x194], PT ; /* 0x0000650014007a0c */ /* 0x000fe20003f06270 */ /*00b0*/ IMAD R21, R2, c[0x0][0x4], R3 ; /* 0x0000010002157a24 */ /* 0x002fca00078e0203 */ /*00c0*/ ISETP.GE.OR P0, PT, R21, c[0x0][0x190], P0 ; /* 0x0000640015007a0c */ /* 0x000fe20000706670 */ /*00d0*/ @!P1 BRA 0x8a0 ; /* 0x000007c000009947 */ /* 0x000fd80003800000 */ /*00e0*/ IMAD R2, R2, c[0x0][0x170], RZ ; /* 0x00005c0002027a24 */ /* 0x000fe200078e02ff */ /*00f0*/ IADD3 R4, R4, 0x1f, RZ ; /* 0x0000001f04047810 */ /* 0x000fe20007ffe0ff */ /*0100*/ IMAD R5, R3.reuse, c[0x0][0x170], R0.reuse ; /* 0x00005c0003057a24 */ /* 0x140fe200078e0200 */ /*0110*/ SHF.L.U32 R19, R3.reuse, 0x7, RZ ; /* 0x0000000703137819 */ /* 0x040fe200000006ff */ /*0120*/ IMAD R18, R3, c[0x0][0x188], R0 ; /* 0x0000620003127a24 */ /* 0x000fe200078e0200 */ /*0130*/ SHF.L.U32 R2, R2, 0x5, RZ ; /* 0x0000000502027819 */ /* 0x000fe200000006ff */ /*0140*/ IMAD.MOV.U32 R23, RZ, RZ, RZ ; /* 0x000000ffff177224 */ /* 0x000fe200078e00ff */ /*0150*/ SHF.R.S32.HI R7, RZ, 0x1f, R4 ; /* 0x0000001fff077819 */ /* 0x000fe20000011404 */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ SHF.R.S32.HI R6, RZ, 0x1f, R2 ; /* 0x0000001fff067819 */ /* 0x000fc40000011402 */ /*0180*/ IADD3 R8, P1, R2, R5, RZ ; /* 0x0000000502087210 */ /* 0x000fe40007f3e0ff */ /*0190*/ LEA.HI R16, R7, R4, RZ, 0x5 ; /* 0x0000000407107211 */ /* 0x000fe400078f28ff */ /*01a0*/ LEA.HI.X.SX32 R5, R5, R6, 0x1, P1 ; /* 0x0000000605057211 */ /* 0x000fe400008f0eff */ /*01b0*/ LEA R2, P1, R8.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a0008027a11 */ /* 0x040fe400078210ff */ /*01c0*/ SHF.L.U32 R7, R9, 0x5, RZ ; /* 0x0000000509077819 */ /* 0x000fe400000006ff */ /*01d0*/ LEA.HI.X R5, R8, c[0x0][0x16c], R5, 0x2, P1 ; /* 0x00005b0008057a11 */ /* 0x000fc400008f1405 */ /*01e0*/ MOV R6, R0 ; /* 0x0000000000067202 */ /* 0x000fe40000000f00 */ /*01f0*/ MOV R4, R3 ; /* 0x0000000300047202 */ /* 0x000fe40000000f00 */ /*0200*/ LEA R17, R0, R19, 0x2 ; /* 0x0000001300117211 */ /* 0x000fe400078e10ff */ /*0210*/ SHF.R.S32.HI R16, RZ, 0x5, R16 ; /* 0x00000005ff107819 */ /* 0x000fe40000011410 */ /*0220*/ ISETP.GE.AND P1, PT, R4, c[0x0][0x178], PT ; /* 0x00005e0004007a0c */ /* 0x000fe40003f26270 */ /*0230*/ ISETP.GE.AND P2, PT, R6, c[0x0][0x164], PT ; /* 0x0000590006007a0c */ /* 0x000fe40003f46270 */ /*0240*/ ISETP.GE.OR P1, PT, R0, c[0x0][0x17c], P1 ; /* 0x00005f0000007a0c */ /* 0x000fc40000f26670 */ /*0250*/ ISETP.GE.OR P2, PT, R3, c[0x0][0x160], P2 ; /* 0x0000580003007a0c */ /* 0x000fe40001746670 */ /*0260*/ SHF.R.S32.HI R11, RZ, 0x1f, R7 ; /* 0x0000001fff0b7819 */ /* 0x000fd20000011407 */ /*0270*/ @!P1 IADD3 R9, P3, R18.reuse, R7, RZ ; /* 0x0000000712099210 */ /* 0x040fe40007f7e0ff */ /*0280*/ @!P2 MOV R10, R2 ; /* 0x00000002000aa202 */ /* 0x000fe40000000f00 */ /*0290*/ @!P1 LEA.HI.X.SX32 R12, R18, R11, 0x1, P3 ; /* 0x0000000b120c9211 */ /* 0x000fe400018f0eff */ /*02a0*/ @!P1 LEA R8, P3, R9.reuse, c[0x0][0x180], 0x2 ; /* 0x0000600009089a11 */ /* 0x040fe400078610ff */ /*02b0*/ @!P2 MOV R11, R5 ; /* 0x00000005000ba202 */ /* 0x000fe40000000f00 */ /*02c0*/ @!P1 LEA.HI.X R9, R9, c[0x0][0x184], R12, 0x2, P3 ; /* 0x0000610009099a11 */ /* 0x000fc600018f140c */ /*02d0*/ @!P2 LDG.E R10, [R10.64] ; /* 0x000000060a0aa981 */ /* 0x000ea8000c1e1900 */ /*02e0*/ @!P1 LDG.E R8, [R8.64] ; /* 0x0000000608089981 */ /* 0x000ee2000c1e1900 */ /*02f0*/ HFMA2.MMA R22, -RZ, RZ, 0, 0 ; /* 0x00000000ff167435 */ /* 0x000fe200000001ff */ /*0300*/ IMAD.MOV.U32 R28, RZ, RZ, RZ ; /* 0x000000ffff1c7224 */ /* 0x000fe200078e00ff */ /*0310*/ UIADD3 UR4, UR4, 0x1, URZ ; /* 0x0000000104047890 */ /* 0x000fe2000fffe03f */ /*0320*/ IADD3 R4, R4, 0x20, RZ ; /* 0x0000002004047810 */ /* 0x000fe40007ffe0ff */ /*0330*/ IADD3 R6, R6, 0x20, RZ ; /* 0x0000002006067810 */ /* 0x000fe20007ffe0ff */ /*0340*/ @!P2 I2F R26, R10 ; /* 0x0000000a001aa306 */ /* 0x004e300000201400 */ /*0350*/ @!P1 I2F R27, R8 ; /* 0x00000008001b9306 */ /* 0x008e700000201400 */ /*0360*/ @!P2 F2I.TRUNC.NTZ R22, R26 ; /* 0x0000001a0016a305 */ /* 0x001e22000020f100 */ /*0370*/ IADD3 R2, P2, R2, 0x80, RZ ; /* 0x0000008002027810 */ /* 0x000fc80007f5e0ff */ /*0380*/ IADD3.X R5, RZ, R5, RZ, P2, !PT ; /* 0x00000005ff057210 */ /* 0x000fc600017fe4ff */ /*0390*/ @!P1 F2I.TRUNC.NTZ R28, R27 ; /* 0x0000001b001c9305 */ /* 0x002e62000020f100 */ /*03a0*/ ISETP.LE.AND P1, PT, R16, UR4, PT ; /* 0x0000000410007c0c */ /* 0x000fe2000bf23270 */ /*03b0*/ STS [R17], R22 ; /* 0x0000001611007388 */ /* 0x001fe80000000800 */ /*03c0*/ STS [R17+0x1000], R28 ; /* 0x0010001c11007388 */ /* 0x002fe80000000800 */ /*03d0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*03e0*/ LDS R11, [R0.X4+0x1000] ; /* 0x00100000000b7984 */ /* 0x000fe80000004800 */ /*03f0*/ LDS.128 R12, [R19] ; /* 0x00000000130c7984 */ /* 0x000e280000000c00 */ /*0400*/ LDS R29, [R0.X4+0x1080] ; /* 0x00108000001d7984 */ /* 0x000e680000004800 */ /*0410*/ LDS R25, [R0.X4+0x1100] ; /* 0x0011000000197984 */ /* 0x000ea80000004800 */ /*0420*/ LDS R24, [R0.X4+0x1180] ; /* 0x0011800000187984 */ /* 0x000ee80000004800 */ /*0430*/ LDS R22, [R0.X4+0x1280] ; /* 0x0012800000167984 */ /* 0x000fe80000004800 */ /*0440*/ LDS R26, [R0.X4+0x1b80] ; /* 0x001b8000001a7984 */ /* 0x000fe80000004800 */ /*0450*/ LDS R27, [R0.X4+0x1c00] ; /* 0x001c0000001b7984 */ /* 0x000fe20000004800 */ /*0460*/ IMAD R12, R11, R12, R23 ; /* 0x0000000c0b0c7224 */ /* 0x001fc600078e0217 */ /*0470*/ LDS R23, [R0.X4+0x1200] ; /* 0x0012000000177984 */ /* 0x000fe20000004800 */ /*0480*/ IMAD R12, R29, R13, R12 ; /* 0x0000000d1d0c7224 */ /* 0x002fc600078e020c */ /*0490*/ LDS.128 R8, [R19+0x10] ; /* 0x0000100013087984 */ /* 0x000e220000000c00 */ /*04a0*/ IMAD R12, R25, R14, R12 ; /* 0x0000000e190c7224 */ /* 0x004fc600078e020c */ /*04b0*/ LDS R25, [R0.X4+0x1300] ; /* 0x0013000000197984 */ /* 0x000e620000004800 */ /*04c0*/ IMAD R12, R24, R15, R12 ; /* 0x0000000f180c7224 */ /* 0x008fc600078e020c */ /*04d0*/ LDS R24, [R0.X4+0x1380] ; /* 0x0013800000187984 */ /* 0x000ea20000004800 */ /*04e0*/ IMAD R8, R23, R8, R12 ; /* 0x0000000817087224 */ /* 0x001fc600078e020c */ /*04f0*/ LDS R23, [R0.X4+0x1400] ; /* 0x0014000000177984 */ /* 0x000fe20000004800 */ /*0500*/ IMAD R8, R22, R9, R8 ; /* 0x0000000916087224 */ /* 0x000fc600078e0208 */ /*0510*/ LDS.128 R12, [R19+0x20] ; /* 0x00002000130c7984 */ /* 0x000e220000000c00 */ /*0520*/ IMAD R8, R25, R10, R8 ; /* 0x0000000a19087224 */ /* 0x002fc600078e0208 */ /*0530*/ LDS R22, [R0.X4+0x1480] ; /* 0x0014800000167984 */ /* 0x000e620000004800 */ /*0540*/ IMAD R8, R24, R11, R8 ; /* 0x0000000b18087224 */ /* 0x004fc600078e0208 */ /*0550*/ LDS R25, [R0.X4+0x1500] ; /* 0x0015000000197984 */ /* 0x000ea80000004800 */ /*0560*/ LDS R24, [R0.X4+0x1580] ; /* 0x0015800000187984 */ /* 0x000ee20000004800 */ /*0570*/ IMAD R12, R23, R12, R8 ; /* 0x0000000c170c7224 */ /* 0x001fc600078e0208 */ /*0580*/ LDS R23, [R0.X4+0x1600] ; /* 0x0016000000177984 */ /* 0x000fe20000004800 */ /*0590*/ IMAD R12, R22, R13, R12 ; /* 0x0000000d160c7224 */ /* 0x002fc600078e020c */ /*05a0*/ LDS.128 R8, [R19+0x30] ; /* 0x0000300013087984 */ /* 0x000e220000000c00 */ /*05b0*/ IMAD R12, R25, R14, R12 ; /* 0x0000000e190c7224 */ /* 0x004fc600078e020c */ /*05c0*/ LDS R22, [R0.X4+0x1680] ; /* 0x0016800000167984 */ /* 0x000e620000004800 */ /*05d0*/ IMAD R12, R24, R15, R12 ; /* 0x0000000f180c7224 */ /* 0x008fc600078e020c */ /*05e0*/ LDS R25, [R0.X4+0x1700] ; /* 0x0017000000197984 */ /* 0x000ea80000004800 */ /*05f0*/ LDS R24, [R0.X4+0x1780] ; /* 0x0017800000187984 */ /* 0x000ee20000004800 */ /*0600*/ IMAD R8, R23, R8, R12 ; /* 0x0000000817087224 */ /* 0x001fc600078e020c */ /*0610*/ LDS R23, [R0.X4+0x1800] ; /* 0x0018000000177984 */ /* 0x000fe20000004800 */ /*0620*/ IMAD R8, R22, R9, R8 ; /* 0x0000000916087224 */ /* 0x002fc600078e0208 */ /*0630*/ LDS.128 R12, [R19+0x40] ; /* 0x00004000130c7984 */ /* 0x000e220000000c00 */ /*0640*/ IMAD R8, R25, R10, R8 ; /* 0x0000000a19087224 */ /* 0x004fc600078e0208 */ /*0650*/ LDS R22, [R0.X4+0x1880] ; /* 0x0018800000167984 */ /* 0x000e620000004800 */ /*0660*/ IMAD R8, R24, R11, R8 ; /* 0x0000000b18087224 */ /* 0x008fc600078e0208 */ /*0670*/ LDS R25, [R0.X4+0x1900] ; /* 0x0019000000197984 */ /* 0x000ea80000004800 */ /*0680*/ LDS R24, [R0.X4+0x1980] ; /* 0x0019800000187984 */ /* 0x000ee20000004800 */ /*0690*/ IMAD R12, R23, R12, R8 ; /* 0x0000000c170c7224 */ /* 0x001fc600078e0208 */ /*06a0*/ LDS R23, [R0.X4+0x1a00] ; /* 0x001a000000177984 */ /* 0x000fe20000004800 */ /*06b0*/ IMAD R12, R22, R13, R12 ; /* 0x0000000d160c7224 */ /* 0x002fc600078e020c */ /*06c0*/ LDS.128 R8, [R19+0x50] ; /* 0x0000500013087984 */ /* 0x000e220000000c00 */ /*06d0*/ IMAD R12, R25, R14, R12 ; /* 0x0000000e190c7224 */ /* 0x004fc600078e020c */ /*06e0*/ LDS R22, [R0.X4+0x1a80] ; /* 0x001a800000167984 */ /* 0x000e620000004800 */ /*06f0*/ IMAD R12, R24, R15, R12 ; /* 0x0000000f180c7224 */ /* 0x008fc600078e020c */ /*0700*/ LDS R25, [R0.X4+0x1b00] ; /* 0x001b000000197984 */ /* 0x000ea80000004800 */ /*0710*/ LDS R24, [R0.X4+0x1c80] ; /* 0x001c800000187984 */ /* 0x000fe20000004800 */ /*0720*/ IMAD R8, R23, R8, R12 ; /* 0x0000000817087224 */ /* 0x001fc600078e020c */ /*0730*/ LDS.128 R12, [R19+0x60] ; /* 0x00006000130c7984 */ /* 0x000e220000000c00 */ /*0740*/ IMAD R8, R22, R9, R8 ; /* 0x0000000916087224 */ /* 0x002fc600078e0208 */ /*0750*/ LDS R23, [R0.X4+0x1d00] ; /* 0x001d000000177984 */ /* 0x000e620000004800 */ /*0760*/ IMAD R8, R25, R10, R8 ; /* 0x0000000a19087224 */ /* 0x004fc600078e0208 */ /*0770*/ LDS R22, [R0.X4+0x1d80] ; /* 0x001d800000167984 */ /* 0x000ea20000004800 */ /*0780*/ IMAD R8, R26, R11, R8 ; /* 0x0000000b1a087224 */ /* 0x000fc600078e0208 */ /*0790*/ LDS R25, [R0.X4+0x1e00] ; /* 0x001e000000197984 */ /* 0x000fe80000004800 */ /*07a0*/ LDS R26, [R0.X4+0x1e80] ; /* 0x001e8000001a7984 */ /* 0x000fe20000004800 */ /*07b0*/ IMAD R12, R27, R12, R8 ; /* 0x0000000c1b0c7224 */ /* 0x001fc600078e0208 */ /*07c0*/ LDS.128 R8, [R19+0x70] ; /* 0x0000700013087984 */ /* 0x000e220000000c00 */ /*07d0*/ IMAD R24, R24, R13, R12 ; /* 0x0000000d18187224 */ /* 0x000fc600078e020c */ /*07e0*/ LDS R13, [R0.X4+0x1f00] ; /* 0x001f0000000d7984 */ /* 0x000ee20000004800 */ /*07f0*/ IMAD R14, R23, R14, R24 ; /* 0x0000000e170e7224 */ /* 0x002fc600078e0218 */ /*0800*/ LDS R12, [R0.X4+0x1f80] ; /* 0x001f8000000c7984 */ /* 0x000e620000004800 */ /*0810*/ IMAD R14, R22, R15, R14 ; /* 0x0000000f160e7224 */ /* 0x004fc800078e020e */ /*0820*/ IMAD R8, R25, R8, R14 ; /* 0x0000000819087224 */ /* 0x001fc800078e020e */ /*0830*/ IMAD R8, R26, R9, R8 ; /* 0x000000091a087224 */ /* 0x000fc800078e0208 */ /*0840*/ IMAD R8, R13, R10, R8 ; /* 0x0000000a0d087224 */ /* 0x008fe200078e0208 */ /*0850*/ MOV R10, c[0x0][0x188] ; /* 0x00006200000a7a02 */ /* 0x000fc60000000f00 */ /*0860*/ IMAD R23, R12, R11, R8 ; /* 0x0000000b0c177224 */ /* 0x002fe200078e0208 */ /*0870*/ LEA R7, R10, R7, 0x5 ; /* 0x000000070a077211 */ /* 0x000fe200078e28ff */ /*0880*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0890*/ @!P1 BRA 0x220 ; /* 0xfffff98000009947 */ /* 0x000fea000383ffff */ /*08a0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*08b0*/ HFMA2.MMA R3, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff037435 */ /* 0x000fe200000001ff */ /*08c0*/ IMAD R2, R21, c[0x0][0x1a0], R20 ; /* 0x0000680015027a24 */ /* 0x000fd200078e0214 */ /*08d0*/ IMAD.WIDE R2, R2, R3, c[0x0][0x198] ; /* 0x0000660002027625 */ /* 0x000fca00078e0203 */ /*08e0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x000fe2000c101906 */ /*08f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0900*/ BRA 0x900; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ /*0980*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0990*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <iostream> #include <stdio.h> #include <cuda_runtime.h> #define MIN(a, b) (a<b?a:b) #define BLOCK_SIZE 32 struct Matrix { int height; int width; int *el; int stride; __host__ __device__ Matrix(int height, int width, int stride ): height(height), width(width),stride(stride){} __host__ __device__ Matrix(const Matrix &a): height(a.height), width(a.width),el(a.el),stride(a.stride){} __device__ float getElement(int row, int col){ return el[row * stride + col]; } __host__ __device__ void operator =(const Matrix &a){height = a.height; width = a.width; el = a.el; stride = a.stride;} __device__ void setElement(int row, int col, int val){ el[row * stride + col] = val; } __device__ Matrix cutMatrix(int row, int col){ Matrix tmp(BLOCK_SIZE, BLOCK_SIZE, stride); tmp.el = &el[stride * BLOCK_SIZE * row + BLOCK_SIZE * col]; return tmp; } __host__ void writeOut(){ for(int i = 0; i < height; i++){ std::cout<<"| "; for(int j = 0; j < width; j++){ std::cout<<el[i * width + j]<<" "; } std::cout<<"|"<<std::endl; } std::cout<<"\n"; } }; __global__ void MatrixMulKernel(Matrix a,Matrix b, Matrix c) { int cutRow = blockIdx.y ; int cutCol = blockIdx.x; int fRow = blockIdx.y * blockDim.y + threadIdx.y; int fCol = blockIdx.x * blockDim.x + threadIdx.x; int row = threadIdx.y; int col = threadIdx.x; int temp = 0; Matrix cutMatC = c.cutMatrix(cutRow, cutCol); for( int v = 0; v < ((a.width + BLOCK_SIZE - 1)/BLOCK_SIZE); ++v){ Matrix cutMatA = a.cutMatrix(cutRow, v); //cut input matrix vector which can fit inside block Matrix cutMatB = b.cutMatrix(v, cutCol); __shared__ int A[BLOCK_SIZE][BLOCK_SIZE]; //Matrix wchich can share memory between threads __shared__ int B[BLOCK_SIZE][BLOCK_SIZE]; if((row < a.height) && ((col + v * BLOCK_SIZE) < a.width)){ A[row][col] = cutMatA.getElement(row, col); } else{ A[row][col] = 0; } if((col < b.width) && ((row + v * BLOCK_SIZE) < b.height)){ B[row][col] = cutMatB.getElement(row, col); } else{ B[row][col] = 0; } __syncthreads(); //make sure that every metrix is filled for (int i = 0; i < BLOCK_SIZE; ++i){ temp += A[row][i] * B[i][col]; } __syncthreads(); } if(fRow < c.height && fCol < c.width) c.setElement(fRow, fCol, temp); } int main(){ int N = 37; Matrix a(N, N, N), g(N, N, N), ag(N, N, N); cudaError_t err = cudaSuccess; dim3 threadsPerBlock(BLOCK_SIZE,BLOCK_SIZE); dim3 blocksPerGrid((N + BLOCK_SIZE - 1) / BLOCK_SIZE ,(N + BLOCK_SIZE - 1) / BLOCK_SIZE ); cudaMallocManaged(&a.el,N * N * sizeof(int)); cudaMallocManaged(&g.el, N * N * sizeof(int)); cudaMallocManaged(&ag.el, N * N * sizeof(int)); for(int i = 0; i < N; i++){ for(int j = 0; j<N; j++){ a.el[i*N+j] = 1; g.el[i*N+j] = 2; } } MatrixMulKernel<<<blocksPerGrid, threadsPerBlock>>>( a, g, ag); cudaDeviceSynchronize(); if (err != cudaSuccess){ fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", cudaGetErrorString(err)); exit(EXIT_FAILURE); } //a.writeOut(); //g.writeOut(); ag.writeOut(); cudaFree(a.el); cudaFree(g.el); cudaFree(ag.el); }
.file "tmpxft_00146033_00000000-6_matrixMultiplication.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3683: .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 .LFE3683: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata._ZN6Matrix8writeOutEv.str1.1,"aMS",@progbits,1 .LC0: .string "| " .LC1: .string " " .LC2: .string "|" .LC3: .string "\n" .section .text._ZN6Matrix8writeOutEv,"axG",@progbits,_ZN6Matrix8writeOutEv,comdat .align 2 .weak _ZN6Matrix8writeOutEv .type _ZN6Matrix8writeOutEv, @function _ZN6Matrix8writeOutEv: .LFB3679: .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 $8, %rsp .cfi_def_cfa_offset 64 cmpl $0, (%rdi) jle .L4 movq %rdi, %rbp movl $0, %r13d leaq .LC0(%rip), %r15 leaq _ZSt4cout(%rip), %r12 leaq .LC1(%rip), %r14 jmp .L10 .L14: call _ZSt16__throw_bad_castv@PLT .L8: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi .L9: movsbl %sil, %esi movq %r12, %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT addl $1, %r13d cmpl %r13d, 0(%rbp) jle .L4 .L10: movl $2, %edx movq %r15, %rsi movq %r12, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl 4(%rbp), %eax testl %eax, %eax jle .L5 movl $0, %ebx .L6: imull %r13d, %eax addl %ebx, %eax cltq movq 8(%rbp), %rdx movl (%rdx,%rax,4), %esi movq %r12, %rdi call _ZNSolsEi@PLT movq %rax, %rdi movl $1, %edx movq %r14, %rsi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT addl $1, %ebx movl 4(%rbp), %eax cmpl %ebx, %eax jg .L6 .L5: movl $1, %edx leaq .LC2(%rip), %rsi movq %r12, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq (%r12), %rax movq -24(%rax), %rax movq 240(%r12,%rax), %rbx testq %rbx, %rbx je .L14 cmpb $0, 56(%rbx) je .L8 movzbl 67(%rbx), %esi jmp .L9 .L4: movl $1, %edx leaq .LC3(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT addq $8, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3679: .size _ZN6Matrix8writeOutEv, .-_ZN6Matrix8writeOutEv .text .globl _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ .type _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_, @function _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_: .LFB3705: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax movq %rdi, 64(%rsp) movq %rsi, 72(%rsp) movq %rdx, 80(%rsp) movl $1, 16(%rsp) movl $1, 20(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) leaq 8(%rsp), %rcx movq %rsp, %rdx leaq 28(%rsp), %rsi leaq 16(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L19 .L15: movq 88(%rsp), %rax subq %fs:40, %rax jne .L20 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L19: .cfi_restore_state pushq 8(%rsp) .cfi_def_cfa_offset 120 pushq 8(%rsp) .cfi_def_cfa_offset 128 leaq 80(%rsp), %r9 movq 44(%rsp), %rcx movl 52(%rsp), %r8d movq 32(%rsp), %rsi movl 40(%rsp), %edx leaq _Z15MatrixMulKernel6MatrixS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L15 .L20: call __stack_chk_fail@PLT .cfi_endproc .LFE3705: .size _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_, .-_Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ .globl _Z15MatrixMulKernel6MatrixS_S_ .type _Z15MatrixMulKernel6MatrixS_S_, @function _Z15MatrixMulKernel6MatrixS_S_: .LFB3706: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3706: .size _Z15MatrixMulKernel6MatrixS_S_, .-_Z15MatrixMulKernel6MatrixS_S_ .globl main .type main, @function main: .LFB3680: .cfi_startproc endbr64 subq $232, %rsp .cfi_def_cfa_offset 240 movq %fs:40, %rax movq %rax, 216(%rsp) xorl %eax, %eax movl $37, 32(%rsp) movl $37, 36(%rsp) movl $37, 48(%rsp) movl $37, 64(%rsp) movl $37, 68(%rsp) movl $37, 80(%rsp) movl $37, 96(%rsp) movl $37, 100(%rsp) movl $37, 112(%rsp) movl $32, 8(%rsp) movl $32, 12(%rsp) movl $1, 16(%rsp) movl $2, 20(%rsp) movl $2, 24(%rsp) movl $1, 28(%rsp) leaq 40(%rsp), %rdi movl $1, %edx movl $5476, %esi call cudaMallocManaged@PLT leaq 72(%rsp), %rdi movl $1, %edx movl $5476, %esi call cudaMallocManaged@PLT leaq 104(%rsp), %rdi movl $1, %edx movl $5476, %esi call cudaMallocManaged@PLT movl $148, %ecx .L24: leaq -148(%rcx), %rax .L25: movq 40(%rsp), %rdx movl $1, (%rdx,%rax) movq 72(%rsp), %rdx movl $2, (%rdx,%rax) addq $4, %rax cmpq %rcx, %rax jne .L25 addq $148, %rcx cmpq $5624, %rcx jne .L24 movl 16(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 8(%rsp), %rdx movq 20(%rsp), %rdi movl 28(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L31 .L27: call cudaDeviceSynchronize@PLT leaq 96(%rsp), %rdi call _ZN6Matrix8writeOutEv movq 40(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT movq 104(%rsp), %rdi call cudaFree@PLT movq 216(%rsp), %rax subq %fs:40, %rax jne .L32 movl $0, %eax addq $232, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L31: .cfi_restore_state movl 96(%rsp), %eax movl %eax, 192(%rsp) movl 100(%rsp), %eax movl %eax, 196(%rsp) movq 104(%rsp), %rax movq %rax, 200(%rsp) movl 112(%rsp), %eax movl %eax, 208(%rsp) movl 64(%rsp), %eax movl %eax, 160(%rsp) movl 68(%rsp), %eax movl %eax, 164(%rsp) movq 72(%rsp), %rax movq %rax, 168(%rsp) movl 80(%rsp), %eax movl %eax, 176(%rsp) movl 32(%rsp), %eax movl %eax, 128(%rsp) movl 36(%rsp), %eax movl %eax, 132(%rsp) movq 40(%rsp), %rax movq %rax, 136(%rsp) movl 48(%rsp), %eax movl %eax, 144(%rsp) leaq 192(%rsp), %rdx leaq 160(%rsp), %rsi leaq 128(%rsp), %rdi call _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ jmp .L27 .L32: call __stack_chk_fail@PLT .cfi_endproc .LFE3680: .size main, .-main .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "_Z15MatrixMulKernel6MatrixS_S_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3708: .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 _Z15MatrixMulKernel6MatrixS_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 .LFE3708: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include <iostream> #include <stdio.h> #include <cuda_runtime.h> #define MIN(a, b) (a<b?a:b) #define BLOCK_SIZE 32 struct Matrix { int height; int width; int *el; int stride; __host__ __device__ Matrix(int height, int width, int stride ): height(height), width(width),stride(stride){} __host__ __device__ Matrix(const Matrix &a): height(a.height), width(a.width),el(a.el),stride(a.stride){} __device__ float getElement(int row, int col){ return el[row * stride + col]; } __host__ __device__ void operator =(const Matrix &a){height = a.height; width = a.width; el = a.el; stride = a.stride;} __device__ void setElement(int row, int col, int val){ el[row * stride + col] = val; } __device__ Matrix cutMatrix(int row, int col){ Matrix tmp(BLOCK_SIZE, BLOCK_SIZE, stride); tmp.el = &el[stride * BLOCK_SIZE * row + BLOCK_SIZE * col]; return tmp; } __host__ void writeOut(){ for(int i = 0; i < height; i++){ std::cout<<"| "; for(int j = 0; j < width; j++){ std::cout<<el[i * width + j]<<" "; } std::cout<<"|"<<std::endl; } std::cout<<"\n"; } }; __global__ void MatrixMulKernel(Matrix a,Matrix b, Matrix c) { int cutRow = blockIdx.y ; int cutCol = blockIdx.x; int fRow = blockIdx.y * blockDim.y + threadIdx.y; int fCol = blockIdx.x * blockDim.x + threadIdx.x; int row = threadIdx.y; int col = threadIdx.x; int temp = 0; Matrix cutMatC = c.cutMatrix(cutRow, cutCol); for( int v = 0; v < ((a.width + BLOCK_SIZE - 1)/BLOCK_SIZE); ++v){ Matrix cutMatA = a.cutMatrix(cutRow, v); //cut input matrix vector which can fit inside block Matrix cutMatB = b.cutMatrix(v, cutCol); __shared__ int A[BLOCK_SIZE][BLOCK_SIZE]; //Matrix wchich can share memory between threads __shared__ int B[BLOCK_SIZE][BLOCK_SIZE]; if((row < a.height) && ((col + v * BLOCK_SIZE) < a.width)){ A[row][col] = cutMatA.getElement(row, col); } else{ A[row][col] = 0; } if((col < b.width) && ((row + v * BLOCK_SIZE) < b.height)){ B[row][col] = cutMatB.getElement(row, col); } else{ B[row][col] = 0; } __syncthreads(); //make sure that every metrix is filled for (int i = 0; i < BLOCK_SIZE; ++i){ temp += A[row][i] * B[i][col]; } __syncthreads(); } if(fRow < c.height && fCol < c.width) c.setElement(fRow, fCol, temp); } int main(){ int N = 37; Matrix a(N, N, N), g(N, N, N), ag(N, N, N); cudaError_t err = cudaSuccess; dim3 threadsPerBlock(BLOCK_SIZE,BLOCK_SIZE); dim3 blocksPerGrid((N + BLOCK_SIZE - 1) / BLOCK_SIZE ,(N + BLOCK_SIZE - 1) / BLOCK_SIZE ); cudaMallocManaged(&a.el,N * N * sizeof(int)); cudaMallocManaged(&g.el, N * N * sizeof(int)); cudaMallocManaged(&ag.el, N * N * sizeof(int)); for(int i = 0; i < N; i++){ for(int j = 0; j<N; j++){ a.el[i*N+j] = 1; g.el[i*N+j] = 2; } } MatrixMulKernel<<<blocksPerGrid, threadsPerBlock>>>( a, g, ag); cudaDeviceSynchronize(); if (err != cudaSuccess){ fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", cudaGetErrorString(err)); exit(EXIT_FAILURE); } //a.writeOut(); //g.writeOut(); ag.writeOut(); cudaFree(a.el); cudaFree(g.el); cudaFree(ag.el); }
#include <iostream> #include <stdio.h> #include <hip/hip_runtime.h> #define MIN(a, b) (a<b?a:b) #define BLOCK_SIZE 32 struct Matrix { int height; int width; int *el; int stride; __host__ __device__ Matrix(int height, int width, int stride ): height(height), width(width),stride(stride){} __host__ __device__ Matrix(const Matrix &a): height(a.height), width(a.width),el(a.el),stride(a.stride){} __device__ float getElement(int row, int col){ return el[row * stride + col]; } __host__ __device__ void operator =(const Matrix &a){height = a.height; width = a.width; el = a.el; stride = a.stride;} __device__ void setElement(int row, int col, int val){ el[row * stride + col] = val; } __device__ Matrix cutMatrix(int row, int col){ Matrix tmp(BLOCK_SIZE, BLOCK_SIZE, stride); tmp.el = &el[stride * BLOCK_SIZE * row + BLOCK_SIZE * col]; return tmp; } __host__ void writeOut(){ for(int i = 0; i < height; i++){ std::cout<<"| "; for(int j = 0; j < width; j++){ std::cout<<el[i * width + j]<<" "; } std::cout<<"|"<<std::endl; } std::cout<<"\n"; } }; __global__ void MatrixMulKernel(Matrix a,Matrix b, Matrix c) { int cutRow = blockIdx.y ; int cutCol = blockIdx.x; int fRow = blockIdx.y * blockDim.y + threadIdx.y; int fCol = blockIdx.x * blockDim.x + threadIdx.x; int row = threadIdx.y; int col = threadIdx.x; int temp = 0; Matrix cutMatC = c.cutMatrix(cutRow, cutCol); for( int v = 0; v < ((a.width + BLOCK_SIZE - 1)/BLOCK_SIZE); ++v){ Matrix cutMatA = a.cutMatrix(cutRow, v); //cut input matrix vector which can fit inside block Matrix cutMatB = b.cutMatrix(v, cutCol); __shared__ int A[BLOCK_SIZE][BLOCK_SIZE]; //Matrix wchich can share memory between threads __shared__ int B[BLOCK_SIZE][BLOCK_SIZE]; if((row < a.height) && ((col + v * BLOCK_SIZE) < a.width)){ A[row][col] = cutMatA.getElement(row, col); } else{ A[row][col] = 0; } if((col < b.width) && ((row + v * BLOCK_SIZE) < b.height)){ B[row][col] = cutMatB.getElement(row, col); } else{ B[row][col] = 0; } __syncthreads(); //make sure that every metrix is filled for (int i = 0; i < BLOCK_SIZE; ++i){ temp += A[row][i] * B[i][col]; } __syncthreads(); } if(fRow < c.height && fCol < c.width) c.setElement(fRow, fCol, temp); } int main(){ int N = 37; Matrix a(N, N, N), g(N, N, N), ag(N, N, N); hipError_t err = hipSuccess; dim3 threadsPerBlock(BLOCK_SIZE,BLOCK_SIZE); dim3 blocksPerGrid((N + BLOCK_SIZE - 1) / BLOCK_SIZE ,(N + BLOCK_SIZE - 1) / BLOCK_SIZE ); hipMallocManaged(&a.el,N * N * sizeof(int)); hipMallocManaged(&g.el, N * N * sizeof(int)); hipMallocManaged(&ag.el, N * N * sizeof(int)); for(int i = 0; i < N; i++){ for(int j = 0; j<N; j++){ a.el[i*N+j] = 1; g.el[i*N+j] = 2; } } MatrixMulKernel<<<blocksPerGrid, threadsPerBlock>>>( a, g, ag); hipDeviceSynchronize(); if (err != hipSuccess){ fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", hipGetErrorString(err)); exit(EXIT_FAILURE); } //a.writeOut(); //g.writeOut(); ag.writeOut(); hipFree(a.el); hipFree(g.el); hipFree(ag.el); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <iostream> #include <stdio.h> #include <hip/hip_runtime.h> #define MIN(a, b) (a<b?a:b) #define BLOCK_SIZE 32 struct Matrix { int height; int width; int *el; int stride; __host__ __device__ Matrix(int height, int width, int stride ): height(height), width(width),stride(stride){} __host__ __device__ Matrix(const Matrix &a): height(a.height), width(a.width),el(a.el),stride(a.stride){} __device__ float getElement(int row, int col){ return el[row * stride + col]; } __host__ __device__ void operator =(const Matrix &a){height = a.height; width = a.width; el = a.el; stride = a.stride;} __device__ void setElement(int row, int col, int val){ el[row * stride + col] = val; } __device__ Matrix cutMatrix(int row, int col){ Matrix tmp(BLOCK_SIZE, BLOCK_SIZE, stride); tmp.el = &el[stride * BLOCK_SIZE * row + BLOCK_SIZE * col]; return tmp; } __host__ void writeOut(){ for(int i = 0; i < height; i++){ std::cout<<"| "; for(int j = 0; j < width; j++){ std::cout<<el[i * width + j]<<" "; } std::cout<<"|"<<std::endl; } std::cout<<"\n"; } }; __global__ void MatrixMulKernel(Matrix a,Matrix b, Matrix c) { int cutRow = blockIdx.y ; int cutCol = blockIdx.x; int fRow = blockIdx.y * blockDim.y + threadIdx.y; int fCol = blockIdx.x * blockDim.x + threadIdx.x; int row = threadIdx.y; int col = threadIdx.x; int temp = 0; Matrix cutMatC = c.cutMatrix(cutRow, cutCol); for( int v = 0; v < ((a.width + BLOCK_SIZE - 1)/BLOCK_SIZE); ++v){ Matrix cutMatA = a.cutMatrix(cutRow, v); //cut input matrix vector which can fit inside block Matrix cutMatB = b.cutMatrix(v, cutCol); __shared__ int A[BLOCK_SIZE][BLOCK_SIZE]; //Matrix wchich can share memory between threads __shared__ int B[BLOCK_SIZE][BLOCK_SIZE]; if((row < a.height) && ((col + v * BLOCK_SIZE) < a.width)){ A[row][col] = cutMatA.getElement(row, col); } else{ A[row][col] = 0; } if((col < b.width) && ((row + v * BLOCK_SIZE) < b.height)){ B[row][col] = cutMatB.getElement(row, col); } else{ B[row][col] = 0; } __syncthreads(); //make sure that every metrix is filled for (int i = 0; i < BLOCK_SIZE; ++i){ temp += A[row][i] * B[i][col]; } __syncthreads(); } if(fRow < c.height && fCol < c.width) c.setElement(fRow, fCol, temp); } int main(){ int N = 37; Matrix a(N, N, N), g(N, N, N), ag(N, N, N); hipError_t err = hipSuccess; dim3 threadsPerBlock(BLOCK_SIZE,BLOCK_SIZE); dim3 blocksPerGrid((N + BLOCK_SIZE - 1) / BLOCK_SIZE ,(N + BLOCK_SIZE - 1) / BLOCK_SIZE ); hipMallocManaged(&a.el,N * N * sizeof(int)); hipMallocManaged(&g.el, N * N * sizeof(int)); hipMallocManaged(&ag.el, N * N * sizeof(int)); for(int i = 0; i < N; i++){ for(int j = 0; j<N; j++){ a.el[i*N+j] = 1; g.el[i*N+j] = 2; } } MatrixMulKernel<<<blocksPerGrid, threadsPerBlock>>>( a, g, ag); hipDeviceSynchronize(); if (err != hipSuccess){ fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", hipGetErrorString(err)); exit(EXIT_FAILURE); } //a.writeOut(); //g.writeOut(); ag.writeOut(); hipFree(a.el); hipFree(g.el); hipFree(ag.el); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15MatrixMulKernel6MatrixS_S_ .globl _Z15MatrixMulKernel6MatrixS_S_ .p2align 8 .type _Z15MatrixMulKernel6MatrixS_S_,@function _Z15MatrixMulKernel6MatrixS_S_: s_clause 0x2 s_load_b32 s11, s[0:1], 0x4 s_load_b64 s[8:9], s[0:1], 0x38 s_load_b32 s10, s[0:1], 0x54 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s11, 1 s_cbranch_scc1 .LBB0_17 s_clause 0x4 s_load_b32 s18, s[0:1], 0x10 s_load_b32 s12, s[0:1], 0x28 s_load_b32 s2, s[0:1], 0x0 s_load_b128 s[4:7], s[0:1], 0x18 s_load_b64 s[16:17], s[0:1], 0x8 v_dual_mov_b32 v2, 0 :: v_dual_lshlrev_b32 v5, 2, v0 s_add_i32 s3, s11, 31 v_lshlrev_b32_e32 v3, 7, v1 s_lshr_b32 s19, s3, 5 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_or_b32_e32 v4, 0x1000, v5 v_mov_b32_e32 v11, 0 v_add_nc_u32_e32 v5, v3, v5 s_delay_alu instid0(VALU_DEP_3) v_add_nc_u32_e32 v6, v4, v3 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[7:8], null, s18, v1, v[0:1] v_mad_u64_u32 v[9:10], null, s12, v1, v[0:1] v_cmp_gt_i32_e32 vcc_lo, s2, v1 v_cmp_le_i32_e64 s13, s2, v1 v_cmp_gt_i32_e64 s2, s5, v0 v_cmp_le_i32_e64 s5, s5, v0 v_ashrrev_i32_e32 v8, 31, v7 v_ashrrev_i32_e32 v10, 31, v9 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[7:8], 2, v[7:8] v_lshlrev_b64 v[9:10], 2, v[9:10] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v7, s3, s16, v7 v_add_co_ci_u32_e64 v8, s3, s17, v8, s3 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v9, s3, s6, v9 v_add_co_ci_u32_e64 v10, s3, s7, v10, s3 s_mul_i32 s6, s18, s15 s_max_i32 s7, s19, 1 s_mov_b32 s16, 0 .LBB0_2: s_mov_b32 s3, s13 s_mov_b32 s17, 0 s_and_saveexec_b32 s18, vcc_lo v_lshl_add_u32 v12, s16, 5, v0 s_and_not1_b32 s19, s13, exec_lo s_mov_b32 s17, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_le_i32_e64 s3, s11, v12 s_and_b32 s3, s3, exec_lo s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 s3, s19, s3 s_or_b32 exec_lo, exec_lo, s18 s_and_saveexec_b32 s18, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s3, exec_lo, s18 s_cbranch_execz .LBB0_6 s_and_not1_b32 s17, s17, exec_lo ds_store_b32 v5, v11 .LBB0_6: s_or_b32 exec_lo, exec_lo, s3 s_and_saveexec_b32 s18, s17 s_cbranch_execz .LBB0_8 s_add_i32 s3, s16, s6 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b32 s20, s3, 5 s_ashr_i32 s21, s20, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[20:21], s[20:21], 2 v_add_co_u32 v12, s3, v7, s20 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v13, s3, s21, v8, s3 global_load_b32 v12, v[12:13], off s_waitcnt vmcnt(0) v_cvt_f32_i32_e32 v12, v12 v_cvt_i32_f32_e32 v12, v12 ds_store_b32 v5, v12 .LBB0_8: s_or_b32 exec_lo, exec_lo, s18 s_mov_b32 s17, 0 s_mov_b32 s3, s5 s_and_saveexec_b32 s18, s2 v_lshl_add_u32 v12, s16, 5, v1 s_and_not1_b32 s19, s5, exec_lo s_mov_b32 s17, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_le_i32_e64 s3, s4, v12 s_and_b32 s3, s3, exec_lo s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 s3, s19, s3 s_or_b32 exec_lo, exec_lo, s18 s_and_saveexec_b32 s18, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s3, exec_lo, s18 s_cbranch_execz .LBB0_12 s_and_not1_b32 s17, s17, exec_lo ds_store_b32 v6, v11 .LBB0_12: s_or_b32 exec_lo, exec_lo, s3 s_and_saveexec_b32 s18, s17 s_cbranch_execz .LBB0_14 s_mul_i32 s3, s16, s12 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s3, s3, s14 s_lshl_b32 s20, s3, 5 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_ashr_i32 s21, s20, 31 s_lshl_b64 s[20:21], s[20:21], 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v12, s3, v9, s20 v_add_co_ci_u32_e64 v13, s3, s21, v10, s3 global_load_b32 v12, v[12:13], off s_waitcnt vmcnt(0) v_cvt_f32_i32_e32 v12, v12 s_delay_alu instid0(VALU_DEP_1) v_cvt_i32_f32_e32 v12, v12 ds_store_b32 v6, v12 .LBB0_14: s_or_b32 exec_lo, exec_lo, s18 v_mov_b32_e32 v12, v4 s_mov_b32 s3, 0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB0_15: v_add_nc_u32_e32 v13, s3, v3 s_add_i32 s3, s3, 4 ds_load_b32 v15, v12 ds_load_b32 v16, v13 v_add_nc_u32_e32 v12, 0x80, v12 s_cmpk_eq_i32 s3, 0x80 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[13:14], null, v15, v16, v[2:3] s_delay_alu instid0(VALU_DEP_1) v_mov_b32_e32 v2, v13 s_cbranch_scc0 .LBB0_15 s_add_i32 s16, s16, 1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_eq_u32 s16, s7 s_barrier buffer_gl0_inv s_cbranch_scc0 .LBB0_2 s_branch .LBB0_18 .LBB0_17: v_mov_b32_e32 v2, 0 .LBB0_18: s_clause 0x1 s_load_b64 s[2:3], s[0:1], 0x30 s_load_b32 s1, s[0:1], 0x40 s_lshr_b32 s0, s10, 16 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s0, 0xffff, s0 v_mad_u64_u32 v[3:4], null, s15, s0, v[1:2] s_and_b32 s0, 0xffff, s10 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_mad_u64_u32 v[4:5], null, s14, s0, v[0:1] s_waitcnt lgkmcnt(0) v_cmp_gt_i32_e32 vcc_lo, s2, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_gt_i32_e64 s0, s3, v4 s_and_b32 s0, vcc_lo, s0 s_delay_alu instid0(SALU_CYCLE_1) s_and_saveexec_b32 s2, s0 s_cbranch_execz .LBB0_20 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, v3, s1, v[4:5] 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, s8, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s9, v1, vcc_lo global_store_b32 v[0:1], v2, off .LBB0_20: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15MatrixMulKernel6MatrixS_S_ .amdhsa_group_segment_fixed_size 8192 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 328 .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 17 .amdhsa_next_free_sgpr 22 .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 _Z15MatrixMulKernel6MatrixS_S_, .Lfunc_end0-_Z15MatrixMulKernel6MatrixS_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: - .offset: 0 .size: 24 .value_kind: by_value - .offset: 24 .size: 24 .value_kind: by_value - .offset: 48 .size: 24 .value_kind: by_value - .offset: 72 .size: 4 .value_kind: hidden_block_count_x - .offset: 76 .size: 4 .value_kind: hidden_block_count_y - .offset: 80 .size: 4 .value_kind: hidden_block_count_z - .offset: 84 .size: 2 .value_kind: hidden_group_size_x - .offset: 86 .size: 2 .value_kind: hidden_group_size_y - .offset: 88 .size: 2 .value_kind: hidden_group_size_z - .offset: 90 .size: 2 .value_kind: hidden_remainder_x - .offset: 92 .size: 2 .value_kind: hidden_remainder_y - .offset: 94 .size: 2 .value_kind: hidden_remainder_z - .offset: 112 .size: 8 .value_kind: hidden_global_offset_x - .offset: 120 .size: 8 .value_kind: hidden_global_offset_y - .offset: 128 .size: 8 .value_kind: hidden_global_offset_z - .offset: 136 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 8192 .kernarg_segment_align: 8 .kernarg_segment_size: 328 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15MatrixMulKernel6MatrixS_S_ .private_segment_fixed_size: 0 .sgpr_count: 24 .sgpr_spill_count: 0 .symbol: _Z15MatrixMulKernel6MatrixS_S_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 17 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <iostream> #include <stdio.h> #include <hip/hip_runtime.h> #define MIN(a, b) (a<b?a:b) #define BLOCK_SIZE 32 struct Matrix { int height; int width; int *el; int stride; __host__ __device__ Matrix(int height, int width, int stride ): height(height), width(width),stride(stride){} __host__ __device__ Matrix(const Matrix &a): height(a.height), width(a.width),el(a.el),stride(a.stride){} __device__ float getElement(int row, int col){ return el[row * stride + col]; } __host__ __device__ void operator =(const Matrix &a){height = a.height; width = a.width; el = a.el; stride = a.stride;} __device__ void setElement(int row, int col, int val){ el[row * stride + col] = val; } __device__ Matrix cutMatrix(int row, int col){ Matrix tmp(BLOCK_SIZE, BLOCK_SIZE, stride); tmp.el = &el[stride * BLOCK_SIZE * row + BLOCK_SIZE * col]; return tmp; } __host__ void writeOut(){ for(int i = 0; i < height; i++){ std::cout<<"| "; for(int j = 0; j < width; j++){ std::cout<<el[i * width + j]<<" "; } std::cout<<"|"<<std::endl; } std::cout<<"\n"; } }; __global__ void MatrixMulKernel(Matrix a,Matrix b, Matrix c) { int cutRow = blockIdx.y ; int cutCol = blockIdx.x; int fRow = blockIdx.y * blockDim.y + threadIdx.y; int fCol = blockIdx.x * blockDim.x + threadIdx.x; int row = threadIdx.y; int col = threadIdx.x; int temp = 0; Matrix cutMatC = c.cutMatrix(cutRow, cutCol); for( int v = 0; v < ((a.width + BLOCK_SIZE - 1)/BLOCK_SIZE); ++v){ Matrix cutMatA = a.cutMatrix(cutRow, v); //cut input matrix vector which can fit inside block Matrix cutMatB = b.cutMatrix(v, cutCol); __shared__ int A[BLOCK_SIZE][BLOCK_SIZE]; //Matrix wchich can share memory between threads __shared__ int B[BLOCK_SIZE][BLOCK_SIZE]; if((row < a.height) && ((col + v * BLOCK_SIZE) < a.width)){ A[row][col] = cutMatA.getElement(row, col); } else{ A[row][col] = 0; } if((col < b.width) && ((row + v * BLOCK_SIZE) < b.height)){ B[row][col] = cutMatB.getElement(row, col); } else{ B[row][col] = 0; } __syncthreads(); //make sure that every metrix is filled for (int i = 0; i < BLOCK_SIZE; ++i){ temp += A[row][i] * B[i][col]; } __syncthreads(); } if(fRow < c.height && fCol < c.width) c.setElement(fRow, fCol, temp); } int main(){ int N = 37; Matrix a(N, N, N), g(N, N, N), ag(N, N, N); hipError_t err = hipSuccess; dim3 threadsPerBlock(BLOCK_SIZE,BLOCK_SIZE); dim3 blocksPerGrid((N + BLOCK_SIZE - 1) / BLOCK_SIZE ,(N + BLOCK_SIZE - 1) / BLOCK_SIZE ); hipMallocManaged(&a.el,N * N * sizeof(int)); hipMallocManaged(&g.el, N * N * sizeof(int)); hipMallocManaged(&ag.el, N * N * sizeof(int)); for(int i = 0; i < N; i++){ for(int j = 0; j<N; j++){ a.el[i*N+j] = 1; g.el[i*N+j] = 2; } } MatrixMulKernel<<<blocksPerGrid, threadsPerBlock>>>( a, g, ag); hipDeviceSynchronize(); if (err != hipSuccess){ fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", hipGetErrorString(err)); exit(EXIT_FAILURE); } //a.writeOut(); //g.writeOut(); ag.writeOut(); hipFree(a.el); hipFree(g.el); hipFree(ag.el); }
.text .file "matrixMultiplication.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z30__device_stub__MatrixMulKernel6MatrixS_S_ # -- Begin function _Z30__device_stub__MatrixMulKernel6MatrixS_S_ .p2align 4, 0x90 .type _Z30__device_stub__MatrixMulKernel6MatrixS_S_,@function _Z30__device_stub__MatrixMulKernel6MatrixS_S_: # @_Z30__device_stub__MatrixMulKernel6MatrixS_S_ .cfi_startproc # %bb.0: subq $72, %rsp .cfi_def_cfa_offset 80 movq %rdi, 48(%rsp) movq %rsi, 56(%rsp) movq %rdx, 64(%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 48(%rsp), %r9 movl $_Z15MatrixMulKernel6MatrixS_S_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $88, %rsp .cfi_adjust_cfa_offset -88 retq .Lfunc_end0: .size _Z30__device_stub__MatrixMulKernel6MatrixS_S_, .Lfunc_end0-_Z30__device_stub__MatrixMulKernel6MatrixS_S_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: subq $232, %rsp .cfi_def_cfa_offset 240 movabsq $158913789989, %rax # imm = 0x2500000025 movq %rax, 56(%rsp) movl $37, 72(%rsp) movq %rax, 32(%rsp) movl $37, 48(%rsp) movq %rax, 8(%rsp) movl $37, 24(%rsp) leaq 64(%rsp), %rdi movl $5476, %esi # imm = 0x1564 movl $1, %edx callq hipMallocManaged leaq 40(%rsp), %rdi movl $5476, %esi # imm = 0x1564 movl $1, %edx callq hipMallocManaged leaq 16(%rsp), %rdi movl $5476, %esi # imm = 0x1564 movl $1, %edx callq hipMallocManaged movq 64(%rsp), %rax xorl %ecx, %ecx movq 40(%rsp), %rdx .p2align 4, 0x90 .LBB1_1: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB1_2 Depth 2 xorl %esi, %esi .p2align 4, 0x90 .LBB1_2: # Parent Loop BB1_1 Depth=1 # => This Inner Loop Header: Depth=2 movl $1, (%rax,%rsi,4) movl $2, (%rdx,%rsi,4) incq %rsi cmpq $37, %rsi jne .LBB1_2 # %bb.3: # in Loop: Header=BB1_1 Depth=1 incq %rcx addq $148, %rdx addq $148, %rax cmpq $37, %rcx jne .LBB1_1 # %bb.4: movabsq $8589934594, %rdi # imm = 0x200000002 movabsq $137438953504, %rdx # imm = 0x2000000020 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_6 # %bb.5: movups 56(%rsp), %xmm0 movups %xmm0, 208(%rsp) movl 72(%rsp), %eax movl %eax, 224(%rsp) movups 32(%rsp), %xmm0 movups %xmm0, 184(%rsp) movl 48(%rsp), %eax movl %eax, 200(%rsp) movups 8(%rsp), %xmm0 movups %xmm0, 160(%rsp) movl 24(%rsp), %eax movl %eax, 176(%rsp) leaq 208(%rsp), %rax movq %rax, 128(%rsp) leaq 184(%rsp), %rax movq %rax, 136(%rsp) leaq 160(%rsp), %rax movq %rax, 144(%rsp) leaq 112(%rsp), %rdi leaq 96(%rsp), %rsi leaq 88(%rsp), %rdx leaq 80(%rsp), %rcx callq __hipPopCallConfiguration movq 112(%rsp), %rsi movl 120(%rsp), %edx movq 96(%rsp), %rcx movl 104(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z15MatrixMulKernel6MatrixS_S_, %edi pushq 80(%rsp) .cfi_adjust_cfa_offset 8 pushq 96(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_6: callq hipDeviceSynchronize leaq 8(%rsp), %rdi callq _ZN6Matrix8writeOutEv movq 64(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree xorl %eax, %eax addq $232, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .section .text._ZN6Matrix8writeOutEv,"axG",@progbits,_ZN6Matrix8writeOutEv,comdat .weak _ZN6Matrix8writeOutEv # -- Begin function _ZN6Matrix8writeOutEv .p2align 4, 0x90 .type _ZN6Matrix8writeOutEv,@function _ZN6Matrix8writeOutEv: # @_ZN6Matrix8writeOutEv .cfi_startproc # %bb.0: 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 cmpl $0, (%rdi) jle .LBB2_10 # %bb.1: # %.lr.ph11 movq %rdi, %rbx xorl %r15d, %r15d jmp .LBB2_2 .p2align 4, 0x90 .LBB2_8: # in Loop: Header=BB2_2 Depth=1 movq %r14, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r14), %rax movq %r14, %rdi movl $10, %esi callq *48(%rax) .LBB2_9: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit # in Loop: Header=BB2_2 Depth=1 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv incl %r15d cmpl (%rbx), %r15d jge .LBB2_10 .LBB2_2: # =>This Loop Header: Depth=1 # Child Loop BB2_4 Depth 2 movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $2, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 4(%rbx), %eax testl %eax, %eax jle .LBB2_5 # %bb.3: # %.lr.ph.preheader # in Loop: Header=BB2_2 Depth=1 xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_4: # %.lr.ph # Parent Loop BB2_2 Depth=1 # => This Inner Loop Header: Depth=2 movq 8(%rbx), %rcx imull %r15d, %eax cltq addq %r14, %rax movl (%rcx,%rax,4), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movl $.L.str.2, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 4(%rbx), %eax incq %r14 cmpl %eax, %r14d jl .LBB2_4 .LBB2_5: # %._crit_edge # in Loop: Header=BB2_2 Depth=1 movl $_ZSt4cout, %edi movl $.L.str.3, %esi movl $1, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %r14 testq %r14, %r14 je .LBB2_11 # %bb.6: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i # in Loop: Header=BB2_2 Depth=1 cmpb $0, 56(%r14) je .LBB2_8 # %bb.7: # in Loop: Header=BB2_2 Depth=1 movzbl 67(%r14), %eax jmp .LBB2_9 .LBB2_10: # %._crit_edge12 movl $_ZSt4cout, %edi movl $.L.str.4, %esi movl $1, %edx popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 jmp _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l # TAILCALL .LBB2_11: .cfi_def_cfa_offset 32 callq _ZSt16__throw_bad_castv .Lfunc_end2: .size _ZN6Matrix8writeOutEv, .Lfunc_end2-_ZN6Matrix8writeOutEv .cfi_endproc # -- End function .text .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 $_Z15MatrixMulKernel6MatrixS_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_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 _Z15MatrixMulKernel6MatrixS_S_,@object # @_Z15MatrixMulKernel6MatrixS_S_ .section .rodata,"a",@progbits .globl _Z15MatrixMulKernel6MatrixS_S_ .p2align 3, 0x0 _Z15MatrixMulKernel6MatrixS_S_: .quad _Z30__device_stub__MatrixMulKernel6MatrixS_S_ .size _Z15MatrixMulKernel6MatrixS_S_, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "| " .size .L.str.1, 3 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz " " .size .L.str.2, 2 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "|" .size .L.str.3, 2 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "\n" .size .L.str.4, 2 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z15MatrixMulKernel6MatrixS_S_" .size .L__unnamed_1, 31 .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__MatrixMulKernel6MatrixS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15MatrixMulKernel6MatrixS_S_ .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 : _Z15MatrixMulKernel6MatrixS_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 R9, SR_CTAID.X ; /* 0x0000000000097919 */ /* 0x000e220000002500 */ /*0020*/ MOV R4, c[0x0][0x164] ; /* 0x0000590000047a02 */ /* 0x000fe20000000f00 */ /*0030*/ ULDC.64 UR6, c[0x0][0x118] ; /* 0x0000460000067ab9 */ /* 0x000fe20000000a00 */ /*0040*/ HFMA2.MMA R23, -RZ, RZ, 0, 0 ; /* 0x00000000ff177435 */ /* 0x000fe200000001ff */ /*0050*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e220000002100 */ /*0060*/ ISETP.GE.AND P1, PT, R4, 0x1, PT ; /* 0x000000010400780c */ /* 0x000fc60003f26270 */ /*0070*/ S2R R2, SR_CTAID.Y ; /* 0x0000000000027919 */ /* 0x000e680000002600 */ /*0080*/ S2R R3, SR_TID.Y ; /* 0x0000000000037919 */ /* 0x000e620000002200 */ /*0090*/ IMAD R20, R9, c[0x0][0x0], R0 ; /* 0x0000000009147a24 */ /* 0x001fca00078e0200 */ /*00a0*/ ISETP.GE.AND P0, PT, R20, c[0x0][0x194], PT ; /* 0x0000650014007a0c */ /* 0x000fe20003f06270 */ /*00b0*/ IMAD R21, R2, c[0x0][0x4], R3 ; /* 0x0000010002157a24 */ /* 0x002fca00078e0203 */ /*00c0*/ ISETP.GE.OR P0, PT, R21, c[0x0][0x190], P0 ; /* 0x0000640015007a0c */ /* 0x000fe20000706670 */ /*00d0*/ @!P1 BRA 0x8a0 ; /* 0x000007c000009947 */ /* 0x000fd80003800000 */ /*00e0*/ IMAD R2, R2, c[0x0][0x170], RZ ; /* 0x00005c0002027a24 */ /* 0x000fe200078e02ff */ /*00f0*/ IADD3 R4, R4, 0x1f, RZ ; /* 0x0000001f04047810 */ /* 0x000fe20007ffe0ff */ /*0100*/ IMAD R5, R3.reuse, c[0x0][0x170], R0.reuse ; /* 0x00005c0003057a24 */ /* 0x140fe200078e0200 */ /*0110*/ SHF.L.U32 R19, R3.reuse, 0x7, RZ ; /* 0x0000000703137819 */ /* 0x040fe200000006ff */ /*0120*/ IMAD R18, R3, c[0x0][0x188], R0 ; /* 0x0000620003127a24 */ /* 0x000fe200078e0200 */ /*0130*/ SHF.L.U32 R2, R2, 0x5, RZ ; /* 0x0000000502027819 */ /* 0x000fe200000006ff */ /*0140*/ IMAD.MOV.U32 R23, RZ, RZ, RZ ; /* 0x000000ffff177224 */ /* 0x000fe200078e00ff */ /*0150*/ SHF.R.S32.HI R7, RZ, 0x1f, R4 ; /* 0x0000001fff077819 */ /* 0x000fe20000011404 */ /*0160*/ UMOV UR4, URZ ; /* 0x0000003f00047c82 */ /* 0x000fe20008000000 */ /*0170*/ SHF.R.S32.HI R6, RZ, 0x1f, R2 ; /* 0x0000001fff067819 */ /* 0x000fc40000011402 */ /*0180*/ IADD3 R8, P1, R2, R5, RZ ; /* 0x0000000502087210 */ /* 0x000fe40007f3e0ff */ /*0190*/ LEA.HI R16, R7, R4, RZ, 0x5 ; /* 0x0000000407107211 */ /* 0x000fe400078f28ff */ /*01a0*/ LEA.HI.X.SX32 R5, R5, R6, 0x1, P1 ; /* 0x0000000605057211 */ /* 0x000fe400008f0eff */ /*01b0*/ LEA R2, P1, R8.reuse, c[0x0][0x168], 0x2 ; /* 0x00005a0008027a11 */ /* 0x040fe400078210ff */ /*01c0*/ SHF.L.U32 R7, R9, 0x5, RZ ; /* 0x0000000509077819 */ /* 0x000fe400000006ff */ /*01d0*/ LEA.HI.X R5, R8, c[0x0][0x16c], R5, 0x2, P1 ; /* 0x00005b0008057a11 */ /* 0x000fc400008f1405 */ /*01e0*/ MOV R6, R0 ; /* 0x0000000000067202 */ /* 0x000fe40000000f00 */ /*01f0*/ MOV R4, R3 ; /* 0x0000000300047202 */ /* 0x000fe40000000f00 */ /*0200*/ LEA R17, R0, R19, 0x2 ; /* 0x0000001300117211 */ /* 0x000fe400078e10ff */ /*0210*/ SHF.R.S32.HI R16, RZ, 0x5, R16 ; /* 0x00000005ff107819 */ /* 0x000fe40000011410 */ /*0220*/ ISETP.GE.AND P1, PT, R4, c[0x0][0x178], PT ; /* 0x00005e0004007a0c */ /* 0x000fe40003f26270 */ /*0230*/ ISETP.GE.AND P2, PT, R6, c[0x0][0x164], PT ; /* 0x0000590006007a0c */ /* 0x000fe40003f46270 */ /*0240*/ ISETP.GE.OR P1, PT, R0, c[0x0][0x17c], P1 ; /* 0x00005f0000007a0c */ /* 0x000fc40000f26670 */ /*0250*/ ISETP.GE.OR P2, PT, R3, c[0x0][0x160], P2 ; /* 0x0000580003007a0c */ /* 0x000fe40001746670 */ /*0260*/ SHF.R.S32.HI R11, RZ, 0x1f, R7 ; /* 0x0000001fff0b7819 */ /* 0x000fd20000011407 */ /*0270*/ @!P1 IADD3 R9, P3, R18.reuse, R7, RZ ; /* 0x0000000712099210 */ /* 0x040fe40007f7e0ff */ /*0280*/ @!P2 MOV R10, R2 ; /* 0x00000002000aa202 */ /* 0x000fe40000000f00 */ /*0290*/ @!P1 LEA.HI.X.SX32 R12, R18, R11, 0x1, P3 ; /* 0x0000000b120c9211 */ /* 0x000fe400018f0eff */ /*02a0*/ @!P1 LEA R8, P3, R9.reuse, c[0x0][0x180], 0x2 ; /* 0x0000600009089a11 */ /* 0x040fe400078610ff */ /*02b0*/ @!P2 MOV R11, R5 ; /* 0x00000005000ba202 */ /* 0x000fe40000000f00 */ /*02c0*/ @!P1 LEA.HI.X R9, R9, c[0x0][0x184], R12, 0x2, P3 ; /* 0x0000610009099a11 */ /* 0x000fc600018f140c */ /*02d0*/ @!P2 LDG.E R10, [R10.64] ; /* 0x000000060a0aa981 */ /* 0x000ea8000c1e1900 */ /*02e0*/ @!P1 LDG.E R8, [R8.64] ; /* 0x0000000608089981 */ /* 0x000ee2000c1e1900 */ /*02f0*/ HFMA2.MMA R22, -RZ, RZ, 0, 0 ; /* 0x00000000ff167435 */ /* 0x000fe200000001ff */ /*0300*/ IMAD.MOV.U32 R28, RZ, RZ, RZ ; /* 0x000000ffff1c7224 */ /* 0x000fe200078e00ff */ /*0310*/ UIADD3 UR4, UR4, 0x1, URZ ; /* 0x0000000104047890 */ /* 0x000fe2000fffe03f */ /*0320*/ IADD3 R4, R4, 0x20, RZ ; /* 0x0000002004047810 */ /* 0x000fe40007ffe0ff */ /*0330*/ IADD3 R6, R6, 0x20, RZ ; /* 0x0000002006067810 */ /* 0x000fe20007ffe0ff */ /*0340*/ @!P2 I2F R26, R10 ; /* 0x0000000a001aa306 */ /* 0x004e300000201400 */ /*0350*/ @!P1 I2F R27, R8 ; /* 0x00000008001b9306 */ /* 0x008e700000201400 */ /*0360*/ @!P2 F2I.TRUNC.NTZ R22, R26 ; /* 0x0000001a0016a305 */ /* 0x001e22000020f100 */ /*0370*/ IADD3 R2, P2, R2, 0x80, RZ ; /* 0x0000008002027810 */ /* 0x000fc80007f5e0ff */ /*0380*/ IADD3.X R5, RZ, R5, RZ, P2, !PT ; /* 0x00000005ff057210 */ /* 0x000fc600017fe4ff */ /*0390*/ @!P1 F2I.TRUNC.NTZ R28, R27 ; /* 0x0000001b001c9305 */ /* 0x002e62000020f100 */ /*03a0*/ ISETP.LE.AND P1, PT, R16, UR4, PT ; /* 0x0000000410007c0c */ /* 0x000fe2000bf23270 */ /*03b0*/ STS [R17], R22 ; /* 0x0000001611007388 */ /* 0x001fe80000000800 */ /*03c0*/ STS [R17+0x1000], R28 ; /* 0x0010001c11007388 */ /* 0x002fe80000000800 */ /*03d0*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*03e0*/ LDS R11, [R0.X4+0x1000] ; /* 0x00100000000b7984 */ /* 0x000fe80000004800 */ /*03f0*/ LDS.128 R12, [R19] ; /* 0x00000000130c7984 */ /* 0x000e280000000c00 */ /*0400*/ LDS R29, [R0.X4+0x1080] ; /* 0x00108000001d7984 */ /* 0x000e680000004800 */ /*0410*/ LDS R25, [R0.X4+0x1100] ; /* 0x0011000000197984 */ /* 0x000ea80000004800 */ /*0420*/ LDS R24, [R0.X4+0x1180] ; /* 0x0011800000187984 */ /* 0x000ee80000004800 */ /*0430*/ LDS R22, [R0.X4+0x1280] ; /* 0x0012800000167984 */ /* 0x000fe80000004800 */ /*0440*/ LDS R26, [R0.X4+0x1b80] ; /* 0x001b8000001a7984 */ /* 0x000fe80000004800 */ /*0450*/ LDS R27, [R0.X4+0x1c00] ; /* 0x001c0000001b7984 */ /* 0x000fe20000004800 */ /*0460*/ IMAD R12, R11, R12, R23 ; /* 0x0000000c0b0c7224 */ /* 0x001fc600078e0217 */ /*0470*/ LDS R23, [R0.X4+0x1200] ; /* 0x0012000000177984 */ /* 0x000fe20000004800 */ /*0480*/ IMAD R12, R29, R13, R12 ; /* 0x0000000d1d0c7224 */ /* 0x002fc600078e020c */ /*0490*/ LDS.128 R8, [R19+0x10] ; /* 0x0000100013087984 */ /* 0x000e220000000c00 */ /*04a0*/ IMAD R12, R25, R14, R12 ; /* 0x0000000e190c7224 */ /* 0x004fc600078e020c */ /*04b0*/ LDS R25, [R0.X4+0x1300] ; /* 0x0013000000197984 */ /* 0x000e620000004800 */ /*04c0*/ IMAD R12, R24, R15, R12 ; /* 0x0000000f180c7224 */ /* 0x008fc600078e020c */ /*04d0*/ LDS R24, [R0.X4+0x1380] ; /* 0x0013800000187984 */ /* 0x000ea20000004800 */ /*04e0*/ IMAD R8, R23, R8, R12 ; /* 0x0000000817087224 */ /* 0x001fc600078e020c */ /*04f0*/ LDS R23, [R0.X4+0x1400] ; /* 0x0014000000177984 */ /* 0x000fe20000004800 */ /*0500*/ IMAD R8, R22, R9, R8 ; /* 0x0000000916087224 */ /* 0x000fc600078e0208 */ /*0510*/ LDS.128 R12, [R19+0x20] ; /* 0x00002000130c7984 */ /* 0x000e220000000c00 */ /*0520*/ IMAD R8, R25, R10, R8 ; /* 0x0000000a19087224 */ /* 0x002fc600078e0208 */ /*0530*/ LDS R22, [R0.X4+0x1480] ; /* 0x0014800000167984 */ /* 0x000e620000004800 */ /*0540*/ IMAD R8, R24, R11, R8 ; /* 0x0000000b18087224 */ /* 0x004fc600078e0208 */ /*0550*/ LDS R25, [R0.X4+0x1500] ; /* 0x0015000000197984 */ /* 0x000ea80000004800 */ /*0560*/ LDS R24, [R0.X4+0x1580] ; /* 0x0015800000187984 */ /* 0x000ee20000004800 */ /*0570*/ IMAD R12, R23, R12, R8 ; /* 0x0000000c170c7224 */ /* 0x001fc600078e0208 */ /*0580*/ LDS R23, [R0.X4+0x1600] ; /* 0x0016000000177984 */ /* 0x000fe20000004800 */ /*0590*/ IMAD R12, R22, R13, R12 ; /* 0x0000000d160c7224 */ /* 0x002fc600078e020c */ /*05a0*/ LDS.128 R8, [R19+0x30] ; /* 0x0000300013087984 */ /* 0x000e220000000c00 */ /*05b0*/ IMAD R12, R25, R14, R12 ; /* 0x0000000e190c7224 */ /* 0x004fc600078e020c */ /*05c0*/ LDS R22, [R0.X4+0x1680] ; /* 0x0016800000167984 */ /* 0x000e620000004800 */ /*05d0*/ IMAD R12, R24, R15, R12 ; /* 0x0000000f180c7224 */ /* 0x008fc600078e020c */ /*05e0*/ LDS R25, [R0.X4+0x1700] ; /* 0x0017000000197984 */ /* 0x000ea80000004800 */ /*05f0*/ LDS R24, [R0.X4+0x1780] ; /* 0x0017800000187984 */ /* 0x000ee20000004800 */ /*0600*/ IMAD R8, R23, R8, R12 ; /* 0x0000000817087224 */ /* 0x001fc600078e020c */ /*0610*/ LDS R23, [R0.X4+0x1800] ; /* 0x0018000000177984 */ /* 0x000fe20000004800 */ /*0620*/ IMAD R8, R22, R9, R8 ; /* 0x0000000916087224 */ /* 0x002fc600078e0208 */ /*0630*/ LDS.128 R12, [R19+0x40] ; /* 0x00004000130c7984 */ /* 0x000e220000000c00 */ /*0640*/ IMAD R8, R25, R10, R8 ; /* 0x0000000a19087224 */ /* 0x004fc600078e0208 */ /*0650*/ LDS R22, [R0.X4+0x1880] ; /* 0x0018800000167984 */ /* 0x000e620000004800 */ /*0660*/ IMAD R8, R24, R11, R8 ; /* 0x0000000b18087224 */ /* 0x008fc600078e0208 */ /*0670*/ LDS R25, [R0.X4+0x1900] ; /* 0x0019000000197984 */ /* 0x000ea80000004800 */ /*0680*/ LDS R24, [R0.X4+0x1980] ; /* 0x0019800000187984 */ /* 0x000ee20000004800 */ /*0690*/ IMAD R12, R23, R12, R8 ; /* 0x0000000c170c7224 */ /* 0x001fc600078e0208 */ /*06a0*/ LDS R23, [R0.X4+0x1a00] ; /* 0x001a000000177984 */ /* 0x000fe20000004800 */ /*06b0*/ IMAD R12, R22, R13, R12 ; /* 0x0000000d160c7224 */ /* 0x002fc600078e020c */ /*06c0*/ LDS.128 R8, [R19+0x50] ; /* 0x0000500013087984 */ /* 0x000e220000000c00 */ /*06d0*/ IMAD R12, R25, R14, R12 ; /* 0x0000000e190c7224 */ /* 0x004fc600078e020c */ /*06e0*/ LDS R22, [R0.X4+0x1a80] ; /* 0x001a800000167984 */ /* 0x000e620000004800 */ /*06f0*/ IMAD R12, R24, R15, R12 ; /* 0x0000000f180c7224 */ /* 0x008fc600078e020c */ /*0700*/ LDS R25, [R0.X4+0x1b00] ; /* 0x001b000000197984 */ /* 0x000ea80000004800 */ /*0710*/ LDS R24, [R0.X4+0x1c80] ; /* 0x001c800000187984 */ /* 0x000fe20000004800 */ /*0720*/ IMAD R8, R23, R8, R12 ; /* 0x0000000817087224 */ /* 0x001fc600078e020c */ /*0730*/ LDS.128 R12, [R19+0x60] ; /* 0x00006000130c7984 */ /* 0x000e220000000c00 */ /*0740*/ IMAD R8, R22, R9, R8 ; /* 0x0000000916087224 */ /* 0x002fc600078e0208 */ /*0750*/ LDS R23, [R0.X4+0x1d00] ; /* 0x001d000000177984 */ /* 0x000e620000004800 */ /*0760*/ IMAD R8, R25, R10, R8 ; /* 0x0000000a19087224 */ /* 0x004fc600078e0208 */ /*0770*/ LDS R22, [R0.X4+0x1d80] ; /* 0x001d800000167984 */ /* 0x000ea20000004800 */ /*0780*/ IMAD R8, R26, R11, R8 ; /* 0x0000000b1a087224 */ /* 0x000fc600078e0208 */ /*0790*/ LDS R25, [R0.X4+0x1e00] ; /* 0x001e000000197984 */ /* 0x000fe80000004800 */ /*07a0*/ LDS R26, [R0.X4+0x1e80] ; /* 0x001e8000001a7984 */ /* 0x000fe20000004800 */ /*07b0*/ IMAD R12, R27, R12, R8 ; /* 0x0000000c1b0c7224 */ /* 0x001fc600078e0208 */ /*07c0*/ LDS.128 R8, [R19+0x70] ; /* 0x0000700013087984 */ /* 0x000e220000000c00 */ /*07d0*/ IMAD R24, R24, R13, R12 ; /* 0x0000000d18187224 */ /* 0x000fc600078e020c */ /*07e0*/ LDS R13, [R0.X4+0x1f00] ; /* 0x001f0000000d7984 */ /* 0x000ee20000004800 */ /*07f0*/ IMAD R14, R23, R14, R24 ; /* 0x0000000e170e7224 */ /* 0x002fc600078e0218 */ /*0800*/ LDS R12, [R0.X4+0x1f80] ; /* 0x001f8000000c7984 */ /* 0x000e620000004800 */ /*0810*/ IMAD R14, R22, R15, R14 ; /* 0x0000000f160e7224 */ /* 0x004fc800078e020e */ /*0820*/ IMAD R8, R25, R8, R14 ; /* 0x0000000819087224 */ /* 0x001fc800078e020e */ /*0830*/ IMAD R8, R26, R9, R8 ; /* 0x000000091a087224 */ /* 0x000fc800078e0208 */ /*0840*/ IMAD R8, R13, R10, R8 ; /* 0x0000000a0d087224 */ /* 0x008fe200078e0208 */ /*0850*/ MOV R10, c[0x0][0x188] ; /* 0x00006200000a7a02 */ /* 0x000fc60000000f00 */ /*0860*/ IMAD R23, R12, R11, R8 ; /* 0x0000000b0c177224 */ /* 0x002fe200078e0208 */ /*0870*/ LEA R7, R10, R7, 0x5 ; /* 0x000000070a077211 */ /* 0x000fe200078e28ff */ /*0880*/ BAR.SYNC.DEFER_BLOCKING 0x0 ; /* 0x0000000000007b1d */ /* 0x000fec0000010000 */ /*0890*/ @!P1 BRA 0x220 ; /* 0xfffff98000009947 */ /* 0x000fea000383ffff */ /*08a0*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*08b0*/ HFMA2.MMA R3, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff037435 */ /* 0x000fe200000001ff */ /*08c0*/ IMAD R2, R21, c[0x0][0x1a0], R20 ; /* 0x0000680015027a24 */ /* 0x000fd200078e0214 */ /*08d0*/ IMAD.WIDE R2, R2, R3, c[0x0][0x198] ; /* 0x0000660002027625 */ /* 0x000fca00078e0203 */ /*08e0*/ STG.E [R2.64], R23 ; /* 0x0000001702007986 */ /* 0x000fe2000c101906 */ /*08f0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0900*/ BRA 0x900; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ /*0980*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0990*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*09f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z15MatrixMulKernel6MatrixS_S_ .globl _Z15MatrixMulKernel6MatrixS_S_ .p2align 8 .type _Z15MatrixMulKernel6MatrixS_S_,@function _Z15MatrixMulKernel6MatrixS_S_: s_clause 0x2 s_load_b32 s11, s[0:1], 0x4 s_load_b64 s[8:9], s[0:1], 0x38 s_load_b32 s10, s[0:1], 0x54 v_bfe_u32 v1, v0, 10, 10 v_and_b32_e32 v0, 0x3ff, v0 s_waitcnt lgkmcnt(0) s_cmp_lt_i32 s11, 1 s_cbranch_scc1 .LBB0_17 s_clause 0x4 s_load_b32 s18, s[0:1], 0x10 s_load_b32 s12, s[0:1], 0x28 s_load_b32 s2, s[0:1], 0x0 s_load_b128 s[4:7], s[0:1], 0x18 s_load_b64 s[16:17], s[0:1], 0x8 v_dual_mov_b32 v2, 0 :: v_dual_lshlrev_b32 v5, 2, v0 s_add_i32 s3, s11, 31 v_lshlrev_b32_e32 v3, 7, v1 s_lshr_b32 s19, s3, 5 s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) v_or_b32_e32 v4, 0x1000, v5 v_mov_b32_e32 v11, 0 v_add_nc_u32_e32 v5, v3, v5 s_delay_alu instid0(VALU_DEP_3) v_add_nc_u32_e32 v6, v4, v3 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[7:8], null, s18, v1, v[0:1] v_mad_u64_u32 v[9:10], null, s12, v1, v[0:1] v_cmp_gt_i32_e32 vcc_lo, s2, v1 v_cmp_le_i32_e64 s13, s2, v1 v_cmp_gt_i32_e64 s2, s5, v0 v_cmp_le_i32_e64 s5, s5, v0 v_ashrrev_i32_e32 v8, 31, v7 v_ashrrev_i32_e32 v10, 31, v9 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[7:8], 2, v[7:8] v_lshlrev_b64 v[9:10], 2, v[9:10] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v7, s3, s16, v7 v_add_co_ci_u32_e64 v8, s3, s17, v8, s3 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v9, s3, s6, v9 v_add_co_ci_u32_e64 v10, s3, s7, v10, s3 s_mul_i32 s6, s18, s15 s_max_i32 s7, s19, 1 s_mov_b32 s16, 0 .LBB0_2: s_mov_b32 s3, s13 s_mov_b32 s17, 0 s_and_saveexec_b32 s18, vcc_lo v_lshl_add_u32 v12, s16, 5, v0 s_and_not1_b32 s19, s13, exec_lo s_mov_b32 s17, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_le_i32_e64 s3, s11, v12 s_and_b32 s3, s3, exec_lo s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 s3, s19, s3 s_or_b32 exec_lo, exec_lo, s18 s_and_saveexec_b32 s18, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s3, exec_lo, s18 s_cbranch_execz .LBB0_6 s_and_not1_b32 s17, s17, exec_lo ds_store_b32 v5, v11 .LBB0_6: s_or_b32 exec_lo, exec_lo, s3 s_and_saveexec_b32 s18, s17 s_cbranch_execz .LBB0_8 s_add_i32 s3, s16, s6 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b32 s20, s3, 5 s_ashr_i32 s21, s20, 31 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_lshl_b64 s[20:21], s[20:21], 2 v_add_co_u32 v12, s3, v7, s20 s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1) v_add_co_ci_u32_e64 v13, s3, s21, v8, s3 global_load_b32 v12, v[12:13], off s_waitcnt vmcnt(0) v_cvt_f32_i32_e32 v12, v12 v_cvt_i32_f32_e32 v12, v12 ds_store_b32 v5, v12 .LBB0_8: s_or_b32 exec_lo, exec_lo, s18 s_mov_b32 s17, 0 s_mov_b32 s3, s5 s_and_saveexec_b32 s18, s2 v_lshl_add_u32 v12, s16, 5, v1 s_and_not1_b32 s19, s5, exec_lo s_mov_b32 s17, exec_lo s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_le_i32_e64 s3, s4, v12 s_and_b32 s3, s3, exec_lo s_delay_alu instid0(SALU_CYCLE_1) s_or_b32 s3, s19, s3 s_or_b32 exec_lo, exec_lo, s18 s_and_saveexec_b32 s18, s3 s_delay_alu instid0(SALU_CYCLE_1) s_xor_b32 s3, exec_lo, s18 s_cbranch_execz .LBB0_12 s_and_not1_b32 s17, s17, exec_lo ds_store_b32 v6, v11 .LBB0_12: s_or_b32 exec_lo, exec_lo, s3 s_and_saveexec_b32 s18, s17 s_cbranch_execz .LBB0_14 s_mul_i32 s3, s16, s12 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_add_i32 s3, s3, s14 s_lshl_b32 s20, s3, 5 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_ashr_i32 s21, s20, 31 s_lshl_b64 s[20:21], s[20:21], 2 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_add_co_u32 v12, s3, v9, s20 v_add_co_ci_u32_e64 v13, s3, s21, v10, s3 global_load_b32 v12, v[12:13], off s_waitcnt vmcnt(0) v_cvt_f32_i32_e32 v12, v12 s_delay_alu instid0(VALU_DEP_1) v_cvt_i32_f32_e32 v12, v12 ds_store_b32 v6, v12 .LBB0_14: s_or_b32 exec_lo, exec_lo, s18 v_mov_b32_e32 v12, v4 s_mov_b32 s3, 0 s_waitcnt lgkmcnt(0) s_barrier buffer_gl0_inv .LBB0_15: v_add_nc_u32_e32 v13, s3, v3 s_add_i32 s3, s3, 4 ds_load_b32 v15, v12 ds_load_b32 v16, v13 v_add_nc_u32_e32 v12, 0x80, v12 s_cmpk_eq_i32 s3, 0x80 s_waitcnt lgkmcnt(0) v_mad_u64_u32 v[13:14], null, v15, v16, v[2:3] s_delay_alu instid0(VALU_DEP_1) v_mov_b32_e32 v2, v13 s_cbranch_scc0 .LBB0_15 s_add_i32 s16, s16, 1 s_delay_alu instid0(SALU_CYCLE_1) s_cmp_eq_u32 s16, s7 s_barrier buffer_gl0_inv s_cbranch_scc0 .LBB0_2 s_branch .LBB0_18 .LBB0_17: v_mov_b32_e32 v2, 0 .LBB0_18: s_clause 0x1 s_load_b64 s[2:3], s[0:1], 0x30 s_load_b32 s1, s[0:1], 0x40 s_lshr_b32 s0, s10, 16 s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1) s_and_b32 s0, 0xffff, s0 v_mad_u64_u32 v[3:4], null, s15, s0, v[1:2] s_and_b32 s0, 0xffff, s10 s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_2) v_mad_u64_u32 v[4:5], null, s14, s0, v[0:1] s_waitcnt lgkmcnt(0) v_cmp_gt_i32_e32 vcc_lo, s2, v3 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1) v_cmp_gt_i32_e64 s0, s3, v4 s_and_b32 s0, vcc_lo, s0 s_delay_alu instid0(SALU_CYCLE_1) s_and_saveexec_b32 s2, s0 s_cbranch_execz .LBB0_20 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1) v_mad_u64_u32 v[0:1], null, v3, s1, v[4:5] 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, s8, v0 s_delay_alu instid0(VALU_DEP_2) v_add_co_ci_u32_e32 v1, vcc_lo, s9, v1, vcc_lo global_store_b32 v[0:1], v2, off .LBB0_20: s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z15MatrixMulKernel6MatrixS_S_ .amdhsa_group_segment_fixed_size 8192 .amdhsa_private_segment_fixed_size 0 .amdhsa_kernarg_size 328 .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 17 .amdhsa_next_free_sgpr 22 .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 _Z15MatrixMulKernel6MatrixS_S_, .Lfunc_end0-_Z15MatrixMulKernel6MatrixS_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: - .offset: 0 .size: 24 .value_kind: by_value - .offset: 24 .size: 24 .value_kind: by_value - .offset: 48 .size: 24 .value_kind: by_value - .offset: 72 .size: 4 .value_kind: hidden_block_count_x - .offset: 76 .size: 4 .value_kind: hidden_block_count_y - .offset: 80 .size: 4 .value_kind: hidden_block_count_z - .offset: 84 .size: 2 .value_kind: hidden_group_size_x - .offset: 86 .size: 2 .value_kind: hidden_group_size_y - .offset: 88 .size: 2 .value_kind: hidden_group_size_z - .offset: 90 .size: 2 .value_kind: hidden_remainder_x - .offset: 92 .size: 2 .value_kind: hidden_remainder_y - .offset: 94 .size: 2 .value_kind: hidden_remainder_z - .offset: 112 .size: 8 .value_kind: hidden_global_offset_x - .offset: 120 .size: 8 .value_kind: hidden_global_offset_y - .offset: 128 .size: 8 .value_kind: hidden_global_offset_z - .offset: 136 .size: 2 .value_kind: hidden_grid_dims .group_segment_fixed_size: 8192 .kernarg_segment_align: 8 .kernarg_segment_size: 328 .language: OpenCL C .language_version: - 2 - 0 .max_flat_workgroup_size: 1024 .name: _Z15MatrixMulKernel6MatrixS_S_ .private_segment_fixed_size: 0 .sgpr_count: 24 .sgpr_spill_count: 0 .symbol: _Z15MatrixMulKernel6MatrixS_S_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 17 .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_00146033_00000000-6_matrixMultiplication.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3683: .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 .LFE3683: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata._ZN6Matrix8writeOutEv.str1.1,"aMS",@progbits,1 .LC0: .string "| " .LC1: .string " " .LC2: .string "|" .LC3: .string "\n" .section .text._ZN6Matrix8writeOutEv,"axG",@progbits,_ZN6Matrix8writeOutEv,comdat .align 2 .weak _ZN6Matrix8writeOutEv .type _ZN6Matrix8writeOutEv, @function _ZN6Matrix8writeOutEv: .LFB3679: .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 $8, %rsp .cfi_def_cfa_offset 64 cmpl $0, (%rdi) jle .L4 movq %rdi, %rbp movl $0, %r13d leaq .LC0(%rip), %r15 leaq _ZSt4cout(%rip), %r12 leaq .LC1(%rip), %r14 jmp .L10 .L14: call _ZSt16__throw_bad_castv@PLT .L8: movq %rbx, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%rbx), %rax movl $10, %esi movq %rbx, %rdi call *48(%rax) movl %eax, %esi .L9: movsbl %sil, %esi movq %r12, %rdi call _ZNSo3putEc@PLT movq %rax, %rdi call _ZNSo5flushEv@PLT addl $1, %r13d cmpl %r13d, 0(%rbp) jle .L4 .L10: movl $2, %edx movq %r15, %rsi movq %r12, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movl 4(%rbp), %eax testl %eax, %eax jle .L5 movl $0, %ebx .L6: imull %r13d, %eax addl %ebx, %eax cltq movq 8(%rbp), %rdx movl (%rdx,%rax,4), %esi movq %r12, %rdi call _ZNSolsEi@PLT movq %rax, %rdi movl $1, %edx movq %r14, %rsi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT addl $1, %ebx movl 4(%rbp), %eax cmpl %ebx, %eax jg .L6 .L5: movl $1, %edx leaq .LC2(%rip), %rsi movq %r12, %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT movq (%r12), %rax movq -24(%rax), %rax movq 240(%r12,%rax), %rbx testq %rbx, %rbx je .L14 cmpb $0, 56(%rbx) je .L8 movzbl 67(%rbx), %esi jmp .L9 .L4: movl $1, %edx leaq .LC3(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT addq $8, %rsp .cfi_def_cfa_offset 56 popq %rbx .cfi_def_cfa_offset 48 popq %rbp .cfi_def_cfa_offset 40 popq %r12 .cfi_def_cfa_offset 32 popq %r13 .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3679: .size _ZN6Matrix8writeOutEv, .-_ZN6Matrix8writeOutEv .text .globl _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ .type _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_, @function _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_: .LFB3705: .cfi_startproc endbr64 subq $104, %rsp .cfi_def_cfa_offset 112 movq %fs:40, %rax movq %rax, 88(%rsp) xorl %eax, %eax movq %rdi, 64(%rsp) movq %rsi, 72(%rsp) movq %rdx, 80(%rsp) movl $1, 16(%rsp) movl $1, 20(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $1, 36(%rsp) leaq 8(%rsp), %rcx movq %rsp, %rdx leaq 28(%rsp), %rsi leaq 16(%rsp), %rdi call __cudaPopCallConfiguration@PLT testl %eax, %eax je .L19 .L15: movq 88(%rsp), %rax subq %fs:40, %rax jne .L20 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L19: .cfi_restore_state pushq 8(%rsp) .cfi_def_cfa_offset 120 pushq 8(%rsp) .cfi_def_cfa_offset 128 leaq 80(%rsp), %r9 movq 44(%rsp), %rcx movl 52(%rsp), %r8d movq 32(%rsp), %rsi movl 40(%rsp), %edx leaq _Z15MatrixMulKernel6MatrixS_S_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L15 .L20: call __stack_chk_fail@PLT .cfi_endproc .LFE3705: .size _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_, .-_Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ .globl _Z15MatrixMulKernel6MatrixS_S_ .type _Z15MatrixMulKernel6MatrixS_S_, @function _Z15MatrixMulKernel6MatrixS_S_: .LFB3706: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3706: .size _Z15MatrixMulKernel6MatrixS_S_, .-_Z15MatrixMulKernel6MatrixS_S_ .globl main .type main, @function main: .LFB3680: .cfi_startproc endbr64 subq $232, %rsp .cfi_def_cfa_offset 240 movq %fs:40, %rax movq %rax, 216(%rsp) xorl %eax, %eax movl $37, 32(%rsp) movl $37, 36(%rsp) movl $37, 48(%rsp) movl $37, 64(%rsp) movl $37, 68(%rsp) movl $37, 80(%rsp) movl $37, 96(%rsp) movl $37, 100(%rsp) movl $37, 112(%rsp) movl $32, 8(%rsp) movl $32, 12(%rsp) movl $1, 16(%rsp) movl $2, 20(%rsp) movl $2, 24(%rsp) movl $1, 28(%rsp) leaq 40(%rsp), %rdi movl $1, %edx movl $5476, %esi call cudaMallocManaged@PLT leaq 72(%rsp), %rdi movl $1, %edx movl $5476, %esi call cudaMallocManaged@PLT leaq 104(%rsp), %rdi movl $1, %edx movl $5476, %esi call cudaMallocManaged@PLT movl $148, %ecx .L24: leaq -148(%rcx), %rax .L25: movq 40(%rsp), %rdx movl $1, (%rdx,%rax) movq 72(%rsp), %rdx movl $2, (%rdx,%rax) addq $4, %rax cmpq %rcx, %rax jne .L25 addq $148, %rcx cmpq $5624, %rcx jne .L24 movl 16(%rsp), %ecx movl $0, %r9d movl $0, %r8d movq 8(%rsp), %rdx movq 20(%rsp), %rdi movl 28(%rsp), %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L31 .L27: call cudaDeviceSynchronize@PLT leaq 96(%rsp), %rdi call _ZN6Matrix8writeOutEv movq 40(%rsp), %rdi call cudaFree@PLT movq 72(%rsp), %rdi call cudaFree@PLT movq 104(%rsp), %rdi call cudaFree@PLT movq 216(%rsp), %rax subq %fs:40, %rax jne .L32 movl $0, %eax addq $232, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L31: .cfi_restore_state movl 96(%rsp), %eax movl %eax, 192(%rsp) movl 100(%rsp), %eax movl %eax, 196(%rsp) movq 104(%rsp), %rax movq %rax, 200(%rsp) movl 112(%rsp), %eax movl %eax, 208(%rsp) movl 64(%rsp), %eax movl %eax, 160(%rsp) movl 68(%rsp), %eax movl %eax, 164(%rsp) movq 72(%rsp), %rax movq %rax, 168(%rsp) movl 80(%rsp), %eax movl %eax, 176(%rsp) movl 32(%rsp), %eax movl %eax, 128(%rsp) movl 36(%rsp), %eax movl %eax, 132(%rsp) movq 40(%rsp), %rax movq %rax, 136(%rsp) movl 48(%rsp), %eax movl %eax, 144(%rsp) leaq 192(%rsp), %rdx leaq 160(%rsp), %rsi leaq 128(%rsp), %rdi call _Z44__device_stub__Z15MatrixMulKernel6MatrixS_S_R6MatrixS0_S0_ jmp .L27 .L32: call __stack_chk_fail@PLT .cfi_endproc .LFE3680: .size main, .-main .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "_Z15MatrixMulKernel6MatrixS_S_" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3708: .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 _Z15MatrixMulKernel6MatrixS_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 .LFE3708: .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 "matrixMultiplication.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z30__device_stub__MatrixMulKernel6MatrixS_S_ # -- Begin function _Z30__device_stub__MatrixMulKernel6MatrixS_S_ .p2align 4, 0x90 .type _Z30__device_stub__MatrixMulKernel6MatrixS_S_,@function _Z30__device_stub__MatrixMulKernel6MatrixS_S_: # @_Z30__device_stub__MatrixMulKernel6MatrixS_S_ .cfi_startproc # %bb.0: subq $72, %rsp .cfi_def_cfa_offset 80 movq %rdi, 48(%rsp) movq %rsi, 56(%rsp) movq %rdx, 64(%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 48(%rsp), %r9 movl $_Z15MatrixMulKernel6MatrixS_S_, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $88, %rsp .cfi_adjust_cfa_offset -88 retq .Lfunc_end0: .size _Z30__device_stub__MatrixMulKernel6MatrixS_S_, .Lfunc_end0-_Z30__device_stub__MatrixMulKernel6MatrixS_S_ .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .cfi_startproc # %bb.0: subq $232, %rsp .cfi_def_cfa_offset 240 movabsq $158913789989, %rax # imm = 0x2500000025 movq %rax, 56(%rsp) movl $37, 72(%rsp) movq %rax, 32(%rsp) movl $37, 48(%rsp) movq %rax, 8(%rsp) movl $37, 24(%rsp) leaq 64(%rsp), %rdi movl $5476, %esi # imm = 0x1564 movl $1, %edx callq hipMallocManaged leaq 40(%rsp), %rdi movl $5476, %esi # imm = 0x1564 movl $1, %edx callq hipMallocManaged leaq 16(%rsp), %rdi movl $5476, %esi # imm = 0x1564 movl $1, %edx callq hipMallocManaged movq 64(%rsp), %rax xorl %ecx, %ecx movq 40(%rsp), %rdx .p2align 4, 0x90 .LBB1_1: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB1_2 Depth 2 xorl %esi, %esi .p2align 4, 0x90 .LBB1_2: # Parent Loop BB1_1 Depth=1 # => This Inner Loop Header: Depth=2 movl $1, (%rax,%rsi,4) movl $2, (%rdx,%rsi,4) incq %rsi cmpq $37, %rsi jne .LBB1_2 # %bb.3: # in Loop: Header=BB1_1 Depth=1 incq %rcx addq $148, %rdx addq $148, %rax cmpq $37, %rcx jne .LBB1_1 # %bb.4: movabsq $8589934594, %rdi # imm = 0x200000002 movabsq $137438953504, %rdx # imm = 0x2000000020 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_6 # %bb.5: movups 56(%rsp), %xmm0 movups %xmm0, 208(%rsp) movl 72(%rsp), %eax movl %eax, 224(%rsp) movups 32(%rsp), %xmm0 movups %xmm0, 184(%rsp) movl 48(%rsp), %eax movl %eax, 200(%rsp) movups 8(%rsp), %xmm0 movups %xmm0, 160(%rsp) movl 24(%rsp), %eax movl %eax, 176(%rsp) leaq 208(%rsp), %rax movq %rax, 128(%rsp) leaq 184(%rsp), %rax movq %rax, 136(%rsp) leaq 160(%rsp), %rax movq %rax, 144(%rsp) leaq 112(%rsp), %rdi leaq 96(%rsp), %rsi leaq 88(%rsp), %rdx leaq 80(%rsp), %rcx callq __hipPopCallConfiguration movq 112(%rsp), %rsi movl 120(%rsp), %edx movq 96(%rsp), %rcx movl 104(%rsp), %r8d leaq 128(%rsp), %r9 movl $_Z15MatrixMulKernel6MatrixS_S_, %edi pushq 80(%rsp) .cfi_adjust_cfa_offset 8 pushq 96(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $16, %rsp .cfi_adjust_cfa_offset -16 .LBB1_6: callq hipDeviceSynchronize leaq 8(%rsp), %rdi callq _ZN6Matrix8writeOutEv movq 64(%rsp), %rdi callq hipFree movq 40(%rsp), %rdi callq hipFree movq 16(%rsp), %rdi callq hipFree xorl %eax, %eax addq $232, %rsp .cfi_def_cfa_offset 8 retq .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc # -- End function .section .text._ZN6Matrix8writeOutEv,"axG",@progbits,_ZN6Matrix8writeOutEv,comdat .weak _ZN6Matrix8writeOutEv # -- Begin function _ZN6Matrix8writeOutEv .p2align 4, 0x90 .type _ZN6Matrix8writeOutEv,@function _ZN6Matrix8writeOutEv: # @_ZN6Matrix8writeOutEv .cfi_startproc # %bb.0: 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 cmpl $0, (%rdi) jle .LBB2_10 # %bb.1: # %.lr.ph11 movq %rdi, %rbx xorl %r15d, %r15d jmp .LBB2_2 .p2align 4, 0x90 .LBB2_8: # in Loop: Header=BB2_2 Depth=1 movq %r14, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv movq (%r14), %rax movq %r14, %rdi movl $10, %esi callq *48(%rax) .LBB2_9: # %_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_.exit # in Loop: Header=BB2_2 Depth=1 movsbl %al, %esi movl $_ZSt4cout, %edi callq _ZNSo3putEc movq %rax, %rdi callq _ZNSo5flushEv incl %r15d cmpl (%rbx), %r15d jge .LBB2_10 .LBB2_2: # =>This Loop Header: Depth=1 # Child Loop BB2_4 Depth 2 movl $_ZSt4cout, %edi movl $.L.str.1, %esi movl $2, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 4(%rbx), %eax testl %eax, %eax jle .LBB2_5 # %bb.3: # %.lr.ph.preheader # in Loop: Header=BB2_2 Depth=1 xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_4: # %.lr.ph # Parent Loop BB2_2 Depth=1 # => This Inner Loop Header: Depth=2 movq 8(%rbx), %rcx imull %r15d, %eax cltq addq %r14, %rax movl (%rcx,%rax,4), %esi movl $_ZSt4cout, %edi callq _ZNSolsEi movl $.L.str.2, %esi movl $1, %edx movq %rax, %rdi callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movl 4(%rbx), %eax incq %r14 cmpl %eax, %r14d jl .LBB2_4 .LBB2_5: # %._crit_edge # in Loop: Header=BB2_2 Depth=1 movl $_ZSt4cout, %edi movl $.L.str.3, %esi movl $1, %edx callq _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l movq _ZSt4cout(%rip), %rax movq -24(%rax), %rax movq _ZSt4cout+240(%rax), %r14 testq %r14, %r14 je .LBB2_11 # %bb.6: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i # in Loop: Header=BB2_2 Depth=1 cmpb $0, 56(%r14) je .LBB2_8 # %bb.7: # in Loop: Header=BB2_2 Depth=1 movzbl 67(%r14), %eax jmp .LBB2_9 .LBB2_10: # %._crit_edge12 movl $_ZSt4cout, %edi movl $.L.str.4, %esi movl $1, %edx popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 jmp _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l # TAILCALL .LBB2_11: .cfi_def_cfa_offset 32 callq _ZSt16__throw_bad_castv .Lfunc_end2: .size _ZN6Matrix8writeOutEv, .Lfunc_end2-_ZN6Matrix8writeOutEv .cfi_endproc # -- End function .text .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 $_Z15MatrixMulKernel6MatrixS_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_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 _Z15MatrixMulKernel6MatrixS_S_,@object # @_Z15MatrixMulKernel6MatrixS_S_ .section .rodata,"a",@progbits .globl _Z15MatrixMulKernel6MatrixS_S_ .p2align 3, 0x0 _Z15MatrixMulKernel6MatrixS_S_: .quad _Z30__device_stub__MatrixMulKernel6MatrixS_S_ .size _Z15MatrixMulKernel6MatrixS_S_, 8 .type .L.str.1,@object # @.str.1 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.1: .asciz "| " .size .L.str.1, 3 .type .L.str.2,@object # @.str.2 .L.str.2: .asciz " " .size .L.str.2, 2 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "|" .size .L.str.3, 2 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "\n" .size .L.str.4, 2 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z15MatrixMulKernel6MatrixS_S_" .size .L__unnamed_1, 31 .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__MatrixMulKernel6MatrixS_S_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z15MatrixMulKernel6MatrixS_S_ .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 <stdio.h> #include <curand.h> #include <fstream> #include <iostream> #define GRID_SIZE 1 #define BLOCK_SIZE 8 #define NUM_TRY 3000000 /** * 線形乱数生成器 */ __device__ unsigned int rand(unsigned int* randx) { *randx = *randx * 1103515245 + 12345; return (*randx)&2147483647; } __device__ float randf(unsigned int* randx) { return rand(randx) / (float(2147483647) + 1); } __device__ float randf(unsigned int* randx, float a, float b) { return randf(randx) * (b - a) + a; } /** * 乱数を生成し、デバイスバッファに格納する */ __global__ void gen_random(int* devResults) { int idx = blockDim.x * blockIdx.x + threadIdx.x; // 乱数シードの初期化 unsigned int randx = idx; for (int i = 0; i < NUM_TRY; ++i) { int x = randf(&randx, 0, 200); devResults[idx * NUM_TRY + i + 0] = x; } } int main() { int* results; int* devResults; // CPU側でメモリを確保する results = new int[GRID_SIZE * BLOCK_SIZE * NUM_TRY]; // GPU側でメモリを確保する cudaMalloc((void**)&devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY); // GPU側の関数を呼び出す。()内が、そのまま関数の引数となる gen_random<<<GRID_SIZE, BLOCK_SIZE>>>(devResults); // 指定したsize分、GPUのd_bufferから、CPUのbufferへ、データを転送する cudaMemcpy(results, devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY, cudaMemcpyDeviceToHost); // GPU側で確保したメモリを開放する cudaFree(devResults); // 結果を表示する for (int i = 0; i < GRID_SIZE * BLOCK_SIZE; ++i) { char filename[256]; sprintf(filename, "random_%d.txt", i); std::ofstream out(filename); for (int j = 0; j < NUM_TRY; ++j) { out << results[i * NUM_TRY + j + 0] << std::endl; if (results[i * NUM_TRY + j + 0] >= 200) { printf("ERROR: x >= 200\n"); } if (results[i * NUM_TRY + j + 1] >= 200) { printf("ERROR: y >= 200\n"); } } out.close(); printf("random numbers were written to %s\n", filename); } // 出力したrandom_X.txtを、plot.pyでグラフにプロットすると、 // きれいにランダムにプロットが生成されていることが分かるよ!! // ヒストグラムを表示して、ほぼ均一に生成されていることが分かる。 // 結論:Rand()関数は、簡単な乱数生成器として、十分使える! // CPU側で確保したメモリを開放する free(results); cudaDeviceReset(); }
code for sm_80 Function : _Z10gen_randomPi .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 R7, SR_CTAID.X ; /* 0x0000000000077919 */ /* 0x000e220000002500 */ /*0020*/ HFMA2.MMA R23, -RZ, RZ, 0, 2.384185791015625e-07 ; /* 0x00000004ff177435 */ /* 0x000fe200000001ff */ /*0030*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fe40000000a00 */ /*0040*/ S2R R0, SR_TID.X ; /* 0x0000000000007919 */ /* 0x000e240000002100 */ /*0050*/ IMAD R7, R7, c[0x0][0x0], R0 ; /* 0x0000000007077a24 */ /* 0x001fe200078e0200 */ /*0060*/ MOV R0, RZ ; /* 0x000000ff00007202 */ /* 0x000fc60000000f00 */ /*0070*/ IMAD R22, R7, 0x2dc6c0, RZ ; /* 0x002dc6c007167824 */ /* 0x000fc800078e02ff */ /*0080*/ IMAD.WIDE R22, R22, R23, c[0x0][0x160] ; /* 0x0000580016167625 */ /* 0x000fca00078e0217 */ /*0090*/ IADD3 R19, P0, R22, 0x10, RZ ; /* 0x0000001016137810 */ /* 0x000fc80007f1e0ff */ /*00a0*/ IADD3.X R22, RZ, R23, RZ, P0, !PT ; /* 0x00000017ff167210 */ /* 0x000fe400007fe4ff */ /*00b0*/ MOV R4, 0x41c64e6d ; /* 0x41c64e6d00047802 */ /* 0x000fe40000000f00 */ /*00c0*/ IADD3 R0, R0, 0x28, RZ ; /* 0x0000002800007810 */ /* 0x000fc60007ffe0ff */ /*00d0*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe200078e0204 */ /*00e0*/ ISETP.NE.AND P0, PT, R0, 0x2dc6c0, PT ; /* 0x002dc6c00000780c */ /* 0x000fc80003f05270 */ /*00f0*/ LOP3.LUT R2, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07027812 */ /* 0x042fe200078ec0ff */ /*0100*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fca00078e0204 */ /*0110*/ LOP3.LUT R5, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07057812 */ /* 0x040fe200078ec0ff */ /*0120*/ I2F.U32 R2, R2 ; /* 0x0000000200027306 */ /* 0x000e220000201000 */ /*0130*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fca00078e0204 */ /*0140*/ LOP3.LUT R6, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07067812 */ /* 0x040fe200078ec0ff */ /*0150*/ IMAD R7, R7, R4.reuse, 0x3039 ; /* 0x0000303907077424 */ /* 0x080fe200078e0204 */ /*0160*/ I2F.U32 R5, R5 ; /* 0x0000000500057306 */ /* 0x000e680000201000 */ /*0170*/ LOP3.LUT R8, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07087812 */ /* 0x040fe200078ec0ff */ /*0180*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe400078e0204 */ /*0190*/ FMUL R3, R2, 4.6566128730773925781e-10 ; /* 0x3000000002037820 */ /* 0x001fe20000400000 */ /*01a0*/ I2F.U32 R6, R6 ; /* 0x0000000600067306 */ /* 0x000e260000201000 */ /*01b0*/ FFMA R3, R3, 200, RZ ; /* 0x4348000003037823 */ /* 0x000fc400000000ff */ /*01c0*/ FMUL R2, R5, 4.6566128730773925781e-10 ; /* 0x3000000005027820 */ /* 0x002fe20000400000 */ /*01d0*/ LOP3.LUT R5, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07057812 */ /* 0x040fe200078ec0ff */ /*01e0*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe200078e0204 */ /*01f0*/ F2I.TRUNC.NTZ R21, R3 ; /* 0x0000000300157305 */ /* 0x0003e2000020f100 */ /*0200*/ FFMA R2, R2, 200, RZ ; /* 0x4348000002027823 */ /* 0x000fe400000000ff */ /*0210*/ FMUL R6, R6, 4.6566128730773925781e-10 ; /* 0x3000000006067820 */ /* 0x001fca0000400000 */ /*0220*/ I2F.U32 R5, R5 ; /* 0x0000000500057306 */ /* 0x000e220000201000 */ /*0230*/ LOP3.LUT R3, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07037812 */ /* 0x042fe200078ec0ff */ /*0240*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe400078e0204 */ /*0250*/ FFMA R6, R6, 200, RZ ; /* 0x4348000006067823 */ /* 0x000fc800000000ff */ /*0260*/ F2I.TRUNC.NTZ R23, R2 ; /* 0x0000000200177305 */ /* 0x0003f0000020f100 */ /*0270*/ I2F.U32 R3, R3 ; /* 0x0000000300037306 */ /* 0x000ea20000201000 */ /*0280*/ LOP3.LUT R2, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07027812 */ /* 0x042fe200078ec0ff */ /*0290*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fc400078e0204 */ /*02a0*/ FMUL R5, R5, 4.6566128730773925781e-10 ; /* 0x3000000005057820 */ /* 0x001fc60000400000 */ /*02b0*/ LOP3.LUT R9, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07097812 */ /* 0x040fe200078ec0ff */ /*02c0*/ I2F.U32 R2, R2 ; /* 0x0000000200027306 */ /* 0x000e220000201000 */ /*02d0*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe400078e0204 */ /*02e0*/ FFMA R5, R5, 200, RZ ; /* 0x4348000005057823 */ /* 0x000fc600000000ff */ /*02f0*/ LOP3.LUT R11, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff070b7812 */ /* 0x040fe200078ec0ff */ /*0300*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe200078e0204 */ /*0310*/ F2I.TRUNC.NTZ R25, R6 ; /* 0x0000000600197305 */ /* 0x000fe2000020f100 */ /*0320*/ FMUL R3, R3, 4.6566128730773925781e-10 ; /* 0x3000000003037820 */ /* 0x004fc80000400000 */ /*0330*/ FFMA R3, R3, 200, RZ ; /* 0x4348000003037823 */ /* 0x000fc600000000ff */ /*0340*/ F2I.TRUNC.NTZ R6, R5 ; /* 0x0000000500067305 */ /* 0x0003e2000020f100 */ /*0350*/ FMUL R2, R2, 4.6566128730773925781e-10 ; /* 0x3000000002027820 */ /* 0x001fc80000400000 */ /*0360*/ FFMA R2, R2, 200, RZ ; /* 0x4348000002027823 */ /* 0x000fc600000000ff */ /*0370*/ I2F.U32 R9, R9 ; /* 0x0000000900097306 */ /* 0x000e220000201000 */ /*0380*/ LOP3.LUT R5, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07057812 */ /* 0x042fe200078ec0ff */ /*0390*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fcc00078e0204 */ /*03a0*/ F2I.TRUNC.NTZ R12, R3 ; /* 0x00000003000c7305 */ /* 0x0003f0000020f100 */ /*03b0*/ I2F.U32 R11, R11 ; /* 0x0000000b000b7306 */ /* 0x000ea20000201000 */ /*03c0*/ LOP3.LUT R3, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07037812 */ /* 0x042fe200078ec0ff */ /*03d0*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fc400078e0204 */ /*03e0*/ FMUL R9, R9, 4.6566128730773925781e-10 ; /* 0x3000000009097820 */ /* 0x001fc80000400000 */ /*03f0*/ F2I.TRUNC.NTZ R10, R2 ; /* 0x00000002000a7305 */ /* 0x0001e2000020f100 */ /*0400*/ FFMA R9, R9, 200, RZ ; /* 0x4348000009097823 */ /* 0x000fce00000000ff */ /*0410*/ I2F.U32 R3, R3 ; /* 0x0000000300037306 */ /* 0x000e620000201000 */ /*0420*/ LOP3.LUT R2, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07027812 */ /* 0x041fe200078ec0ff */ /*0430*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe400078e0204 */ /*0440*/ FMUL R11, R11, 4.6566128730773925781e-10 ; /* 0x300000000b0b7820 */ /* 0x004fc80000400000 */ /*0450*/ I2F.U32 R2, R2 ; /* 0x0000000200027306 */ /* 0x000e220000201000 */ /*0460*/ FFMA R11, R11, 200, RZ ; /* 0x434800000b0b7823 */ /* 0x000fce00000000ff */ /*0470*/ F2I.TRUNC.NTZ R16, R9 ; /* 0x0000000900107305 */ /* 0x0005e2000020f100 */ /*0480*/ FMUL R3, R3, 4.6566128730773925781e-10 ; /* 0x3000000003037820 */ /* 0x002fc80000400000 */ /*0490*/ FFMA R3, R3, 200, RZ ; /* 0x4348000003037823 */ /* 0x000fc600000000ff */ /*04a0*/ F2I.TRUNC.NTZ R14, R11 ; /* 0x0000000b000e7305 */ /* 0x0003e2000020f100 */ /*04b0*/ LOP3.LUT R9, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07097812 */ /* 0x044fe200078ec0ff */ /*04c0*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe400078e0204 */ /*04d0*/ FMUL R2, R2, 4.6566128730773925781e-10 ; /* 0x3000000002027820 */ /* 0x001fc80000400000 */ /*04e0*/ I2F.U32 R5, R5 ; /* 0x0000000500057306 */ /* 0x000e220000201000 */ /*04f0*/ LOP3.LUT R11, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff070b7812 */ /* 0x042fe200078ec0ff */ /*0500*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fe400078e0204 */ /*0510*/ FFMA R29, R2, 200, RZ ; /* 0x43480000021d7823 */ /* 0x000fc600000000ff */ /*0520*/ LOP3.LUT R2, R7.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07027812 */ /* 0x040fe200078ec0ff */ /*0530*/ I2F.U32 R9, R9 ; /* 0x0000000900097306 */ /* 0x000e620000201000 */ /*0540*/ IMAD R7, R7, R4, 0x3039 ; /* 0x0000303907077424 */ /* 0x000fce00078e0204 */ /*0550*/ I2F.U32 R11, R11 ; /* 0x0000000b000b7306 */ /* 0x000ea20000201000 */ /*0560*/ FMUL R5, R5, 4.6566128730773925781e-10 ; /* 0x3000000005057820 */ /* 0x001fc80000400000 */ /*0570*/ FFMA R5, R5, 200, RZ ; /* 0x4348000005057823 */ /* 0x000fc600000000ff */ /*0580*/ F2I.TRUNC.NTZ R27, R3 ; /* 0x00000003001b7305 */ /* 0x0001e2000020f100 */ /*0590*/ FMUL R9, R9, 4.6566128730773925781e-10 ; /* 0x3000000009097820 */ /* 0x002fce0000400000 */ /*05a0*/ I2F.U32 R2, R2 ; /* 0x0000000200027306 */ /* 0x000e620000201000 */ /*05b0*/ LOP3.LUT R3, R7, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07037812 */ /* 0x001fe200078ec0ff */ /*05c0*/ FMUL R11, R11, 4.6566128730773925781e-10 ; /* 0x300000000b0b7820 */ /* 0x004fcc0000400000 */ /*05d0*/ I2F.U32 R3, R3 ; /* 0x0000000300037306 */ /* 0x000e300000201000 */ /*05e0*/ F2I.TRUNC.NTZ R18, R5 ; /* 0x0000000500127305 */ /* 0x0005e2000020f100 */ /*05f0*/ FMUL R2, R2, 4.6566128730773925781e-10 ; /* 0x3000000002027820 */ /* 0x002fe40000400000 */ /*0600*/ FMUL R3, R3, 4.6566128730773925781e-10 ; /* 0x3000000003037820 */ /* 0x001fca0000400000 */ /*0610*/ I2F.U32 R8, R8 ; /* 0x0000000800087306 */ /* 0x000e220000201000 */ /*0620*/ FFMA R5, R9, 200, RZ ; /* 0x4348000009057823 */ /* 0x004fe400000000ff */ /*0630*/ IMAD R9, R7, R4.reuse, 0x3039 ; /* 0x0000303907097424 */ /* 0x080fe400078e0204 */ /*0640*/ FFMA R7, R11, 200, RZ ; /* 0x434800000b077823 */ /* 0x000fe400000000ff */ /*0650*/ IMAD R11, R9.reuse, R4.reuse, 0x3039 ; /* 0x00003039090b7424 */ /* 0x0c0fe200078e0204 */ /*0660*/ LOP3.LUT R13, R9, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff090d7812 */ /* 0x000fe200078ec0ff */ /*0670*/ FFMA R9, R2, 200, RZ ; /* 0x4348000002097823 */ /* 0x000fe200000000ff */ /*0680*/ F2I.TRUNC.NTZ R29, R29 ; /* 0x0000001d001d7305 */ /* 0x000fe2000020f100 */ /*0690*/ IMAD R15, R11.reuse, R4, 0x3039 ; /* 0x000030390b0f7424 */ /* 0x040fe200078e0204 */ /*06a0*/ LOP3.LUT R2, R11, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff0b027812 */ /* 0x000fe200078ec0ff */ /*06b0*/ FFMA R11, R3, 200, RZ ; /* 0x43480000030b7823 */ /* 0x000fc600000000ff */ /*06c0*/ LOP3.LUT R3, R15.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff0f037812 */ /* 0x040fe200078ec0ff */ /*06d0*/ IMAD R15, R15, R4.reuse, 0x3039 ; /* 0x000030390f0f7424 */ /* 0x080fe200078e0204 */ /*06e0*/ I2F.U32 R2, R2 ; /* 0x0000000200027306 */ /* 0x000e620000201000 */ /*06f0*/ FMUL R8, R8, 4.6566128730773925781e-10 ; /* 0x3000000008087820 */ /* 0x001fe40000400000 */ /*0700*/ IMAD R17, R15.reuse, R4, 0x3039 ; /* 0x000030390f117424 */ /* 0x040fe200078e0204 */ /*0710*/ LOP3.LUT R24, R15, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff0f187812 */ /* 0x000fe200078ec0ff */ /*0720*/ FFMA R8, R8, 200, RZ ; /* 0x4348000008087823 */ /* 0x000fc600000000ff */ /*0730*/ I2F.U32 R3, R3 ; /* 0x0000000300037306 */ /* 0x000e220000201000 */ /*0740*/ LOP3.LUT R20, R17, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff11147812 */ /* 0x000fce00078ec0ff */ /*0750*/ I2F.U32 R24, R24 ; /* 0x0000001800187306 */ /* 0x000ea20000201000 */ /*0760*/ FMUL R2, R2, 4.6566128730773925781e-10 ; /* 0x3000000002027820 */ /* 0x002fc80000400000 */ /*0770*/ FFMA R2, R2, 200, RZ ; /* 0x4348000002027823 */ /* 0x000fe400000000ff */ /*0780*/ FMUL R26, R3, 4.6566128730773925781e-10 ; /* 0x30000000031a7820 */ /* 0x001fe20000400000 */ /*0790*/ I2F.U32 R20, R20 ; /* 0x0000001400147306 */ /* 0x000e260000201000 */ /*07a0*/ FFMA R3, R26, 200, RZ ; /* 0x434800001a037823 */ /* 0x000fe400000000ff */ /*07b0*/ IMAD R26, R17, R4, 0x3039 ; /* 0x00003039111a7424 */ /* 0x000fe400078e0204 */ /*07c0*/ FMUL R24, R24, 4.6566128730773925781e-10 ; /* 0x3000000018187820 */ /* 0x004fe20000400000 */ /*07d0*/ F2I.TRUNC.NTZ R17, R3 ; /* 0x0000000300117305 */ /* 0x0003f0000020f100 */ /*07e0*/ F2I.TRUNC.NTZ R15, R2 ; /* 0x00000002000f7305 */ /* 0x0005e2000020f100 */ /*07f0*/ MOV R3, R22 ; /* 0x0000001600037202 */ /* 0x002fc40000000f00 */ /*0800*/ LOP3.LUT R22, R26, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff1a167812 */ /* 0x000fca00078ec0ff */ /*0810*/ F2I.TRUNC.NTZ R8, R8 ; /* 0x0000000800087305 */ /* 0x000e62000020f100 */ /*0820*/ MOV R2, R19 ; /* 0x0000001300027202 */ /* 0x004fe20000000f00 */ /*0830*/ FFMA R19, R24, 200, RZ ; /* 0x4348000018137823 */ /* 0x000fe400000000ff */ /*0840*/ IMAD R24, R26, R4.reuse, 0x3039 ; /* 0x000030391a187424 */ /* 0x080fe400078e0204 */ /*0850*/ FMUL R26, R20, 4.6566128730773925781e-10 ; /* 0x30000000141a7820 */ /* 0x001fe20000400000 */ /*0860*/ STG.E [R2.64+-0xc], R23 ; /* 0xfffff41702007986 */ /* 0x000fe2000c101904 */ /*0870*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000e220000201000 */ /*0880*/ LOP3.LUT R20, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18147812 */ /* 0x040fe200078ec0ff */ /*0890*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe200078e0204 */ /*08a0*/ STG.E [R2.64+-0x10], R21 ; /* 0xfffff01502007986 */ /* 0x0005e8000c101904 */ /*08b0*/ LOP3.LUT R28, R24, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff181c7812 */ /* 0x000fe200078ec0ff */ /*08c0*/ I2F.U32 R20, R20 ; /* 0x0000001400147306 */ /* 0x000ee20000201000 */ /*08d0*/ STG.E [R2.64+-0x8], R25 ; /* 0xfffff81902007986 */ /* 0x0009e8000c101904 */ /*08e0*/ STG.E [R2.64+-0x4], R8 ; /* 0xfffffc0802007986 */ /* 0x0023e2000c101904 */ /*08f0*/ FFMA R21, R26, 200, RZ ; /* 0x434800001a157823 */ /* 0x004fc400000000ff */ /*0900*/ F2I.TRUNC.NTZ R7, R7 ; /* 0x0000000700077305 */ /* 0x000fe2000020f100 */ /*0910*/ FMUL R23, R22, 4.6566128730773925781e-10 ; /* 0x3000000016177820 */ /* 0x001fe20000400000 */ /*0920*/ STG.E [R2.64], R6 ; /* 0x0000000602007986 */ /* 0x0001e2000c101904 */ /*0930*/ IMAD R26, R24, R4.reuse, 0x3039 ; /* 0x00003039181a7424 */ /* 0x080fe400078e0204 */ /*0940*/ FFMA R23, R23, 200, RZ ; /* 0x4348000017177823 */ /* 0x000fe200000000ff */ /*0950*/ STG.E [R2.64+0x4], R12 ; /* 0x0000040c02007986 */ /* 0x0005e4000c101904 */ /*0960*/ I2F.U32 R22, R28 ; /* 0x0000001c00167306 */ /* 0x000f620000201000 */ /*0970*/ LOP3.LUT R24, R26, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff1a187812 */ /* 0x000fe200078ec0ff */ /*0980*/ FMUL R20, R20, 4.6566128730773925781e-10 ; /* 0x3000000014147820 */ /* 0x008fe20000400000 */ /*0990*/ STG.E [R2.64+0x8], R10 ; /* 0x0000080a02007986 */ /* 0x0007e2000c101904 */ /*09a0*/ IMAD R26, R26, R4, 0x3039 ; /* 0x000030391a1a7424 */ /* 0x000fc400078e0204 */ /*09b0*/ FFMA R25, R20, 200, RZ ; /* 0x4348000014197823 */ /* 0x010fe200000000ff */ /*09c0*/ STG.E [R2.64+0xc], R16 ; /* 0x00000c1002007986 */ /* 0x0009e2000c101904 */ /*09d0*/ I2F.U32 R24, R24 ; /* 0x0000001800187306 */ /* 0x000e220000201000 */ /*09e0*/ LOP3.LUT R20, R26.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff1a147812 */ /* 0x040fe200078ec0ff */ /*09f0*/ IMAD R26, R26, R4, 0x3039 ; /* 0x000030391a1a7424 */ /* 0x000fe200078e0204 */ /*0a00*/ STG.E [R2.64+0x10], R14 ; /* 0x0000100e02007986 */ /* 0x0001e8000c101904 */ /*0a10*/ STG.E [R2.64+0x14], R18 ; /* 0x0000141202007986 */ /* 0x0005e2000c101904 */ /*0a20*/ FMUL R22, R22, 4.6566128730773925781e-10 ; /* 0x3000000016167820 */ /* 0x020fe20000400000 */ /*0a30*/ I2F.U32 R20, R20 ; /* 0x0000001400147306 */ /* 0x000ea40000201000 */ /*0a40*/ STG.E [R2.64+0x18], R27 ; /* 0x0000181b02007986 */ /* 0x000be2000c101904 */ /*0a50*/ FFMA R8, R22, 200, RZ ; /* 0x4348000016087823 */ /* 0x002fe200000000ff */ /*0a60*/ LOP3.LUT R22, R26, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff1a167812 */ /* 0x000fc400078ec0ff */ /*0a70*/ STG.E [R2.64+0x1c], R29 ; /* 0x00001c1d02007986 */ /* 0x0003e2000c101904 */ /*0a80*/ FMUL R24, R24, 4.6566128730773925781e-10 ; /* 0x3000000018187820 */ /* 0x001fe20000400000 */ /*0a90*/ F2I.TRUNC.NTZ R5, R5 ; /* 0x0000000500057305 */ /* 0x000e24000020f100 */ /*0aa0*/ STG.E [R2.64+0x24], R7 ; /* 0x0000240702007986 */ /* 0x000fe2000c101904 */ /*0ab0*/ FFMA R6, R24, 200, RZ ; /* 0x4348000018067823 */ /* 0x000fe400000000ff */ /*0ac0*/ IMAD R24, R26, R4.reuse, 0x3039 ; /* 0x000030391a187424 */ /* 0x080fe200078e0204 */ /*0ad0*/ STG.E [R2.64+0x34], R15 ; /* 0x0000340f02007986 */ /* 0x000fe4000c101904 */ /*0ae0*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000e620000201000 */ /*0af0*/ FMUL R12, R20, 4.6566128730773925781e-10 ; /* 0x30000000140c7820 */ /* 0x004fe20000400000 */ /*0b00*/ LOP3.LUT R28, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff181c7812 */ /* 0x040fe200078ec0ff */ /*0b10*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe200078e0204 */ /*0b20*/ STG.E [R2.64+0x38], R17 ; /* 0x0000381102007986 */ /* 0x000fe2000c101904 */ /*0b30*/ FFMA R12, R12, 200, RZ ; /* 0x434800000c0c7823 */ /* 0x000fc600000000ff */ /*0b40*/ I2F.U32 R20, R28 ; /* 0x0000001c00147306 */ /* 0x0005220000201000 */ /*0b50*/ STG.E [R2.64+0x20], R5 ; /* 0x0000200502007986 */ /* 0x0011e2000c101904 */ /*0b60*/ FMUL R26, R22, 4.6566128730773925781e-10 ; /* 0x30000000161a7820 */ /* 0x002fe20000400000 */ /*0b70*/ LOP3.LUT R22, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18167812 */ /* 0x040fe200078ec0ff */ /*0b80*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fc800078e0204 */ /*0b90*/ F2I.TRUNC.NTZ R9, R9 ; /* 0x0000000900097305 */ /* 0x000e62000020f100 */ /*0ba0*/ FFMA R10, R26, 200, RZ ; /* 0x434800001a0a7823 */ /* 0x008fe200000000ff */ /*0bb0*/ LOP3.LUT R28, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff181c7812 */ /* 0x044fe200078ec0ff */ /*0bc0*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe400078e0204 */ /*0bd0*/ FMUL R16, R20, 4.6566128730773925781e-10 ; /* 0x3000000014107820 */ /* 0x010fc60000400000 */ /*0be0*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000ea20000201000 */ /*0bf0*/ FFMA R16, R16, 200, RZ ; /* 0x4348000010107823 */ /* 0x000fce00000000ff */ /*0c00*/ I2F.U32 R20, R28 ; /* 0x0000001c00147306 */ /* 0x0007220000201000 */ /*0c10*/ STG.E [R2.64+0x28], R9 ; /* 0x0000280902007986 */ /* 0x0023e2000c101904 */ /*0c20*/ FMUL R26, R22, 4.6566128730773925781e-10 ; /* 0x30000000161a7820 */ /* 0x004fe20000400000 */ /*0c30*/ LOP3.LUT R22, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18167812 */ /* 0x040fe200078ec0ff */ /*0c40*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fc800078e0204 */ /*0c50*/ I2F.U32 R13, R13 ; /* 0x0000000d000d7306 */ /* 0x000ea20000201000 */ /*0c60*/ FFMA R14, R26, 200, RZ ; /* 0x434800001a0e7823 */ /* 0x000fe200000000ff */ /*0c70*/ LOP3.LUT R28, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff181c7812 */ /* 0x048fe200078ec0ff */ /*0c80*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe400078e0204 */ /*0c90*/ FMUL R18, R20, 4.6566128730773925781e-10 ; /* 0x3000000014127820 */ /* 0x010fc60000400000 */ /*0ca0*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000ee20000201000 */ /*0cb0*/ FFMA R18, R18, 200, RZ ; /* 0x4348000012127823 */ /* 0x000fce00000000ff */ /*0cc0*/ I2F.U32 R20, R28 ; /* 0x0000001c00147306 */ /* 0x0008220000201000 */ /*0cd0*/ FMUL R13, R13, 4.6566128730773925781e-10 ; /* 0x300000000d0d7820 */ /* 0x004fc80000400000 */ /*0ce0*/ FFMA R13, R13, 200, RZ ; /* 0x434800000d0d7823 */ /* 0x000fe400000000ff */ /*0cf0*/ FMUL R26, R22, 4.6566128730773925781e-10 ; /* 0x30000000161a7820 */ /* 0x008fe20000400000 */ /*0d00*/ LOP3.LUT R22, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18167812 */ /* 0x040fe200078ec0ff */ /*0d10*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe200078e0204 */ /*0d20*/ F2I.TRUNC.NTZ R11, R11 ; /* 0x0000000b000b7305 */ /* 0x000ea2000020f100 */ /*0d30*/ FFMA R27, R26, 200, RZ ; /* 0x434800001a1b7823 */ /* 0x020fc600000000ff */ /*0d40*/ LOP3.LUT R28, R24, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff181c7812 */ /* 0x010fe200078ec0ff */ /*0d50*/ FMUL R26, R20, 4.6566128730773925781e-10 ; /* 0x30000000141a7820 */ /* 0x001fe40000400000 */ /*0d60*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe200078e0204 */ /*0d70*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000e220000201000 */ /*0d80*/ FFMA R29, R26, 200, RZ ; /* 0x434800001a1d7823 */ /* 0x000fce00000000ff */ /*0d90*/ I2F.U32 R20, R28 ; /* 0x0000001c00147306 */ /* 0x000ee20000201000 */ /*0da0*/ STG.E [R2.64+0x2c], R11 ; /* 0x00002c0b02007986 */ /* 0x0045e2000c101904 */ /*0db0*/ FMUL R26, R22, 4.6566128730773925781e-10 ; /* 0x30000000161a7820 */ /* 0x001fe20000400000 */ /*0dc0*/ LOP3.LUT R22, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18167812 */ /* 0x040fe200078ec0ff */ /*0dd0*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fc800078e0204 */ /*0de0*/ F2I.TRUNC.NTZ R13, R13 ; /* 0x0000000d000d7305 */ /* 0x000e22000020f100 */ /*0df0*/ FFMA R5, R26, 200, RZ ; /* 0x434800001a057823 */ /* 0x000fe200000000ff */ /*0e00*/ LOP3.LUT R7, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18077812 */ /* 0x040fe200078ec0ff */ /*0e10*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fe400078e0204 */ /*0e20*/ FMUL R20, R20, 4.6566128730773925781e-10 ; /* 0x3000000014147820 */ /* 0x008fc60000400000 */ /*0e30*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000ee20000201000 */ /*0e40*/ FFMA R20, R20, 200, RZ ; /* 0x4348000014147823 */ /* 0x000fce00000000ff */ /*0e50*/ I2F.U32 R7, R7 ; /* 0x0000000700077306 */ /* 0x000f220000201000 */ /*0e60*/ STG.E [R2.64+0x30], R13 ; /* 0x0000300d02007986 */ /* 0x001fe2000c101904 */ /*0e70*/ FMUL R26, R22, 4.6566128730773925781e-10 ; /* 0x30000000161a7820 */ /* 0x008fe20000400000 */ /*0e80*/ LOP3.LUT R22, R24.reuse, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff18167812 */ /* 0x040fe200078ec0ff */ /*0e90*/ IMAD R24, R24, R4, 0x3039 ; /* 0x0000303918187424 */ /* 0x000fc800078e0204 */ /*0ea0*/ F2I.TRUNC.NTZ R19, R19 ; /* 0x0000001300137305 */ /* 0x000e22000020f100 */ /*0eb0*/ FFMA R9, R26, 200, RZ ; /* 0x434800001a097823 */ /* 0x002fe400000000ff */ /*0ec0*/ IMAD R26, R24.reuse, R4, 0x3039 ; /* 0x00003039181a7424 */ /* 0x040fe200078e0204 */ /*0ed0*/ LOP3.LUT R11, R24, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff180b7812 */ /* 0x004fe200078ec0ff */ /*0ee0*/ FMUL R7, R7, 4.6566128730773925781e-10 ; /* 0x3000000007077820 */ /* 0x010fc60000400000 */ /*0ef0*/ I2F.U32 R22, R22 ; /* 0x0000001600167306 */ /* 0x000e620000201000 */ /*0f00*/ FFMA R28, R7, 200, RZ ; /* 0x43480000071c7823 */ /* 0x000fe400000000ff */ /*0f10*/ IMAD R7, R26.reuse, R4, 0x3039 ; /* 0x000030391a077424 */ /* 0x040fe200078e0204 */ /*0f20*/ LOP3.LUT R26, R26, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff1a1a7812 */ /* 0x000fc800078ec0ff */ /*0f30*/ LOP3.LUT R4, R7, 0x7fffffff, RZ, 0xc0, !PT ; /* 0x7fffffff07047812 */ /* 0x000fe200078ec0ff */ /*0f40*/ I2F.U32 R11, R11 ; /* 0x0000000b000b7306 */ /* 0x000ea20000201000 */ /*0f50*/ STG.E [R2.64+0x3c], R19 ; /* 0x00003c1302007986 */ /* 0x0011e2000c101904 */ /*0f60*/ FMUL R22, R22, 4.6566128730773925781e-10 ; /* 0x3000000016167820 */ /* 0x002fcc0000400000 */ /*0f70*/ I2F.U32 R26, R26 ; /* 0x0000001a001a7306 */ /* 0x000e620000201000 */ /*0f80*/ FFMA R22, R22, 200, RZ ; /* 0x4348000016167823 */ /* 0x000fe200000000ff */ /*0f90*/ IADD3 R19, P1, R2, 0xa0, RZ ; /* 0x000000a002137810 */ /* 0x001fcc0007f3e0ff */ /*0fa0*/ I2F.U32 R4, R4 ; /* 0x0000000400047306 */ /* 0x000e220000201000 */ /*0fb0*/ FMUL R13, R11, 4.6566128730773925781e-10 ; /* 0x300000000b0d7820 */ /* 0x004fc80000400000 */ /*0fc0*/ FFMA R13, R13, 200, RZ ; /* 0x434800000d0d7823 */ /* 0x000fe400000000ff */ /*0fd0*/ FMUL R15, R26, 4.6566128730773925781e-10 ; /* 0x300000001a0f7820 */ /* 0x002fe20000400000 */ /*0fe0*/ F2I.TRUNC.NTZ R21, R21 ; /* 0x0000001500157305 */ /* 0x000e66000020f100 */ /*0ff0*/ FFMA R15, R15, 200, RZ ; /* 0x434800000f0f7823 */ /* 0x000fe400000000ff */ /*1000*/ FMUL R26, R4, 4.6566128730773925781e-10 ; /* 0x30000000041a7820 */ /* 0x001fc60000400000 */ /*1010*/ F2I.TRUNC.NTZ R23, R23 ; /* 0x0000001700177305 */ /* 0x000e22000020f100 */ /*1020*/ FFMA R26, R26, 200, RZ ; /* 0x434800001a1a7823 */ /* 0x000fce00000000ff */ /*1030*/ F2I.TRUNC.NTZ R25, R25 ; /* 0x0000001900197305 */ /* 0x000ea2000020f100 */ /*1040*/ STG.E [R2.64+0x40], R21 ; /* 0x0000401502007986 */ /* 0x0023ee000c101904 */ /*1050*/ F2I.TRUNC.NTZ R8, R8 ; /* 0x0000000800087305 */ /* 0x000ee2000020f100 */ /*1060*/ STG.E [R2.64+0x44], R23 ; /* 0x0000441702007986 */ /* 0x0013ee000c101904 */ /*1070*/ F2I.TRUNC.NTZ R6, R6 ; /* 0x0000000600067305 */ /* 0x000e22000020f100 */ /*1080*/ STG.E [R2.64+0x48], R25 ; /* 0x0000481902007986 */ /* 0x0043ee000c101904 */ /*1090*/ F2I.TRUNC.NTZ R12, R12 ; /* 0x0000000c000c7305 */ /* 0x000ea2000020f100 */ /*10a0*/ STG.E [R2.64+0x4c], R8 ; /* 0x00004c0802007986 */ /* 0x0083ee000c101904 */ /*10b0*/ F2I.TRUNC.NTZ R10, R10 ; /* 0x0000000a000a7305 */ /* 0x000ee2000020f100 */ /*10c0*/ STG.E [R2.64+0x50], R6 ; /* 0x0000500602007986 */ /* 0x0013ee000c101904 */ /*10d0*/ F2I.TRUNC.NTZ R16, R16 ; /* 0x0000001000107305 */ /* 0x000e22000020f100 */ /*10e0*/ STG.E [R2.64+0x54], R12 ; /* 0x0000540c02007986 */ /* 0x0043ee000c101904 */ /*10f0*/ F2I.TRUNC.NTZ R14, R14 ; /* 0x0000000e000e7305 */ /* 0x000ea2000020f100 */ /*1100*/ STG.E [R2.64+0x58], R10 ; /* 0x0000580a02007986 */ /* 0x0083ee000c101904 */ /*1110*/ F2I.TRUNC.NTZ R18, R18 ; /* 0x0000001200127305 */ /* 0x000ee2000020f100 */ /*1120*/ STG.E [R2.64+0x5c], R16 ; /* 0x00005c1002007986 */ /* 0x0013ee000c101904 */ /*1130*/ F2I.TRUNC.NTZ R27, R27 ; /* 0x0000001b001b7305 */ /* 0x000e22000020f100 */ /*1140*/ STG.E [R2.64+0x60], R14 ; /* 0x0000600e02007986 */ /* 0x0043ee000c101904 */ /*1150*/ F2I.TRUNC.NTZ R29, R29 ; /* 0x0000001d001d7305 */ /* 0x000ea2000020f100 */ /*1160*/ STG.E [R2.64+0x64], R18 ; /* 0x0000641202007986 */ /* 0x0083ee000c101904 */ /*1170*/ F2I.TRUNC.NTZ R5, R5 ; /* 0x0000000500057305 */ /* 0x000ee2000020f100 */ /*1180*/ STG.E [R2.64+0x68], R27 ; /* 0x0000681b02007986 */ /* 0x0013ee000c101904 */ /*1190*/ F2I.TRUNC.NTZ R20, R20 ; /* 0x0000001400147305 */ /* 0x000e22000020f100 */ /*11a0*/ STG.E [R2.64+0x6c], R29 ; /* 0x00006c1d02007986 */ /* 0x0043ee000c101904 */ /*11b0*/ F2I.TRUNC.NTZ R9, R9 ; /* 0x0000000900097305 */ /* 0x000ea2000020f100 */ /*11c0*/ STG.E [R2.64+0x70], R5 ; /* 0x0000700502007986 */ /* 0x0083ee000c101904 */ /*11d0*/ F2I.TRUNC.NTZ R24, R28 ; /* 0x0000001c00187305 */ /* 0x000ee2000020f100 */ /*11e0*/ STG.E [R2.64+0x74], R20 ; /* 0x0000741402007986 */ /* 0x0013ee000c101904 */ /*11f0*/ F2I.TRUNC.NTZ R11, R22 ; /* 0x00000016000b7305 */ /* 0x000122000020f100 */ /*1200*/ STG.E [R2.64+0x78], R9 ; /* 0x0000780902007986 */ /* 0x0043ee000c101904 */ /*1210*/ F2I.TRUNC.NTZ R13, R13 ; /* 0x0000000d000d7305 */ /* 0x000ea2000020f100 */ /*1220*/ STG.E [R2.64+0x7c], R24 ; /* 0x00007c1802007986 */ /* 0x0083e2000c101904 */ /*1230*/ IADD3.X R22, RZ, R3, RZ, P1, !PT ; /* 0x00000003ff167210 */ /* 0x001fcc0000ffe4ff */ /*1240*/ F2I.TRUNC.NTZ R15, R15 ; /* 0x0000000f000f7305 */ /* 0x000e22000020f100 */ /*1250*/ STG.E [R2.64+0x80], R11 ; /* 0x0000800b02007986 */ /* 0x0103ee000c101904 */ /*1260*/ F2I.TRUNC.NTZ R26, R26 ; /* 0x0000001a001a7305 */ /* 0x000ee2000020f100 */ /*1270*/ STG.E [R2.64+0x84], R13 ; /* 0x0000840d02007986 */ /* 0x0043e8000c101904 */ /*1280*/ STG.E [R2.64+0x88], R15 ; /* 0x0000880f02007986 */ /* 0x0013e8000c101904 */ /*1290*/ STG.E [R2.64+0x8c], R26 ; /* 0x00008c1a02007986 */ /* 0x0083e2000c101904 */ /*12a0*/ @!P0 CALL.REL.NOINC 0x12c0 ; /* 0x0000001000008944 */ /* 0x000fe20003c00000 */ /*12b0*/ BRA 0xb0 ; /* 0xffffedf000007947 */ /* 0x000fea000383ffff */ /*12c0*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*12d0*/ BRA 0x12d0; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*12e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*12f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1300*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1310*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1320*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1330*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1340*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1350*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1360*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*1370*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <stdio.h> #include <curand.h> #include <fstream> #include <iostream> #define GRID_SIZE 1 #define BLOCK_SIZE 8 #define NUM_TRY 3000000 /** * 線形乱数生成器 */ __device__ unsigned int rand(unsigned int* randx) { *randx = *randx * 1103515245 + 12345; return (*randx)&2147483647; } __device__ float randf(unsigned int* randx) { return rand(randx) / (float(2147483647) + 1); } __device__ float randf(unsigned int* randx, float a, float b) { return randf(randx) * (b - a) + a; } /** * 乱数を生成し、デバイスバッファに格納する */ __global__ void gen_random(int* devResults) { int idx = blockDim.x * blockIdx.x + threadIdx.x; // 乱数シードの初期化 unsigned int randx = idx; for (int i = 0; i < NUM_TRY; ++i) { int x = randf(&randx, 0, 200); devResults[idx * NUM_TRY + i + 0] = x; } } int main() { int* results; int* devResults; // CPU側でメモリを確保する results = new int[GRID_SIZE * BLOCK_SIZE * NUM_TRY]; // GPU側でメモリを確保する cudaMalloc((void**)&devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY); // GPU側の関数を呼び出す。()内が、そのまま関数の引数となる gen_random<<<GRID_SIZE, BLOCK_SIZE>>>(devResults); // 指定したsize分、GPUのd_bufferから、CPUのbufferへ、データを転送する cudaMemcpy(results, devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY, cudaMemcpyDeviceToHost); // GPU側で確保したメモリを開放する cudaFree(devResults); // 結果を表示する for (int i = 0; i < GRID_SIZE * BLOCK_SIZE; ++i) { char filename[256]; sprintf(filename, "random_%d.txt", i); std::ofstream out(filename); for (int j = 0; j < NUM_TRY; ++j) { out << results[i * NUM_TRY + j + 0] << std::endl; if (results[i * NUM_TRY + j + 0] >= 200) { printf("ERROR: x >= 200\n"); } if (results[i * NUM_TRY + j + 1] >= 200) { printf("ERROR: y >= 200\n"); } } out.close(); printf("random numbers were written to %s\n", filename); } // 出力したrandom_X.txtを、plot.pyでグラフにプロットすると、 // きれいにランダムにプロットが生成されていることが分かるよ!! // ヒストグラムを表示して、ほぼ均一に生成されていることが分かる。 // 結論:Rand()関数は、簡単な乱数生成器として、十分使える! // CPU側で確保したメモリを開放する free(results); cudaDeviceReset(); }
.file "tmpxft_00195753_00000000-6_random_test.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3806: .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 .LFE3806: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z4randPj .type _Z4randPj, @function _Z4randPj: .LFB3800: .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 .LFE3800: .size _Z4randPj, .-_Z4randPj .globl _Z5randfPj .type _Z5randfPj, @function _Z5randfPj: .LFB3801: .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 .LFE3801: .size _Z5randfPj, .-_Z5randfPj .globl _Z5randfPjff .type _Z5randfPjff, @function _Z5randfPjff: .LFB3802: .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 .LFE3802: .size _Z5randfPjff, .-_Z5randfPjff .globl _Z30__device_stub__Z10gen_randomPiPi .type _Z30__device_stub__Z10gen_randomPiPi, @function _Z30__device_stub__Z10gen_randomPiPi: .LFB3828: .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 .L13 .L9: movq 88(%rsp), %rax subq %fs:40, %rax jne .L14 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L13: .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 _Z10gen_randomPi(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L9 .L14: call __stack_chk_fail@PLT .cfi_endproc .LFE3828: .size _Z30__device_stub__Z10gen_randomPiPi, .-_Z30__device_stub__Z10gen_randomPiPi .globl _Z10gen_randomPi .type _Z10gen_randomPi, @function _Z10gen_randomPi: .LFB3829: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z10gen_randomPiPi addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3829: .size _Z10gen_randomPi, .-_Z10gen_randomPi .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z10gen_randomPi" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3831: .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 _Z10gen_randomPi(%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 .LFE3831: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .rodata.str1.1 .LC1: .string "random_%d.txt" .LC2: .string "ERROR: x >= 200\n" .LC3: .string "ERROR: y >= 200\n" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "random numbers were written to %s\n" .text .globl main .type main, @function main: .LFB3803: .cfi_startproc .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 .cfi_lsda 0x1b,.LLSDA3803 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 $840, %rsp .cfi_def_cfa_offset 896 movq %fs:40, %rax movq %rax, 824(%rsp) xorl %eax, %eax movl $96000000, %edi .LEHB0: call _Znam@PLT movq %rax, 8(%rsp) leaq 16(%rsp), %rdi movl $96000000, %esi call cudaMalloc@PLT movl $8, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L52 .L20: movl $2, %ecx movl $96000000, %edx movq 16(%rsp), %rsi movq 8(%rsp), %rbx movq %rbx, %rdi call cudaMemcpy@PLT movq 16(%rsp), %rdi call cudaFree@PLT leaq 12000000(%rbx), %r14 movl $0, 4(%rsp) jmp .L35 .L52: movq 16(%rsp), %rdi call _Z30__device_stub__Z10gen_randomPiPi .LEHE0: jmp .L20 .L64: leaq 24+_ZTVSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) leaq 40(%rax), %rax movq %rax, 296(%rsp) leaq 56(%rsp), %rdi .LEHB1: call _ZNSt13basic_filebufIcSt11char_traitsIcEEC1Ev@PLT .LEHE1: leaq 56(%rsp), %rsi leaq 296(%rsp), %rdi .LEHB2: call _ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@PLT leaq 560(%rsp), %rsi leaq 56(%rsp), %rdi movl $16, %edx call _ZNSt13basic_filebufIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT testq %rax, %rax je .L53 movq 48(%rsp), %rax movq -24(%rax), %rax leaq 48(%rsp,%rax), %rdi movl $0, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L23 .L53: movq 48(%rsp), %rax movq -24(%rax), %rax leaq 48(%rsp,%rax), %rdi movl 32(%rdi), %esi orl $4, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT .LEHE2: .L23: leaq -12000000(%r14), %rbp leaq 48(%rsp), %r15 jmp .L22 .L45: endbr64 movq %rax, %rbx leaq 56(%rsp), %rdi call _ZNSt13basic_filebufIcSt11char_traitsIcEED1Ev@PLT .L25: movq 8+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) movq -24(%rax), %rax movq 16+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rdx movq %rdx, 48(%rsp,%rax) .L26: leaq 16+_ZTVSt9basic_iosIcSt11char_traitsIcEE(%rip), %rax movq %rax, 296(%rsp) leaq 296(%rsp), %rdi call _ZNSt8ios_baseD2Ev@PLT movq 824(%rsp), %rax subq %fs:40, %rax je .L27 call __stack_chk_fail@PLT .L44: endbr64 movq %rax, %rbx jmp .L25 .L43: endbr64 movq %rax, %rbx jmp .L26 .L27: movq %rbx, %rdi .LEHB3: call _Unwind_Resume@PLT .LEHE3: .L60: movq %rax, %rbx movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %r12 testq %r12, %r12 je .L54 cmpb $0, 56(%r12) je .L30 movzbl 67(%r12), %esi .L31: movsbl %sil, %esi movq %rbx, %rdi .LEHB4: call _ZNSo3putEc@PLT jmp .L55 .L54: movq 824(%rsp), %rax subq %fs:40, %rax jne .L56 call _ZSt16__throw_bad_castv@PLT .L42: endbr64 movq %rax, %rbx leaq 48(%rsp), %rdi call _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT movq 824(%rsp), %rax subq %fs:40, %rax je .L40 call __stack_chk_fail@PLT .L56: call __stack_chk_fail@PLT .L30: movq %r12, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%r12), %rax movl $10, %esi movq %r12, %rdi call *48(%rax) movl %eax, %esi jmp .L31 .L55: movq %rax, %rdi call _ZNSo5flushEv@PLT cmpl $199, 0(%r13) jg .L57 .L32: cmpl $199, 4(%r13) jg .L58 .L33: addq $4, %rbp cmpq %r14, %rbp je .L59 .L22: movq %rbp, %r13 movl 0(%rbp), %esi movq %r15, %rdi call _ZNSolsEi@PLT jmp .L60 .L57: leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L32 .L58: leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L33 .L59: leaq 56(%rsp), %rdi call _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv@PLT testq %rax, %rax je .L61 .L34: leaq 560(%rsp), %rdx leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L62 .L61: movq 48(%rsp), %rax movq -24(%rax), %rax leaq 48(%rsp,%rax), %rdi movl 32(%rdi), %esi orl $4, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT .LEHE4: jmp .L34 .L62: leaq 24+_ZTVSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) leaq 40(%rax), %rax movq %rax, 296(%rsp) leaq 16+_ZTVSt13basic_filebufIcSt11char_traitsIcEE(%rip), %rax movq %rax, 56(%rsp) leaq 56(%rsp), %rdi .LEHB5: call _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv@PLT .LEHE5: jmp .L38 .L46: endbr64 movq %rax, %rdi call __cxa_begin_catch@PLT call __cxa_end_catch@PLT .L38: leaq 160(%rsp), %rdi call _ZNSt12__basic_fileIcED1Ev@PLT leaq 16+_ZTVSt15basic_streambufIcSt11char_traitsIcEE(%rip), %rax movq %rax, 56(%rsp) leaq 112(%rsp), %rdi call _ZNSt6localeD1Ev@PLT movq 8+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) movq -24(%rax), %rax movq 16+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rcx movq %rcx, 48(%rsp,%rax) leaq 16+_ZTVSt9basic_iosIcSt11char_traitsIcEE(%rip), %rax movq %rax, 296(%rsp) leaq 296(%rsp), %rdi call _ZNSt8ios_baseD2Ev@PLT addl $1, 4(%rsp) movl 4(%rsp), %eax addq $12000000, %r14 cmpl $8, %eax je .L63 .L35: leaq 560(%rsp), %rdi movl 4(%rsp), %r8d leaq .LC1(%rip), %rcx movl $256, %edx movl $2, %esi movl $0, %eax call __sprintf_chk@PLT leaq 48(%rsp), %rbx leaq 296(%rsp), %rdi call _ZNSt8ios_baseC2Ev@PLT leaq 16+_ZTVSt9basic_iosIcSt11char_traitsIcEE(%rip), %rax movq %rax, 296(%rsp) movq $0, 512(%rsp) movb $0, 520(%rsp) movb $0, 521(%rsp) movq $0, 528(%rsp) movq $0, 536(%rsp) movq $0, 544(%rsp) movq $0, 552(%rsp) movq 8+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) movq -24(%rax), %rax movq 16+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rcx movq %rcx, 48(%rsp,%rax) movq 48(%rsp), %rax addq -24(%rax), %rbx movq %rbx, %rdi movl $0, %esi .LEHB6: call _ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@PLT .LEHE6: jmp .L64 .L63: movq 8(%rsp), %rdi call free@PLT .LEHB7: call cudaDeviceReset@PLT movq 824(%rsp), %rax subq %fs:40, %rax jne .L65 movl $0, %eax addq $840, %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 .L40: .cfi_restore_state movq %rbx, %rdi call _Unwind_Resume@PLT .LEHE7: .L65: call __stack_chk_fail@PLT .cfi_endproc .LFE3803: .globl __gxx_personality_v0 .section .gcc_except_table,"a",@progbits .align 4 .LLSDA3803: .byte 0xff .byte 0x9b .uleb128 .LLSDATT3803-.LLSDATTD3803 .LLSDATTD3803: .byte 0x1 .uleb128 .LLSDACSE3803-.LLSDACSB3803 .LLSDACSB3803: .uleb128 .LEHB0-.LFB3803 .uleb128 .LEHE0-.LEHB0 .uleb128 0 .uleb128 0 .uleb128 .LEHB1-.LFB3803 .uleb128 .LEHE1-.LEHB1 .uleb128 .L44-.LFB3803 .uleb128 0 .uleb128 .LEHB2-.LFB3803 .uleb128 .LEHE2-.LEHB2 .uleb128 .L45-.LFB3803 .uleb128 0 .uleb128 .LEHB3-.LFB3803 .uleb128 .LEHE3-.LEHB3 .uleb128 0 .uleb128 0 .uleb128 .LEHB4-.LFB3803 .uleb128 .LEHE4-.LEHB4 .uleb128 .L42-.LFB3803 .uleb128 0 .uleb128 .LEHB5-.LFB3803 .uleb128 .LEHE5-.LEHB5 .uleb128 .L46-.LFB3803 .uleb128 0x1 .uleb128 .LEHB6-.LFB3803 .uleb128 .LEHE6-.LEHB6 .uleb128 .L43-.LFB3803 .uleb128 0 .uleb128 .LEHB7-.LFB3803 .uleb128 .LEHE7-.LEHB7 .uleb128 0 .uleb128 0 .LLSDACSE3803: .byte 0x1 .byte 0 .align 4 .long 0 .LLSDATT3803: .text .size main, .-main .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 .hidden DW.ref.__gxx_personality_v0 .weak DW.ref.__gxx_personality_v0 .section .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat .align 8 .type DW.ref.__gxx_personality_v0, @object .size DW.ref.__gxx_personality_v0, 8 DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0 .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 <curand.h> #include <fstream> #include <iostream> #define GRID_SIZE 1 #define BLOCK_SIZE 8 #define NUM_TRY 3000000 /** * 線形乱数生成器 */ __device__ unsigned int rand(unsigned int* randx) { *randx = *randx * 1103515245 + 12345; return (*randx)&2147483647; } __device__ float randf(unsigned int* randx) { return rand(randx) / (float(2147483647) + 1); } __device__ float randf(unsigned int* randx, float a, float b) { return randf(randx) * (b - a) + a; } /** * 乱数を生成し、デバイスバッファに格納する */ __global__ void gen_random(int* devResults) { int idx = blockDim.x * blockIdx.x + threadIdx.x; // 乱数シードの初期化 unsigned int randx = idx; for (int i = 0; i < NUM_TRY; ++i) { int x = randf(&randx, 0, 200); devResults[idx * NUM_TRY + i + 0] = x; } } int main() { int* results; int* devResults; // CPU側でメモリを確保する results = new int[GRID_SIZE * BLOCK_SIZE * NUM_TRY]; // GPU側でメモリを確保する cudaMalloc((void**)&devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY); // GPU側の関数を呼び出す。()内が、そのまま関数の引数となる gen_random<<<GRID_SIZE, BLOCK_SIZE>>>(devResults); // 指定したsize分、GPUのd_bufferから、CPUのbufferへ、データを転送する cudaMemcpy(results, devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY, cudaMemcpyDeviceToHost); // GPU側で確保したメモリを開放する cudaFree(devResults); // 結果を表示する for (int i = 0; i < GRID_SIZE * BLOCK_SIZE; ++i) { char filename[256]; sprintf(filename, "random_%d.txt", i); std::ofstream out(filename); for (int j = 0; j < NUM_TRY; ++j) { out << results[i * NUM_TRY + j + 0] << std::endl; if (results[i * NUM_TRY + j + 0] >= 200) { printf("ERROR: x >= 200\n"); } if (results[i * NUM_TRY + j + 1] >= 200) { printf("ERROR: y >= 200\n"); } } out.close(); printf("random numbers were written to %s\n", filename); } // 出力したrandom_X.txtを、plot.pyでグラフにプロットすると、 // きれいにランダムにプロットが生成されていることが分かるよ!! // ヒストグラムを表示して、ほぼ均一に生成されていることが分かる。 // 結論:Rand()関数は、簡単な乱数生成器として、十分使える! // CPU側で確保したメモリを開放する free(results); cudaDeviceReset(); }
 #include <hip/hip_runtime.h> #include <stdio.h> #include <hiprand/hiprand.h> #include <fstream> #include <iostream> #define GRID_SIZE 1 #define BLOCK_SIZE 8 #define NUM_TRY 3000000 /** * 線形乱数生成器 */ __device__ unsigned int rand(unsigned int* randx) { *randx = *randx * 1103515245 + 12345; return (*randx)&2147483647; } __device__ float randf(unsigned int* randx) { return rand(randx) / (float(2147483647) + 1); } __device__ float randf(unsigned int* randx, float a, float b) { return randf(randx) * (b - a) + a; } /** * 乱数を生成し、デバイスバッファに格納する */ __global__ void gen_random(int* devResults) { int idx = blockDim.x * blockIdx.x + threadIdx.x; // 乱数シードの初期化 unsigned int randx = idx; for (int i = 0; i < NUM_TRY; ++i) { int x = randf(&randx, 0, 200); devResults[idx * NUM_TRY + i + 0] = x; } } int main() { int* results; int* devResults; // CPU側でメモリを確保する results = new int[GRID_SIZE * BLOCK_SIZE * NUM_TRY]; // GPU側でメモリを確保する hipMalloc((void**)&devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY); // GPU側の関数を呼び出す。()内が、そのまま関数の引数となる gen_random<<<GRID_SIZE, BLOCK_SIZE>>>(devResults); // 指定したsize分、GPUのd_bufferから、CPUのbufferへ、データを転送する hipMemcpy(results, devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY, hipMemcpyDeviceToHost); // GPU側で確保したメモリを開放する hipFree(devResults); // 結果を表示する for (int i = 0; i < GRID_SIZE * BLOCK_SIZE; ++i) { char filename[256]; sprintf(filename, "random_%d.txt", i); std::ofstream out(filename); for (int j = 0; j < NUM_TRY; ++j) { out << results[i * NUM_TRY + j + 0] << std::endl; if (results[i * NUM_TRY + j + 0] >= 200) { printf("ERROR: x >= 200\n"); } if (results[i * NUM_TRY + j + 1] >= 200) { printf("ERROR: y >= 200\n"); } } out.close(); printf("random numbers were written to %s\n", filename); } // 出力したrandom_X.txtを、plot.pyでグラフにプロットすると、 // きれいにランダムにプロットが生成されていることが分かるよ!! // ヒストグラムを表示して、ほぼ均一に生成されていることが分かる。 // 結論:Rand()関数は、簡単な乱数生成器として、十分使える! // CPU側で確保したメモリを開放する free(results); hipDeviceReset(); }
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 <hiprand/hiprand.h> #include <fstream> #include <iostream> #define GRID_SIZE 1 #define BLOCK_SIZE 8 #define NUM_TRY 3000000 /** * 線形乱数生成器 */ __device__ unsigned int rand(unsigned int* randx) { *randx = *randx * 1103515245 + 12345; return (*randx)&2147483647; } __device__ float randf(unsigned int* randx) { return rand(randx) / (float(2147483647) + 1); } __device__ float randf(unsigned int* randx, float a, float b) { return randf(randx) * (b - a) + a; } /** * 乱数を生成し、デバイスバッファに格納する */ __global__ void gen_random(int* devResults) { int idx = blockDim.x * blockIdx.x + threadIdx.x; // 乱数シードの初期化 unsigned int randx = idx; for (int i = 0; i < NUM_TRY; ++i) { int x = randf(&randx, 0, 200); devResults[idx * NUM_TRY + i + 0] = x; } } int main() { int* results; int* devResults; // CPU側でメモリを確保する results = new int[GRID_SIZE * BLOCK_SIZE * NUM_TRY]; // GPU側でメモリを確保する hipMalloc((void**)&devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY); // GPU側の関数を呼び出す。()内が、そのまま関数の引数となる gen_random<<<GRID_SIZE, BLOCK_SIZE>>>(devResults); // 指定したsize分、GPUのd_bufferから、CPUのbufferへ、データを転送する hipMemcpy(results, devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY, hipMemcpyDeviceToHost); // GPU側で確保したメモリを開放する hipFree(devResults); // 結果を表示する for (int i = 0; i < GRID_SIZE * BLOCK_SIZE; ++i) { char filename[256]; sprintf(filename, "random_%d.txt", i); std::ofstream out(filename); for (int j = 0; j < NUM_TRY; ++j) { out << results[i * NUM_TRY + j + 0] << std::endl; if (results[i * NUM_TRY + j + 0] >= 200) { printf("ERROR: x >= 200\n"); } if (results[i * NUM_TRY + j + 1] >= 200) { printf("ERROR: y >= 200\n"); } } out.close(); printf("random numbers were written to %s\n", filename); } // 出力したrandom_X.txtを、plot.pyでグラフにプロットすると、 // きれいにランダムにプロットが生成されていることが分かるよ!! // ヒストグラムを表示して、ほぼ均一に生成されていることが分かる。 // 結論:Rand()関数は、簡単な乱数生成器として、十分使える! // CPU側で確保したメモリを開放する free(results); hipDeviceReset(); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z10gen_randomPi .globl _Z10gen_randomPi .p2align 8 .type _Z10gen_randomPi,@function _Z10gen_randomPi: s_clause 0x1 s_load_b32 s2, s[0:1], 0x14 s_load_b64 s[0:1], 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[1:2], null, s15, s2, v[0:1] s_mov_b32 s2, 0x41c64e6d v_mul_lo_u32 v2, v1, 0x2dc6c0 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_ashrrev_i32_e32 v3, 31, v2 v_lshlrev_b64 v[2:3], 2, v[2:3] s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, s0, v2 v_add_co_ci_u32_e32 v2, vcc_lo, s1, v3, vcc_lo s_mov_b64 s[0:1], 0 .p2align 6 .LBB0_1: v_mad_u64_u32 v[3:4], null, v1, s2, 0x3039 s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v4, vcc_lo, v0, s0 v_add_co_ci_u32_e32 v5, vcc_lo, s1, v2, vcc_lo s_add_u32 s0, s0, 4 s_addc_u32 s1, s1, 0 s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1) v_and_b32_e32 v1, 0x7fffffff, v3 s_cmp_eq_u32 s0, 0xb71b00 v_cvt_f32_u32_e32 v1, v1 s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1) v_mul_f32_e32 v1, 0x30000000, v1 v_fma_f32 v1, v1, 0x43480000, 0 s_delay_alu instid0(VALU_DEP_1) v_cvt_i32_f32_e32 v6, v1 v_mov_b32_e32 v1, v3 global_store_b32 v[4:5], v6, off s_cbranch_scc0 .LBB0_1 s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _Z10gen_randomPi .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 7 .amdhsa_next_free_sgpr 16 .amdhsa_float_round_mode_32 0 .amdhsa_float_round_mode_16_64 0 .amdhsa_float_denorm_mode_32 3 .amdhsa_float_denorm_mode_16_64 3 .amdhsa_dx10_clamp 1 .amdhsa_ieee_mode 1 .amdhsa_fp16_overflow 0 .amdhsa_workgroup_processor_mode 1 .amdhsa_memory_ordered 1 .amdhsa_forward_progress 0 .amdhsa_shared_vgpr_count 0 .amdhsa_exception_fp_ieee_invalid_op 0 .amdhsa_exception_fp_denorm_src 0 .amdhsa_exception_fp_ieee_div_zero 0 .amdhsa_exception_fp_ieee_overflow 0 .amdhsa_exception_fp_ieee_underflow 0 .amdhsa_exception_fp_ieee_inexact 0 .amdhsa_exception_int_div_zero 0 .end_amdhsa_kernel .text .Lfunc_end0: .size _Z10gen_randomPi, .Lfunc_end0-_Z10gen_randomPi .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: 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 .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: _Z10gen_randomPi .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z10gen_randomPi.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 7 .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 <hiprand/hiprand.h> #include <fstream> #include <iostream> #define GRID_SIZE 1 #define BLOCK_SIZE 8 #define NUM_TRY 3000000 /** * 線形乱数生成器 */ __device__ unsigned int rand(unsigned int* randx) { *randx = *randx * 1103515245 + 12345; return (*randx)&2147483647; } __device__ float randf(unsigned int* randx) { return rand(randx) / (float(2147483647) + 1); } __device__ float randf(unsigned int* randx, float a, float b) { return randf(randx) * (b - a) + a; } /** * 乱数を生成し、デバイスバッファに格納する */ __global__ void gen_random(int* devResults) { int idx = blockDim.x * blockIdx.x + threadIdx.x; // 乱数シードの初期化 unsigned int randx = idx; for (int i = 0; i < NUM_TRY; ++i) { int x = randf(&randx, 0, 200); devResults[idx * NUM_TRY + i + 0] = x; } } int main() { int* results; int* devResults; // CPU側でメモリを確保する results = new int[GRID_SIZE * BLOCK_SIZE * NUM_TRY]; // GPU側でメモリを確保する hipMalloc((void**)&devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY); // GPU側の関数を呼び出す。()内が、そのまま関数の引数となる gen_random<<<GRID_SIZE, BLOCK_SIZE>>>(devResults); // 指定したsize分、GPUのd_bufferから、CPUのbufferへ、データを転送する hipMemcpy(results, devResults, sizeof(int) * GRID_SIZE * BLOCK_SIZE * NUM_TRY, hipMemcpyDeviceToHost); // GPU側で確保したメモリを開放する hipFree(devResults); // 結果を表示する for (int i = 0; i < GRID_SIZE * BLOCK_SIZE; ++i) { char filename[256]; sprintf(filename, "random_%d.txt", i); std::ofstream out(filename); for (int j = 0; j < NUM_TRY; ++j) { out << results[i * NUM_TRY + j + 0] << std::endl; if (results[i * NUM_TRY + j + 0] >= 200) { printf("ERROR: x >= 200\n"); } if (results[i * NUM_TRY + j + 1] >= 200) { printf("ERROR: y >= 200\n"); } } out.close(); printf("random numbers were written to %s\n", filename); } // 出力したrandom_X.txtを、plot.pyでグラフにプロットすると、 // きれいにランダムにプロットが生成されていることが分かるよ!! // ヒストグラムを表示して、ほぼ均一に生成されていることが分かる。 // 結論:Rand()関数は、簡単な乱数生成器として、十分使える! // CPU側で確保したメモリを開放する free(results); hipDeviceReset(); }
.text .file "random_test.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z25__device_stub__gen_randomPi # -- Begin function _Z25__device_stub__gen_randomPi .p2align 4, 0x90 .type _Z25__device_stub__gen_randomPi,@function _Z25__device_stub__gen_randomPi: # @_Z25__device_stub__gen_randomPi .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 $_Z10gen_randomPi, %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_end0: .size _Z25__device_stub__gen_randomPi, .Lfunc_end0-_Z25__device_stub__gen_randomPi .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .Lfunc_begin0: .cfi_startproc .cfi_personality 3, __gxx_personality_v0 .cfi_lsda 3, .Lexception0 # %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 $840, %rsp # imm = 0x348 .cfi_def_cfa_offset 896 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 .cfi_escape 0x2e, 0x00 movl $96000000, %edi # imm = 0x5B8D800 callq _Znam movq %rax, %r14 .cfi_escape 0x2e, 0x00 leaq 8(%rsp), %rdi movl $96000000, %esi # imm = 0x5B8D800 callq hipMalloc movabsq $4294967297, %rdi # imm = 0x100000001 leaq 7(%rdi), %rdx .cfi_escape 0x2e, 0x00 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_2 # %bb.1: movq 8(%rsp), %rax movq %rax, 56(%rsp) leaq 56(%rsp), %rax movq %rax, 16(%rsp) .cfi_escape 0x2e, 0x00 leaq 328(%rsp), %rdi leaq 64(%rsp), %rsi leaq 48(%rsp), %rdx leaq 40(%rsp), %rcx callq __hipPopCallConfiguration movq 328(%rsp), %rsi movl 336(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d .cfi_escape 0x2e, 0x10 leaq 16(%rsp), %r9 movl $_Z10gen_randomPi, %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_2: movq 8(%rsp), %rsi .cfi_escape 0x2e, 0x00 movl $96000000, %edx # imm = 0x5B8D800 movq %r14, %rdi movl $2, %ecx callq hipMemcpy movq 8(%rsp), %rdi .cfi_escape 0x2e, 0x00 callq hipFree leaq 64(%rsp), %r15 leaq 328(%rsp), %r12 movq %r14, 32(%rsp) # 8-byte Spill xorl %r13d, %r13d jmp .LBB1_3 .p2align 4, 0x90 .LBB1_10: # %_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv.exit # in Loop: Header=BB1_3 Depth=1 .cfi_escape 0x2e, 0x00 movl $.L.str.3, %edi leaq 64(%rsp), %r15 movq %r15, %rsi xorl %eax, %eax callq printf .cfi_escape 0x2e, 0x00 movq %r12, %rdi callq _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev incq %r13 addq $12000000, %r14 # imm = 0xB71B00 cmpq $8, %r13 je .LBB1_11 .LBB1_3: # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 .cfi_escape 0x2e, 0x00 movl $.L.str, %esi movq %r15, %rdi movl %r13d, %edx xorl %eax, %eax callq sprintf .cfi_escape 0x2e, 0x00 movq %r12, %rdi movq %r15, %rsi movl $16, %edx callq _ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode xorl %r15d, %r15d jmp .LBB1_4 .p2align 4, 0x90 .LBB1_23: # in Loop: Header=BB1_4 Depth=2 incq %r15 cmpq $3000000, %r15 # imm = 0x2DC6C0 je .LBB1_7 .LBB1_4: # Parent Loop BB1_3 Depth=1 # => This Inner Loop Header: Depth=2 movl (%r14,%r15,4), %esi .Ltmp0: .cfi_escape 0x2e, 0x00 movq %r12, %rdi callq _ZNSolsEi .Ltmp1: # %bb.5: # in Loop: Header=BB1_4 Depth=2 movq %rax, %rbp movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbp,%rax), %rbx testq %rbx, %rbx je .LBB1_6 # %bb.13: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i # in Loop: Header=BB1_4 Depth=2 cmpb $0, 56(%rbx) je .LBB1_15 # %bb.14: # in Loop: Header=BB1_4 Depth=2 movzbl 67(%rbx), %eax jmp .LBB1_17 .p2align 4, 0x90 .LBB1_15: # in Loop: Header=BB1_4 Depth=2 .Ltmp2: .cfi_escape 0x2e, 0x00 movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv .Ltmp3: # %bb.16: # %.noexc28 # in Loop: Header=BB1_4 Depth=2 movq (%rbx), %rax .Ltmp4: .cfi_escape 0x2e, 0x00 movq %rbx, %rdi movl $10, %esi callq *48(%rax) .Ltmp5: .LBB1_17: # %_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc.exit.i # in Loop: Header=BB1_4 Depth=2 .Ltmp6: .cfi_escape 0x2e, 0x00 movsbl %al, %esi movq %rbp, %rdi callq _ZNSo3putEc .Ltmp7: # %bb.18: # %.noexc30 # in Loop: Header=BB1_4 Depth=2 .Ltmp8: .cfi_escape 0x2e, 0x00 movq %rax, %rdi callq _ZNSo5flushEv .Ltmp9: # %bb.19: # %_ZNSolsEPFRSoS_E.exit # in Loop: Header=BB1_4 Depth=2 cmpl $200, (%r14,%r15,4) jl .LBB1_21 # %bb.20: # in Loop: Header=BB1_4 Depth=2 .cfi_escape 0x2e, 0x00 movl $.Lstr, %edi callq puts@PLT .LBB1_21: # in Loop: Header=BB1_4 Depth=2 cmpl $200, 4(%r14,%r15,4) jl .LBB1_23 # %bb.22: # in Loop: Header=BB1_4 Depth=2 .cfi_escape 0x2e, 0x00 movl $.Lstr.1, %edi callq puts@PLT jmp .LBB1_23 .p2align 4, 0x90 .LBB1_7: # in Loop: Header=BB1_3 Depth=1 .Ltmp11: .cfi_escape 0x2e, 0x00 leaq 336(%rsp), %rdi callq _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv .Ltmp12: # %bb.8: # %.noexc # in Loop: Header=BB1_3 Depth=1 testq %rax, %rax jne .LBB1_10 # %bb.9: # in Loop: Header=BB1_3 Depth=1 movq 328(%rsp), %rax movq -24(%rax), %rax leaq (%rsp,%rax), %rdi addq $328, %rdi # imm = 0x148 movl 360(%rsp,%rax), %esi orl $4, %esi .Ltmp13: .cfi_escape 0x2e, 0x00 callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .Ltmp14: jmp .LBB1_10 .LBB1_11: .cfi_escape 0x2e, 0x00 movq 32(%rsp), %rdi # 8-byte Reload callq free .cfi_escape 0x2e, 0x00 callq hipDeviceReset xorl %eax, %eax addq $840, %rsp # imm = 0x348 .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_6: .cfi_def_cfa_offset 896 .Ltmp16: .cfi_escape 0x2e, 0x00 callq _ZSt16__throw_bad_castv .Ltmp17: # %bb.12: # %.noexc27 .LBB1_26: .Ltmp15: jmp .LBB1_27 .LBB1_25: # %.loopexit.split-lp .Ltmp18: jmp .LBB1_27 .LBB1_24: # %.loopexit .Ltmp10: .LBB1_27: movq %rax, %rbx .cfi_escape 0x2e, 0x00 leaq 328(%rsp), %rdi callq _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev .cfi_escape 0x2e, 0x00 movq %rbx, %rdi callq _Unwind_Resume@PLT .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc .section .gcc_except_table,"a",@progbits .p2align 2, 0x0 GCC_except_table1: .Lexception0: .byte 255 # @LPStart Encoding = omit .byte 255 # @TType Encoding = omit .byte 1 # Call site Encoding = uleb128 .uleb128 .Lcst_end0-.Lcst_begin0 .Lcst_begin0: .uleb128 .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 << .uleb128 .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0 .byte 0 # has no landing pad .byte 0 # On action: cleanup .uleb128 .Ltmp0-.Lfunc_begin0 # >> Call Site 2 << .uleb128 .Ltmp9-.Ltmp0 # Call between .Ltmp0 and .Ltmp9 .uleb128 .Ltmp10-.Lfunc_begin0 # jumps to .Ltmp10 .byte 0 # On action: cleanup .uleb128 .Ltmp11-.Lfunc_begin0 # >> Call Site 3 << .uleb128 .Ltmp14-.Ltmp11 # Call between .Ltmp11 and .Ltmp14 .uleb128 .Ltmp15-.Lfunc_begin0 # jumps to .Ltmp15 .byte 0 # On action: cleanup .uleb128 .Ltmp14-.Lfunc_begin0 # >> Call Site 4 << .uleb128 .Ltmp16-.Ltmp14 # Call between .Ltmp14 and .Ltmp16 .byte 0 # has no landing pad .byte 0 # On action: cleanup .uleb128 .Ltmp16-.Lfunc_begin0 # >> Call Site 5 << .uleb128 .Ltmp17-.Ltmp16 # Call between .Ltmp16 and .Ltmp17 .uleb128 .Ltmp18-.Lfunc_begin0 # jumps to .Ltmp18 .byte 0 # On action: cleanup .uleb128 .Ltmp17-.Lfunc_begin0 # >> Call Site 6 << .uleb128 .Lfunc_end1-.Ltmp17 # Call between .Ltmp17 and .Lfunc_end1 .byte 0 # has no landing pad .byte 0 # On action: cleanup .Lcst_end0: .p2align 2, 0x0 # -- End function .text .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 $_Z10gen_randomPi, %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 _Z10gen_randomPi,@object # @_Z10gen_randomPi .section .rodata,"a",@progbits .globl _Z10gen_randomPi .p2align 3, 0x0 _Z10gen_randomPi: .quad _Z25__device_stub__gen_randomPi .size _Z10gen_randomPi, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "random_%d.txt" .size .L.str, 14 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "random numbers were written to %s\n" .size .L.str.3, 35 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z10gen_randomPi" .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 "ERROR: x >= 200" .size .Lstr, 16 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "ERROR: y >= 200" .size .Lstr.1, 16 .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__gen_randomPi .addrsig_sym __gxx_personality_v0 .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Unwind_Resume .addrsig_sym _Z10gen_randomPi .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_00195753_00000000-6_random_test.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3806: .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 .LFE3806: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .globl _Z4randPj .type _Z4randPj, @function _Z4randPj: .LFB3800: .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 .LFE3800: .size _Z4randPj, .-_Z4randPj .globl _Z5randfPj .type _Z5randfPj, @function _Z5randfPj: .LFB3801: .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 .LFE3801: .size _Z5randfPj, .-_Z5randfPj .globl _Z5randfPjff .type _Z5randfPjff, @function _Z5randfPjff: .LFB3802: .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 .LFE3802: .size _Z5randfPjff, .-_Z5randfPjff .globl _Z30__device_stub__Z10gen_randomPiPi .type _Z30__device_stub__Z10gen_randomPiPi, @function _Z30__device_stub__Z10gen_randomPiPi: .LFB3828: .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 .L13 .L9: movq 88(%rsp), %rax subq %fs:40, %rax jne .L14 addq $104, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L13: .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 _Z10gen_randomPi(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 112 jmp .L9 .L14: call __stack_chk_fail@PLT .cfi_endproc .LFE3828: .size _Z30__device_stub__Z10gen_randomPiPi, .-_Z30__device_stub__Z10gen_randomPiPi .globl _Z10gen_randomPi .type _Z10gen_randomPi, @function _Z10gen_randomPi: .LFB3829: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z30__device_stub__Z10gen_randomPiPi addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3829: .size _Z10gen_randomPi, .-_Z10gen_randomPi .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z10gen_randomPi" .text .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3831: .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 _Z10gen_randomPi(%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 .LFE3831: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .rodata.str1.1 .LC1: .string "random_%d.txt" .LC2: .string "ERROR: x >= 200\n" .LC3: .string "ERROR: y >= 200\n" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC4: .string "random numbers were written to %s\n" .text .globl main .type main, @function main: .LFB3803: .cfi_startproc .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 .cfi_lsda 0x1b,.LLSDA3803 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 $840, %rsp .cfi_def_cfa_offset 896 movq %fs:40, %rax movq %rax, 824(%rsp) xorl %eax, %eax movl $96000000, %edi .LEHB0: call _Znam@PLT movq %rax, 8(%rsp) leaq 16(%rsp), %rdi movl $96000000, %esi call cudaMalloc@PLT movl $8, 36(%rsp) movl $1, 40(%rsp) movl $1, 44(%rsp) movl $1, 24(%rsp) movl $1, 28(%rsp) movl $1, 32(%rsp) movl $0, %r9d movl $0, %r8d movq 36(%rsp), %rdx movl $1, %ecx movq 24(%rsp), %rdi movl $1, %esi call __cudaPushCallConfiguration@PLT testl %eax, %eax je .L52 .L20: movl $2, %ecx movl $96000000, %edx movq 16(%rsp), %rsi movq 8(%rsp), %rbx movq %rbx, %rdi call cudaMemcpy@PLT movq 16(%rsp), %rdi call cudaFree@PLT leaq 12000000(%rbx), %r14 movl $0, 4(%rsp) jmp .L35 .L52: movq 16(%rsp), %rdi call _Z30__device_stub__Z10gen_randomPiPi .LEHE0: jmp .L20 .L64: leaq 24+_ZTVSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) leaq 40(%rax), %rax movq %rax, 296(%rsp) leaq 56(%rsp), %rdi .LEHB1: call _ZNSt13basic_filebufIcSt11char_traitsIcEEC1Ev@PLT .LEHE1: leaq 56(%rsp), %rsi leaq 296(%rsp), %rdi .LEHB2: call _ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@PLT leaq 560(%rsp), %rsi leaq 56(%rsp), %rdi movl $16, %edx call _ZNSt13basic_filebufIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT testq %rax, %rax je .L53 movq 48(%rsp), %rax movq -24(%rax), %rax leaq 48(%rsp,%rax), %rdi movl $0, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT jmp .L23 .L53: movq 48(%rsp), %rax movq -24(%rax), %rax leaq 48(%rsp,%rax), %rdi movl 32(%rdi), %esi orl $4, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT .LEHE2: .L23: leaq -12000000(%r14), %rbp leaq 48(%rsp), %r15 jmp .L22 .L45: endbr64 movq %rax, %rbx leaq 56(%rsp), %rdi call _ZNSt13basic_filebufIcSt11char_traitsIcEED1Ev@PLT .L25: movq 8+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) movq -24(%rax), %rax movq 16+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rdx movq %rdx, 48(%rsp,%rax) .L26: leaq 16+_ZTVSt9basic_iosIcSt11char_traitsIcEE(%rip), %rax movq %rax, 296(%rsp) leaq 296(%rsp), %rdi call _ZNSt8ios_baseD2Ev@PLT movq 824(%rsp), %rax subq %fs:40, %rax je .L27 call __stack_chk_fail@PLT .L44: endbr64 movq %rax, %rbx jmp .L25 .L43: endbr64 movq %rax, %rbx jmp .L26 .L27: movq %rbx, %rdi .LEHB3: call _Unwind_Resume@PLT .LEHE3: .L60: movq %rax, %rbx movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbx,%rax), %r12 testq %r12, %r12 je .L54 cmpb $0, 56(%r12) je .L30 movzbl 67(%r12), %esi .L31: movsbl %sil, %esi movq %rbx, %rdi .LEHB4: call _ZNSo3putEc@PLT jmp .L55 .L54: movq 824(%rsp), %rax subq %fs:40, %rax jne .L56 call _ZSt16__throw_bad_castv@PLT .L42: endbr64 movq %rax, %rbx leaq 48(%rsp), %rdi call _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT movq 824(%rsp), %rax subq %fs:40, %rax je .L40 call __stack_chk_fail@PLT .L56: call __stack_chk_fail@PLT .L30: movq %r12, %rdi call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT movq (%r12), %rax movl $10, %esi movq %r12, %rdi call *48(%rax) movl %eax, %esi jmp .L31 .L55: movq %rax, %rdi call _ZNSo5flushEv@PLT cmpl $199, 0(%r13) jg .L57 .L32: cmpl $199, 4(%r13) jg .L58 .L33: addq $4, %rbp cmpq %r14, %rbp je .L59 .L22: movq %rbp, %r13 movl 0(%rbp), %esi movq %r15, %rdi call _ZNSolsEi@PLT jmp .L60 .L57: leaq .LC2(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L32 .L58: leaq .LC3(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L33 .L59: leaq 56(%rsp), %rdi call _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv@PLT testq %rax, %rax je .L61 .L34: leaq 560(%rsp), %rdx leaq .LC4(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT jmp .L62 .L61: movq 48(%rsp), %rax movq -24(%rax), %rax leaq 48(%rsp,%rax), %rdi movl 32(%rdi), %esi orl $4, %esi call _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate@PLT .LEHE4: jmp .L34 .L62: leaq 24+_ZTVSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) leaq 40(%rax), %rax movq %rax, 296(%rsp) leaq 16+_ZTVSt13basic_filebufIcSt11char_traitsIcEE(%rip), %rax movq %rax, 56(%rsp) leaq 56(%rsp), %rdi .LEHB5: call _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv@PLT .LEHE5: jmp .L38 .L46: endbr64 movq %rax, %rdi call __cxa_begin_catch@PLT call __cxa_end_catch@PLT .L38: leaq 160(%rsp), %rdi call _ZNSt12__basic_fileIcED1Ev@PLT leaq 16+_ZTVSt15basic_streambufIcSt11char_traitsIcEE(%rip), %rax movq %rax, 56(%rsp) leaq 112(%rsp), %rdi call _ZNSt6localeD1Ev@PLT movq 8+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) movq -24(%rax), %rax movq 16+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rcx movq %rcx, 48(%rsp,%rax) leaq 16+_ZTVSt9basic_iosIcSt11char_traitsIcEE(%rip), %rax movq %rax, 296(%rsp) leaq 296(%rsp), %rdi call _ZNSt8ios_baseD2Ev@PLT addl $1, 4(%rsp) movl 4(%rsp), %eax addq $12000000, %r14 cmpl $8, %eax je .L63 .L35: leaq 560(%rsp), %rdi movl 4(%rsp), %r8d leaq .LC1(%rip), %rcx movl $256, %edx movl $2, %esi movl $0, %eax call __sprintf_chk@PLT leaq 48(%rsp), %rbx leaq 296(%rsp), %rdi call _ZNSt8ios_baseC2Ev@PLT leaq 16+_ZTVSt9basic_iosIcSt11char_traitsIcEE(%rip), %rax movq %rax, 296(%rsp) movq $0, 512(%rsp) movb $0, 520(%rsp) movb $0, 521(%rsp) movq $0, 528(%rsp) movq $0, 536(%rsp) movq $0, 544(%rsp) movq $0, 552(%rsp) movq 8+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax movq %rax, 48(%rsp) movq -24(%rax), %rax movq 16+_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rcx movq %rcx, 48(%rsp,%rax) movq 48(%rsp), %rax addq -24(%rax), %rbx movq %rbx, %rdi movl $0, %esi .LEHB6: call _ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@PLT .LEHE6: jmp .L64 .L63: movq 8(%rsp), %rdi call free@PLT .LEHB7: call cudaDeviceReset@PLT movq 824(%rsp), %rax subq %fs:40, %rax jne .L65 movl $0, %eax addq $840, %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 .L40: .cfi_restore_state movq %rbx, %rdi call _Unwind_Resume@PLT .LEHE7: .L65: call __stack_chk_fail@PLT .cfi_endproc .LFE3803: .globl __gxx_personality_v0 .section .gcc_except_table,"a",@progbits .align 4 .LLSDA3803: .byte 0xff .byte 0x9b .uleb128 .LLSDATT3803-.LLSDATTD3803 .LLSDATTD3803: .byte 0x1 .uleb128 .LLSDACSE3803-.LLSDACSB3803 .LLSDACSB3803: .uleb128 .LEHB0-.LFB3803 .uleb128 .LEHE0-.LEHB0 .uleb128 0 .uleb128 0 .uleb128 .LEHB1-.LFB3803 .uleb128 .LEHE1-.LEHB1 .uleb128 .L44-.LFB3803 .uleb128 0 .uleb128 .LEHB2-.LFB3803 .uleb128 .LEHE2-.LEHB2 .uleb128 .L45-.LFB3803 .uleb128 0 .uleb128 .LEHB3-.LFB3803 .uleb128 .LEHE3-.LEHB3 .uleb128 0 .uleb128 0 .uleb128 .LEHB4-.LFB3803 .uleb128 .LEHE4-.LEHB4 .uleb128 .L42-.LFB3803 .uleb128 0 .uleb128 .LEHB5-.LFB3803 .uleb128 .LEHE5-.LEHB5 .uleb128 .L46-.LFB3803 .uleb128 0x1 .uleb128 .LEHB6-.LFB3803 .uleb128 .LEHE6-.LEHB6 .uleb128 .L43-.LFB3803 .uleb128 0 .uleb128 .LEHB7-.LFB3803 .uleb128 .LEHE7-.LEHB7 .uleb128 0 .uleb128 0 .LLSDACSE3803: .byte 0x1 .byte 0 .align 4 .long 0 .LLSDATT3803: .text .size main, .-main .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 .hidden DW.ref.__gxx_personality_v0 .weak DW.ref.__gxx_personality_v0 .section .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat .align 8 .type DW.ref.__gxx_personality_v0, @object .size DW.ref.__gxx_personality_v0, 8 DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0 .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 "random_test.hip" # Start of file scope inline assembly .globl _ZSt21ios_base_library_initv # End of file scope inline assembly .globl _Z25__device_stub__gen_randomPi # -- Begin function _Z25__device_stub__gen_randomPi .p2align 4, 0x90 .type _Z25__device_stub__gen_randomPi,@function _Z25__device_stub__gen_randomPi: # @_Z25__device_stub__gen_randomPi .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 $_Z10gen_randomPi, %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_end0: .size _Z25__device_stub__gen_randomPi, .Lfunc_end0-_Z25__device_stub__gen_randomPi .cfi_endproc # -- End function .globl main # -- Begin function main .p2align 4, 0x90 .type main,@function main: # @main .Lfunc_begin0: .cfi_startproc .cfi_personality 3, __gxx_personality_v0 .cfi_lsda 3, .Lexception0 # %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 $840, %rsp # imm = 0x348 .cfi_def_cfa_offset 896 .cfi_offset %rbx, -56 .cfi_offset %r12, -48 .cfi_offset %r13, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 .cfi_escape 0x2e, 0x00 movl $96000000, %edi # imm = 0x5B8D800 callq _Znam movq %rax, %r14 .cfi_escape 0x2e, 0x00 leaq 8(%rsp), %rdi movl $96000000, %esi # imm = 0x5B8D800 callq hipMalloc movabsq $4294967297, %rdi # imm = 0x100000001 leaq 7(%rdi), %rdx .cfi_escape 0x2e, 0x00 movl $1, %esi movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB1_2 # %bb.1: movq 8(%rsp), %rax movq %rax, 56(%rsp) leaq 56(%rsp), %rax movq %rax, 16(%rsp) .cfi_escape 0x2e, 0x00 leaq 328(%rsp), %rdi leaq 64(%rsp), %rsi leaq 48(%rsp), %rdx leaq 40(%rsp), %rcx callq __hipPopCallConfiguration movq 328(%rsp), %rsi movl 336(%rsp), %edx movq 64(%rsp), %rcx movl 72(%rsp), %r8d .cfi_escape 0x2e, 0x10 leaq 16(%rsp), %r9 movl $_Z10gen_randomPi, %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_2: movq 8(%rsp), %rsi .cfi_escape 0x2e, 0x00 movl $96000000, %edx # imm = 0x5B8D800 movq %r14, %rdi movl $2, %ecx callq hipMemcpy movq 8(%rsp), %rdi .cfi_escape 0x2e, 0x00 callq hipFree leaq 64(%rsp), %r15 leaq 328(%rsp), %r12 movq %r14, 32(%rsp) # 8-byte Spill xorl %r13d, %r13d jmp .LBB1_3 .p2align 4, 0x90 .LBB1_10: # %_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv.exit # in Loop: Header=BB1_3 Depth=1 .cfi_escape 0x2e, 0x00 movl $.L.str.3, %edi leaq 64(%rsp), %r15 movq %r15, %rsi xorl %eax, %eax callq printf .cfi_escape 0x2e, 0x00 movq %r12, %rdi callq _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev incq %r13 addq $12000000, %r14 # imm = 0xB71B00 cmpq $8, %r13 je .LBB1_11 .LBB1_3: # =>This Loop Header: Depth=1 # Child Loop BB1_4 Depth 2 .cfi_escape 0x2e, 0x00 movl $.L.str, %esi movq %r15, %rdi movl %r13d, %edx xorl %eax, %eax callq sprintf .cfi_escape 0x2e, 0x00 movq %r12, %rdi movq %r15, %rsi movl $16, %edx callq _ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode xorl %r15d, %r15d jmp .LBB1_4 .p2align 4, 0x90 .LBB1_23: # in Loop: Header=BB1_4 Depth=2 incq %r15 cmpq $3000000, %r15 # imm = 0x2DC6C0 je .LBB1_7 .LBB1_4: # Parent Loop BB1_3 Depth=1 # => This Inner Loop Header: Depth=2 movl (%r14,%r15,4), %esi .Ltmp0: .cfi_escape 0x2e, 0x00 movq %r12, %rdi callq _ZNSolsEi .Ltmp1: # %bb.5: # in Loop: Header=BB1_4 Depth=2 movq %rax, %rbp movq (%rax), %rax movq -24(%rax), %rax movq 240(%rbp,%rax), %rbx testq %rbx, %rbx je .LBB1_6 # %bb.13: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit.i.i # in Loop: Header=BB1_4 Depth=2 cmpb $0, 56(%rbx) je .LBB1_15 # %bb.14: # in Loop: Header=BB1_4 Depth=2 movzbl 67(%rbx), %eax jmp .LBB1_17 .p2align 4, 0x90 .LBB1_15: # in Loop: Header=BB1_4 Depth=2 .Ltmp2: .cfi_escape 0x2e, 0x00 movq %rbx, %rdi callq _ZNKSt5ctypeIcE13_M_widen_initEv .Ltmp3: # %bb.16: # %.noexc28 # in Loop: Header=BB1_4 Depth=2 movq (%rbx), %rax .Ltmp4: .cfi_escape 0x2e, 0x00 movq %rbx, %rdi movl $10, %esi callq *48(%rax) .Ltmp5: .LBB1_17: # %_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc.exit.i # in Loop: Header=BB1_4 Depth=2 .Ltmp6: .cfi_escape 0x2e, 0x00 movsbl %al, %esi movq %rbp, %rdi callq _ZNSo3putEc .Ltmp7: # %bb.18: # %.noexc30 # in Loop: Header=BB1_4 Depth=2 .Ltmp8: .cfi_escape 0x2e, 0x00 movq %rax, %rdi callq _ZNSo5flushEv .Ltmp9: # %bb.19: # %_ZNSolsEPFRSoS_E.exit # in Loop: Header=BB1_4 Depth=2 cmpl $200, (%r14,%r15,4) jl .LBB1_21 # %bb.20: # in Loop: Header=BB1_4 Depth=2 .cfi_escape 0x2e, 0x00 movl $.Lstr, %edi callq puts@PLT .LBB1_21: # in Loop: Header=BB1_4 Depth=2 cmpl $200, 4(%r14,%r15,4) jl .LBB1_23 # %bb.22: # in Loop: Header=BB1_4 Depth=2 .cfi_escape 0x2e, 0x00 movl $.Lstr.1, %edi callq puts@PLT jmp .LBB1_23 .p2align 4, 0x90 .LBB1_7: # in Loop: Header=BB1_3 Depth=1 .Ltmp11: .cfi_escape 0x2e, 0x00 leaq 336(%rsp), %rdi callq _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv .Ltmp12: # %bb.8: # %.noexc # in Loop: Header=BB1_3 Depth=1 testq %rax, %rax jne .LBB1_10 # %bb.9: # in Loop: Header=BB1_3 Depth=1 movq 328(%rsp), %rax movq -24(%rax), %rax leaq (%rsp,%rax), %rdi addq $328, %rdi # imm = 0x148 movl 360(%rsp,%rax), %esi orl $4, %esi .Ltmp13: .cfi_escape 0x2e, 0x00 callq _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate .Ltmp14: jmp .LBB1_10 .LBB1_11: .cfi_escape 0x2e, 0x00 movq 32(%rsp), %rdi # 8-byte Reload callq free .cfi_escape 0x2e, 0x00 callq hipDeviceReset xorl %eax, %eax addq $840, %rsp # imm = 0x348 .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_6: .cfi_def_cfa_offset 896 .Ltmp16: .cfi_escape 0x2e, 0x00 callq _ZSt16__throw_bad_castv .Ltmp17: # %bb.12: # %.noexc27 .LBB1_26: .Ltmp15: jmp .LBB1_27 .LBB1_25: # %.loopexit.split-lp .Ltmp18: jmp .LBB1_27 .LBB1_24: # %.loopexit .Ltmp10: .LBB1_27: movq %rax, %rbx .cfi_escape 0x2e, 0x00 leaq 328(%rsp), %rdi callq _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev .cfi_escape 0x2e, 0x00 movq %rbx, %rdi callq _Unwind_Resume@PLT .Lfunc_end1: .size main, .Lfunc_end1-main .cfi_endproc .section .gcc_except_table,"a",@progbits .p2align 2, 0x0 GCC_except_table1: .Lexception0: .byte 255 # @LPStart Encoding = omit .byte 255 # @TType Encoding = omit .byte 1 # Call site Encoding = uleb128 .uleb128 .Lcst_end0-.Lcst_begin0 .Lcst_begin0: .uleb128 .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 << .uleb128 .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0 .byte 0 # has no landing pad .byte 0 # On action: cleanup .uleb128 .Ltmp0-.Lfunc_begin0 # >> Call Site 2 << .uleb128 .Ltmp9-.Ltmp0 # Call between .Ltmp0 and .Ltmp9 .uleb128 .Ltmp10-.Lfunc_begin0 # jumps to .Ltmp10 .byte 0 # On action: cleanup .uleb128 .Ltmp11-.Lfunc_begin0 # >> Call Site 3 << .uleb128 .Ltmp14-.Ltmp11 # Call between .Ltmp11 and .Ltmp14 .uleb128 .Ltmp15-.Lfunc_begin0 # jumps to .Ltmp15 .byte 0 # On action: cleanup .uleb128 .Ltmp14-.Lfunc_begin0 # >> Call Site 4 << .uleb128 .Ltmp16-.Ltmp14 # Call between .Ltmp14 and .Ltmp16 .byte 0 # has no landing pad .byte 0 # On action: cleanup .uleb128 .Ltmp16-.Lfunc_begin0 # >> Call Site 5 << .uleb128 .Ltmp17-.Ltmp16 # Call between .Ltmp16 and .Ltmp17 .uleb128 .Ltmp18-.Lfunc_begin0 # jumps to .Ltmp18 .byte 0 # On action: cleanup .uleb128 .Ltmp17-.Lfunc_begin0 # >> Call Site 6 << .uleb128 .Lfunc_end1-.Ltmp17 # Call between .Ltmp17 and .Lfunc_end1 .byte 0 # has no landing pad .byte 0 # On action: cleanup .Lcst_end0: .p2align 2, 0x0 # -- End function .text .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 $_Z10gen_randomPi, %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 _Z10gen_randomPi,@object # @_Z10gen_randomPi .section .rodata,"a",@progbits .globl _Z10gen_randomPi .p2align 3, 0x0 _Z10gen_randomPi: .quad _Z25__device_stub__gen_randomPi .size _Z10gen_randomPi, 8 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "random_%d.txt" .size .L.str, 14 .type .L.str.3,@object # @.str.3 .L.str.3: .asciz "random numbers were written to %s\n" .size .L.str.3, 35 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_Z10gen_randomPi" .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 "ERROR: x >= 200" .size .Lstr, 16 .type .Lstr.1,@object # @str.1 .Lstr.1: .asciz "ERROR: y >= 200" .size .Lstr.1, 16 .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__gen_randomPi .addrsig_sym __gxx_personality_v0 .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Unwind_Resume .addrsig_sym _Z10gen_randomPi .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 <assert.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #include <device_launch_parameters.h> #define CUDA_CALL(x) { const cudaError_t a = (x); if(a != cudaSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", cudaGetErrorString(a), a, __LINE__); cudaDeviceReset(); assert(0);}} #define MATRIX_SIZE 1024 int BLOCK_WIDTH,BLOCK_HEIGHT; void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]); static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]); extern "C" void cuda_version_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { void *A_dev, *B_dev, *C_dev; cudaEvent_t start,stop; CUDA_CALL(cudaMalloc((void**)&A_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(cudaMalloc((void**)&B_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(cudaMalloc((void**)&C_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); // take data from host to device. CUDA_CALL(cudaMemcpy(A_dev, A, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,cudaMemcpyHostToDevice)); CUDA_CALL(cudaMemcpy(A_dev, B, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,cudaMemcpyHostToDevice)); dim3 block(BLOCK_WIDTH, BLOCK_HEIGHT); dim3 grid(MATRIX_SIZE/BLOCK_WIDTH, MATRIX_SIZE/BLOCK_HEIGHT); float dev_time; printf("[CUDA 1] Start Launching Kernel.\n"); //CHECK_TIME_START_GPU(); cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0); cuda_1<<<grid, block>>>((float(*)[MATRIX_SIZE])C_dev, (float(*)[MATRIX_SIZE])A_dev, (float(*)[MATRIX_SIZE])B_dev); //CHECK_TIME_END_GPU(dev_time); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&dev_time, start, stop); cudaEventDestroy(start); cudaEventDestroy(stop); printf("[CUDA 1] Processing Elapsed Time : %.3f (sec).\n",dev_time/1000); //take result from device to host. CUDA_CALL(cudaMemcpy( C, C_dev, sizeof(float) * MATRIX_SIZE* MATRIX_SIZE, cudaMemcpyDeviceToHost)); CUDA_CALL( cudaDeviceSynchronize() ); } static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float result = 0.0f; for(int i = 0 ; i < MATRIX_SIZE; ++i) { result += A[row][i] * B[i][col]; } C[row][col] = result; } void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]) { for (int i = 0 ; i < MATRIX_SIZE; ++i) for(int j = 0 ; j < MATRIX_SIZE; ++j) mat[i][j] = ( (float) rand()*2.f/RAND_MAX ) - 1.f; } float A[MATRIX_SIZE][MATRIX_SIZE],B[MATRIX_SIZE][MATRIX_SIZE],C_cuda_1[MATRIX_SIZE][MATRIX_SIZE]; int main(int argc, char *argv[]) { printf("input BLOCK WIDTH , BLOCK HEIGHT : "); scanf("%d %d",&BLOCK_WIDTH,&BLOCK_HEIGHT); init_mat(A); init_mat(B); cuda_version_1(C_cuda_1, A, B); }
code for sm_80 Function : _Z6cuda_1PA1024_fS0_S0_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ MOV R7, 0x4 ; /* 0x0000000400077802 */ /* 0x000fe20000000f00 */ /*0030*/ HFMA2.MMA R16, -RZ, RZ, 0, 0 ; /* 0x00000000ff107435 */ /* 0x000fe200000001ff */ /*0040*/ MOV R8, RZ ; /* 0x000000ff00087202 */ /* 0x000fe20000000f00 */ /*0050*/ S2R R5, SR_TID.Y ; /* 0x0000000000057919 */ /* 0x000e220000002200 */ /*0060*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0070*/ S2R R6, SR_CTAID.X ; /* 0x0000000000067919 */ /* 0x000e680000002500 */ /*0080*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e620000002100 */ /*0090*/ IMAD R0, R0, c[0x0][0x4], R5 ; /* 0x0000010000007a24 */ /* 0x001fe200078e0205 */ /*00a0*/ HFMA2.MMA R5, -RZ, RZ, 0, 0.00048828125 ; /* 0x00001000ff057435 */ /* 0x000fc800000001ff */ /*00b0*/ SHF.R.S32.HI R9, RZ, 0x1f, R0 ; /* 0x0000001fff097819 */ /* 0x000fe20000011400 */ /*00c0*/ IMAD R6, R6, c[0x0][0x0], R3 ; /* 0x0000000006067a24 */ /* 0x002fca00078e0203 */ /*00d0*/ IMAD.WIDE R2, R0, R5, c[0x0][0x168] ; /* 0x00005a0000027625 */ /* 0x000fc800078e0205 */ /*00e0*/ IMAD.WIDE R4, R6, R7, c[0x0][0x170] ; /* 0x00005c0006047625 */ /* 0x000fe200078e0207 */ /*00f0*/ IADD3 R11, P0, R2, 0x20, RZ ; /* 0x00000020020b7810 */ /* 0x000fe40007f1e0ff */ /*0100*/ SHF.R.S32.HI R7, RZ, 0x1f, R6 ; /* 0x0000001fff077819 */ /* 0x000fe40000011406 */ /*0110*/ IADD3 R2, P1, R4, 0x8000, RZ ; /* 0x0000800004027810 */ /* 0x000fe40007f3e0ff */ /*0120*/ IADD3.X R12, RZ, R3, RZ, P0, !PT ; /* 0x00000003ff0c7210 */ /* 0x000fe400007fe4ff */ /*0130*/ IADD3.X R3, RZ, R5, RZ, P1, !PT ; /* 0x00000005ff037210 */ /* 0x000fc80000ffe4ff */ /*0140*/ MOV R4, R11 ; /* 0x0000000b00047202 */ /* 0x000fe20000000f00 */ /*0150*/ LDG.E R17, [R2.64+-0x8000] ; /* 0xff80000402117981 */ /* 0x000ea2000c1e1900 */ /*0160*/ MOV R5, R12 ; /* 0x0000000c00057202 */ /* 0x000fc60000000f00 */ /*0170*/ LDG.E R26, [R2.64+-0x7000] ; /* 0xff900004021a7981 */ /* 0x000ee8000c1e1900 */ /*0180*/ LDG.E R24, [R4.64+-0x20] ; /* 0xffffe00404187981 */ /* 0x000ea8000c1e1900 */ /*0190*/ LDG.E R25, [R4.64+-0x1c] ; /* 0xffffe40404197981 */ /* 0x000ee8000c1e1900 */ /*01a0*/ LDG.E R19, [R2.64+-0x6000] ; /* 0xffa0000402137981 */ /* 0x000f28000c1e1900 */ /*01b0*/ LDG.E R18, [R4.64+-0x18] ; /* 0xffffe80404127981 */ /* 0x000f28000c1e1900 */ /*01c0*/ LDG.E R20, [R2.64+-0x5000] ; /* 0xffb0000402147981 */ /* 0x000f68000c1e1900 */ /*01d0*/ LDG.E R21, [R4.64+-0x14] ; /* 0xffffec0404157981 */ /* 0x000f68000c1e1900 */ /*01e0*/ LDG.E R22, [R2.64+-0x4000] ; /* 0xffc0000402167981 */ /* 0x000f68000c1e1900 */ /*01f0*/ LDG.E R23, [R4.64+-0x10] ; /* 0xfffff00404177981 */ /* 0x000f68000c1e1900 */ /*0200*/ LDG.E R10, [R2.64+-0x3000] ; /* 0xffd00004020a7981 */ /* 0x000f68000c1e1900 */ /*0210*/ LDG.E R11, [R4.64+-0xc] ; /* 0xfffff404040b7981 */ /* 0x000f68000c1e1900 */ /*0220*/ LDG.E R12, [R2.64+-0x2000] ; /* 0xffe00004020c7981 */ /* 0x000f68000c1e1900 */ /*0230*/ LDG.E R13, [R4.64+-0x8] ; /* 0xfffff804040d7981 */ /* 0x000f68000c1e1900 */ /*0240*/ LDG.E R14, [R2.64+-0x1000] ; /* 0xfff00004020e7981 */ /* 0x000f68000c1e1900 */ /*0250*/ LDG.E R15, [R4.64+-0x4] ; /* 0xfffffc04040f7981 */ /* 0x000f62000c1e1900 */ /*0260*/ FFMA R17, R17, R24, R16 ; /* 0x0000001811117223 */ /* 0x004fc60000000010 */ /*0270*/ LDG.E R16, [R2.64] ; /* 0x0000000402107981 */ /* 0x0000a2000c1e1900 */ /*0280*/ FFMA R25, R26, R25, R17 ; /* 0x000000191a197223 */ /* 0x008fc60000000011 */ /*0290*/ LDG.E R17, [R4.64] ; /* 0x0000000404117981 */ /* 0x000ea8000c1e1900 */ /*02a0*/ LDG.E R24, [R2.64+0x7000] ; /* 0x0070000402187981 */ /* 0x0000e2000c1e1900 */ /*02b0*/ FFMA R25, R19, R18, R25 ; /* 0x0000001213197223 */ /* 0x010fc60000000019 */ /*02c0*/ LDG.E R19, [R2.64+0x1000] ; /* 0x0010000402137981 */ /* 0x000128000c1e1900 */ /*02d0*/ LDG.E R18, [R4.64+0x4] ; /* 0x0000040404127981 */ /* 0x000f22000c1e1900 */ /*02e0*/ FFMA R25, R20, R21, R25 ; /* 0x0000001514197223 */ /* 0x020fc60000000019 */ /*02f0*/ LDG.E R20, [R2.64+0x2000] ; /* 0x0020000402147981 */ /* 0x000168000c1e1900 */ /*0300*/ LDG.E R21, [R4.64+0x8] ; /* 0x0000080404157981 */ /* 0x000f62000c1e1900 */ /*0310*/ FFMA R25, R22, R23, R25 ; /* 0x0000001716197223 */ /* 0x000fc60000000019 */ /*0320*/ LDG.E R22, [R2.64+0x3000] ; /* 0x0030000402167981 */ /* 0x0000e8000c1e1900 */ /*0330*/ LDG.E R23, [R4.64+0xc] ; /* 0x00000c0404177981 */ /* 0x000ee2000c1e1900 */ /*0340*/ FFMA R25, R10, R11, R25 ; /* 0x0000000b0a197223 */ /* 0x000fc60000000019 */ /*0350*/ LDG.E R10, [R2.64+0x4000] ; /* 0x00400004020a7981 */ /* 0x0000e8000c1e1900 */ /*0360*/ LDG.E R11, [R4.64+0x10] ; /* 0x00001004040b7981 */ /* 0x000ee2000c1e1900 */ /*0370*/ FFMA R25, R12, R13, R25 ; /* 0x0000000d0c197223 */ /* 0x000fc60000000019 */ /*0380*/ LDG.E R12, [R2.64+0x5000] ; /* 0x00500004020c7981 */ /* 0x0000e8000c1e1900 */ /*0390*/ LDG.E R13, [R4.64+0x14] ; /* 0x00001404040d7981 */ /* 0x000ee2000c1e1900 */ /*03a0*/ FFMA R26, R14, R15, R25 ; /* 0x0000000f0e1a7223 */ /* 0x000fc60000000019 */ /*03b0*/ LDG.E R15, [R2.64+0x6000] ; /* 0x00600004020f7981 */ /* 0x0000e8000c1e1900 */ /*03c0*/ LDG.E R14, [R4.64+0x18] ; /* 0x00001804040e7981 */ /* 0x000ee8000c1e1900 */ /*03d0*/ LDG.E R25, [R4.64+0x1c] ; /* 0x00001c0404197981 */ /* 0x000ee2000c1e1900 */ /*03e0*/ IADD3 R8, R8, 0x10, RZ ; /* 0x0000001008087810 */ /* 0x000fc80007ffe0ff */ /*03f0*/ ISETP.NE.AND P0, PT, R8, 0x400, PT ; /* 0x000004000800780c */ /* 0x000fe40003f05270 */ /*0400*/ IADD3 R2, P2, R2, 0x10000, RZ ; /* 0x0001000002027810 */ /* 0x001fc80007f5e0ff */ /*0410*/ IADD3.X R3, RZ, R3, RZ, P2, !PT ; /* 0x00000003ff037210 */ /* 0x000fe200017fe4ff */ /*0420*/ FFMA R16, R16, R17, R26 ; /* 0x0000001110107223 */ /* 0x004fc8000000001a */ /*0430*/ FFMA R16, R19, R18, R16 ; /* 0x0000001213107223 */ /* 0x010fc80000000010 */ /*0440*/ FFMA R16, R20, R21, R16 ; /* 0x0000001514107223 */ /* 0x020fc80000000010 */ /*0450*/ FFMA R16, R22, R23, R16 ; /* 0x0000001716107223 */ /* 0x008fc80000000010 */ /*0460*/ FFMA R10, R10, R11, R16 ; /* 0x0000000b0a0a7223 */ /* 0x000fe20000000010 */ /*0470*/ IADD3 R11, P1, R4, 0x40, RZ ; /* 0x00000040040b7810 */ /* 0x000fc60007f3e0ff */ /*0480*/ FFMA R10, R12, R13, R10 ; /* 0x0000000d0c0a7223 */ /* 0x000fe2000000000a */ /*0490*/ IADD3.X R12, RZ, R5, RZ, P1, !PT ; /* 0x00000005ff0c7210 */ /* 0x000fc60000ffe4ff */ /*04a0*/ FFMA R10, R15, R14, R10 ; /* 0x0000000e0f0a7223 */ /* 0x000fc8000000000a */ /*04b0*/ FFMA R16, R24, R25, R10 ; /* 0x0000001918107223 */ /* 0x000fe2000000000a */ /*04c0*/ @P0 BRA 0x140 ; /* 0xfffffc7000000947 */ /* 0x000fea000383ffff */ /*04d0*/ LEA R3, P0, R0, c[0x0][0x160], 0xc ; /* 0x0000580000037a11 */ /* 0x000fc800078060ff */ /*04e0*/ LEA.HI.X R9, R0, c[0x0][0x164], R9, 0xc, P0 ; /* 0x0000590000097a11 */ /* 0x000fe400000f6409 */ /*04f0*/ LEA R2, P0, R6, R3, 0x2 ; /* 0x0000000306027211 */ /* 0x000fc800078010ff */ /*0500*/ LEA.HI.X R3, R6, R9, R7, 0x2, P0 ; /* 0x0000000906037211 */ /* 0x000fca00000f1407 */ /*0510*/ STG.E [R2.64], R16 ; /* 0x0000001002007986 */ /* 0x000fe2000c101904 */ /*0520*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0530*/ BRA 0x530; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include <cuda_runtime.h> #include <assert.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #include <device_launch_parameters.h> #define CUDA_CALL(x) { const cudaError_t a = (x); if(a != cudaSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", cudaGetErrorString(a), a, __LINE__); cudaDeviceReset(); assert(0);}} #define MATRIX_SIZE 1024 int BLOCK_WIDTH,BLOCK_HEIGHT; void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]); static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]); extern "C" void cuda_version_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { void *A_dev, *B_dev, *C_dev; cudaEvent_t start,stop; CUDA_CALL(cudaMalloc((void**)&A_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(cudaMalloc((void**)&B_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(cudaMalloc((void**)&C_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); // take data from host to device. CUDA_CALL(cudaMemcpy(A_dev, A, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,cudaMemcpyHostToDevice)); CUDA_CALL(cudaMemcpy(A_dev, B, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,cudaMemcpyHostToDevice)); dim3 block(BLOCK_WIDTH, BLOCK_HEIGHT); dim3 grid(MATRIX_SIZE/BLOCK_WIDTH, MATRIX_SIZE/BLOCK_HEIGHT); float dev_time; printf("[CUDA 1] Start Launching Kernel.\n"); //CHECK_TIME_START_GPU(); cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0); cuda_1<<<grid, block>>>((float(*)[MATRIX_SIZE])C_dev, (float(*)[MATRIX_SIZE])A_dev, (float(*)[MATRIX_SIZE])B_dev); //CHECK_TIME_END_GPU(dev_time); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&dev_time, start, stop); cudaEventDestroy(start); cudaEventDestroy(stop); printf("[CUDA 1] Processing Elapsed Time : %.3f (sec).\n",dev_time/1000); //take result from device to host. CUDA_CALL(cudaMemcpy( C, C_dev, sizeof(float) * MATRIX_SIZE* MATRIX_SIZE, cudaMemcpyDeviceToHost)); CUDA_CALL( cudaDeviceSynchronize() ); } static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float result = 0.0f; for(int i = 0 ; i < MATRIX_SIZE; ++i) { result += A[row][i] * B[i][col]; } C[row][col] = result; } void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]) { for (int i = 0 ; i < MATRIX_SIZE; ++i) for(int j = 0 ; j < MATRIX_SIZE; ++j) mat[i][j] = ( (float) rand()*2.f/RAND_MAX ) - 1.f; } float A[MATRIX_SIZE][MATRIX_SIZE],B[MATRIX_SIZE][MATRIX_SIZE],C_cuda_1[MATRIX_SIZE][MATRIX_SIZE]; int main(int argc, char *argv[]) { printf("input BLOCK WIDTH , BLOCK HEIGHT : "); scanf("%d %d",&BLOCK_WIDTH,&BLOCK_HEIGHT); init_mat(A); init_mat(B); cuda_version_1(C_cuda_1, A, B); }
.file "tmpxft_0009b45f_00000000-6_cuda.cudafe1.cpp" .text #APP #NO_APP .type _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_, @function _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_: .LFB2084: .cfi_startproc 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 .L5 .L1: movq 120(%rsp), %rax subq %fs:40, %rax jne .L6 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L5: .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 _ZL6cuda_1PA1024_fS0_S0_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L1 .L6: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_, .-_ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_ .type _ZL6cuda_1PA1024_fS0_S0_, @function _ZL6cuda_1PA1024_fS0_S0_: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL6cuda_1PA1024_fS0_S0_, .-_ZL6cuda_1PA1024_fS0_S0_ .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 .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "\nCuda Error: %s (err_num=%d) at line:%d\n" .align 8 .LC1: .string "[CUDA 1] Start Launching Kernel.\n" .align 8 .LC3: .string "[CUDA 1] Processing Elapsed Time : %.3f (sec).\n" .text .globl cuda_version_1 .type cuda_version_1, @function cuda_version_1: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $88, %rsp .cfi_def_cfa_offset 128 movq %rdi, %rbp movq %rsi, %r13 movq %rdx, %r12 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq 8(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT testl %eax, %eax jne .L22 .L12: leaq 16(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT movl %eax, %ebx testl %eax, %eax jne .L23 .L13: leaq 24(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT movl %eax, %ebx testl %eax, %eax jne .L24 .L14: movl $1, %ecx movl $4194304, %edx movq %r13, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %ebx testl %eax, %eax jne .L25 .L15: movl $1, %ecx movl $4194304, %edx movq %r12, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %ebx testl %eax, %eax jne .L26 .L16: movl BLOCK_HEIGHT(%rip), %esi movl BLOCK_WIDTH(%rip), %edi movl %edi, 48(%rsp) movl %esi, 52(%rsp) movl $1, 56(%rsp) movl $1024, %ecx movl %ecx, %eax cltd idivl %edi movl %eax, 60(%rsp) movl %ecx, %eax cltd idivl %esi movl %eax, 64(%rsp) movl $1, 68(%rsp) leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 32(%rsp), %rdi call cudaEventCreate@PLT leaq 40(%rsp), %rdi call cudaEventCreate@PLT 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 .L17: movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 4(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT movq 32(%rsp), %rdi call cudaEventDestroy@PLT movq 40(%rsp), %rdi call cudaEventDestroy@PLT movss 4(%rsp), %xmm0 divss .LC2(%rip), %xmm0 cvtss2sd %xmm0, %xmm0 leaq .LC3(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $2, %ecx movl $4194304, %edx movq 24(%rsp), %rsi movq %rbp, %rdi call cudaMemcpy@PLT movl %eax, %ebx testl %eax, %eax jne .L28 .L18: call cudaDeviceSynchronize@PLT movl %eax, %ebx testl %eax, %eax jne .L29 .L11: movq 72(%rsp), %rax subq %fs:40, %rax jne .L30 addq $88, %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 .L22: .cfi_restore_state movl %eax, %ebx movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $26, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L12 .L23: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $27, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L13 .L24: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $28, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L14 .L25: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $31, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L15 .L26: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $33, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L16 .L27: movq 16(%rsp), %rdx movq 8(%rsp), %rsi movq 24(%rsp), %rdi call _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_ jmp .L17 .L28: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $64, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L18 .L29: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $65, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L11 .L30: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size cuda_version_1, .-cuda_version_1 .globl _Z8init_matPA1024_f .type _Z8init_matPA1024_f, @function _Z8init_matPA1024_f: .LFB2058: .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 movq %rdi, %r12 leaq 4096(%rdi), %rbp addq $4198400, %r12 .L32: leaq -4096(%rbp), %rbx .L33: call rand@PLT pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 addss %xmm0, %xmm0 mulss .LC4(%rip), %xmm0 subss .LC5(%rip), %xmm0 movss %xmm0, (%rbx) addq $4, %rbx cmpq %rbp, %rbx jne .L33 addq $4096, %rbp cmpq %r12, %rbp jne .L32 popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z8init_matPA1024_f, .-_Z8init_matPA1024_f .section .rodata.str1.8 .align 8 .LC6: .string "input BLOCK WIDTH , BLOCK HEIGHT : " .section .rodata.str1.1,"aMS",@progbits,1 .LC7: .string "%d %d" .text .globl main .type main, @function main: .LFB2059: .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 $8, %rsp .cfi_def_cfa_offset 32 leaq .LC6(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq BLOCK_HEIGHT(%rip), %rdx leaq BLOCK_WIDTH(%rip), %rsi leaq .LC7(%rip), %rdi movl $0, %eax call __isoc23_scanf@PLT leaq A(%rip), %rbx movq %rbx, %rdi call _Z8init_matPA1024_f leaq B(%rip), %rbp movq %rbp, %rdi call _Z8init_matPA1024_f movq %rbp, %rdx movq %rbx, %rsi leaq C_cuda_1(%rip), %rdi call cuda_version_1 movl $0, %eax addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2059: .size main, .-main .section .rodata.str1.1 .LC8: .string "_Z6cuda_1PA1024_fS0_S0_" .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 .LC8(%rip), %rdx movq %rdx, %rcx leaq _ZL6cuda_1PA1024_fS0_S0_(%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 .globl C_cuda_1 .bss .align 32 .type C_cuda_1, @object .size C_cuda_1, 4194304 C_cuda_1: .zero 4194304 .globl B .align 32 .type B, @object .size B, 4194304 B: .zero 4194304 .globl A .align 32 .type A, @object .size A, 4194304 A: .zero 4194304 .globl BLOCK_HEIGHT .align 4 .type BLOCK_HEIGHT, @object .size BLOCK_HEIGHT, 4 BLOCK_HEIGHT: .zero 4 .globl BLOCK_WIDTH .align 4 .type BLOCK_WIDTH, @object .size BLOCK_WIDTH, 4 BLOCK_WIDTH: .zero 4 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC2: .long 1148846080 .align 4 .LC4: .long 805306368 .align 4 .LC5: .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 <cuda_runtime.h> #include <assert.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #include <device_launch_parameters.h> #define CUDA_CALL(x) { const cudaError_t a = (x); if(a != cudaSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", cudaGetErrorString(a), a, __LINE__); cudaDeviceReset(); assert(0);}} #define MATRIX_SIZE 1024 int BLOCK_WIDTH,BLOCK_HEIGHT; void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]); static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]); extern "C" void cuda_version_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { void *A_dev, *B_dev, *C_dev; cudaEvent_t start,stop; CUDA_CALL(cudaMalloc((void**)&A_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(cudaMalloc((void**)&B_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(cudaMalloc((void**)&C_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); // take data from host to device. CUDA_CALL(cudaMemcpy(A_dev, A, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,cudaMemcpyHostToDevice)); CUDA_CALL(cudaMemcpy(A_dev, B, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,cudaMemcpyHostToDevice)); dim3 block(BLOCK_WIDTH, BLOCK_HEIGHT); dim3 grid(MATRIX_SIZE/BLOCK_WIDTH, MATRIX_SIZE/BLOCK_HEIGHT); float dev_time; printf("[CUDA 1] Start Launching Kernel.\n"); //CHECK_TIME_START_GPU(); cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0); cuda_1<<<grid, block>>>((float(*)[MATRIX_SIZE])C_dev, (float(*)[MATRIX_SIZE])A_dev, (float(*)[MATRIX_SIZE])B_dev); //CHECK_TIME_END_GPU(dev_time); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&dev_time, start, stop); cudaEventDestroy(start); cudaEventDestroy(stop); printf("[CUDA 1] Processing Elapsed Time : %.3f (sec).\n",dev_time/1000); //take result from device to host. CUDA_CALL(cudaMemcpy( C, C_dev, sizeof(float) * MATRIX_SIZE* MATRIX_SIZE, cudaMemcpyDeviceToHost)); CUDA_CALL( cudaDeviceSynchronize() ); } static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float result = 0.0f; for(int i = 0 ; i < MATRIX_SIZE; ++i) { result += A[row][i] * B[i][col]; } C[row][col] = result; } void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]) { for (int i = 0 ; i < MATRIX_SIZE; ++i) for(int j = 0 ; j < MATRIX_SIZE; ++j) mat[i][j] = ( (float) rand()*2.f/RAND_MAX ) - 1.f; } float A[MATRIX_SIZE][MATRIX_SIZE],B[MATRIX_SIZE][MATRIX_SIZE],C_cuda_1[MATRIX_SIZE][MATRIX_SIZE]; int main(int argc, char *argv[]) { printf("input BLOCK WIDTH , BLOCK HEIGHT : "); scanf("%d %d",&BLOCK_WIDTH,&BLOCK_HEIGHT); init_mat(A); init_mat(B); cuda_version_1(C_cuda_1, A, B); }
#include <hip/hip_runtime.h> #include <assert.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #define CUDA_CALL(x) { const hipError_t a = (x); if(a != hipSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", hipGetErrorString(a), a, __LINE__); hipDeviceReset(); assert(0);}} #define MATRIX_SIZE 1024 int BLOCK_WIDTH,BLOCK_HEIGHT; void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]); static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]); extern "C" void cuda_version_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { void *A_dev, *B_dev, *C_dev; hipEvent_t start,stop; CUDA_CALL(hipMalloc((void**)&A_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(hipMalloc((void**)&B_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(hipMalloc((void**)&C_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); // take data from host to device. CUDA_CALL(hipMemcpy(A_dev, A, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,hipMemcpyHostToDevice)); CUDA_CALL(hipMemcpy(A_dev, B, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,hipMemcpyHostToDevice)); dim3 block(BLOCK_WIDTH, BLOCK_HEIGHT); dim3 grid(MATRIX_SIZE/BLOCK_WIDTH, MATRIX_SIZE/BLOCK_HEIGHT); float dev_time; printf("[CUDA 1] Start Launching Kernel.\n"); //CHECK_TIME_START_GPU(); hipEventCreate(&start); hipEventCreate(&stop); hipEventRecord(start, 0); cuda_1<<<grid, block>>>((float(*)[MATRIX_SIZE])C_dev, (float(*)[MATRIX_SIZE])A_dev, (float(*)[MATRIX_SIZE])B_dev); //CHECK_TIME_END_GPU(dev_time); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&dev_time, start, stop); hipEventDestroy(start); hipEventDestroy(stop); printf("[CUDA 1] Processing Elapsed Time : %.3f (sec).\n",dev_time/1000); //take result from device to host. CUDA_CALL(hipMemcpy( C, C_dev, sizeof(float) * MATRIX_SIZE* MATRIX_SIZE, hipMemcpyDeviceToHost)); CUDA_CALL( hipDeviceSynchronize() ); } static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float result = 0.0f; for(int i = 0 ; i < MATRIX_SIZE; ++i) { result += A[row][i] * B[i][col]; } C[row][col] = result; } void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]) { for (int i = 0 ; i < MATRIX_SIZE; ++i) for(int j = 0 ; j < MATRIX_SIZE; ++j) mat[i][j] = ( (float) rand()*2.f/RAND_MAX ) - 1.f; } float A[MATRIX_SIZE][MATRIX_SIZE],B[MATRIX_SIZE][MATRIX_SIZE],C_cuda_1[MATRIX_SIZE][MATRIX_SIZE]; int main(int argc, char *argv[]) { printf("input BLOCK WIDTH , BLOCK HEIGHT : "); scanf("%d %d",&BLOCK_WIDTH,&BLOCK_HEIGHT); init_mat(A); init_mat(B); cuda_version_1(C_cuda_1, A, B); }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include <hip/hip_runtime.h> #include <assert.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #define CUDA_CALL(x) { const hipError_t a = (x); if(a != hipSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", hipGetErrorString(a), a, __LINE__); hipDeviceReset(); assert(0);}} #define MATRIX_SIZE 1024 int BLOCK_WIDTH,BLOCK_HEIGHT; void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]); static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]); extern "C" void cuda_version_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { void *A_dev, *B_dev, *C_dev; hipEvent_t start,stop; CUDA_CALL(hipMalloc((void**)&A_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(hipMalloc((void**)&B_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(hipMalloc((void**)&C_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); // take data from host to device. CUDA_CALL(hipMemcpy(A_dev, A, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,hipMemcpyHostToDevice)); CUDA_CALL(hipMemcpy(A_dev, B, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,hipMemcpyHostToDevice)); dim3 block(BLOCK_WIDTH, BLOCK_HEIGHT); dim3 grid(MATRIX_SIZE/BLOCK_WIDTH, MATRIX_SIZE/BLOCK_HEIGHT); float dev_time; printf("[CUDA 1] Start Launching Kernel.\n"); //CHECK_TIME_START_GPU(); hipEventCreate(&start); hipEventCreate(&stop); hipEventRecord(start, 0); cuda_1<<<grid, block>>>((float(*)[MATRIX_SIZE])C_dev, (float(*)[MATRIX_SIZE])A_dev, (float(*)[MATRIX_SIZE])B_dev); //CHECK_TIME_END_GPU(dev_time); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&dev_time, start, stop); hipEventDestroy(start); hipEventDestroy(stop); printf("[CUDA 1] Processing Elapsed Time : %.3f (sec).\n",dev_time/1000); //take result from device to host. CUDA_CALL(hipMemcpy( C, C_dev, sizeof(float) * MATRIX_SIZE* MATRIX_SIZE, hipMemcpyDeviceToHost)); CUDA_CALL( hipDeviceSynchronize() ); } static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float result = 0.0f; for(int i = 0 ; i < MATRIX_SIZE; ++i) { result += A[row][i] * B[i][col]; } C[row][col] = result; } void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]) { for (int i = 0 ; i < MATRIX_SIZE; ++i) for(int j = 0 ; j < MATRIX_SIZE; ++j) mat[i][j] = ( (float) rand()*2.f/RAND_MAX ) - 1.f; } float A[MATRIX_SIZE][MATRIX_SIZE],B[MATRIX_SIZE][MATRIX_SIZE],C_cuda_1[MATRIX_SIZE][MATRIX_SIZE]; int main(int argc, char *argv[]) { printf("input BLOCK WIDTH , BLOCK HEIGHT : "); scanf("%d %d",&BLOCK_WIDTH,&BLOCK_HEIGHT); init_mat(A); init_mat(B); cuda_version_1(C_cuda_1, A, B); }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .section .text._ZL6cuda_1PA1024_fS0_S0_,"axG",@progbits,_ZL6cuda_1PA1024_fS0_S0_,comdat .globl _ZL6cuda_1PA1024_fS0_S0_ .p2align 8 .type _ZL6cuda_1PA1024_fS0_S0_,@function _ZL6cuda_1PA1024_fS0_S0_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x24 s_load_b128 s[4:7], s[0:1], 0x8 v_bfe_u32 v2, v0, 10, 10 v_and_b32_e32 v4, 0x3ff, v0 v_mov_b32_e32 v6, 0 s_waitcnt lgkmcnt(0) s_lshr_b32 s3, s2, 16 s_and_b32 s2, s2, 0xffff v_mad_u64_u32 v[0:1], null, s15, s3, v[2:3] v_mad_u64_u32 v[2:3], null, s14, s2, v[4:5] s_mov_b64 s[2:3], 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v1, 31, v0 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[4:5], 12, v[0:1] v_lshlrev_b64 v[9:10], 2, v[2:3] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v7, vcc_lo, s4, v4 v_add_co_ci_u32_e32 v8, vcc_lo, s5, v5, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v4, vcc_lo, s6, v9 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v10, vcc_lo .LBB0_1: s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v9, vcc_lo, v7, s2 v_add_co_ci_u32_e32 v10, vcc_lo, s3, v8, vcc_lo s_add_u32 s2, s2, 4 s_addc_u32 s3, s3, 0 global_load_b32 v11, v[4:5], off global_load_b32 v9, v[9:10], off v_add_co_u32 v4, vcc_lo, v4, 0x1000 v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo s_cmpk_eq_i32 s2, 0x1000 s_waitcnt vmcnt(0) v_fmac_f32_e32 v6, v9, v11 s_cbranch_scc0 .LBB0_1 s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b64 v[0:1], 12, v[0:1] v_lshlrev_b64 v[2:3], 2, v[2:3] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, v0, v2 v_add_co_ci_u32_e32 v1, vcc_lo, v1, v3, vcc_lo global_store_b32 v[0:1], v6, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _ZL6cuda_1PA1024_fS0_S0_ .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 12 .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 .section .text._ZL6cuda_1PA1024_fS0_S0_,"axG",@progbits,_ZL6cuda_1PA1024_fS0_S0_,comdat .Lfunc_end0: .size _ZL6cuda_1PA1024_fS0_S0_, .Lfunc_end0-_ZL6cuda_1PA1024_fS0_S0_ .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: _ZL6cuda_1PA1024_fS0_S0_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _ZL6cuda_1PA1024_fS0_S0_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 12 .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 <assert.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #define CUDA_CALL(x) { const hipError_t a = (x); if(a != hipSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", hipGetErrorString(a), a, __LINE__); hipDeviceReset(); assert(0);}} #define MATRIX_SIZE 1024 int BLOCK_WIDTH,BLOCK_HEIGHT; void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]); static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]); extern "C" void cuda_version_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { void *A_dev, *B_dev, *C_dev; hipEvent_t start,stop; CUDA_CALL(hipMalloc((void**)&A_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(hipMalloc((void**)&B_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); CUDA_CALL(hipMalloc((void**)&C_dev, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE)); // take data from host to device. CUDA_CALL(hipMemcpy(A_dev, A, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,hipMemcpyHostToDevice)); CUDA_CALL(hipMemcpy(A_dev, B, sizeof(float) * MATRIX_SIZE * MATRIX_SIZE,hipMemcpyHostToDevice)); dim3 block(BLOCK_WIDTH, BLOCK_HEIGHT); dim3 grid(MATRIX_SIZE/BLOCK_WIDTH, MATRIX_SIZE/BLOCK_HEIGHT); float dev_time; printf("[CUDA 1] Start Launching Kernel.\n"); //CHECK_TIME_START_GPU(); hipEventCreate(&start); hipEventCreate(&stop); hipEventRecord(start, 0); cuda_1<<<grid, block>>>((float(*)[MATRIX_SIZE])C_dev, (float(*)[MATRIX_SIZE])A_dev, (float(*)[MATRIX_SIZE])B_dev); //CHECK_TIME_END_GPU(dev_time); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&dev_time, start, stop); hipEventDestroy(start); hipEventDestroy(stop); printf("[CUDA 1] Processing Elapsed Time : %.3f (sec).\n",dev_time/1000); //take result from device to host. CUDA_CALL(hipMemcpy( C, C_dev, sizeof(float) * MATRIX_SIZE* MATRIX_SIZE, hipMemcpyDeviceToHost)); CUDA_CALL( hipDeviceSynchronize() ); } static __global__ void cuda_1(float C[MATRIX_SIZE][MATRIX_SIZE],float A[MATRIX_SIZE][MATRIX_SIZE] , float B[MATRIX_SIZE][MATRIX_SIZE]) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float result = 0.0f; for(int i = 0 ; i < MATRIX_SIZE; ++i) { result += A[row][i] * B[i][col]; } C[row][col] = result; } void init_mat(float mat[MATRIX_SIZE][MATRIX_SIZE]) { for (int i = 0 ; i < MATRIX_SIZE; ++i) for(int j = 0 ; j < MATRIX_SIZE; ++j) mat[i][j] = ( (float) rand()*2.f/RAND_MAX ) - 1.f; } float A[MATRIX_SIZE][MATRIX_SIZE],B[MATRIX_SIZE][MATRIX_SIZE],C_cuda_1[MATRIX_SIZE][MATRIX_SIZE]; int main(int argc, char *argv[]) { printf("input BLOCK WIDTH , BLOCK HEIGHT : "); scanf("%d %d",&BLOCK_WIDTH,&BLOCK_HEIGHT); init_mat(A); init_mat(B); cuda_version_1(C_cuda_1, A, B); }
.text .file "cuda.hip" .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function cuda_version_1 .LCPI0_0: .long 0x447a0000 # float 1000 .text .globl cuda_version_1 .p2align 4, 0x90 .type cuda_version_1,@function cuda_version_1: # @cuda_version_1 .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 %rbx .cfi_def_cfa_offset 40 subq $136, %rsp .cfi_def_cfa_offset 176 .cfi_offset %rbx, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq %rdx, %r14 movq %rsi, %r15 movq %rdi, %rbx leaq 16(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc testl %eax, %eax je .LBB0_2 # %bb.1: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $26, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_2: leaq 56(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc testl %eax, %eax je .LBB0_4 # %bb.3: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $27, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_4: leaq 24(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc testl %eax, %eax je .LBB0_6 # %bb.5: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $28, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_6: movq 16(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r15, %rsi movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB0_8 # %bb.7: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $31, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_8: movq 16(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB0_10 # %bb.9: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $33, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_10: movl BLOCK_WIDTH(%rip), %ecx movl BLOCK_HEIGHT(%rip), %r15d movl $1024, %eax # imm = 0x400 xorl %edx, %edx idivl %ecx movl %eax, %r14d movl $1024, %eax # imm = 0x400 xorl %edx, %edx idivl %r15d # kill: def $eax killed $eax def $rax shlq $32, %r15 orq %rcx, %r15 shlq $32, %rax orq %rax, %r14 movl $.Lstr, %edi callq puts@PLT leaq 8(%rsp), %rdi callq hipEventCreate movq %rsp, %rdi callq hipEventCreate movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq %r14, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB0_12 # %bb.11: movq 24(%rsp), %rax movq 16(%rsp), %rcx movq 56(%rsp), %rdx movq %rax, 128(%rsp) movq %rcx, 120(%rsp) movq %rdx, 112(%rsp) leaq 128(%rsp), %rax movq %rax, 32(%rsp) leaq 120(%rsp), %rax movq %rax, 40(%rsp) leaq 112(%rsp), %rax movq %rax, 48(%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 32(%rsp), %r9 movl $_ZL6cuda_1PA1024_fS0_S0_, %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 .LBB0_12: movq (%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq (%rsp), %rdi callq hipEventSynchronize movq 8(%rsp), %rsi movq (%rsp), %rdx leaq 32(%rsp), %rdi callq hipEventElapsedTime movq 8(%rsp), %rdi callq hipEventDestroy movq (%rsp), %rdi callq hipEventDestroy movss 32(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero divss .LCPI0_0(%rip), %xmm0 cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf movq 24(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movq %rbx, %rdi movl $2, %ecx callq hipMemcpy testl %eax, %eax je .LBB0_14 # %bb.13: movl %eax, %edi movl %eax, %ebx callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebx, %edx movl $64, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_14: callq hipDeviceSynchronize testl %eax, %eax je .LBB0_16 # %bb.15: movl %eax, %edi movl %eax, %ebx callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebx, %edx movl $65, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_16: addq $136, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size cuda_version_1, .Lfunc_end0-cuda_version_1 .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function _ZL21__device_stub__cuda_1PA1024_fS0_S0_ .type _ZL21__device_stub__cuda_1PA1024_fS0_S0_,@function _ZL21__device_stub__cuda_1PA1024_fS0_S0_: # @_ZL21__device_stub__cuda_1PA1024_fS0_S0_ .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 $_ZL6cuda_1PA1024_fS0_S0_, %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_end1: .size _ZL21__device_stub__cuda_1PA1024_fS0_S0_, .Lfunc_end1-_ZL21__device_stub__cuda_1PA1024_fS0_S0_ .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z8init_matPA1024_f .LCPI2_0: .long 0x30000000 # float 4.65661287E-10 .LCPI2_1: .long 0xbf800000 # float -1 .text .globl _Z8init_matPA1024_f .p2align 4, 0x90 .type _Z8init_matPA1024_f,@function _Z8init_matPA1024_f: # @_Z8init_matPA1024_f .cfi_startproc # %bb.0: 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 xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_1: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_2 Depth 2 xorl %r15d, %r15d .p2align 4, 0x90 .LBB2_2: # Parent Loop BB2_1 Depth=1 # => This Inner Loop Header: Depth=2 callq rand movss .LCPI2_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 addss %xmm0, %xmm0 mulss %xmm1, %xmm0 movss .LCPI2_1(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero addss %xmm1, %xmm0 movss %xmm0, (%rbx,%r15,4) incq %r15 cmpq $1024, %r15 # imm = 0x400 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: popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size _Z8init_matPA1024_f, .Lfunc_end2-_Z8init_matPA1024_f .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI3_0: .long 0x30000000 # float 4.65661287E-10 .LCPI3_1: .long 0xbf800000 # float -1 .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 %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 xorl %ebx, %ebx movl $.L.str.3, %edi xorl %eax, %eax callq printf movl $.L.str.4, %edi movl $BLOCK_WIDTH, %esi movl $BLOCK_HEIGHT, %edx xorl %eax, %eax callq __isoc23_scanf movl $A, %r14d .p2align 4, 0x90 .LBB3_1: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB3_2 Depth 2 xorl %r15d, %r15d .p2align 4, 0x90 .LBB3_2: # Parent Loop BB3_1 Depth=1 # => This Inner Loop Header: Depth=2 callq rand movss .LCPI3_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 addss %xmm0, %xmm0 mulss %xmm1, %xmm0 movss .LCPI3_1(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero addss %xmm1, %xmm0 movss %xmm0, (%r14,%r15,4) incq %r15 cmpq $1024, %r15 # imm = 0x400 jne .LBB3_2 # %bb.3: # in Loop: Header=BB3_1 Depth=1 incq %rbx addq $4096, %r14 # imm = 0x1000 cmpq $1024, %rbx # imm = 0x400 jne .LBB3_1 # %bb.4: # %.preheader.i1.preheader movl $B, %ebx xorl %r14d, %r14d .p2align 4, 0x90 .LBB3_5: # %.preheader.i1 # =>This Loop Header: Depth=1 # Child Loop BB3_6 Depth 2 xorl %r15d, %r15d .p2align 4, 0x90 .LBB3_6: # Parent Loop BB3_5 Depth=1 # => This Inner Loop Header: Depth=2 callq rand xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 addss %xmm0, %xmm0 mulss .LCPI3_0(%rip), %xmm0 addss .LCPI3_1(%rip), %xmm0 movss %xmm0, (%rbx,%r15,4) incq %r15 cmpq $1024, %r15 # imm = 0x400 jne .LBB3_6 # %bb.7: # in Loop: Header=BB3_5 Depth=1 incq %r14 addq $4096, %rbx # imm = 0x1000 cmpq $1024, %r14 # imm = 0x400 jne .LBB3_5 # %bb.8: # %_Z8init_matPA1024_f.exit8 movl $C_cuda_1, %edi movl $A, %esi movl $B, %edx callq cuda_version_1 xorl %eax, %eax popq %rbx .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 $_ZL6cuda_1PA1024_fS0_S0_, %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 BLOCK_WIDTH,@object # @BLOCK_WIDTH .bss .globl BLOCK_WIDTH .p2align 2, 0x0 BLOCK_WIDTH: .long 0 # 0x0 .size BLOCK_WIDTH, 4 .type BLOCK_HEIGHT,@object # @BLOCK_HEIGHT .globl BLOCK_HEIGHT .p2align 2, 0x0 BLOCK_HEIGHT: .long 0 # 0x0 .size BLOCK_HEIGHT, 4 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "\nCuda Error: %s (err_num=%d) at line:%d\n" .size .L.str, 41 .type _ZL6cuda_1PA1024_fS0_S0_,@object # @_ZL6cuda_1PA1024_fS0_S0_ .section .rodata,"a",@progbits .p2align 3, 0x0 _ZL6cuda_1PA1024_fS0_S0_: .quad _ZL21__device_stub__cuda_1PA1024_fS0_S0_ .size _ZL6cuda_1PA1024_fS0_S0_, 8 .type .L.str.2,@object # @.str.2 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.2: .asciz "[CUDA 1] Processing Elapsed Time : %.3f (sec).\n" .size .L.str.2, 48 .type A,@object # @A .bss .globl A .p2align 4, 0x0 A: .zero 4194304 .size A, 4194304 .type B,@object # @B .globl B .p2align 4, 0x0 B: .zero 4194304 .size B, 4194304 .type C_cuda_1,@object # @C_cuda_1 .globl C_cuda_1 .p2align 4, 0x0 C_cuda_1: .zero 4194304 .size C_cuda_1, 4194304 .type .L.str.3,@object # @.str.3 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.3: .asciz "input BLOCK WIDTH , BLOCK HEIGHT : " .size .L.str.3, 36 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "%d %d" .size .L.str.4, 6 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_ZL6cuda_1PA1024_fS0_S0_" .size .L__unnamed_1, 25 .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 "[CUDA 1] Start Launching Kernel." .size .Lstr, 33 .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 _ZL21__device_stub__cuda_1PA1024_fS0_S0_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym BLOCK_WIDTH .addrsig_sym BLOCK_HEIGHT .addrsig_sym _ZL6cuda_1PA1024_fS0_S0_ .addrsig_sym A .addrsig_sym B .addrsig_sym C_cuda_1 .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 : _Z6cuda_1PA1024_fS0_S0_ .headerflags @"EF_CUDA_TEXMODE_UNIFIED EF_CUDA_64BIT_ADDRESS EF_CUDA_SM80 EF_CUDA_VIRTUAL_SM(EF_CUDA_SM80)" /*0000*/ MOV R1, c[0x0][0x28] ; /* 0x00000a0000017a02 */ /* 0x000fe40000000f00 */ /*0010*/ S2R R0, SR_CTAID.Y ; /* 0x0000000000007919 */ /* 0x000e220000002600 */ /*0020*/ MOV R7, 0x4 ; /* 0x0000000400077802 */ /* 0x000fe20000000f00 */ /*0030*/ HFMA2.MMA R16, -RZ, RZ, 0, 0 ; /* 0x00000000ff107435 */ /* 0x000fe200000001ff */ /*0040*/ MOV R8, RZ ; /* 0x000000ff00087202 */ /* 0x000fe20000000f00 */ /*0050*/ S2R R5, SR_TID.Y ; /* 0x0000000000057919 */ /* 0x000e220000002200 */ /*0060*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*0070*/ S2R R6, SR_CTAID.X ; /* 0x0000000000067919 */ /* 0x000e680000002500 */ /*0080*/ S2R R3, SR_TID.X ; /* 0x0000000000037919 */ /* 0x000e620000002100 */ /*0090*/ IMAD R0, R0, c[0x0][0x4], R5 ; /* 0x0000010000007a24 */ /* 0x001fe200078e0205 */ /*00a0*/ HFMA2.MMA R5, -RZ, RZ, 0, 0.00048828125 ; /* 0x00001000ff057435 */ /* 0x000fc800000001ff */ /*00b0*/ SHF.R.S32.HI R9, RZ, 0x1f, R0 ; /* 0x0000001fff097819 */ /* 0x000fe20000011400 */ /*00c0*/ IMAD R6, R6, c[0x0][0x0], R3 ; /* 0x0000000006067a24 */ /* 0x002fca00078e0203 */ /*00d0*/ IMAD.WIDE R2, R0, R5, c[0x0][0x168] ; /* 0x00005a0000027625 */ /* 0x000fc800078e0205 */ /*00e0*/ IMAD.WIDE R4, R6, R7, c[0x0][0x170] ; /* 0x00005c0006047625 */ /* 0x000fe200078e0207 */ /*00f0*/ IADD3 R11, P0, R2, 0x20, RZ ; /* 0x00000020020b7810 */ /* 0x000fe40007f1e0ff */ /*0100*/ SHF.R.S32.HI R7, RZ, 0x1f, R6 ; /* 0x0000001fff077819 */ /* 0x000fe40000011406 */ /*0110*/ IADD3 R2, P1, R4, 0x8000, RZ ; /* 0x0000800004027810 */ /* 0x000fe40007f3e0ff */ /*0120*/ IADD3.X R12, RZ, R3, RZ, P0, !PT ; /* 0x00000003ff0c7210 */ /* 0x000fe400007fe4ff */ /*0130*/ IADD3.X R3, RZ, R5, RZ, P1, !PT ; /* 0x00000005ff037210 */ /* 0x000fc80000ffe4ff */ /*0140*/ MOV R4, R11 ; /* 0x0000000b00047202 */ /* 0x000fe20000000f00 */ /*0150*/ LDG.E R17, [R2.64+-0x8000] ; /* 0xff80000402117981 */ /* 0x000ea2000c1e1900 */ /*0160*/ MOV R5, R12 ; /* 0x0000000c00057202 */ /* 0x000fc60000000f00 */ /*0170*/ LDG.E R26, [R2.64+-0x7000] ; /* 0xff900004021a7981 */ /* 0x000ee8000c1e1900 */ /*0180*/ LDG.E R24, [R4.64+-0x20] ; /* 0xffffe00404187981 */ /* 0x000ea8000c1e1900 */ /*0190*/ LDG.E R25, [R4.64+-0x1c] ; /* 0xffffe40404197981 */ /* 0x000ee8000c1e1900 */ /*01a0*/ LDG.E R19, [R2.64+-0x6000] ; /* 0xffa0000402137981 */ /* 0x000f28000c1e1900 */ /*01b0*/ LDG.E R18, [R4.64+-0x18] ; /* 0xffffe80404127981 */ /* 0x000f28000c1e1900 */ /*01c0*/ LDG.E R20, [R2.64+-0x5000] ; /* 0xffb0000402147981 */ /* 0x000f68000c1e1900 */ /*01d0*/ LDG.E R21, [R4.64+-0x14] ; /* 0xffffec0404157981 */ /* 0x000f68000c1e1900 */ /*01e0*/ LDG.E R22, [R2.64+-0x4000] ; /* 0xffc0000402167981 */ /* 0x000f68000c1e1900 */ /*01f0*/ LDG.E R23, [R4.64+-0x10] ; /* 0xfffff00404177981 */ /* 0x000f68000c1e1900 */ /*0200*/ LDG.E R10, [R2.64+-0x3000] ; /* 0xffd00004020a7981 */ /* 0x000f68000c1e1900 */ /*0210*/ LDG.E R11, [R4.64+-0xc] ; /* 0xfffff404040b7981 */ /* 0x000f68000c1e1900 */ /*0220*/ LDG.E R12, [R2.64+-0x2000] ; /* 0xffe00004020c7981 */ /* 0x000f68000c1e1900 */ /*0230*/ LDG.E R13, [R4.64+-0x8] ; /* 0xfffff804040d7981 */ /* 0x000f68000c1e1900 */ /*0240*/ LDG.E R14, [R2.64+-0x1000] ; /* 0xfff00004020e7981 */ /* 0x000f68000c1e1900 */ /*0250*/ LDG.E R15, [R4.64+-0x4] ; /* 0xfffffc04040f7981 */ /* 0x000f62000c1e1900 */ /*0260*/ FFMA R17, R17, R24, R16 ; /* 0x0000001811117223 */ /* 0x004fc60000000010 */ /*0270*/ LDG.E R16, [R2.64] ; /* 0x0000000402107981 */ /* 0x0000a2000c1e1900 */ /*0280*/ FFMA R25, R26, R25, R17 ; /* 0x000000191a197223 */ /* 0x008fc60000000011 */ /*0290*/ LDG.E R17, [R4.64] ; /* 0x0000000404117981 */ /* 0x000ea8000c1e1900 */ /*02a0*/ LDG.E R24, [R2.64+0x7000] ; /* 0x0070000402187981 */ /* 0x0000e2000c1e1900 */ /*02b0*/ FFMA R25, R19, R18, R25 ; /* 0x0000001213197223 */ /* 0x010fc60000000019 */ /*02c0*/ LDG.E R19, [R2.64+0x1000] ; /* 0x0010000402137981 */ /* 0x000128000c1e1900 */ /*02d0*/ LDG.E R18, [R4.64+0x4] ; /* 0x0000040404127981 */ /* 0x000f22000c1e1900 */ /*02e0*/ FFMA R25, R20, R21, R25 ; /* 0x0000001514197223 */ /* 0x020fc60000000019 */ /*02f0*/ LDG.E R20, [R2.64+0x2000] ; /* 0x0020000402147981 */ /* 0x000168000c1e1900 */ /*0300*/ LDG.E R21, [R4.64+0x8] ; /* 0x0000080404157981 */ /* 0x000f62000c1e1900 */ /*0310*/ FFMA R25, R22, R23, R25 ; /* 0x0000001716197223 */ /* 0x000fc60000000019 */ /*0320*/ LDG.E R22, [R2.64+0x3000] ; /* 0x0030000402167981 */ /* 0x0000e8000c1e1900 */ /*0330*/ LDG.E R23, [R4.64+0xc] ; /* 0x00000c0404177981 */ /* 0x000ee2000c1e1900 */ /*0340*/ FFMA R25, R10, R11, R25 ; /* 0x0000000b0a197223 */ /* 0x000fc60000000019 */ /*0350*/ LDG.E R10, [R2.64+0x4000] ; /* 0x00400004020a7981 */ /* 0x0000e8000c1e1900 */ /*0360*/ LDG.E R11, [R4.64+0x10] ; /* 0x00001004040b7981 */ /* 0x000ee2000c1e1900 */ /*0370*/ FFMA R25, R12, R13, R25 ; /* 0x0000000d0c197223 */ /* 0x000fc60000000019 */ /*0380*/ LDG.E R12, [R2.64+0x5000] ; /* 0x00500004020c7981 */ /* 0x0000e8000c1e1900 */ /*0390*/ LDG.E R13, [R4.64+0x14] ; /* 0x00001404040d7981 */ /* 0x000ee2000c1e1900 */ /*03a0*/ FFMA R26, R14, R15, R25 ; /* 0x0000000f0e1a7223 */ /* 0x000fc60000000019 */ /*03b0*/ LDG.E R15, [R2.64+0x6000] ; /* 0x00600004020f7981 */ /* 0x0000e8000c1e1900 */ /*03c0*/ LDG.E R14, [R4.64+0x18] ; /* 0x00001804040e7981 */ /* 0x000ee8000c1e1900 */ /*03d0*/ LDG.E R25, [R4.64+0x1c] ; /* 0x00001c0404197981 */ /* 0x000ee2000c1e1900 */ /*03e0*/ IADD3 R8, R8, 0x10, RZ ; /* 0x0000001008087810 */ /* 0x000fc80007ffe0ff */ /*03f0*/ ISETP.NE.AND P0, PT, R8, 0x400, PT ; /* 0x000004000800780c */ /* 0x000fe40003f05270 */ /*0400*/ IADD3 R2, P2, R2, 0x10000, RZ ; /* 0x0001000002027810 */ /* 0x001fc80007f5e0ff */ /*0410*/ IADD3.X R3, RZ, R3, RZ, P2, !PT ; /* 0x00000003ff037210 */ /* 0x000fe200017fe4ff */ /*0420*/ FFMA R16, R16, R17, R26 ; /* 0x0000001110107223 */ /* 0x004fc8000000001a */ /*0430*/ FFMA R16, R19, R18, R16 ; /* 0x0000001213107223 */ /* 0x010fc80000000010 */ /*0440*/ FFMA R16, R20, R21, R16 ; /* 0x0000001514107223 */ /* 0x020fc80000000010 */ /*0450*/ FFMA R16, R22, R23, R16 ; /* 0x0000001716107223 */ /* 0x008fc80000000010 */ /*0460*/ FFMA R10, R10, R11, R16 ; /* 0x0000000b0a0a7223 */ /* 0x000fe20000000010 */ /*0470*/ IADD3 R11, P1, R4, 0x40, RZ ; /* 0x00000040040b7810 */ /* 0x000fc60007f3e0ff */ /*0480*/ FFMA R10, R12, R13, R10 ; /* 0x0000000d0c0a7223 */ /* 0x000fe2000000000a */ /*0490*/ IADD3.X R12, RZ, R5, RZ, P1, !PT ; /* 0x00000005ff0c7210 */ /* 0x000fc60000ffe4ff */ /*04a0*/ FFMA R10, R15, R14, R10 ; /* 0x0000000e0f0a7223 */ /* 0x000fc8000000000a */ /*04b0*/ FFMA R16, R24, R25, R10 ; /* 0x0000001918107223 */ /* 0x000fe2000000000a */ /*04c0*/ @P0 BRA 0x140 ; /* 0xfffffc7000000947 */ /* 0x000fea000383ffff */ /*04d0*/ LEA R3, P0, R0, c[0x0][0x160], 0xc ; /* 0x0000580000037a11 */ /* 0x000fc800078060ff */ /*04e0*/ LEA.HI.X R9, R0, c[0x0][0x164], R9, 0xc, P0 ; /* 0x0000590000097a11 */ /* 0x000fe400000f6409 */ /*04f0*/ LEA R2, P0, R6, R3, 0x2 ; /* 0x0000000306027211 */ /* 0x000fc800078010ff */ /*0500*/ LEA.HI.X R3, R6, R9, R7, 0x2, P0 ; /* 0x0000000906037211 */ /* 0x000fca00000f1407 */ /*0510*/ STG.E [R2.64], R16 ; /* 0x0000001002007986 */ /* 0x000fe2000c101904 */ /*0520*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0530*/ BRA 0x530; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*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 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .section .text._ZL6cuda_1PA1024_fS0_S0_,"axG",@progbits,_ZL6cuda_1PA1024_fS0_S0_,comdat .globl _ZL6cuda_1PA1024_fS0_S0_ .p2align 8 .type _ZL6cuda_1PA1024_fS0_S0_,@function _ZL6cuda_1PA1024_fS0_S0_: s_clause 0x1 s_load_b32 s2, s[0:1], 0x24 s_load_b128 s[4:7], s[0:1], 0x8 v_bfe_u32 v2, v0, 10, 10 v_and_b32_e32 v4, 0x3ff, v0 v_mov_b32_e32 v6, 0 s_waitcnt lgkmcnt(0) s_lshr_b32 s3, s2, 16 s_and_b32 s2, s2, 0xffff v_mad_u64_u32 v[0:1], null, s15, s3, v[2:3] v_mad_u64_u32 v[2:3], null, s14, s2, v[4:5] s_mov_b64 s[2:3], 0 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_ashrrev_i32_e32 v1, 31, v0 v_ashrrev_i32_e32 v3, 31, v2 s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_lshlrev_b64 v[4:5], 12, v[0:1] v_lshlrev_b64 v[9:10], 2, v[2:3] s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v7, vcc_lo, s4, v4 v_add_co_ci_u32_e32 v8, vcc_lo, s5, v5, vcc_lo s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v4, vcc_lo, s6, v9 v_add_co_ci_u32_e32 v5, vcc_lo, s7, v10, vcc_lo .LBB0_1: s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4) v_add_co_u32 v9, vcc_lo, v7, s2 v_add_co_ci_u32_e32 v10, vcc_lo, s3, v8, vcc_lo s_add_u32 s2, s2, 4 s_addc_u32 s3, s3, 0 global_load_b32 v11, v[4:5], off global_load_b32 v9, v[9:10], off v_add_co_u32 v4, vcc_lo, v4, 0x1000 v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo s_cmpk_eq_i32 s2, 0x1000 s_waitcnt vmcnt(0) v_fmac_f32_e32 v6, v9, v11 s_cbranch_scc0 .LBB0_1 s_load_b64 s[0:1], s[0:1], 0x0 v_lshlrev_b64 v[0:1], 12, v[0:1] v_lshlrev_b64 v[2:3], 2, v[2:3] s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3) v_add_co_u32 v0, vcc_lo, s0, v0 v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v0, vcc_lo, v0, v2 v_add_co_ci_u32_e32 v1, vcc_lo, v1, v3, vcc_lo global_store_b32 v[0:1], v6, off s_nop 0 s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) s_endpgm .section .rodata,"a",@progbits .p2align 6, 0x0 .amdhsa_kernel _ZL6cuda_1PA1024_fS0_S0_ .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 12 .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 .section .text._ZL6cuda_1PA1024_fS0_S0_,"axG",@progbits,_ZL6cuda_1PA1024_fS0_S0_,comdat .Lfunc_end0: .size _ZL6cuda_1PA1024_fS0_S0_, .Lfunc_end0-_ZL6cuda_1PA1024_fS0_S0_ .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: _ZL6cuda_1PA1024_fS0_S0_ .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _ZL6cuda_1PA1024_fS0_S0_.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 12 .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_0009b45f_00000000-6_cuda.cudafe1.cpp" .text #APP #NO_APP .type _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_, @function _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_: .LFB2084: .cfi_startproc 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 .L5 .L1: movq 120(%rsp), %rax subq %fs:40, %rax jne .L6 addq $136, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .L5: .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 _ZL6cuda_1PA1024_fS0_S0_(%rip), %rdi call cudaLaunchKernel@PLT addq $16, %rsp .cfi_def_cfa_offset 144 jmp .L1 .L6: call __stack_chk_fail@PLT .cfi_endproc .LFE2084: .size _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_, .-_ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_ .type _ZL6cuda_1PA1024_fS0_S0_, @function _ZL6cuda_1PA1024_fS0_S0_: .LFB2085: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_ addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2085: .size _ZL6cuda_1PA1024_fS0_S0_, .-_ZL6cuda_1PA1024_fS0_S0_ .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 .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: .string "\nCuda Error: %s (err_num=%d) at line:%d\n" .align 8 .LC1: .string "[CUDA 1] Start Launching Kernel.\n" .align 8 .LC3: .string "[CUDA 1] Processing Elapsed Time : %.3f (sec).\n" .text .globl cuda_version_1 .type cuda_version_1, @function cuda_version_1: .LFB2057: .cfi_startproc endbr64 pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 subq $88, %rsp .cfi_def_cfa_offset 128 movq %rdi, %rbp movq %rsi, %r13 movq %rdx, %r12 movq %fs:40, %rax movq %rax, 72(%rsp) xorl %eax, %eax leaq 8(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT testl %eax, %eax jne .L22 .L12: leaq 16(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT movl %eax, %ebx testl %eax, %eax jne .L23 .L13: leaq 24(%rsp), %rdi movl $4194304, %esi call cudaMalloc@PLT movl %eax, %ebx testl %eax, %eax jne .L24 .L14: movl $1, %ecx movl $4194304, %edx movq %r13, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %ebx testl %eax, %eax jne .L25 .L15: movl $1, %ecx movl $4194304, %edx movq %r12, %rsi movq 8(%rsp), %rdi call cudaMemcpy@PLT movl %eax, %ebx testl %eax, %eax jne .L26 .L16: movl BLOCK_HEIGHT(%rip), %esi movl BLOCK_WIDTH(%rip), %edi movl %edi, 48(%rsp) movl %esi, 52(%rsp) movl $1, 56(%rsp) movl $1024, %ecx movl %ecx, %eax cltd idivl %edi movl %eax, 60(%rsp) movl %ecx, %eax cltd idivl %esi movl %eax, 64(%rsp) movl $1, 68(%rsp) leaq .LC1(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq 32(%rsp), %rdi call cudaEventCreate@PLT leaq 40(%rsp), %rdi call cudaEventCreate@PLT 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 .L17: movl $0, %esi movq 40(%rsp), %rdi call cudaEventRecord@PLT movq 40(%rsp), %rdi call cudaEventSynchronize@PLT leaq 4(%rsp), %rdi movq 40(%rsp), %rdx movq 32(%rsp), %rsi call cudaEventElapsedTime@PLT movq 32(%rsp), %rdi call cudaEventDestroy@PLT movq 40(%rsp), %rdi call cudaEventDestroy@PLT movss 4(%rsp), %xmm0 divss .LC2(%rip), %xmm0 cvtss2sd %xmm0, %xmm0 leaq .LC3(%rip), %rsi movl $2, %edi movl $1, %eax call __printf_chk@PLT movl $2, %ecx movl $4194304, %edx movq 24(%rsp), %rsi movq %rbp, %rdi call cudaMemcpy@PLT movl %eax, %ebx testl %eax, %eax jne .L28 .L18: call cudaDeviceSynchronize@PLT movl %eax, %ebx testl %eax, %eax jne .L29 .L11: movq 72(%rsp), %rax subq %fs:40, %rax jne .L30 addq $88, %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 .L22: .cfi_restore_state movl %eax, %ebx movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $26, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L12 .L23: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $27, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L13 .L24: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $28, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L14 .L25: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $31, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L15 .L26: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $33, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L16 .L27: movq 16(%rsp), %rdx movq 8(%rsp), %rsi movq 24(%rsp), %rdi call _ZL37__device_stub__Z6cuda_1PA1024_fS0_S0_PA1024_fS0_S0_ jmp .L17 .L28: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $64, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L18 .L29: movl %eax, %edi call cudaGetErrorString@PLT movq %rax, %rdx movl $65, %r8d movl %ebx, %ecx leaq .LC0(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT call cudaDeviceReset@PLT jmp .L11 .L30: call __stack_chk_fail@PLT .cfi_endproc .LFE2057: .size cuda_version_1, .-cuda_version_1 .globl _Z8init_matPA1024_f .type _Z8init_matPA1024_f, @function _Z8init_matPA1024_f: .LFB2058: .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 movq %rdi, %r12 leaq 4096(%rdi), %rbp addq $4198400, %r12 .L32: leaq -4096(%rbp), %rbx .L33: call rand@PLT pxor %xmm0, %xmm0 cvtsi2ssl %eax, %xmm0 addss %xmm0, %xmm0 mulss .LC4(%rip), %xmm0 subss .LC5(%rip), %xmm0 movss %xmm0, (%rbx) addq $4, %rbx cmpq %rbp, %rbx jne .L33 addq $4096, %rbp cmpq %r12, %rbp jne .L32 popq %rbx .cfi_def_cfa_offset 24 popq %rbp .cfi_def_cfa_offset 16 popq %r12 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2058: .size _Z8init_matPA1024_f, .-_Z8init_matPA1024_f .section .rodata.str1.8 .align 8 .LC6: .string "input BLOCK WIDTH , BLOCK HEIGHT : " .section .rodata.str1.1,"aMS",@progbits,1 .LC7: .string "%d %d" .text .globl main .type main, @function main: .LFB2059: .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 $8, %rsp .cfi_def_cfa_offset 32 leaq .LC6(%rip), %rsi movl $2, %edi movl $0, %eax call __printf_chk@PLT leaq BLOCK_HEIGHT(%rip), %rdx leaq BLOCK_WIDTH(%rip), %rsi leaq .LC7(%rip), %rdi movl $0, %eax call __isoc23_scanf@PLT leaq A(%rip), %rbx movq %rbx, %rdi call _Z8init_matPA1024_f leaq B(%rip), %rbp movq %rbp, %rdi call _Z8init_matPA1024_f movq %rbp, %rdx movq %rbx, %rsi leaq C_cuda_1(%rip), %rdi call cuda_version_1 movl $0, %eax addq $8, %rsp .cfi_def_cfa_offset 24 popq %rbx .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2059: .size main, .-main .section .rodata.str1.1 .LC8: .string "_Z6cuda_1PA1024_fS0_S0_" .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 .LC8(%rip), %rdx movq %rdx, %rcx leaq _ZL6cuda_1PA1024_fS0_S0_(%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 .globl C_cuda_1 .bss .align 32 .type C_cuda_1, @object .size C_cuda_1, 4194304 C_cuda_1: .zero 4194304 .globl B .align 32 .type B, @object .size B, 4194304 B: .zero 4194304 .globl A .align 32 .type A, @object .size A, 4194304 A: .zero 4194304 .globl BLOCK_HEIGHT .align 4 .type BLOCK_HEIGHT, @object .size BLOCK_HEIGHT, 4 BLOCK_HEIGHT: .zero 4 .globl BLOCK_WIDTH .align 4 .type BLOCK_WIDTH, @object .size BLOCK_WIDTH, 4 BLOCK_WIDTH: .zero 4 .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC2: .long 1148846080 .align 4 .LC4: .long 805306368 .align 4 .LC5: .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 "cuda.hip" .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function cuda_version_1 .LCPI0_0: .long 0x447a0000 # float 1000 .text .globl cuda_version_1 .p2align 4, 0x90 .type cuda_version_1,@function cuda_version_1: # @cuda_version_1 .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 %rbx .cfi_def_cfa_offset 40 subq $136, %rsp .cfi_def_cfa_offset 176 .cfi_offset %rbx, -40 .cfi_offset %r14, -32 .cfi_offset %r15, -24 .cfi_offset %rbp, -16 movq %rdx, %r14 movq %rsi, %r15 movq %rdi, %rbx leaq 16(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc testl %eax, %eax je .LBB0_2 # %bb.1: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $26, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_2: leaq 56(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc testl %eax, %eax je .LBB0_4 # %bb.3: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $27, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_4: leaq 24(%rsp), %rdi movl $4194304, %esi # imm = 0x400000 callq hipMalloc testl %eax, %eax je .LBB0_6 # %bb.5: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $28, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_6: movq 16(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r15, %rsi movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB0_8 # %bb.7: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $31, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_8: movq 16(%rsp), %rdi movl $4194304, %edx # imm = 0x400000 movq %r14, %rsi movl $1, %ecx callq hipMemcpy testl %eax, %eax je .LBB0_10 # %bb.9: movl %eax, %edi movl %eax, %ebp callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebp, %edx movl $33, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_10: movl BLOCK_WIDTH(%rip), %ecx movl BLOCK_HEIGHT(%rip), %r15d movl $1024, %eax # imm = 0x400 xorl %edx, %edx idivl %ecx movl %eax, %r14d movl $1024, %eax # imm = 0x400 xorl %edx, %edx idivl %r15d # kill: def $eax killed $eax def $rax shlq $32, %r15 orq %rcx, %r15 shlq $32, %rax orq %rax, %r14 movl $.Lstr, %edi callq puts@PLT leaq 8(%rsp), %rdi callq hipEventCreate movq %rsp, %rdi callq hipEventCreate movq 8(%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq %r14, %rdi movl $1, %esi movq %r15, %rdx movl $1, %ecx xorl %r8d, %r8d xorl %r9d, %r9d callq __hipPushCallConfiguration testl %eax, %eax jne .LBB0_12 # %bb.11: movq 24(%rsp), %rax movq 16(%rsp), %rcx movq 56(%rsp), %rdx movq %rax, 128(%rsp) movq %rcx, 120(%rsp) movq %rdx, 112(%rsp) leaq 128(%rsp), %rax movq %rax, 32(%rsp) leaq 120(%rsp), %rax movq %rax, 40(%rsp) leaq 112(%rsp), %rax movq %rax, 48(%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 32(%rsp), %r9 movl $_ZL6cuda_1PA1024_fS0_S0_, %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 .LBB0_12: movq (%rsp), %rdi xorl %esi, %esi callq hipEventRecord movq (%rsp), %rdi callq hipEventSynchronize movq 8(%rsp), %rsi movq (%rsp), %rdx leaq 32(%rsp), %rdi callq hipEventElapsedTime movq 8(%rsp), %rdi callq hipEventDestroy movq (%rsp), %rdi callq hipEventDestroy movss 32(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero divss .LCPI0_0(%rip), %xmm0 cvtss2sd %xmm0, %xmm0 movl $.L.str.2, %edi movb $1, %al callq printf movq 24(%rsp), %rsi movl $4194304, %edx # imm = 0x400000 movq %rbx, %rdi movl $2, %ecx callq hipMemcpy testl %eax, %eax je .LBB0_14 # %bb.13: movl %eax, %edi movl %eax, %ebx callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebx, %edx movl $64, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_14: callq hipDeviceSynchronize testl %eax, %eax je .LBB0_16 # %bb.15: movl %eax, %edi movl %eax, %ebx callq hipGetErrorString movl $.L.str, %edi movq %rax, %rsi movl %ebx, %edx movl $65, %ecx xorl %eax, %eax callq printf callq hipDeviceReset .LBB0_16: addq $136, %rsp .cfi_def_cfa_offset 40 popq %rbx .cfi_def_cfa_offset 32 popq %r14 .cfi_def_cfa_offset 24 popq %r15 .cfi_def_cfa_offset 16 popq %rbp .cfi_def_cfa_offset 8 retq .Lfunc_end0: .size cuda_version_1, .Lfunc_end0-cuda_version_1 .cfi_endproc # -- End function .p2align 4, 0x90 # -- Begin function _ZL21__device_stub__cuda_1PA1024_fS0_S0_ .type _ZL21__device_stub__cuda_1PA1024_fS0_S0_,@function _ZL21__device_stub__cuda_1PA1024_fS0_S0_: # @_ZL21__device_stub__cuda_1PA1024_fS0_S0_ .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 $_ZL6cuda_1PA1024_fS0_S0_, %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_end1: .size _ZL21__device_stub__cuda_1PA1024_fS0_S0_, .Lfunc_end1-_ZL21__device_stub__cuda_1PA1024_fS0_S0_ .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function _Z8init_matPA1024_f .LCPI2_0: .long 0x30000000 # float 4.65661287E-10 .LCPI2_1: .long 0xbf800000 # float -1 .text .globl _Z8init_matPA1024_f .p2align 4, 0x90 .type _Z8init_matPA1024_f,@function _Z8init_matPA1024_f: # @_Z8init_matPA1024_f .cfi_startproc # %bb.0: 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 xorl %r14d, %r14d .p2align 4, 0x90 .LBB2_1: # %.preheader # =>This Loop Header: Depth=1 # Child Loop BB2_2 Depth 2 xorl %r15d, %r15d .p2align 4, 0x90 .LBB2_2: # Parent Loop BB2_1 Depth=1 # => This Inner Loop Header: Depth=2 callq rand movss .LCPI2_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 addss %xmm0, %xmm0 mulss %xmm1, %xmm0 movss .LCPI2_1(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero addss %xmm1, %xmm0 movss %xmm0, (%rbx,%r15,4) incq %r15 cmpq $1024, %r15 # imm = 0x400 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: popq %rbx .cfi_def_cfa_offset 24 popq %r14 .cfi_def_cfa_offset 16 popq %r15 .cfi_def_cfa_offset 8 retq .Lfunc_end2: .size _Z8init_matPA1024_f, .Lfunc_end2-_Z8init_matPA1024_f .cfi_endproc # -- End function .section .rodata.cst4,"aM",@progbits,4 .p2align 2, 0x0 # -- Begin function main .LCPI3_0: .long 0x30000000 # float 4.65661287E-10 .LCPI3_1: .long 0xbf800000 # float -1 .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 %rbx .cfi_def_cfa_offset 32 .cfi_offset %rbx, -32 .cfi_offset %r14, -24 .cfi_offset %r15, -16 xorl %ebx, %ebx movl $.L.str.3, %edi xorl %eax, %eax callq printf movl $.L.str.4, %edi movl $BLOCK_WIDTH, %esi movl $BLOCK_HEIGHT, %edx xorl %eax, %eax callq __isoc23_scanf movl $A, %r14d .p2align 4, 0x90 .LBB3_1: # %.preheader.i # =>This Loop Header: Depth=1 # Child Loop BB3_2 Depth 2 xorl %r15d, %r15d .p2align 4, 0x90 .LBB3_2: # Parent Loop BB3_1 Depth=1 # => This Inner Loop Header: Depth=2 callq rand movss .LCPI3_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 addss %xmm0, %xmm0 mulss %xmm1, %xmm0 movss .LCPI3_1(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero addss %xmm1, %xmm0 movss %xmm0, (%r14,%r15,4) incq %r15 cmpq $1024, %r15 # imm = 0x400 jne .LBB3_2 # %bb.3: # in Loop: Header=BB3_1 Depth=1 incq %rbx addq $4096, %r14 # imm = 0x1000 cmpq $1024, %rbx # imm = 0x400 jne .LBB3_1 # %bb.4: # %.preheader.i1.preheader movl $B, %ebx xorl %r14d, %r14d .p2align 4, 0x90 .LBB3_5: # %.preheader.i1 # =>This Loop Header: Depth=1 # Child Loop BB3_6 Depth 2 xorl %r15d, %r15d .p2align 4, 0x90 .LBB3_6: # Parent Loop BB3_5 Depth=1 # => This Inner Loop Header: Depth=2 callq rand xorps %xmm0, %xmm0 cvtsi2ss %eax, %xmm0 addss %xmm0, %xmm0 mulss .LCPI3_0(%rip), %xmm0 addss .LCPI3_1(%rip), %xmm0 movss %xmm0, (%rbx,%r15,4) incq %r15 cmpq $1024, %r15 # imm = 0x400 jne .LBB3_6 # %bb.7: # in Loop: Header=BB3_5 Depth=1 incq %r14 addq $4096, %rbx # imm = 0x1000 cmpq $1024, %r14 # imm = 0x400 jne .LBB3_5 # %bb.8: # %_Z8init_matPA1024_f.exit8 movl $C_cuda_1, %edi movl $A, %esi movl $B, %edx callq cuda_version_1 xorl %eax, %eax popq %rbx .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 $_ZL6cuda_1PA1024_fS0_S0_, %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 BLOCK_WIDTH,@object # @BLOCK_WIDTH .bss .globl BLOCK_WIDTH .p2align 2, 0x0 BLOCK_WIDTH: .long 0 # 0x0 .size BLOCK_WIDTH, 4 .type BLOCK_HEIGHT,@object # @BLOCK_HEIGHT .globl BLOCK_HEIGHT .p2align 2, 0x0 BLOCK_HEIGHT: .long 0 # 0x0 .size BLOCK_HEIGHT, 4 .type .L.str,@object # @.str .section .rodata.str1.1,"aMS",@progbits,1 .L.str: .asciz "\nCuda Error: %s (err_num=%d) at line:%d\n" .size .L.str, 41 .type _ZL6cuda_1PA1024_fS0_S0_,@object # @_ZL6cuda_1PA1024_fS0_S0_ .section .rodata,"a",@progbits .p2align 3, 0x0 _ZL6cuda_1PA1024_fS0_S0_: .quad _ZL21__device_stub__cuda_1PA1024_fS0_S0_ .size _ZL6cuda_1PA1024_fS0_S0_, 8 .type .L.str.2,@object # @.str.2 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.2: .asciz "[CUDA 1] Processing Elapsed Time : %.3f (sec).\n" .size .L.str.2, 48 .type A,@object # @A .bss .globl A .p2align 4, 0x0 A: .zero 4194304 .size A, 4194304 .type B,@object # @B .globl B .p2align 4, 0x0 B: .zero 4194304 .size B, 4194304 .type C_cuda_1,@object # @C_cuda_1 .globl C_cuda_1 .p2align 4, 0x0 C_cuda_1: .zero 4194304 .size C_cuda_1, 4194304 .type .L.str.3,@object # @.str.3 .section .rodata.str1.1,"aMS",@progbits,1 .L.str.3: .asciz "input BLOCK WIDTH , BLOCK HEIGHT : " .size .L.str.3, 36 .type .L.str.4,@object # @.str.4 .L.str.4: .asciz "%d %d" .size .L.str.4, 6 .type .L__unnamed_1,@object # @0 .L__unnamed_1: .asciz "_ZL6cuda_1PA1024_fS0_S0_" .size .L__unnamed_1, 25 .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 "[CUDA 1] Start Launching Kernel." .size .Lstr, 33 .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 _ZL21__device_stub__cuda_1PA1024_fS0_S0_ .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym BLOCK_WIDTH .addrsig_sym BLOCK_HEIGHT .addrsig_sym _ZL6cuda_1PA1024_fS0_S0_ .addrsig_sym A .addrsig_sym B .addrsig_sym C_cuda_1 .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 vectFill( int * data1, int * data2, int * restult, unsigned long sizeOfArray ) { unsigned long i = blockDim.x * blockIdx.x + threadIdx.x; if( i < sizeOfArray ) { restult[ i ] = data1[i] + data2[i]; } }
code for sm_80 Function : _Z8vectFillPiS_S_m .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.U32.AND P0, PT, R0, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x000fc80003f06070 */ /*0050*/ ISETP.GE.U32.AND.EX P0, PT, RZ, c[0x0][0x17c], PT, P0 ; /* 0x00005f00ff007a0c */ /* 0x000fda0003f06100 */ /*0060*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0070*/ IMAD.SHL.U32 R6, R0, 0x4, RZ ; /* 0x0000000400067824 */ /* 0x000fe200078e00ff */ /*0080*/ SHF.R.U32.HI R0, RZ, 0x1e, R0 ; /* 0x0000001eff007819 */ /* 0x000fe20000011600 */ /*0090*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*00a0*/ IADD3 R4, P0, R6.reuse, c[0x0][0x160], RZ ; /* 0x0000580006047a10 */ /* 0x040fe40007f1e0ff */ /*00b0*/ IADD3 R2, P1, R6, c[0x0][0x168], RZ ; /* 0x00005a0006027a10 */ /* 0x000fe40007f3e0ff */ /*00c0*/ IADD3.X R5, R0.reuse, c[0x0][0x164], RZ, P0, !PT ; /* 0x0000590000057a10 */ /* 0x040fe400007fe4ff */ /*00d0*/ IADD3.X R3, R0, c[0x0][0x16c], RZ, P1, !PT ; /* 0x00005b0000037a10 */ /* 0x000fc80000ffe4ff */ /*00e0*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea8000c1e1900 */ /*00f0*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea2000c1e1900 */ /*0100*/ IADD3 R6, P0, R6, c[0x0][0x170], RZ ; /* 0x00005c0006067a10 */ /* 0x000fc80007f1e0ff */ /*0110*/ IADD3.X R7, R0, c[0x0][0x174], RZ, P0, !PT ; /* 0x00005d0000077a10 */ /* 0x000fe200007fe4ff */ /*0120*/ IMAD.IADD R9, R2, 0x1, R5 ; /* 0x0000000102097824 */ /* 0x004fca00078e0205 */ /*0130*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*0140*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0150*/ BRA 0x150; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include "includes.h" __global__ void vectFill( int * data1, int * data2, int * restult, unsigned long sizeOfArray ) { unsigned long i = blockDim.x * blockIdx.x + threadIdx.x; if( i < sizeOfArray ) { restult[ i ] = data1[i] + data2[i]; } }
.file "tmpxft_000b011f_00000000-6_vectFill.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 _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m .type _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m, @function _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m: .LFB2051: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%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 16(%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 .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 _Z8vectFillPiS_S_m(%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 _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m, .-_Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m .globl _Z8vectFillPiS_S_m .type _Z8vectFillPiS_S_m, @function _Z8vectFillPiS_S_m: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z8vectFillPiS_S_m, .-_Z8vectFillPiS_S_m .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z8vectFillPiS_S_m" .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 _Z8vectFillPiS_S_m(%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 vectFill( int * data1, int * data2, int * restult, unsigned long sizeOfArray ) { unsigned long i = blockDim.x * blockIdx.x + threadIdx.x; if( i < sizeOfArray ) { restult[ i ] = data1[i] + data2[i]; } }
#include <hip/hip_runtime.h> #include "includes.h" __global__ void vectFill( int * data1, int * data2, int * restult, unsigned long sizeOfArray ) { unsigned long i = blockDim.x * blockIdx.x + threadIdx.x; if( i < sizeOfArray ) { restult[ i ] = data1[i] + data2[i]; } }
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 vectFill( int * data1, int * data2, int * restult, unsigned long sizeOfArray ) { unsigned long i = blockDim.x * blockIdx.x + threadIdx.x; if( i < sizeOfArray ) { restult[ i ] = data1[i] + data2[i]; } }
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z8vectFillPiS_S_m .globl _Z8vectFillPiS_S_m .p2align 8 .type _Z8vectFillPiS_S_m,@function _Z8vectFillPiS_S_m: s_clause 0x1 s_load_b32 s4, s[0:1], 0x2c s_load_b64 s[2:3], s[0:1], 0x18 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] v_mov_b32_e32 v2, 0 v_cmp_gt_u64_e32 vcc_lo, s[2:3], v[1:2] s_and_saveexec_b32 s2, vcc_lo s_cbranch_execz .LBB0_2 s_load_b128 s[4:7], s[0:1], 0x0 v_lshlrev_b64 v[0:1], 2, v[1:2] s_load_b64 s[0:1], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v2, vcc_lo, s4, v0 v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 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 _Z8vectFillPiS_S_m .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 _Z8vectFillPiS_S_m, .Lfunc_end0-_Z8vectFillPiS_S_m .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: 8 .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: _Z8vectFillPiS_S_m .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z8vectFillPiS_S_m.kd .uniform_work_group_size: 1 .uses_dynamic_stack: false .vgpr_count: 6 .vgpr_spill_count: 0 .wavefront_size: 32 .workgroup_processor_mode: 1 amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata
You are a helpful coding assistant specialized in converting HIP source code to AMD host assembly.
#include <hip/hip_runtime.h> #include "includes.h" __global__ void vectFill( int * data1, int * data2, int * restult, unsigned long sizeOfArray ) { unsigned long i = blockDim.x * blockIdx.x + threadIdx.x; if( i < sizeOfArray ) { restult[ i ] = data1[i] + data2[i]; } }
.text .file "vectFill.hip" .globl _Z23__device_stub__vectFillPiS_S_m # -- Begin function _Z23__device_stub__vectFillPiS_S_m .p2align 4, 0x90 .type _Z23__device_stub__vectFillPiS_S_m,@function _Z23__device_stub__vectFillPiS_S_m: # @_Z23__device_stub__vectFillPiS_S_m .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) movq %rcx, 48(%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 48(%rsp), %rax movq %rax, 104(%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 80(%rsp), %r9 movl $_Z8vectFillPiS_S_m, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end0: .size _Z23__device_stub__vectFillPiS_S_m, .Lfunc_end0-_Z23__device_stub__vectFillPiS_S_m .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 $_Z8vectFillPiS_S_m, %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 _Z8vectFillPiS_S_m,@object # @_Z8vectFillPiS_S_m .section .rodata,"a",@progbits .globl _Z8vectFillPiS_S_m .p2align 3, 0x0 _Z8vectFillPiS_S_m: .quad _Z23__device_stub__vectFillPiS_S_m .size _Z8vectFillPiS_S_m, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z8vectFillPiS_S_m" .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 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z23__device_stub__vectFillPiS_S_m .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z8vectFillPiS_S_m .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 : _Z8vectFillPiS_S_m .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.U32.AND P0, PT, R0, c[0x0][0x178], PT ; /* 0x00005e0000007a0c */ /* 0x000fc80003f06070 */ /*0050*/ ISETP.GE.U32.AND.EX P0, PT, RZ, c[0x0][0x17c], PT, P0 ; /* 0x00005f00ff007a0c */ /* 0x000fda0003f06100 */ /*0060*/ @P0 EXIT ; /* 0x000000000000094d */ /* 0x000fea0003800000 */ /*0070*/ IMAD.SHL.U32 R6, R0, 0x4, RZ ; /* 0x0000000400067824 */ /* 0x000fe200078e00ff */ /*0080*/ SHF.R.U32.HI R0, RZ, 0x1e, R0 ; /* 0x0000001eff007819 */ /* 0x000fe20000011600 */ /*0090*/ ULDC.64 UR4, c[0x0][0x118] ; /* 0x0000460000047ab9 */ /* 0x000fc60000000a00 */ /*00a0*/ IADD3 R4, P0, R6.reuse, c[0x0][0x160], RZ ; /* 0x0000580006047a10 */ /* 0x040fe40007f1e0ff */ /*00b0*/ IADD3 R2, P1, R6, c[0x0][0x168], RZ ; /* 0x00005a0006027a10 */ /* 0x000fe40007f3e0ff */ /*00c0*/ IADD3.X R5, R0.reuse, c[0x0][0x164], RZ, P0, !PT ; /* 0x0000590000057a10 */ /* 0x040fe400007fe4ff */ /*00d0*/ IADD3.X R3, R0, c[0x0][0x16c], RZ, P1, !PT ; /* 0x00005b0000037a10 */ /* 0x000fc80000ffe4ff */ /*00e0*/ LDG.E R5, [R4.64] ; /* 0x0000000404057981 */ /* 0x000ea8000c1e1900 */ /*00f0*/ LDG.E R2, [R2.64] ; /* 0x0000000402027981 */ /* 0x000ea2000c1e1900 */ /*0100*/ IADD3 R6, P0, R6, c[0x0][0x170], RZ ; /* 0x00005c0006067a10 */ /* 0x000fc80007f1e0ff */ /*0110*/ IADD3.X R7, R0, c[0x0][0x174], RZ, P0, !PT ; /* 0x00005d0000077a10 */ /* 0x000fe200007fe4ff */ /*0120*/ IMAD.IADD R9, R2, 0x1, R5 ; /* 0x0000000102097824 */ /* 0x004fca00078e0205 */ /*0130*/ STG.E [R6.64], R9 ; /* 0x0000000906007986 */ /* 0x000fe2000c101904 */ /*0140*/ EXIT ; /* 0x000000000000794d */ /* 0x000fea0003800000 */ /*0150*/ BRA 0x150; /* 0xfffffff000007947 */ /* 0x000fc0000383ffff */ /*0160*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0170*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0180*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*0190*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01a0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01b0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01c0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01d0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01e0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ /*01f0*/ NOP; /* 0x0000000000007918 */ /* 0x000fc00000000000 */ ..........
.text .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .protected _Z8vectFillPiS_S_m .globl _Z8vectFillPiS_S_m .p2align 8 .type _Z8vectFillPiS_S_m,@function _Z8vectFillPiS_S_m: s_clause 0x1 s_load_b32 s4, s[0:1], 0x2c s_load_b64 s[2:3], s[0:1], 0x18 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] v_mov_b32_e32 v2, 0 v_cmp_gt_u64_e32 vcc_lo, s[2:3], v[1:2] s_and_saveexec_b32 s2, vcc_lo s_cbranch_execz .LBB0_2 s_load_b128 s[4:7], s[0:1], 0x0 v_lshlrev_b64 v[0:1], 2, v[1:2] s_load_b64 s[0:1], s[0:1], 0x10 s_waitcnt lgkmcnt(0) s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2) v_add_co_u32 v2, vcc_lo, s4, v0 v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo v_add_co_u32 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 _Z8vectFillPiS_S_m .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 _Z8vectFillPiS_S_m, .Lfunc_end0-_Z8vectFillPiS_S_m .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: 8 .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: _Z8vectFillPiS_S_m .private_segment_fixed_size: 0 .sgpr_count: 18 .sgpr_spill_count: 0 .symbol: _Z8vectFillPiS_S_m.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_000b011f_00000000-6_vectFill.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 _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m .type _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m, @function _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m: .LFB2051: .cfi_startproc endbr64 subq $152, %rsp .cfi_def_cfa_offset 160 movq %rdi, 24(%rsp) movq %rsi, 16(%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 16(%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 .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 _Z8vectFillPiS_S_m(%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 _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m, .-_Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m .globl _Z8vectFillPiS_S_m .type _Z8vectFillPiS_S_m, @function _Z8vectFillPiS_S_m: .LFB2052: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 call _Z32__device_stub__Z8vectFillPiS_S_mPiS_S_m addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2052: .size _Z8vectFillPiS_S_m, .-_Z8vectFillPiS_S_m .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "_Z8vectFillPiS_S_m" .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 _Z8vectFillPiS_S_m(%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 "vectFill.hip" .globl _Z23__device_stub__vectFillPiS_S_m # -- Begin function _Z23__device_stub__vectFillPiS_S_m .p2align 4, 0x90 .type _Z23__device_stub__vectFillPiS_S_m,@function _Z23__device_stub__vectFillPiS_S_m: # @_Z23__device_stub__vectFillPiS_S_m .cfi_startproc # %bb.0: subq $120, %rsp .cfi_def_cfa_offset 128 movq %rdi, 72(%rsp) movq %rsi, 64(%rsp) movq %rdx, 56(%rsp) movq %rcx, 48(%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 48(%rsp), %rax movq %rax, 104(%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 80(%rsp), %r9 movl $_Z8vectFillPiS_S_m, %edi pushq (%rsp) .cfi_adjust_cfa_offset 8 pushq 16(%rsp) .cfi_adjust_cfa_offset 8 callq hipLaunchKernel addq $136, %rsp .cfi_adjust_cfa_offset -136 retq .Lfunc_end0: .size _Z23__device_stub__vectFillPiS_S_m, .Lfunc_end0-_Z23__device_stub__vectFillPiS_S_m .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 $_Z8vectFillPiS_S_m, %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 _Z8vectFillPiS_S_m,@object # @_Z8vectFillPiS_S_m .section .rodata,"a",@progbits .globl _Z8vectFillPiS_S_m .p2align 3, 0x0 _Z8vectFillPiS_S_m: .quad _Z23__device_stub__vectFillPiS_S_m .size _Z8vectFillPiS_S_m, 8 .type .L__unnamed_1,@object # @0 .section .rodata.str1.1,"aMS",@progbits,1 .L__unnamed_1: .asciz "_Z8vectFillPiS_S_m" .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 .section ".linker-options","e",@llvm_linker_options .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym _Z23__device_stub__vectFillPiS_S_m .addrsig_sym __hip_module_ctor .addrsig_sym __hip_module_dtor .addrsig_sym _Z8vectFillPiS_S_m .addrsig_sym __hip_fatbin .addrsig_sym __hip_fatbin_wrapper .addrsig_sym __hip_cuid_
You are a helpful coding assistant specialized in converting CUDA source code to CUDA device assembly.
#include<iostream> #include<string> #include<cuda.h> using namespace std; int main(){ struct cudaDeviceProp prop; cudaError_t err; err = cudaGetDeviceProperties(&prop,0); if(err!=cudaSuccess){ cout<<"Get failed. Exiting."<<endl; } else{ cout<<"Name : "<<string(prop.name)<<endl; cout<<"Total global memory : "<<prop.totalGlobalMem/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Shared memmory per block : "<<prop.sharedMemPerBlock/(1024.0)<<" KB"<<endl; cout<<"32 bit registers per block : "<<prop.regsPerBlock<<endl; cout<<"Warp size (in threads) : "<<prop.warpSize<<endl; cout<<"Max pitch allowed by mem copy : "<<prop.memPitch/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Max threads per block : "<<prop.maxThreadsPerBlock<<endl; cout<<"Max thread dimensions : "<<"("<<prop.maxThreadsDim[0]<<","<<prop.maxThreadsDim[1]<<","<<prop.maxThreadsDim[2]<<")"<<endl; cout<<"Max grid dimensions : "<<"("<<prop.maxGridSize[0]<<","<<prop.maxGridSize[1]<<","<<prop.maxGridSize[2]<<")"<<endl; cout<<"Max const memory : "<<prop.totalConstMem/1024.0<<" KB"<<endl; cout<<"Major compute capability : "<<prop.major<<endl; cout<<"Minor compute capability : "<<prop.minor<<endl; cout<<"Clock frequency : "<<prop.clockRate/1000.0<<" MHz"<<endl; cout<<"Alignment requirement for textures : "<<prop.textureAlignment<<endl; cout<<"Device can concurrently copy memory and execute a kernel : "<<(bool)prop.deviceOverlap<<endl; cout<<"Number of multiprocessors on device : "<<prop.multiProcessorCount<<endl; cout<<"Specified whether there is a run time limit on kernels : "<<(bool)prop.kernelExecTimeoutEnabled<<endl; cout<<"Integrated : "<<(bool)prop.integrated<<endl; cout<<"Can map host memory : "<<(bool)prop.canMapHostMemory<<endl; cout<<"Compute Mode : "<<prop.computeMode<<endl; cout<<"Concurrent kernels : "<<(bool)prop.concurrentKernels<<endl; cout<<"ECC support : "<<(bool)prop.ECCEnabled<<endl; cout<<"PCI bus id : "<<prop.pciBusID<<endl; cout<<"PCI device id : "<<prop.pciDeviceID<<endl; cout<<"TCC Driver : "<<(bool)prop.tccDriver<<endl; } return 0; }
code for sm_80
You are a helpful coding assistant specialized in converting CUDA source code to CUDA host assembly.
#include<iostream> #include<string> #include<cuda.h> using namespace std; int main(){ struct cudaDeviceProp prop; cudaError_t err; err = cudaGetDeviceProperties(&prop,0); if(err!=cudaSuccess){ cout<<"Get failed. Exiting."<<endl; } else{ cout<<"Name : "<<string(prop.name)<<endl; cout<<"Total global memory : "<<prop.totalGlobalMem/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Shared memmory per block : "<<prop.sharedMemPerBlock/(1024.0)<<" KB"<<endl; cout<<"32 bit registers per block : "<<prop.regsPerBlock<<endl; cout<<"Warp size (in threads) : "<<prop.warpSize<<endl; cout<<"Max pitch allowed by mem copy : "<<prop.memPitch/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Max threads per block : "<<prop.maxThreadsPerBlock<<endl; cout<<"Max thread dimensions : "<<"("<<prop.maxThreadsDim[0]<<","<<prop.maxThreadsDim[1]<<","<<prop.maxThreadsDim[2]<<")"<<endl; cout<<"Max grid dimensions : "<<"("<<prop.maxGridSize[0]<<","<<prop.maxGridSize[1]<<","<<prop.maxGridSize[2]<<")"<<endl; cout<<"Max const memory : "<<prop.totalConstMem/1024.0<<" KB"<<endl; cout<<"Major compute capability : "<<prop.major<<endl; cout<<"Minor compute capability : "<<prop.minor<<endl; cout<<"Clock frequency : "<<prop.clockRate/1000.0<<" MHz"<<endl; cout<<"Alignment requirement for textures : "<<prop.textureAlignment<<endl; cout<<"Device can concurrently copy memory and execute a kernel : "<<(bool)prop.deviceOverlap<<endl; cout<<"Number of multiprocessors on device : "<<prop.multiProcessorCount<<endl; cout<<"Specified whether there is a run time limit on kernels : "<<(bool)prop.kernelExecTimeoutEnabled<<endl; cout<<"Integrated : "<<(bool)prop.integrated<<endl; cout<<"Can map host memory : "<<(bool)prop.canMapHostMemory<<endl; cout<<"Compute Mode : "<<prop.computeMode<<endl; cout<<"Concurrent kernels : "<<(bool)prop.concurrentKernels<<endl; cout<<"ECC support : "<<(bool)prop.ECCEnabled<<endl; cout<<"PCI bus id : "<<prop.pciBusID<<endl; cout<<"PCI device id : "<<prop.pciDeviceID<<endl; cout<<"TCC Driver : "<<(bool)prop.tccDriver<<endl; } return 0; }
.file "tmpxft_0004fa51_00000000-6_test2.cudafe1.cpp" .text #APP .globl _ZSt21ios_base_library_initv #NO_APP .type _ZL26__cudaUnregisterBinaryUtilv, @function _ZL26__cudaUnregisterBinaryUtilv: .LFB3672: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 movq _ZL20__cudaFatCubinHandle(%rip), %rdi call __cudaUnregisterFatBinary@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3672: .size _ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "Get failed. Exiting." .LC1: .string "Name : " .LC2: .string "Total global memory : " .LC4: .string " GB" .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC5: .string "Shared memmory per block : " .section .rodata.str1.1 .LC7: .string " KB" .section .rodata.str1.8 .align 8 .LC8: .string "32 bit registers per block : " .section .rodata.str1.1 .LC9: .string "Warp size (in threads) : " .section .rodata.str1.8 .align 8 .LC10: .string "Max pitch allowed by mem copy : " .section .rodata.str1.1 .LC11: .string "Max threads per block : " .LC12: .string "Max thread dimensions : " .LC13: .string "(" .LC14: .string "," .LC15: .string ")" .LC16: .string "Max grid dimensions : " .LC17: .string "Max const memory : " .section .rodata.str1.8 .align 8 .LC18: .string "Major compute capability : " .align 8 .LC19: .string "Minor compute capability : " .section .rodata.str1.1 .LC20: .string "Clock frequency : " .LC22: .string " MHz" .section .rodata.str1.8 .align 8 .LC23: .string "Alignment requirement for textures : " .align 8 .LC24: .string "Device can concurrently copy memory and execute a kernel : " .align 8 .LC25: .string "Number of multiprocessors on device : " .align 8 .LC26: .string "Specified whether there is a run time limit on kernels : " .section .rodata.str1.1 .LC27: .string "Integrated : " .LC28: .string "Can map host memory : " .LC29: .string "Compute Mode : " .LC30: .string "Concurrent kernels : " .LC31: .string "ECC support : " .LC32: .string "PCI bus id : " .LC33: .string "PCI device id : " .LC34: .string "TCC Driver : " .text .globl main .type main, @function main: .LFB3669: .cfi_startproc .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 .cfi_lsda 0x1b,.LLSDA3669 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 $1096, %rsp .cfi_def_cfa_offset 1136 movq %fs:40, %rax movq %rax, 1080(%rsp) xorl %eax, %eax leaq 48(%rsp), %rdi movl $0, %esi .LEHB0: call cudaGetDeviceProperties_v2@PLT testl %eax, %eax je .L4 leaq .LC0(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT .L5: movq 1080(%rsp), %rax subq %fs:40, %rax jne .L28 movl $0, %eax addq $1096, %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 .L4: .cfi_restore_state leaq .LC1(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT .LEHE0: movq %rax, %rbp leaq 32(%rsp), %rax movq %rax, 16(%rsp) leaq 48(%rsp), %rdi call strlen@PLT movq %rax, %rbx movq %rax, 8(%rsp) cmpq $15, %rax ja .L29 cmpq $1, %rax jne .L8 movzbl 48(%rsp), %eax movb %al, 32(%rsp) .L9: movq 8(%rsp), %rax movq %rax, 24(%rsp) movq 16(%rsp), %rdx movb $0, (%rdx,%rax) movq 24(%rsp), %rdx movq 16(%rsp), %rsi movq %rbp, %rdi .LEHB1: call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT .LEHE1: jmp .L30 .L29: leaq 8(%rsp), %rsi leaq 16(%rsp), %rdi movl $0, %edx .LEHB2: call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT .LEHE2: movq %rax, 16(%rsp) movq 8(%rsp), %rdx movq %rdx, 32(%rsp) .L7: leaq 48(%rsp), %rsi movq %rax, %rdx cmpl $8, %ebx jnb .L10 testb $4, %bl jne .L31 testl %ebx, %ebx je .L9 movzbl 48(%rsp), %eax movb %al, (%rdx) testb $2, %bl je .L9 movl %ebx, %ebx movzwl -2(%rsi,%rbx), %eax movw %ax, -2(%rdx,%rbx) jmp .L9 .L8: testq %rax, %rax je .L9 leaq 32(%rsp), %rax jmp .L7 .L31: movl 48(%rsp), %eax movl %eax, (%rdx) movl %ebx, %ebx movl -4(%rsi,%rbx), %eax movl %eax, -4(%rdx,%rbx) jmp .L9 .L10: movq 48(%rsp), %rdx movq %rdx, (%rax) movl %ebx, %edx movq -8(%rsi,%rdx), %rcx movq %rcx, -8(%rax,%rdx) leaq 8(%rax), %rdi andq $-8, %rdi subq %rdi, %rax subq %rax, %rsi leal (%rbx,%rax), %ecx shrl $3, %ecx movl %ecx, %ecx rep movsq jmp .L9 .L30: movq %rax, %rdi .LEHB3: call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT .LEHE3: leaq 16(%rsp), %rdi call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT leaq .LC2(%rip), %rsi leaq _ZSt4cout(%rip), %rdi .LEHB4: call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq 336(%rsp), %rdx testq %rdx, %rdx js .L14 pxor %xmm0, %xmm0 cvtsi2sdq %rdx, %xmm0 .L15: mulsd .LC3(%rip), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi leaq .LC4(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC5(%rip), %rsi leaq _ZSt4cout(%rip), %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq 344(%rsp), %rdx testq %rdx, %rdx js .L16 pxor %xmm0, %xmm0 cvtsi2sdq %rdx, %xmm0 .L17: mulsd .LC6(%rip), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi leaq .LC7(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC8(%rip), %rsi leaq _ZSt4cout(%rip), %rbx movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 352(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC9(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 356(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC10(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq 360(%rsp), %rdx testq %rdx, %rdx js .L18 pxor %xmm0, %xmm0 cvtsi2sdq %rdx, %xmm0 .L19: mulsd .LC3(%rip), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi leaq .LC4(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC11(%rip), %rsi leaq _ZSt4cout(%rip), %rbx movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 368(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC12(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi leaq .LC13(%rip), %r13 movq %r13, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 372(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC14(%rip), %rbp movq %rbp, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 376(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi movq %rbp, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 380(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi leaq .LC15(%rip), %r12 movq %r12, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC16(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq %r13, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 384(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi movq %rbp, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 388(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi movq %rbp, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 392(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi movq %r12, %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC17(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq 400(%rsp), %rdx testq %rdx, %rdx js .L20 pxor %xmm0, %xmm0 cvtsi2sdq %rdx, %xmm0 .L21: mulsd .LC6(%rip), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi leaq .LC7(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC18(%rip), %rsi leaq _ZSt4cout(%rip), %rbx movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 408(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC19(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 412(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC20(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi pxor %xmm0, %xmm0 cvtsi2sdl 396(%rsp), %xmm0 divsd .LC21(%rip), %xmm0 call _ZNSo9_M_insertIdEERSoT_@PLT movq %rax, %rdi leaq .LC22(%rip), %rsi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC23(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movq 416(%rsp), %rsi call _ZNSo9_M_insertImEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC24(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 432(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC25(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 436(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC26(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 440(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC27(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 444(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC28(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 448(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC29(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 452(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC30(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 624(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC31(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 628(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC32(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 632(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC33(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi movl 636(%rsp), %esi call _ZNSolsEi@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT leaq .LC34(%rip), %rsi movq %rbx, %rdi call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT movq %rax, %rdi cmpl $0, 644(%rsp) setne %sil movzbl %sil, %esi call _ZNSo9_M_insertIbEERSoT_@PLT movq %rax, %rdi call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT jmp .L5 .L14: movq %rdx, %rax shrq %rax andl $1, %edx orq %rdx, %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 addsd %xmm0, %xmm0 jmp .L15 .L16: movq %rdx, %rax shrq %rax andl $1, %edx orq %rdx, %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 addsd %xmm0, %xmm0 jmp .L17 .L18: movq %rdx, %rax shrq %rax andl $1, %edx orq %rdx, %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 addsd %xmm0, %xmm0 jmp .L19 .L20: movq %rdx, %rax shrq %rax andl $1, %edx orq %rdx, %rax pxor %xmm0, %xmm0 cvtsi2sdq %rax, %xmm0 addsd %xmm0, %xmm0 jmp .L21 .L25: endbr64 movq %rax, %rbx leaq 16(%rsp), %rdi call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT movq 1080(%rsp), %rax subq %fs:40, %rax je .L23 call __stack_chk_fail@PLT .L23: movq %rbx, %rdi call _Unwind_Resume@PLT .LEHE4: .L28: call __stack_chk_fail@PLT .cfi_endproc .LFE3669: .globl __gxx_personality_v0 .section .gcc_except_table,"a",@progbits .LLSDA3669: .byte 0xff .byte 0xff .byte 0x1 .uleb128 .LLSDACSE3669-.LLSDACSB3669 .LLSDACSB3669: .uleb128 .LEHB0-.LFB3669 .uleb128 .LEHE0-.LEHB0 .uleb128 0 .uleb128 0 .uleb128 .LEHB1-.LFB3669 .uleb128 .LEHE1-.LEHB1 .uleb128 .L25-.LFB3669 .uleb128 0 .uleb128 .LEHB2-.LFB3669 .uleb128 .LEHE2-.LEHB2 .uleb128 0 .uleb128 0 .uleb128 .LEHB3-.LFB3669 .uleb128 .LEHE3-.LEHB3 .uleb128 .L25-.LFB3669 .uleb128 0 .uleb128 .LEHB4-.LFB3669 .uleb128 .LEHE4-.LEHB4 .uleb128 0 .uleb128 0 .LLSDACSE3669: .text .size main, .-main .type _ZL24__sti____cudaRegisterAllv, @function _ZL24__sti____cudaRegisterAllv: .LFB3695: .cfi_startproc endbr64 subq $8, %rsp .cfi_def_cfa_offset 16 leaq _ZL15__fatDeviceText(%rip), %rdi call __cudaRegisterFatBinary@PLT movq %rax, %rdi movq %rax, _ZL20__cudaFatCubinHandle(%rip) call __cudaRegisterFatBinaryEnd@PLT leaq _ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi call atexit@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE3695: .size _ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv .section .init_array,"aw" .align 8 .quad _ZL24__sti____cudaRegisterAllv .section .nvFatBinSegment,"aw" .align 8 .type _ZL15__fatDeviceText, @object .size _ZL15__fatDeviceText, 24 _ZL15__fatDeviceText: .long 1180844977 .long 1 .quad fatbinData .quad 0 .local _ZL20__cudaFatCubinHandle .comm _ZL20__cudaFatCubinHandle,8,8 .section .rodata.cst8,"aM",@progbits,8 .align 8 .LC3: .long 0 .long 1041235968 .align 8 .LC6: .long 0 .long 1062207488 .align 8 .LC21: .long 0 .long 1083129856 .hidden DW.ref.__gxx_personality_v0 .weak DW.ref.__gxx_personality_v0 .section .data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat .align 8 .type DW.ref.__gxx_personality_v0, @object .size DW.ref.__gxx_personality_v0, 8 DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0 .ident "GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4:
You are a helpful coding assistant specialized in converting CUDA source code to HIP/AMD source code.
#include<iostream> #include<string> #include<cuda.h> using namespace std; int main(){ struct cudaDeviceProp prop; cudaError_t err; err = cudaGetDeviceProperties(&prop,0); if(err!=cudaSuccess){ cout<<"Get failed. Exiting."<<endl; } else{ cout<<"Name : "<<string(prop.name)<<endl; cout<<"Total global memory : "<<prop.totalGlobalMem/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Shared memmory per block : "<<prop.sharedMemPerBlock/(1024.0)<<" KB"<<endl; cout<<"32 bit registers per block : "<<prop.regsPerBlock<<endl; cout<<"Warp size (in threads) : "<<prop.warpSize<<endl; cout<<"Max pitch allowed by mem copy : "<<prop.memPitch/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Max threads per block : "<<prop.maxThreadsPerBlock<<endl; cout<<"Max thread dimensions : "<<"("<<prop.maxThreadsDim[0]<<","<<prop.maxThreadsDim[1]<<","<<prop.maxThreadsDim[2]<<")"<<endl; cout<<"Max grid dimensions : "<<"("<<prop.maxGridSize[0]<<","<<prop.maxGridSize[1]<<","<<prop.maxGridSize[2]<<")"<<endl; cout<<"Max const memory : "<<prop.totalConstMem/1024.0<<" KB"<<endl; cout<<"Major compute capability : "<<prop.major<<endl; cout<<"Minor compute capability : "<<prop.minor<<endl; cout<<"Clock frequency : "<<prop.clockRate/1000.0<<" MHz"<<endl; cout<<"Alignment requirement for textures : "<<prop.textureAlignment<<endl; cout<<"Device can concurrently copy memory and execute a kernel : "<<(bool)prop.deviceOverlap<<endl; cout<<"Number of multiprocessors on device : "<<prop.multiProcessorCount<<endl; cout<<"Specified whether there is a run time limit on kernels : "<<(bool)prop.kernelExecTimeoutEnabled<<endl; cout<<"Integrated : "<<(bool)prop.integrated<<endl; cout<<"Can map host memory : "<<(bool)prop.canMapHostMemory<<endl; cout<<"Compute Mode : "<<prop.computeMode<<endl; cout<<"Concurrent kernels : "<<(bool)prop.concurrentKernels<<endl; cout<<"ECC support : "<<(bool)prop.ECCEnabled<<endl; cout<<"PCI bus id : "<<prop.pciBusID<<endl; cout<<"PCI device id : "<<prop.pciDeviceID<<endl; cout<<"TCC Driver : "<<(bool)prop.tccDriver<<endl; } return 0; }
#include<iostream> #include<string> #include<hip/hip_runtime.h> using namespace std; int main(){ struct hipDeviceProp_t prop; hipError_t err; err = hipGetDeviceProperties(&prop,0); if(err!=hipSuccess){ cout<<"Get failed. Exiting."<<endl; } else{ cout<<"Name : "<<string(prop.name)<<endl; cout<<"Total global memory : "<<prop.totalGlobalMem/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Shared memmory per block : "<<prop.sharedMemPerBlock/(1024.0)<<" KB"<<endl; cout<<"32 bit registers per block : "<<prop.regsPerBlock<<endl; cout<<"Warp size (in threads) : "<<prop.warpSize<<endl; cout<<"Max pitch allowed by mem copy : "<<prop.memPitch/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Max threads per block : "<<prop.maxThreadsPerBlock<<endl; cout<<"Max thread dimensions : "<<"("<<prop.maxThreadsDim[0]<<","<<prop.maxThreadsDim[1]<<","<<prop.maxThreadsDim[2]<<")"<<endl; cout<<"Max grid dimensions : "<<"("<<prop.maxGridSize[0]<<","<<prop.maxGridSize[1]<<","<<prop.maxGridSize[2]<<")"<<endl; cout<<"Max const memory : "<<prop.totalConstMem/1024.0<<" KB"<<endl; cout<<"Major compute capability : "<<prop.major<<endl; cout<<"Minor compute capability : "<<prop.minor<<endl; cout<<"Clock frequency : "<<prop.clockRate/1000.0<<" MHz"<<endl; cout<<"Alignment requirement for textures : "<<prop.textureAlignment<<endl; cout<<"Device can concurrently copy memory and execute a kernel : "<<(bool)prop.deviceOverlap<<endl; cout<<"Number of multiprocessors on device : "<<prop.multiProcessorCount<<endl; cout<<"Specified whether there is a run time limit on kernels : "<<(bool)prop.kernelExecTimeoutEnabled<<endl; cout<<"Integrated : "<<(bool)prop.integrated<<endl; cout<<"Can map host memory : "<<(bool)prop.canMapHostMemory<<endl; cout<<"Compute Mode : "<<prop.computeMode<<endl; cout<<"Concurrent kernels : "<<(bool)prop.concurrentKernels<<endl; cout<<"ECC support : "<<(bool)prop.ECCEnabled<<endl; cout<<"PCI bus id : "<<prop.pciBusID<<endl; cout<<"PCI device id : "<<prop.pciDeviceID<<endl; cout<<"TCC Driver : "<<(bool)prop.tccDriver<<endl; } return 0; }
You are a helpful coding assistant specialized in converting HIP source code to AMD device assembly.
#include<iostream> #include<string> #include<hip/hip_runtime.h> using namespace std; int main(){ struct hipDeviceProp_t prop; hipError_t err; err = hipGetDeviceProperties(&prop,0); if(err!=hipSuccess){ cout<<"Get failed. Exiting."<<endl; } else{ cout<<"Name : "<<string(prop.name)<<endl; cout<<"Total global memory : "<<prop.totalGlobalMem/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Shared memmory per block : "<<prop.sharedMemPerBlock/(1024.0)<<" KB"<<endl; cout<<"32 bit registers per block : "<<prop.regsPerBlock<<endl; cout<<"Warp size (in threads) : "<<prop.warpSize<<endl; cout<<"Max pitch allowed by mem copy : "<<prop.memPitch/(1024*1024*1024.0)<<" GB"<<endl; cout<<"Max threads per block : "<<prop.maxThreadsPerBlock<<endl; cout<<"Max thread dimensions : "<<"("<<prop.maxThreadsDim[0]<<","<<prop.maxThreadsDim[1]<<","<<prop.maxThreadsDim[2]<<")"<<endl; cout<<"Max grid dimensions : "<<"("<<prop.maxGridSize[0]<<","<<prop.maxGridSize[1]<<","<<prop.maxGridSize[2]<<")"<<endl; cout<<"Max const memory : "<<prop.totalConstMem/1024.0<<" KB"<<endl; cout<<"Major compute capability : "<<prop.major<<endl; cout<<"Minor compute capability : "<<prop.minor<<endl; cout<<"Clock frequency : "<<prop.clockRate/1000.0<<" MHz"<<endl; cout<<"Alignment requirement for textures : "<<prop.textureAlignment<<endl; cout<<"Device can concurrently copy memory and execute a kernel : "<<(bool)prop.deviceOverlap<<endl; cout<<"Number of multiprocessors on device : "<<prop.multiProcessorCount<<endl; cout<<"Specified whether there is a run time limit on kernels : "<<(bool)prop.kernelExecTimeoutEnabled<<endl; cout<<"Integrated : "<<(bool)prop.integrated<<endl; cout<<"Can map host memory : "<<(bool)prop.canMapHostMemory<<endl; cout<<"Compute Mode : "<<prop.computeMode<<endl; cout<<"Concurrent kernels : "<<(bool)prop.concurrentKernels<<endl; cout<<"ECC support : "<<(bool)prop.ECCEnabled<<endl; cout<<"PCI bus id : "<<prop.pciBusID<<endl; cout<<"PCI device id : "<<prop.pciDeviceID<<endl; cout<<"TCC Driver : "<<(bool)prop.tccDriver<<endl; } return 0; }
.text .p2alignl 7, 3214868480 .fill 96, 4, 3214868480 .type __hip_cuid_,@object .section .bss,"aw",@nobits .globl __hip_cuid_ __hip_cuid_: .byte 0 .size __hip_cuid_, 1 .ident "AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)" .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym __hip_cuid_ .amdgcn_target "amdgcn-amd-amdhsa--gfx1100" .amdgpu_metadata --- amdhsa.kernels: [] amdhsa.target: amdgcn-amd-amdhsa--gfx1100 amdhsa.version: - 1 - 2 ... .end_amdgpu_metadata