#include <iostream>
#include <cuda_runtime.h>
#include <vector>

// Define constants
#define GRID_SIZE 64
#define BLOCK_SIZE 16
#define NUM_GPUS 2

// Define a simple struct for cloth particle
struct Particle {
    float x, y, z;
    float vx, vy, vz;
};

// CUDA kernel for cloth simulation
__global__ void clothSimulationKernel(Particle* particles, int numParticles) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx >= numParticles) return;

    // Simple verlet integration for demonstration
    float dt = 0.01f;
    particles[idx].x += particles[idx].vx * dt;
    particles[idx].y += particles[idx].vy * dt;
    particles[idx].z += particles[idx].vz * dt;

    // Example of instruction-level parallelism: compute forces in parallel
    float fx = 0.0f, fy = -9.81f * 0.1f, fz = 0.0f; // Simple gravity force
    particles[idx].vx += fx * dt;
    particles[idx].vy += fy * dt;
    particles[idx].vz += fz * dt;
}

// Function to check CUDA errors
void checkCudaError(cudaError_t err, const char* msg) {
    if (err != cudaSuccess) {
        std::cerr << "CUDA error: " << msg << " (" << cudaGetErrorString(err) << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    // Number of particles per GPU
    int numParticlesPerGPU = GRID_SIZE * GRID_SIZE;

    // Allocate memory on host
    std::vector<Particle> h_particles(NUM_GPUS * numParticlesPerGPU);

    // Initialize particles
    for (int i = 0; i < NUM_GPUS * numParticlesPerGPU; ++i) {
        h_particles[i] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
    }

    // Allocate and initialize device memory for each GPU
    Particle* d_particles[NUM_GPUS];
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        cudaSetDevice(gpu);
        checkCudaError(cudaMalloc(&d_particles[gpu], numParticlesPerGPU * sizeof(Particle)), "Failed to allocate device memory");
        checkCudaError(cudaMemcpy(d_particles[gpu], h_particles.data() + gpu * numParticlesPerGPU, numParticlesPerGPU * sizeof(Particle), cudaMemcpyHostToDevice), "Failed to copy data to device");
    }

    // Launch kernel on each GPU
    dim3 threadsPerBlock(BLOCK_SIZE);
    dim3 blocksPerGrid(GRID_SIZE / BLOCK_SIZE);
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        cudaSetDevice(gpu);
        clothSimulationKernel<<<blocksPerGrid, threadsPerBlock>>>(d_particles[gpu], numParticlesPerGPU);
        checkCudaError(cudaGetLastError(), "Kernel launch failed");
        checkCudaError(cudaDeviceSynchronize(), "Failed to synchronize device");
    }

    // Copy results back to host
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        cudaSetDevice(gpu);
        checkCudaError(cudaMemcpy(h_particles.data() + gpu * numParticlesPerGPU, d_particles[gpu], numParticlesPerGPU * sizeof(Particle), cudaMemcpyDeviceToHost), "Failed to copy data from device");
    }

    // Free device memory
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        cudaSetDevice(gpu);
        checkCudaError(cudaFree(d_particles[gpu]), "Failed to free device memory");
    }

    // Output the first few particles to verify
    for (int i = 0; i < 5; ++i) {
        std::cout << "Particle " << i << ": (" << h_particles[i].x << ", " << h_particles[i].y << ", " << h_particles[i].z << ")" << std::endl;
    }

    return 0;
}
	.file	"tmpxft_000b018d_00000000-6_cuda_code_021014.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4002:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4002:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error: "
.LC1:
	.string	" ("
.LC2:
	.string	")"
	.text
	.globl	_Z14checkCudaError9cudaErrorPKc
	.type	_Z14checkCudaError9cudaErrorPKc, @function
_Z14checkCudaError9cudaErrorPKc:
.LFB3998:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE3998:
	.size	_Z14checkCudaError9cudaErrorPKc, .-_Z14checkCudaError9cudaErrorPKc
	.globl	_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei
	.type	_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei, @function
_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei:
.LFB4024:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z21clothSimulationKernelP8Particlei(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L8:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4024:
	.size	_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei, .-_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei
	.globl	_Z21clothSimulationKernelP8Particlei
	.type	_Z21clothSimulationKernelP8Particlei, @function
_Z21clothSimulationKernelP8Particlei:
.LFB4025:
	.cfi_startproc
	endbr64
	jmp	_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei
	.cfi_endproc
.LFE4025:
	.size	_Z21clothSimulationKernelP8Particlei, .-_Z21clothSimulationKernelP8Particlei
	.section	.rodata.str1.1
.LC3:
	.string	"_Z21clothSimulationKernelP8Particlei"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC3(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z21clothSimulationKernelP8Particlei(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4027:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorI8ParticleSaIS0_EED2Ev,"axG",@progbits,_ZNSt6vectorI8ParticleSaIS0_EED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorI8ParticleSaIS0_EED2Ev
	.type	_ZNSt6vectorI8ParticleSaIS0_EED2Ev, @function
_ZNSt6vectorI8ParticleSaIS0_EED2Ev:
.LFB4340:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L15
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L15:
	ret
	.cfi_endproc
.LFE4340:
	.size	_ZNSt6vectorI8ParticleSaIS0_EED2Ev, .-_ZNSt6vectorI8ParticleSaIS0_EED2Ev
	.weak	_ZNSt6vectorI8ParticleSaIS0_EED1Ev
	.set	_ZNSt6vectorI8ParticleSaIS0_EED1Ev,_ZNSt6vectorI8ParticleSaIS0_EED2Ev
	.section	.rodata.str1.1
.LC4:
	.string	"Failed to allocate device memory"
.LC5:
	.string	"Failed to copy data to device"
.LC6:
	.string	"Kernel launch failed"
.LC7:
	.string	"Failed to synchronize device"
.LC8:
	.string	"Failed to copy data from device"
.LC9:
	.string	"Failed to free device memory"
.LC10:
	.string	"Particle "
.LC11:
	.string	": ("
.LC12:
	.string	", "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3999:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3999
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$196608, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
.LEHB0:
	call	_Znwm@PLT
.LEHE0:
	movl	$6, %ecx
	leaq	196608(%rax), %rdx
	movq	%rax, %rbx
	movq	%rax, 32(%rsp)
	xorl	%eax, %eax
	movq	%rdx, 48(%rsp)
	movq	%rbx, %rdi
	rep stosl
	xorl	%eax, %eax
.L18:
	addq	$24, %rax
	cmpq	$196608, %rax
	je	.L34
	movups	(%rbx), %xmm1
	movups	%xmm1, (%rbx,%rax)
	movq	16(%rbx), %rcx
	movq	%rcx, 16(%rbx,%rax)
	jmp	.L18
.L34:
	movl	$49152, %ecx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	movq	%rdx, 40(%rsp)
	rep stosl
	xorl	%edi, %edi
.LEHB1:
	call	cudaSetDevice@PLT
	leaq	56(%rsp), %r13
	movl	$98304, %esi
	movq	%r13, %rdi
	call	cudaMalloc@PLT
	leaq	.LC4(%rip), %r12
	movl	%eax, %edi
	movq	%r12, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movl	$98304, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	leaq	.LC5(%rip), %rbp
	movl	%eax, %edi
	movq	%rbp, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$1, %edi
	call	cudaSetDevice@PLT
	leaq	64(%rsp), %rdi
	movl	$98304, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	movq	%r12, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	64(%rsp), %rdi
	movl	$1, %ecx
	movl	$98304, %edx
	leaq	98304(%rbx), %r12
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	movq	%rbp, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$268435457, %eax
	movl	$1, 16(%rsp)
	xorl	%ebp, %ebp
	leaq	.LC6(%rip), %r14
	salq	$4, %rax
	movl	$1, 28(%rsp)
	movq	%rax, 8(%rsp)
	subq	$12, %rax
	movq	%rax, 20(%rsp)
.L23:
	movl	%ebp, %edi
	call	cudaSetDevice@PLT
	movl	16(%rsp), %ecx
	movq	8(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	20(%rsp), %rdi
	movl	28(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L20
.L22:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	movq	%r14, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	jmp	.L35
.L20:
	movq	0(%r13,%rbp,8), %rdi
	movl	$4096, %esi
	call	_Z50__device_stub__Z21clothSimulationKernelP8ParticleiP8Particlei
	jmp	.L22
.L35:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	leaq	.LC7(%rip), %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	testq	%rbp, %rbp
	jne	.L36
	movl	$1, %ebp
	jmp	.L23
.L36:
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movl	$98304, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	leaq	.LC8(%rip), %rbp
	movl	%eax, %edi
	movq	%rbp, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$1, %edi
	call	cudaSetDevice@PLT
	movq	64(%rsp), %rsi
	movl	$2, %ecx
	movl	$98304, %edx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	movq	%rbp, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	leaq	.LC9(%rip), %rbp
	movl	%eax, %edi
	movq	%rbp, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$1, %edi
	call	cudaSetDevice@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	movq	%rbp, %rsi
	call	_Z14checkCudaError9cudaErrorPKc
	xorl	%ebp, %ebp
	leaq	.LC10(%rip), %r12
.L24:
	movq	%r12, %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	%ebp, %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC11(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	cvtss2sd	(%rbx), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC12(%rip), %r13
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	cvtss2sd	4(%rbx), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movq	%r13, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	cvtss2sd	8(%rbx), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	leaq	.LC2(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.LEHE1:
	incl	%ebp
	addq	$24, %rbx
	cmpl	$5, %ebp
	jne	.L24
	leaq	32(%rsp), %rdi
	call	_ZNSt6vectorI8ParticleSaIS0_EED1Ev
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	jmp	.L32
.L29:
	endbr64
	movq	%rax, %rbx
.L25:
	leaq	32(%rsp), %rdi
	call	_ZNSt6vectorI8ParticleSaIS0_EED1Ev
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L32:
	call	__stack_chk_fail@PLT
.L27:
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
	.cfi_endproc
.LFE3999:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3999:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3999-.LLSDACSB3999
.LLSDACSB3999:
	.uleb128 .LEHB0-.LFB3999
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3999
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L29-.LFB3999
	.uleb128 0
	.uleb128 .LEHB2-.LFB3999
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3999:
	.section	.text.startup
	.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:

#include <iostream>
#include <hip/hip_runtime.h>
#include <vector>

// Define constants
#define GRID_SIZE 64
#define BLOCK_SIZE 16
#define NUM_GPUS 2

// Define a simple struct for cloth particle
struct Particle {
    float x, y, z;
    float vx, vy, vz;
};

// CUDA kernel for cloth simulation
__global__ void clothSimulationKernel(Particle* particles, int numParticles) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx >= numParticles) return;

    // Simple verlet integration for demonstration
    float dt = 0.01f;
    particles[idx].x += particles[idx].vx * dt;
    particles[idx].y += particles[idx].vy * dt;
    particles[idx].z += particles[idx].vz * dt;

    // Example of instruction-level parallelism: compute forces in parallel
    float fx = 0.0f, fy = -9.81f * 0.1f, fz = 0.0f; // Simple gravity force
    particles[idx].vx += fx * dt;
    particles[idx].vy += fy * dt;
    particles[idx].vz += fz * dt;
}

// Function to check CUDA errors
void checkCudaError(hipError_t err, const char* msg) {
    if (err != hipSuccess) {
        std::cerr << "CUDA error: " << msg << " (" << hipGetErrorString(err) << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    // Number of particles per GPU
    int numParticlesPerGPU = GRID_SIZE * GRID_SIZE;

    // Allocate memory on host
    std::vector<Particle> h_particles(NUM_GPUS * numParticlesPerGPU);

    // Initialize particles
    for (int i = 0; i < NUM_GPUS * numParticlesPerGPU; ++i) {
        h_particles[i] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
    }

    // Allocate and initialize device memory for each GPU
    Particle* d_particles[NUM_GPUS];
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        hipSetDevice(gpu);
        checkCudaError(hipMalloc(&d_particles[gpu], numParticlesPerGPU * sizeof(Particle)), "Failed to allocate device memory");
        checkCudaError(hipMemcpy(d_particles[gpu], h_particles.data() + gpu * numParticlesPerGPU, numParticlesPerGPU * sizeof(Particle), hipMemcpyHostToDevice), "Failed to copy data to device");
    }

    // Launch kernel on each GPU
    dim3 threadsPerBlock(BLOCK_SIZE);
    dim3 blocksPerGrid(GRID_SIZE / BLOCK_SIZE);
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        hipSetDevice(gpu);
        clothSimulationKernel<<<blocksPerGrid, threadsPerBlock>>>(d_particles[gpu], numParticlesPerGPU);
        checkCudaError(hipGetLastError(), "Kernel launch failed");
        checkCudaError(hipDeviceSynchronize(), "Failed to synchronize device");
    }

    // Copy results back to host
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        hipSetDevice(gpu);
        checkCudaError(hipMemcpy(h_particles.data() + gpu * numParticlesPerGPU, d_particles[gpu], numParticlesPerGPU * sizeof(Particle), hipMemcpyDeviceToHost), "Failed to copy data from device");
    }

    // Free device memory
    for (int gpu = 0; gpu < NUM_GPUS; ++gpu) {
        hipSetDevice(gpu);
        checkCudaError(hipFree(d_particles[gpu]), "Failed to free device memory");
    }

    // Output the first few particles to verify
    for (int i = 0; i < 5; ++i) {
        std::cout << "Particle " << i << ": (" << h_particles[i].x << ", " << h_particles[i].y << ", " << h_particles[i].z << ")" << std::endl;
    }

    return 0;
}
	.text
	.file	"cuda_code_021014.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z36__device_stub__clothSimulationKernelP8Particlei # -- Begin function _Z36__device_stub__clothSimulationKernelP8Particlei
	.type	_Z36__device_stub__clothSimulationKernelP8Particlei,@function
_Z36__device_stub__clothSimulationKernelP8Particlei: # @_Z36__device_stub__clothSimulationKernelP8Particlei
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z21clothSimulationKernelP8Particlei, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.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
	retq
.Lfunc_end0:
	.size	_Z36__device_stub__clothSimulationKernelP8Particlei, .Lfunc_end0-_Z36__device_stub__clothSimulationKernelP8Particlei
	.cfi_endproc
                                        # -- End function
	.globl	_Z14checkCudaError10hipError_tPKc # -- Begin function _Z14checkCudaError10hipError_tPKc
	.type	_Z14checkCudaError10hipError_tPKc,@function
_Z14checkCudaError10hipError_tPKc:      # @_Z14checkCudaError10hipError_tPKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB1_2
# %bb.1:
	retq
.LBB1_2:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %r14
	movl	%edi, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.1, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z14checkCudaError10hipError_tPKc, .Lfunc_end1-_Z14checkCudaError10hipError_tPKc
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:                                # %.noexc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$196608, %edi                   # imm = 0x30000
	callq	_Znwm
	movq	%rax, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movq	$0, 16(%rax)
	movl	$24, %eax
.LBB2_1:                                # %.lr.ph.i.i.i.i.i.i.i.i.i
                                        # =>This Inner Loop Header: Depth=1
	movq	16(%rbx), %rcx
	movq	%rcx, 16(%rbx,%rax)
	movups	(%rbx), %xmm0
	movups	%xmm0, (%rbx,%rax)
	addq	$24, %rax
	cmpq	$196608, %rax                   # imm = 0x30000
	jne	.LBB2_1
# %bb.2:                                # %_ZNSt6vectorI8ParticleSaIS0_EEC2EmRKS1_.exit.preheader
	xorl	%eax, %eax
	xorps	%xmm0, %xmm0
.LBB2_3:                                # %_ZNSt6vectorI8ParticleSaIS0_EEC2EmRKS1_.exit
                                        # =>This Inner Loop Header: Depth=1
	movups	%xmm0, (%rbx,%rax)
	movq	$0, 16(%rbx,%rax)
	addq	$24, %rax
	cmpq	$196608, %rax                   # imm = 0x30000
	jne	.LBB2_3
# %bb.4:
	movb	$1, %bpl
	xorl	%r14d, %r14d
.LBB2_5:                                # =>This Inner Loop Header: Depth=1
.Ltmp0:
	movl	%r14d, %edi
	callq	hipSetDevice
.Ltmp1:
# %bb.6:                                #   in Loop: Header=BB2_5 Depth=1
	leaq	(%rsp,%r14,8), %rdi
.Ltmp2:
	movl	$98304, %esi                    # imm = 0x18000
	callq	hipMalloc
.Ltmp3:
# %bb.7:                                # %_ZL9hipMallocI8ParticleE10hipError_tPPT_m.exit
                                        #   in Loop: Header=BB2_5 Depth=1
.Ltmp4:
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp5:
# %bb.8:                                #   in Loop: Header=BB2_5 Depth=1
	movq	(%rsp,%r14,8), %rdi
	leaq	(%r14,%r14,2), %rsi
	shlq	$15, %rsi
	addq	%rbx, %rsi
.Ltmp6:
	movl	$98304, %edx                    # imm = 0x18000
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp7:
# %bb.9:                                #   in Loop: Header=BB2_5 Depth=1
.Ltmp8:
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp9:
# %bb.10:                               #   in Loop: Header=BB2_5 Depth=1
	movl	$1, %r14d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB2_5
# %bb.11:                               # %.preheader93.preheader
	movb	$1, %bpl
	xorl	%r12d, %r12d
	movabsq	$4294967300, %r14               # imm = 0x100000004
	movabsq	$4294967312, %r15               # imm = 0x100000010
.LBB2_12:                               # %.preheader93
                                        # =>This Inner Loop Header: Depth=1
.Ltmp11:
	movl	%r12d, %edi
	callq	hipSetDevice
.Ltmp12:
# %bb.13:                               #   in Loop: Header=BB2_12 Depth=1
.Ltmp13:
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp14:
# %bb.14:                               #   in Loop: Header=BB2_12 Depth=1
	testl	%eax, %eax
	jne	.LBB2_16
# %bb.15:                               #   in Loop: Header=BB2_12 Depth=1
	movq	(%rsp,%r12,8), %rdi
.Ltmp15:
	movl	$4096, %esi                     # imm = 0x1000
	callq	_Z36__device_stub__clothSimulationKernelP8Particlei
.Ltmp16:
.LBB2_16:                               #   in Loop: Header=BB2_12 Depth=1
.Ltmp17:
	callq	hipGetLastError
.Ltmp18:
# %bb.17:                               #   in Loop: Header=BB2_12 Depth=1
.Ltmp19:
	movl	$.L.str.5, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp20:
# %bb.18:                               #   in Loop: Header=BB2_12 Depth=1
.Ltmp21:
	callq	hipDeviceSynchronize
.Ltmp22:
# %bb.19:                               #   in Loop: Header=BB2_12 Depth=1
.Ltmp23:
	movl	$.L.str.6, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp24:
# %bb.20:                               #   in Loop: Header=BB2_12 Depth=1
	movl	$1, %r12d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB2_12
# %bb.21:                               # %.preheader92.preheader
	movb	$1, %bpl
	xorl	%r14d, %r14d
.LBB2_22:                               # %.preheader92
                                        # =>This Inner Loop Header: Depth=1
.Ltmp26:
	movl	%r14d, %edi
	callq	hipSetDevice
.Ltmp27:
# %bb.23:                               #   in Loop: Header=BB2_22 Depth=1
	leaq	(%r14,%r14,2), %rdi
	shlq	$15, %rdi
	addq	%rbx, %rdi
	movq	(%rsp,%r14,8), %rsi
.Ltmp28:
	movl	$98304, %edx                    # imm = 0x18000
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp29:
# %bb.24:                               #   in Loop: Header=BB2_22 Depth=1
.Ltmp30:
	movl	$.L.str.7, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp31:
# %bb.25:                               #   in Loop: Header=BB2_22 Depth=1
	movl	$1, %r14d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB2_22
# %bb.26:                               # %.preheader91.preheader
	movb	$1, %bpl
	xorl	%r14d, %r14d
.LBB2_27:                               # %.preheader91
                                        # =>This Inner Loop Header: Depth=1
.Ltmp33:
	movl	%r14d, %edi
	callq	hipSetDevice
.Ltmp34:
# %bb.28:                               #   in Loop: Header=BB2_27 Depth=1
	movq	(%rsp,%r14,8), %rdi
.Ltmp35:
	callq	hipFree
.Ltmp36:
# %bb.29:                               #   in Loop: Header=BB2_27 Depth=1
.Ltmp37:
	movl	$.L.str.8, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.Ltmp38:
# %bb.30:                               #   in Loop: Header=BB2_27 Depth=1
	movl	$1, %r14d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB2_27
# %bb.31:                               # %.preheader.preheader
	movq	%rbx, %r12
	addq	$8, %r12
	xorl	%r14d, %r14d
.LBB2_32:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
.Ltmp40:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.9, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp41:
# %bb.33:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   in Loop: Header=BB2_32 Depth=1
.Ltmp42:
	movl	$_ZSt4cout, %edi
	movl	%r14d, %esi
	callq	_ZNSolsEi
.Ltmp43:
# %bb.34:                               #   in Loop: Header=BB2_32 Depth=1
.Ltmp44:
	movq	%rax, %r15
	movl	$.L.str.10, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp45:
# %bb.35:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit60
                                        #   in Loop: Header=BB2_32 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	-8(%r12), %xmm0
.Ltmp46:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp47:
# %bb.36:                               # %_ZNSolsEf.exit
                                        #   in Loop: Header=BB2_32 Depth=1
.Ltmp48:
	movq	%rax, %r15
	movl	$.L.str.11, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp49:
# %bb.37:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit63
                                        #   in Loop: Header=BB2_32 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%r12), %xmm0
.Ltmp50:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp51:
# %bb.38:                               # %_ZNSolsEf.exit65
                                        #   in Loop: Header=BB2_32 Depth=1
.Ltmp52:
	movq	%rax, %r15
	movl	$.L.str.11, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp53:
# %bb.39:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit67
                                        #   in Loop: Header=BB2_32 Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12), %xmm0
.Ltmp54:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp55:
# %bb.40:                               # %_ZNSolsEf.exit69
                                        #   in Loop: Header=BB2_32 Depth=1
.Ltmp56:
	movq	%rax, %r15
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp57:
# %bb.41:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit71
                                        #   in Loop: Header=BB2_32 Depth=1
	movq	(%r15), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
.Ltmp58:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp59:
# %bb.42:                               # %.noexc76
                                        #   in Loop: Header=BB2_32 Depth=1
.Ltmp60:
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
.Ltmp61:
# %bb.43:                               # %.noexc77
                                        #   in Loop: Header=BB2_32 Depth=1
.Ltmp62:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp63:
# %bb.44:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB2_32 Depth=1
	incq	%r14
	addq	$24, %r12
	cmpq	$5, %r14
	jne	.LBB2_32
# %bb.45:                               # %_ZNSt6vectorI8ParticleSaIS0_EED2Ev.exit
	movq	%rbx, %rdi
	callq	_ZdlPv
	xorl	%eax, %eax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_46:
	.cfi_def_cfa_offset 64
.Ltmp39:
	jmp	.LBB2_48
.LBB2_51:
.Ltmp32:
	jmp	.LBB2_48
.LBB2_49:
.Ltmp10:
	jmp	.LBB2_48
.LBB2_50:
.Ltmp25:
	jmp	.LBB2_48
.LBB2_47:
.Ltmp64:
.LBB2_48:                               # %_ZNSt6vectorI8ParticleSaIS0_EED2Ev.exit74
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.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 .Ltmp24-.Ltmp11                #   Call between .Ltmp11 and .Ltmp24
	.uleb128 .Ltmp25-.Lfunc_begin0          #     jumps to .Ltmp25
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp26-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp31-.Ltmp26                #   Call between .Ltmp26 and .Ltmp31
	.uleb128 .Ltmp32-.Lfunc_begin0          #     jumps to .Ltmp32
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp33-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp38-.Ltmp33                #   Call between .Ltmp33 and .Ltmp38
	.uleb128 .Ltmp39-.Lfunc_begin0          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp40-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp63-.Ltmp40                #   Call between .Ltmp40 and .Ltmp63
	.uleb128 .Ltmp64-.Lfunc_begin0          #     jumps to .Ltmp64
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp63-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Lfunc_end2-.Ltmp63            #   Call between .Ltmp63 and .Lfunc_end2
	.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
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z21clothSimulationKernelP8Particlei, %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	_Z21clothSimulationKernelP8Particlei,@object # @_Z21clothSimulationKernelP8Particlei
	.section	.rodata,"a",@progbits
	.globl	_Z21clothSimulationKernelP8Particlei
	.p2align	3, 0x0
_Z21clothSimulationKernelP8Particlei:
	.quad	_Z36__device_stub__clothSimulationKernelP8Particlei
	.size	_Z21clothSimulationKernelP8Particlei, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA error: "
	.size	.L.str, 13

	.type	.L.str.1,@object                # @.str.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	"Failed to allocate device memory"
	.size	.L.str.3, 33

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Failed to copy data to device"
	.size	.L.str.4, 30

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Kernel launch failed"
	.size	.L.str.5, 21

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Failed to synchronize device"
	.size	.L.str.6, 29

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Failed to copy data from device"
	.size	.L.str.7, 32

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Failed to free device memory"
	.size	.L.str.8, 29

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Particle "
	.size	.L.str.9, 10

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	": ("
	.size	.L.str.10, 4

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	", "
	.size	.L.str.11, 3

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z21clothSimulationKernelP8Particlei"
	.size	.L__unnamed_1, 37

	.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

	.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__clothSimulationKernelP8Particlei
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z21clothSimulationKernelP8Particlei
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z21clothSimulationKernelP8Particlei ; -- Begin function _Z21clothSimulationKernelP8Particlei
	.globl	_Z21clothSimulationKernelP8Particlei
	.p2align	8
	.type	_Z21clothSimulationKernelP8Particlei,@function
_Z21clothSimulationKernelP8Particlei:   ; @_Z21clothSimulationKernelP8Particlei
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b32 s3, s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	v_mad_i64_i32 v[4:5], null, v1, 24, s[0:1]
	s_clause 0x1
	global_load_b128 v[0:3], v[4:5], off
	global_load_b64 v[6:7], v[4:5], off offset:16
	s_waitcnt vmcnt(0)
	v_dual_fmamk_f32 v0, v3, 0x3c23d70a, v0 :: v_dual_fmamk_f32 v1, v6, 0x3c23d70a, v1
	v_dual_fmamk_f32 v2, v7, 0x3c23d70a, v2 :: v_dual_add_f32 v3, 0, v3
	v_dual_add_f32 v6, 0xbc20ba20, v6 :: v_dual_add_f32 v7, 0, v7
	s_clause 0x1
	global_store_b128 v[4:5], v[0:3], off
	global_store_b64 v[4:5], v[6:7], off offset:16
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21clothSimulationKernelP8Particlei
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.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	_Z21clothSimulationKernelP8Particlei, .Lfunc_end0-_Z21clothSimulationKernelP8Particlei
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 172
; NumSgprs: 16
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z21clothSimulationKernelP8Particlei
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z21clothSimulationKernelP8Particlei.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
