
#include <cstdio>
#include <cmath>

#define BLOCKDIM 1024

// device kernel def
__global__ void Action_noImage_center_GPU(double *D_,double *maskCenter,double *SolventMols_,double maxD, int Nmols , int NAtoms, int active_size);
__global__ void Action_noImage_no_center_GPU(double *D_,double *SolventMols_,double *Solute_atoms ,double maxD, int Nmols , int NAtoms,int NSAtoms , int active_size);

////////////////////////





void Action_NoImage_Center(double *SolventMols_,double *D_, double maskCenter[3],double maxD,int  NMols, int NAtoms, float &time_gpu)
{


  cudaEvent_t start_event, stop_event;
  float elapsed_time_gpu;

  double *devI2Ptr;
  double *devI1Ptr;
  double *devO1Ptr;
  int t4;
  int t2;
  double Dist;
  int solventMol;
  int solventAtom;



  cudaMalloc(((void **)(&devO1Ptr)),NMols * sizeof(double ));
  cudaMalloc(((void **)(&devI1Ptr)),3 * sizeof(double ));
  cudaMemcpy(devI1Ptr,maskCenter,3 * sizeof(double ),cudaMemcpyHostToDevice);
  cudaMalloc(((void **)(&devI2Ptr)),NMols * NAtoms * 3 * sizeof(double ));
  cudaMemcpy(devI2Ptr,SolventMols_,NMols * NAtoms * 3 * sizeof(double ),cudaMemcpyHostToDevice);



  //figue out the decomposition here
  //we need to pad as well

  //figure out how many active thread in a block
  int active_size  =  BLOCKDIM/NAtoms * NAtoms;
  int NBlocks =  ceil(NMols * NAtoms / float(active_size));
  // printf("Nmols = %d; Natoms = %d\n", NMols, NAtoms);
  // printf("active_size =  %d\n", active_size);
  // printf("NBlocks =  %d\n", NBlocks);
  //printf("sezeof(double) = %d\n", sizeof(double));
  //exit(0);



  dim3 dimGrid0 = dim3(NBlocks,1);
  dim3 dimBlock0 = dim3(BLOCKDIM,1);


  printf("NMols =  %d, NAtoms = %d\n", NMols, NAtoms); 
  printf("About to launch kernel.\n");


  cudaEventCreate(&start_event);
  cudaEventCreate(&stop_event);
  cudaEventRecord(start_event, 0);

  Action_noImage_center_GPU<<<dimGrid0,dimBlock0>>>(devO1Ptr,devI1Ptr, devI2Ptr, maxD, NMols, NAtoms,active_size);
  
  cudaThreadSynchronize();
  cudaEventRecord(stop_event, 0);
  cudaEventSynchronize(stop_event);
  cudaEventElapsedTime(&elapsed_time_gpu,start_event, stop_event );


  printf("Done with kernel CUDA Kernel Time: %.2f\n", elapsed_time_gpu);

  time_gpu  = elapsed_time_gpu;
  
  cudaMemcpy(D_,devO1Ptr,NMols * sizeof(double ),cudaMemcpyDeviceToHost);
  cudaFree(devO1Ptr);
  cudaFree(devI1Ptr);
  cudaFree(devI2Ptr);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Action_NoImage_no_Center(double *SolventMols_,double *D_, double *Solute_atoms,double maxD,int  NMols, int NAtoms,int NSAtoms, float &time_gpu)
{


  cudaEvent_t start_event, stop_event;
  float elapsed_time_gpu;

  double *devI3Ptr;
  double *devI2Ptr;
  double *devI1Ptr;
  double *devO1Ptr;
  int t4;
  int t2;
  double Dist;
  int solventMol;
  int solventAtom;



  cudaMalloc(((void **)(&devO1Ptr)),NMols * sizeof(double ));

  //cudaMalloc(((void **)(&devI1Ptr)),3 * sizeof(double ));
  //cudaMemcpy(devI1Ptr,maskCenter,3 * sizeof(double ),cudaMemcpyHostToDevice);
  cudaMalloc(((void **)(&devI2Ptr)),NMols * NAtoms * 3 * sizeof(double ));
  cudaMemcpy(devI2Ptr,SolventMols_,NMols * NAtoms * 3 * sizeof(double ),cudaMemcpyHostToDevice);
  
  cudaMalloc(((void **)(&devI3Ptr)), NSAtoms * 3 * sizeof(double ));
  cudaMemcpy(devI3Ptr,Solute_atoms,NSAtoms * 3 * sizeof(double ),cudaMemcpyHostToDevice);



  //figue out the decomposition here
  //we need to pad as well

  //figure out how many active thread in a block
  int active_size  =  BLOCKDIM/NAtoms * NAtoms;
  int NBlocks =  ceil(NMols * NAtoms / float(active_size));
  // printf("Nmols = %d; Natoms = %d\n", NMols, NAtoms);
  // printf("active_size =  %d\n", active_size);
  // printf("NBlocks =  %d\n", NBlocks);
  //printf("sezeof(double) = %d\n", sizeof(double));
  //exit(0);



  dim3 dimGrid0 = dim3(NBlocks,1);
  dim3 dimBlock0 = dim3(BLOCKDIM,1);


  printf("NMols =  %d, NAtoms = %d\n", NMols, NAtoms); 
  printf("About to launch kernel.\n");


  cudaEventCreate(&start_event);
  cudaEventCreate(&stop_event);
  cudaEventRecord(start_event, 0);

  Action_noImage_no_center_GPU<<<dimGrid0,dimBlock0>>>(devO1Ptr, devI2Ptr,devI3Ptr, maxD, NMols, NAtoms,NSAtoms,active_size);
  
  cudaThreadSynchronize();
  cudaEventRecord(stop_event, 0);
  cudaEventSynchronize(stop_event);
  cudaEventElapsedTime(&elapsed_time_gpu,start_event, stop_event );


  printf("Done with kernel CUDA Kernel Time: %.2f\n", elapsed_time_gpu);

  time_gpu  = elapsed_time_gpu;
  
  cudaMemcpy(D_,devO1Ptr,NMols * sizeof(double ),cudaMemcpyDeviceToHost);
  cudaFree(devO1Ptr);
  cudaFree(devI1Ptr);
  cudaFree(devI2Ptr);
  cudaFree(devI3Ptr);
}
	.file	"tmpxft_002f73d3_00000000-6_kernel_wrappers.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"NMols =  %d, NAtoms = %d\n"
.LC1:
	.string	"About to launch kernel.\n"
.LC2:
	.string	"Done with kernel CUDA Kernel Time: %.2f\n"
	.text
	.globl	_Z21Action_NoImage_CenterPdS_S_diiRf
	.type	_Z21Action_NoImage_CenterPdS_S_diiRf, @function
_Z21Action_NoImage_CenterPdS_S_diiRf:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r9, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ebp, %r12d
	movl	%r8d, %ebx
	imull	%ebx, %r12d
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%rsi, 16(%rsp)
	leaq	72(%rsp), %rdi
	movsd	%xmm0, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	movslq	%ecx, %rax
	salq	$3, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movl	$24, %esi
	call	cudaMalloc@PLT
	movq	%r15, %rsi
	leal	(%r12,%r12,2), %r15d
	movq	64(%rsp), %rdi
	movslq	%r15d, %r15
	movl	$1, %ecx
	movl	$24, %edx
	call	cudaMemcpy@PLT
	salq	$3, %r15
	leaq	56(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	movq	56(%rsp), %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$1024, %eax
	cvtsi2ssl	%r12d, %xmm0
	cltd
	idivl	%ebx
	imull	%ebx, %eax
	cvtsi2ssl	%eax, %xmm1
	movl	%eax, %r14d
	divss	%xmm1, %xmm0
	call	ceilf@PLT
	movl	%ebx, %ecx
	movl	%ebp, %edx
	leaq	.LC0(%rip), %rsi
	cvttss2sil	%xmm0, %eax
	movl	$2, %edi
	movl	$1, 100(%rsp)
	movl	%eax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 84(%rsp)
	addq	$1023, %rax
	movq	%rax, 92(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	100(%rsp), %ecx
	movl	88(%rsp), %esi
	xorl	%r9d, %r9d
	movq	92(%rsp), %rdx
	movq	80(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L3
	movsd	24(%rsp), %xmm0
	movq	56(%rsp), %rdx
	movl	%r14d, %r9d
	movl	%ebp, %ecx
	movq	64(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	%ebx, %r8d
	call	_Z25Action_noImage_center_GPUPdS_S_diii@PLT
.L3:
	call	cudaThreadSynchronize@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	48(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	leaq	36(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	36(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	8(%rsp), %rdx
	movss	36(%rsp), %xmm0
	movq	72(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	$2, %ecx
	movss	%xmm0, 0(%r13)
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$120, %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
.LFE2027:
	.size	_Z21Action_NoImage_CenterPdS_S_diiRf, .-_Z21Action_NoImage_CenterPdS_S_diiRf
	.globl	_Z24Action_NoImage_no_CenterPdS_S_diiiRf
	.type	_Z24Action_NoImage_no_CenterPdS_S_diiiRf, @function
_Z24Action_NoImage_no_CenterPdS_S_diiiRf:
.LFB2028:
	.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
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ebp, %r12d
	movl	%r8d, %ebx
	imull	%ebx, %r12d
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movl	%r9d, 20(%rsp)
	leaq	88(%rsp), %rdi
	movq	192(%rsp), %r15
	movq	%rsi, 24(%rsp)
	movsd	%xmm0, 32(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	movslq	%ecx, %rax
	salq	$3, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	leal	(%r12,%r12,2), %edx
	leaq	80(%rsp), %rdi
	movslq	%edx, %rdx
	salq	$3, %rdx
	movq	%rdx, %rsi
	movq	%rdx, 40(%rsp)
	call	cudaMalloc@PLT
	movq	40(%rsp), %rdx
	movq	80(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	imull	$3, 20(%rsp), %r14d
	leaq	72(%rsp), %rdi
	movslq	%r14d, %r14
	salq	$3, %r14
	movq	%r14, %rsi
	call	cudaMalloc@PLT
	movq	72(%rsp), %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$1024, %eax
	cvtsi2ssl	%r12d, %xmm0
	cltd
	idivl	%ebx
	imull	%ebx, %eax
	cvtsi2ssl	%eax, %xmm1
	movl	%eax, %r13d
	divss	%xmm1, %xmm0
	call	ceilf@PLT
	movl	%ebx, %ecx
	movl	%ebp, %edx
	leaq	.LC0(%rip), %rsi
	cvttss2sil	%xmm0, %eax
	movl	$2, %edi
	movl	$1, 116(%rsp)
	movl	%eax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 100(%rsp)
	addq	$1023, %rax
	movq	%rax, 108(%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	116(%rsp), %ecx
	movl	104(%rsp), %esi
	xorl	%r9d, %r9d
	movq	108(%rsp), %rdx
	movq	96(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	%rax
	.cfi_def_cfa_offset 200
	movl	%ebp, %ecx
	movl	%ebx, %r8d
	pushq	%r13
	.cfi_def_cfa_offset 208
	movl	36(%rsp), %r9d
	movsd	48(%rsp), %xmm0
	movq	88(%rsp), %rdx
	movq	96(%rsp), %rsi
	movq	104(%rsp), %rdi
	call	_Z28Action_noImage_no_center_GPUPdS_S_diiii@PLT
	popq	%rdx
	.cfi_def_cfa_offset 200
	popq	%rcx
	.cfi_def_cfa_offset 192
.L8:
	call	cudaThreadSynchronize@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	64(%rsp), %rdx
	movq	56(%rsp), %rsi
	leaq	52(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	52(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	8(%rsp), %rdx
	movss	52(%rsp), %xmm0
	movq	88(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	$2, %ecx
	movss	%xmm0, (%r15)
	call	cudaMemcpy@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	xorl	%edi, %edi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	addq	$136, %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
.LFE2028:
	.size	_Z24Action_NoImage_no_CenterPdS_S_diiiRf, .-_Z24Action_NoImage_no_CenterPdS_S_diiiRf
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2054:
	.cfi_startproc
	endbr64
	pushq	%rax
	.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
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.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:



#include <hip/hip_runtime.h>
#include <cstdio>
#include <cmath>

#define BLOCKDIM 1024

// device kernel def
__global__ void Action_noImage_center_GPU(double *D_,double *maskCenter,double *SolventMols_,double maxD, int Nmols , int NAtoms, int active_size);
__global__ void Action_noImage_no_center_GPU(double *D_,double *SolventMols_,double *Solute_atoms ,double maxD, int Nmols , int NAtoms,int NSAtoms , int active_size);

////////////////////////





void Action_NoImage_Center(double *SolventMols_,double *D_, double maskCenter[3],double maxD,int  NMols, int NAtoms, float &time_gpu)
{


  hipEvent_t start_event, stop_event;
  float elapsed_time_gpu;

  double *devI2Ptr;
  double *devI1Ptr;
  double *devO1Ptr;
  int t4;
  int t2;
  double Dist;
  int solventMol;
  int solventAtom;



  hipMalloc(((void **)(&devO1Ptr)),NMols * sizeof(double ));
  hipMalloc(((void **)(&devI1Ptr)),3 * sizeof(double ));
  hipMemcpy(devI1Ptr,maskCenter,3 * sizeof(double ),hipMemcpyHostToDevice);
  hipMalloc(((void **)(&devI2Ptr)),NMols * NAtoms * 3 * sizeof(double ));
  hipMemcpy(devI2Ptr,SolventMols_,NMols * NAtoms * 3 * sizeof(double ),hipMemcpyHostToDevice);



  //figue out the decomposition here
  //we need to pad as well

  //figure out how many active thread in a block
  int active_size  =  BLOCKDIM/NAtoms * NAtoms;
  int NBlocks =  ceil(NMols * NAtoms / float(active_size));
  // printf("Nmols = %d; Natoms = %d\n", NMols, NAtoms);
  // printf("active_size =  %d\n", active_size);
  // printf("NBlocks =  %d\n", NBlocks);
  //printf("sezeof(double) = %d\n", sizeof(double));
  //exit(0);



  dim3 dimGrid0 = dim3(NBlocks,1);
  dim3 dimBlock0 = dim3(BLOCKDIM,1);


  printf("NMols =  %d, NAtoms = %d\n", NMols, NAtoms); 
  printf("About to launch kernel.\n");


  hipEventCreate(&start_event);
  hipEventCreate(&stop_event);
  hipEventRecord(start_event, 0);

  Action_noImage_center_GPU<<<dimGrid0,dimBlock0>>>(devO1Ptr,devI1Ptr, devI2Ptr, maxD, NMols, NAtoms,active_size);
  
  hipDeviceSynchronize();
  hipEventRecord(stop_event, 0);
  hipEventSynchronize(stop_event);
  hipEventElapsedTime(&elapsed_time_gpu,start_event, stop_event );


  printf("Done with kernel CUDA Kernel Time: %.2f\n", elapsed_time_gpu);

  time_gpu  = elapsed_time_gpu;
  
  hipMemcpy(D_,devO1Ptr,NMols * sizeof(double ),hipMemcpyDeviceToHost);
  hipFree(devO1Ptr);
  hipFree(devI1Ptr);
  hipFree(devI2Ptr);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Action_NoImage_no_Center(double *SolventMols_,double *D_, double *Solute_atoms,double maxD,int  NMols, int NAtoms,int NSAtoms, float &time_gpu)
{


  hipEvent_t start_event, stop_event;
  float elapsed_time_gpu;

  double *devI3Ptr;
  double *devI2Ptr;
  double *devI1Ptr;
  double *devO1Ptr;
  int t4;
  int t2;
  double Dist;
  int solventMol;
  int solventAtom;



  hipMalloc(((void **)(&devO1Ptr)),NMols * sizeof(double ));

  //cudaMalloc(((void **)(&devI1Ptr)),3 * sizeof(double ));
  //cudaMemcpy(devI1Ptr,maskCenter,3 * sizeof(double ),cudaMemcpyHostToDevice);
  hipMalloc(((void **)(&devI2Ptr)),NMols * NAtoms * 3 * sizeof(double ));
  hipMemcpy(devI2Ptr,SolventMols_,NMols * NAtoms * 3 * sizeof(double ),hipMemcpyHostToDevice);
  
  hipMalloc(((void **)(&devI3Ptr)), NSAtoms * 3 * sizeof(double ));
  hipMemcpy(devI3Ptr,Solute_atoms,NSAtoms * 3 * sizeof(double ),hipMemcpyHostToDevice);



  //figue out the decomposition here
  //we need to pad as well

  //figure out how many active thread in a block
  int active_size  =  BLOCKDIM/NAtoms * NAtoms;
  int NBlocks =  ceil(NMols * NAtoms / float(active_size));
  // printf("Nmols = %d; Natoms = %d\n", NMols, NAtoms);
  // printf("active_size =  %d\n", active_size);
  // printf("NBlocks =  %d\n", NBlocks);
  //printf("sezeof(double) = %d\n", sizeof(double));
  //exit(0);



  dim3 dimGrid0 = dim3(NBlocks,1);
  dim3 dimBlock0 = dim3(BLOCKDIM,1);


  printf("NMols =  %d, NAtoms = %d\n", NMols, NAtoms); 
  printf("About to launch kernel.\n");


  hipEventCreate(&start_event);
  hipEventCreate(&stop_event);
  hipEventRecord(start_event, 0);

  Action_noImage_no_center_GPU<<<dimGrid0,dimBlock0>>>(devO1Ptr, devI2Ptr,devI3Ptr, maxD, NMols, NAtoms,NSAtoms,active_size);
  
  hipDeviceSynchronize();
  hipEventRecord(stop_event, 0);
  hipEventSynchronize(stop_event);
  hipEventElapsedTime(&elapsed_time_gpu,start_event, stop_event );


  printf("Done with kernel CUDA Kernel Time: %.2f\n", elapsed_time_gpu);

  time_gpu  = elapsed_time_gpu;
  
  hipMemcpy(D_,devO1Ptr,NMols * sizeof(double ),hipMemcpyDeviceToHost);
  hipFree(devO1Ptr);
  hipFree(devI1Ptr);
  hipFree(devI2Ptr);
  hipFree(devI3Ptr);
}
	.text
	.file	"kernel_wrappers.hip"
	.globl	_Z21Action_NoImage_CenterPdS_S_diiRf # -- Begin function _Z21Action_NoImage_CenterPdS_S_diiRf
	.type	_Z21Action_NoImage_CenterPdS_S_diiRf,@function
_Z21Action_NoImage_CenterPdS_S_diiRf:   # @_Z21Action_NoImage_CenterPdS_S_diiRf
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, 80(%rsp)                   # 8-byte Spill
	movl	%r8d, %r13d
	movl	%ecx, %ebp
	movsd	%xmm0, 48(%rsp)                 # 8-byte Spill
	movq	%rdx, %r14
	movq	%rsi, 72(%rsp)                  # 8-byte Spill
	movq	%rdi, 56(%rsp)                  # 8-byte Spill
	movslq	%ecx, %rbx
	leaq	(,%rbx,8), %rsi
	leaq	8(%rsp), %rdi
	movq	%rsi, 64(%rsp)                  # 8-byte Spill
	callq	hipMalloc
	leaq	32(%rsp), %r15
	movl	$24, %esi
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r15), %rdi
	movl	$24, %edx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%r13d, %r12d
	movl	%ebp, 28(%rsp)                  # 4-byte Spill
	imull	%ebp, %r12d
	movl	%r13d, %ebp
	leal	(%r12,%r12,2), %eax
	movslq	%eax, %r14
	shlq	$3, %r14
	leaq	40(%rsp), %r15
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r15), %rdi
	movq	56(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$1024, %r13d                    # imm = 0x400
	movl	$1024, %eax                     # imm = 0x400
	xorl	%edx, %edx
	idivl	%ebp
	subl	%edx, %r13d
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r12d, %xmm0
	cvtsi2ss	%r13d, %xmm1
	divss	%xmm1, %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r14d
	btsq	$32, %r14
	movl	$.L.str, %edi
	movl	%ebx, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	leaq	88(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbx), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$1024, %rdx                     # imm = 0x400
	movq	%r14, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_2
# %bb.1:
	movq	8(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	40(%rsp), %rdx
	movsd	48(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	28(%rsp), %ecx                  # 4-byte Reload
	movl	%ebp, %r8d
	movl	%r13d, %r9d
	callq	_Z40__device_stub__Action_noImage_center_GPUPdS_S_diii
.LBB0_2:
	callq	hipDeviceSynchronize
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	88(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	100(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movss	(%rbx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movq	80(%rsp), %rax                  # 8-byte Reload
	movss	%xmm0, (%rax)
	movq	8(%rsp), %rsi
	movq	72(%rsp), %rdi                  # 8-byte Reload
	movq	64(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	addq	$104, %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_end0:
	.size	_Z21Action_NoImage_CenterPdS_S_diiRf, .Lfunc_end0-_Z21Action_NoImage_CenterPdS_S_diiRf
	.cfi_endproc
                                        # -- End function
	.globl	_Z24Action_NoImage_no_CenterPdS_S_diiiRf # -- Begin function _Z24Action_NoImage_no_CenterPdS_S_diiiRf
	.type	_Z24Action_NoImage_no_CenterPdS_S_diiiRf,@function
_Z24Action_NoImage_no_CenterPdS_S_diiiRf: # @_Z24Action_NoImage_no_CenterPdS_S_diiiRf
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.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	%r9d, %ebx
	movl	%r8d, %r13d
	movl	%ecx, %r14d
	movsd	%xmm0, 48(%rsp)                 # 8-byte Spill
	movq	%rdx, 56(%rsp)                  # 8-byte Spill
	movq	%rsi, 80(%rsp)                  # 8-byte Spill
	movq	%rdi, %r15
	movslq	%ecx, %rax
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	leaq	(,%rax,8), %rsi
	leaq	8(%rsp), %rdi
	movq	%rsi, 72(%rsp)                  # 8-byte Spill
	callq	hipMalloc
	movl	%r13d, %ebp
	movl	%r14d, 28(%rsp)                 # 4-byte Spill
	imull	%r14d, %ebp
	leal	(%rbp,%rbp,2), %eax
	movslq	%eax, %r14
	shlq	$3, %r14
	leaq	32(%rsp), %r12
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r12), %rdi
	movq	%rbx, %r12
	movq	%r15, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	(%rbx,%rbx,2), %eax
	movslq	%eax, %r14
	shlq	$3, %r14
	leaq	40(%rsp), %r15
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	(%r15), %rdi
	movq	56(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$1024, %r15d                    # imm = 0x400
	movl	$1024, %eax                     # imm = 0x400
	xorl	%edx, %edx
	idivl	%r13d
	subl	%edx, %r15d
	cvtsi2ss	%ebp, %xmm0
	cvtsi2ss	%r15d, %xmm1
	divss	%xmm1, %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %ebx
	btsq	$32, %rbx
	movl	$.L.str, %edi
	movq	64(%rsp), %rsi                  # 8-byte Reload
                                        # kill: def $esi killed $esi killed $rsi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	leaq	88(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$1024, %rdx                     # imm = 0x400
	movq	%rbx, %rdi
	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), %rdi
	movq	32(%rsp), %rsi
	movq	40(%rsp), %rdx
	movl	%r15d, (%rsp)
	movsd	48(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	28(%rsp), %ecx                  # 4-byte Reload
	movl	%r13d, %r8d
	movl	%r12d, %r9d
	callq	_Z43__device_stub__Action_noImage_no_center_GPUPdS_S_diiii
.LBB1_2:
	callq	hipDeviceSynchronize
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	88(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	100(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	movss	(%rbx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movq	160(%rsp), %rax
	movss	%xmm0, (%rax)
	movq	8(%rsp), %rsi
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movq	72(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	callq	hipFree
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	addq	$104, %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	_Z24Action_NoImage_no_CenterPdS_S_diiiRf, .Lfunc_end1-_Z24Action_NoImage_no_CenterPdS_S_diiiRf
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"NMols =  %d, NAtoms = %d\n"
	.size	.L.str, 26

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Done with kernel CUDA Kernel Time: %.2f\n"
	.size	.L.str.2, 41

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr.1,@object                 # @str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.1:
	.asciz	"About to launch kernel."
	.size	.Lstr.1, 24

	.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_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
