/******************************************************************
File		:	lcsRedistributeParticles.cu
Author		:	Mingcheng Chen
Last Update	:	January 29th, 2013
*******************************************************************/

#include <stdio.h>

#define BLOCK_SIZE 512

__device__ inline int Sign(double a, double eps) {
	return a < -eps ? -1 : a > eps;
}

__device__ inline int GetLocalTetID(int blockID, int tetID,
			 int *startOffsetsInLocalIDMap,
			 int *blocksOfTets,
			 int *localIDsOfTets) { // blockID and tetID are all global IDs.
	int offset = startOffsetsInLocalIDMap[tetID];
	int endOffset = -1;
	while (1) {
		if (blocksOfTets[offset] == blockID) return localIDsOfTets[offset];
		if (endOffset == -1) endOffset = startOffsetsInLocalIDMap[tetID + 1];

		offset++;
		if (offset >= endOffset) return -1;
	}
}

__device__ inline int GetBlockID(int x, int y, int z, int numOfBlocksInY, int numOfBlocksInZ) {
	return (x * numOfBlocksInY + y) * numOfBlocksInZ + z;
}

__global__ void CollectActiveBlocksKernel(int *activeParticles,
				int *exitCells,
				double *placesOfInterest,

				int *localTetIDs,
				int *blockLocations,

				int *interestingBlockMap,

				int *startOffsetsInLocalIDMap,
				int *blocksOfTets,
				int *localIDsOfTets,

				int *interestingBlockMarks,

				int *activeBlocks,
				int *activeBlockIndices,
				int *numOfActiveBlocks, // Initially 0

				int mark,
				int numOfActiveParticles, //int numOfStages,
				int numOfBlocksInX, int numOfBlocksInY, int numOfBlocksInZ,
				double globalMinX, double globalMinY, double globalMinZ,
				double blockSize,
				double epsilon) {
	int globalID = blockDim.x * blockIdx.x + threadIdx.x;

	if (globalID < numOfActiveParticles) {
		int particleID = activeParticles[globalID];
		double posX = placesOfInterest[particleID * 3];
		double posY = placesOfInterest[particleID * 3 + 1];
		double posZ = placesOfInterest[particleID * 3 + 2];

		int x = (int)((posX - globalMinX) / blockSize);
		int y = (int)((posY - globalMinY) / blockSize);
		int z = (int)((posZ - globalMinZ) / blockSize);

		// Intuitive block ID
		int blockID = GetBlockID(x, y, z, numOfBlocksInY, numOfBlocksInZ);
		int tetID = exitCells[particleID];

		int localTetID = GetLocalTetID(blockID, tetID, startOffsetsInLocalIDMap, blocksOfTets, localIDsOfTets);

		/// DEBUG ///
		/*
		if (particleID == 303)
			printf("x, y, z: %d %d %d\n", x, y, z);
		*/


		if (localTetID == -1) {
			int dx[3], dy[3], dz[3];
			int lx = 1, ly = 1, lz = 1;
			dx[0] = dy[0] = dz[0] = 0;

			double xLower = globalMinX + x * blockSize;
			double yLower = globalMinY + y * blockSize;
			double zLower = globalMinZ + z * blockSize;

			if (!Sign(xLower - posX, 10 * epsilon)) dx[lx++] = -1;
			if (!Sign(yLower - posY, 10 * epsilon)) dy[ly++] = -1;
			if (!Sign(zLower - posZ, 10 * epsilon)) dz[lz++] = -1;

			if (!Sign(xLower + blockSize - posX, 10 * epsilon)) dx[lx++] = 1;
			if (!Sign(yLower + blockSize - posY, 10 * epsilon)) dy[ly++] = 1;
			if (!Sign(zLower + blockSize - posZ, 10 * epsilon)) dz[lz++] = 1;

			// Check every necessary neightbor
			for (int i = 0; localTetID == -1 && i < lx; i++)
				for (int j = 0; localTetID == -1 && j < ly; j++)
					for (int k = 0; k < lz; k++) {
						if (i + j + k == 0) continue;
						int _x = x + dx[i];
						int _y = y + dy[j];
						int _z = z + dz[k];

						if (_x < 0 || _y < 0 || _z < 0 ||
						    _x >= numOfBlocksInX || _y >= numOfBlocksInY || _z >= numOfBlocksInZ)
							continue;

						blockID = GetBlockID(_x, _y, _z, numOfBlocksInY, numOfBlocksInZ);

						/// DEBUG ///
						// if (particleID == 303 && tetID == 6825504) printf("_x = %d, _y = %d, _z = %d, blockID = %d\n", _x, _y, _z, blockID); 

						localTetID = GetLocalTetID(blockID, tetID, startOffsetsInLocalIDMap,
									   blocksOfTets, localIDsOfTets);

						if (localTetID != -1) break;
					}

			/// DEBUG ///
			if (localTetID == -1) {
				/*
				if (particleID == 303) {
					printf("%lf %lf %lf\n", posX, posY, posZ);
					printf("tetID = %d\n", tetID);
					printf("%lf %lf %lf\n", xLower, yLower, zLower);
					for (int i = 0; i < lx; i++)
						printf(" %d", dx[i]);
					printf("\n");
					for (int i = 0; i < ly; i++)
						printf(" %d", dy[i]);
					printf("\n");
					for (int i = 0; i < lz; i++)
						printf(" %d", dz[i]);
					printf("\n");
				}
				return;
				*/
				while (1);
			}
		}

		// localTetID must not be -1 at that point.

		localTetIDs[particleID] = localTetID;

		int interestingBlockID = interestingBlockMap[blockID];
		blockLocations[particleID] = interestingBlockID;

		int oldMark = atomicAdd(interestingBlockMarks + interestingBlockID, 0);

		int index;

		if (oldMark < mark) {
			int delta = mark - oldMark;
			int newMark = atomicAdd(interestingBlockMarks + interestingBlockID, delta);

			if (newMark >= mark)
				atomicAdd(interestingBlockMarks + interestingBlockID, -delta);
			else {
				index = atomicAdd(numOfActiveBlocks, 1);
				activeBlocks[index] = interestingBlockID;
				activeBlockIndices[interestingBlockID] = index;
			}
		}

		// This one cannot be calculated in that kernel
		//activeBlockOfParticles[particleID] = index;
	}
}

__global__ void GetNumOfParticlesByStageInBlocksKernel(int *numOfParticlesByStageInBlocks,
					       int *particleOrders,
					       int *stages,
					       int *activeParticles,
					       
					       int *blockLocations,
					       int *activeBlockIndices,
					       int numOfStages, int numOfActiveParticles) {
	int globalID = blockDim.x * blockIdx.x + threadIdx.x;
	if (globalID < numOfActiveParticles) {
		int particleID = activeParticles[globalID];

		int posi = activeBlockIndices[blockLocations[particleID]] * numOfStages + stages[particleID];
		particleOrders[particleID] = atomicAdd(numOfParticlesByStageInBlocks + posi, 1);
	}
}

__global__ void CollectParticlesToBlocksKernel(int *numOfParticlesByStageInBlocks, // Now it is a prefix sum array.
				       int *particleOrders,
				       int *stages,
				       int *activeParticles,
				       int *blockLocations,
				       int *activeBlockIndices,

				       int *blockedParticleList,
				       int numOfStages, int numOfActiveParticles
				       ) {
	int globalID = blockDim.x * blockIdx.x + threadIdx.x;

	if (globalID < numOfActiveParticles) {
		int particleID = activeParticles[globalID];

		int interestingBlockID = blockLocations[particleID];
		int activeBlockID = activeBlockIndices[interestingBlockID];
		int stage = stages[particleID];

		int position = numOfParticlesByStageInBlocks[activeBlockID * numOfStages + stage] + particleOrders[particleID];

		blockedParticleList[position] = particleID;
	}
}

extern "C"
void CollectActiveBlocks(int *activeParticles,
				int *exitCells,
				double *placesOfInterest,

				int *localTetIDs,
				int *blockLocations,

				int *interestingBlockMap,

				int *startOffsetsInLocalIDMap,
				int *blocksOfTets,
				int *localIDsOfTets,

				int *interestingBlockMarks,

				int *activeBlocks,
				int *activeBlockIndices,
				int *numOfActiveBlocks, // Initially 0

				int mark,
				int numOfActiveParticles, //int numOfStages,
				int numOfBlocksInX, int numOfBlocksInY, int numOfBlocksInZ,
				double globalMinX, double globalMinY, double globalMinZ,
				double blockSize,
				double epsilon) {
	dim3 dimBlock(BLOCK_SIZE, 1, 1);
	dim3 dimGrid((numOfActiveParticles - 1) / dimBlock.x + 1, 1, 1);

	CollectActiveBlocksKernel<<<dimGrid, dimBlock>>>(activeParticles, exitCells, placesOfInterest, localTetIDs, blockLocations, interestingBlockMap,
							startOffsetsInLocalIDMap, blocksOfTets, localIDsOfTets, interestingBlockMarks, activeBlocks,
							activeBlockIndices, numOfActiveBlocks, // Initially 0
							mark, numOfActiveParticles, numOfBlocksInX, numOfBlocksInY, numOfBlocksInZ,
							globalMinX, globalMinY, globalMinZ, blockSize, epsilon);

	cudaError_t err = cudaDeviceSynchronize();
	if (err) {
		cudaGetErrorString(err);
		exit(0);
	}
}

extern "C"
void GetNumOfParticlesByStageInBlocks(int *numOfParticlesByStageInBlocks,
					       int *particleOrders,
					       int *stages,
					       int *activeParticles,
					       
					       int *blockLocations,
					       int *activeBlockIndices,
					       int numOfStages, int numOfActiveParticles) {
	dim3 dimBlock(BLOCK_SIZE, 1, 1);
	dim3 dimGrid((numOfActiveParticles - 1) / dimBlock.x + 1, 1, 1);

	GetNumOfParticlesByStageInBlocksKernel<<<dimGrid, dimBlock>>>(numOfParticlesByStageInBlocks, particleOrders, stages, activeParticles, blockLocations,
									activeBlockIndices, numOfStages, numOfActiveParticles);

	cudaError_t err = cudaDeviceSynchronize();
	if (err) {
		cudaGetErrorString(err);
		exit(0);
	}

}

extern "C"
void CollectParticlesToBlocks(int *numOfParticlesByStageInBlocks, // Now it is a prefix sum array.
				       int *particleOrders,
				       int *stages,
				       int *activeParticles,
				       int *blockLocations,
				       int *activeBlockIndices,

				       int *blockedParticleList,
				       int numOfStages, int numOfActiveParticles) {
	dim3 dimBlock(BLOCK_SIZE, 1, 1);
	dim3 dimGrid((numOfActiveParticles - 1 ) / dimBlock.x + 1, 1, 1);

	CollectParticlesToBlocksKernel<<<dimGrid, dimBlock>>>(numOfParticlesByStageInBlocks, // Now it is a prefix sum array.
								particleOrders, stages, activeParticles, blockLocations, activeBlockIndices, blockedParticleList,
								numOfStages, numOfActiveParticles);

	cudaError_t err = cudaDeviceSynchronize();
	if (err) {
		cudaGetErrorString(err);
		exit(0);
	}
}

	.file	"tmpxft_0031b699_00000000-6_lcsRedistributeParticles.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2035:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2035:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.type	_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, @function
_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$408, %rsp
	.cfi_def_cfa_offset 416
	movq	416(%rsp), %rax
	movq	%rdi, 136(%rsp)
	leaq	160(%rsp), %rdi
	movq	%rsi, 128(%rsp)
	leaq	172(%rsp), %rsi
	movq	%rax, 88(%rsp)
	movq	424(%rsp), %rax
	movq	%rdx, 120(%rsp)
	leaq	144(%rsp), %rdx
	movq	%rax, 80(%rsp)
	movq	432(%rsp), %rax
	movq	%rcx, 112(%rsp)
	leaq	152(%rsp), %rcx
	movq	%rax, 72(%rsp)
	movq	440(%rsp), %rax
	movq	%r8, 104(%rsp)
	movq	%rax, 64(%rsp)
	movq	448(%rsp), %rax
	movq	%r9, 96(%rsp)
	movq	%rax, 56(%rsp)
	movq	456(%rsp), %rax
	movsd	%xmm0, 32(%rsp)
	movq	%rax, 48(%rsp)
	movq	464(%rsp), %rax
	movsd	%xmm1, 24(%rsp)
	movq	%rax, 40(%rsp)
	movsd	%xmm2, 16(%rsp)
	movsd	%xmm3, 8(%rsp)
	movsd	%xmm4, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 392(%rsp)
	xorl	%eax, %eax
	leaq	136(%rsp), %rax
	movq	%rax, 208(%rsp)
	leaq	128(%rsp), %rax
	movq	%rax, 216(%rsp)
	leaq	120(%rsp), %rax
	movq	%rax, 224(%rsp)
	leaq	112(%rsp), %rax
	movq	%rax, 232(%rsp)
	leaq	104(%rsp), %rax
	movq	%rax, 240(%rsp)
	leaq	96(%rsp), %rax
	movq	%rax, 248(%rsp)
	leaq	88(%rsp), %rax
	movq	%rax, 256(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 264(%rsp)
	leaq	72(%rsp), %rax
	movq	%rax, 272(%rsp)
	leaq	64(%rsp), %rax
	movq	%rax, 280(%rsp)
	leaq	56(%rsp), %rax
	movq	%rax, 288(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 296(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 304(%rsp)
	leaq	472(%rsp), %rax
	movq	%rax, 312(%rsp)
	leaq	480(%rsp), %rax
	movq	%rax, 320(%rsp)
	leaq	488(%rsp), %rax
	movq	%rax, 328(%rsp)
	leaq	496(%rsp), %rax
	movq	%rax, 336(%rsp)
	leaq	504(%rsp), %rax
	movq	%rax, 344(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 352(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 360(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 368(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 376(%rsp)
	movq	%rsp, %rax
	movq	%rax, 384(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 160(%rsp)
	movl	$1, 168(%rsp)
	movq	%rax, 172(%rsp)
	movl	$1, 180(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	152(%rsp)
	.cfi_def_cfa_offset 424
	leaq	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd(%rip), %rdi
	pushq	152(%rsp)
	.cfi_def_cfa_offset 432
	movq	188(%rsp), %rcx
	movl	196(%rsp), %r8d
	movq	176(%rsp), %rsi
	movl	184(%rsp), %edx
	leaq	224(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 424
	popq	%rdx
	.cfi_def_cfa_offset 416
.L2:
	movq	392(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$408, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, .-_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.globl	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.type	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, @function
_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.cfi_endproc
.LFE2058:
	.size	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, .-_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.globl	CollectActiveBlocks
	.type	CollectActiveBlocks, @function
CollectActiveBlocks:
.LFB2030:
	.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	%r9, %r14
	xorl	%r9d, %r9d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r8, %r13
	xorl	%r8d, %r8d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	movl	$1, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	movl	$8388609, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	salq	$9, %rdx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movl	208(%rsp), %r15d
	movq	%rdi, (%rsp)
	movsd	%xmm0, 40(%rsp)
	leal	-1(%r15), %eax
	movsd	%xmm1, 32(%rsp)
	shrl	$9, %eax
	movsd	%xmm2, 24(%rsp)
	incl	%eax
	movsd	%xmm3, 16(%rsp)
	movl	%eax, 68(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	68(%rsp), %rdi
	movl	76(%rsp), %esi
	movsd	%xmm4, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	movsd	8(%rsp), %xmm4
	movsd	16(%rsp), %xmm3
	testl	%eax, %eax
	movsd	24(%rsp), %xmm2
	movsd	32(%rsp), %xmm1
	movsd	40(%rsp), %xmm0
	jne	.L9
	movl	232(%rsp), %eax
	movq	%r14, %r9
	movq	%r13, %r8
	movq	%r12, %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	pushq	%rax
	.cfi_def_cfa_offset 152
	movl	232(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 160
	movl	232(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 168
	pushq	%r15
	.cfi_def_cfa_offset 176
	movl	232(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 184
	pushq	232(%rsp)
	.cfi_def_cfa_offset 192
	pushq	232(%rsp)
	.cfi_def_cfa_offset 200
	pushq	232(%rsp)
	.cfi_def_cfa_offset 208
	pushq	232(%rsp)
	.cfi_def_cfa_offset 216
	pushq	232(%rsp)
	.cfi_def_cfa_offset 224
	pushq	232(%rsp)
	.cfi_def_cfa_offset 232
	pushq	232(%rsp)
	.cfi_def_cfa_offset 240
	movq	96(%rsp), %rdi
	call	_Z79__device_stub__Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiidddddPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	addq	$96, %rsp
	.cfi_def_cfa_offset 144
.L9:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L8
	call	cudaGetErrorString@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L8:
	addq	$88, %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
.LFE2030:
	.size	CollectActiveBlocks, .-CollectActiveBlocks
	.globl	_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii
	.type	_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii, @function
_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 152(%rsp)
	movq	%rsp, %rax
	movq	%rax, 160(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	216(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L12:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii, .-_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii
	.globl	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.type	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, @function
_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii
	.cfi_endproc
.LFE2060:
	.size	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, .-_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.globl	GetNumOfParticlesByStageInBlocks
	.type	GetNumOfParticlesByStageInBlocks, @function
GetNumOfParticlesByStageInBlocks:
.LFB2031:
	.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	%r9, %r14
	xorl	%r9d, %r9d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r8, %r13
	xorl	%r8d, %r8d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	movl	$1, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	movl	$8388609, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	salq	$9, %rdx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	120(%rsp), %r15d
	movq	%rdi, 8(%rsp)
	leal	-1(%r15), %eax
	shrl	$9, %eax
	incl	%eax
	movl	%eax, 36(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	36(%rsp), %rdi
	movl	44(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	%r15
	.cfi_def_cfa_offset 120
	movl	120(%rsp), %eax
	movq	%rbp, %rdx
	movq	%r14, %r9
	movq	%r13, %r8
	movq	%r12, %rcx
	movq	%rbx, %rsi
	pushq	%rax
	.cfi_def_cfa_offset 128
	movq	24(%rsp), %rdi
	call	_Z70__device_stub__Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_iiPiS_S_S_S_S_ii
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L18:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L17
	call	cudaGetErrorString@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L17:
	addq	$56, %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
.LFE2031:
	.size	GetNumOfParticlesByStageInBlocks, .-GetNumOfParticlesByStageInBlocks
	.globl	_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii
	.type	_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii, @function
_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	224(%rsp), %rax
	movq	%rdi, 56(%rsp)
	leaq	80(%rsp), %rdi
	movq	%rsi, 48(%rsp)
	leaq	92(%rsp), %rsi
	movq	%rdx, 40(%rsp)
	leaq	64(%rsp), %rdx
	movq	%rcx, 32(%rsp)
	leaq	72(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 88(%rsp)
	movq	%rax, 128(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	232(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	240(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 80(%rsp)
	movq	%rax, 92(%rsp)
	movl	$1, 100(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	pushq	72(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii(%rip), %rdi
	pushq	72(%rsp)
	.cfi_def_cfa_offset 240
	movq	108(%rsp), %rcx
	movl	116(%rsp), %r8d
	movq	96(%rsp), %rsi
	movl	104(%rsp), %edx
	leaq	144(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L21:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii, .-_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii
	.globl	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.type	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, @function
_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii
	.cfi_endproc
.LFE2062:
	.size	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, .-_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.globl	CollectParticlesToBlocks
	.type	CollectParticlesToBlocks, @function
CollectParticlesToBlocks:
.LFB2032:
	.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	%r9, %r14
	xorl	%r9d, %r9d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r8, %r13
	xorl	%r8d, %r8d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	movl	$1, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	movl	$8388609, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	salq	$9, %rdx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	128(%rsp), %r15d
	movq	%rdi, 8(%rsp)
	leal	-1(%r15), %eax
	shrl	$9, %eax
	incl	%eax
	movl	%eax, 36(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	36(%rsp), %rdi
	movl	44(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	pushq	%rax
	.cfi_def_cfa_offset 120
	movq	%r14, %r9
	movq	%r13, %r8
	movq	%r12, %rcx
	pushq	%r15
	.cfi_def_cfa_offset 128
	movl	136(%rsp), %eax
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	pushq	%rax
	.cfi_def_cfa_offset 136
	pushq	136(%rsp)
	.cfi_def_cfa_offset 144
	movq	40(%rsp), %rdi
	call	_Z64__device_stub__Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_iiPiS_S_S_S_S_S_ii
	addq	$32, %rsp
	.cfi_def_cfa_offset 112
.L27:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L26
	call	cudaGetErrorString@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L26:
	addq	$56, %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
.LFE2032:
	.size	CollectParticlesToBlocks, .-CollectParticlesToBlocks
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii"
.LC1:
	.string	"_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii"
.LC2:
	.string	"_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC2(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2064:
	.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:

/******************************************************************
File		:	lcsRedistributeParticles.cu
Author		:	Mingcheng Chen
Last Update	:	January 29th, 2013
*******************************************************************/


#include <hip/hip_runtime.h>
#include <stdio.h>

#define BLOCK_SIZE 512

__device__ inline int Sign(double a, double eps) {
	return a < -eps ? -1 : a > eps;
}

__device__ inline int GetLocalTetID(int blockID, int tetID,
			 int *startOffsetsInLocalIDMap,
			 int *blocksOfTets,
			 int *localIDsOfTets) { // blockID and tetID are all global IDs.
	int offset = startOffsetsInLocalIDMap[tetID];
	int endOffset = -1;
	while (1) {
		if (blocksOfTets[offset] == blockID) return localIDsOfTets[offset];
		if (endOffset == -1) endOffset = startOffsetsInLocalIDMap[tetID + 1];

		offset++;
		if (offset >= endOffset) return -1;
	}
}

__device__ inline int GetBlockID(int x, int y, int z, int numOfBlocksInY, int numOfBlocksInZ) {
	return (x * numOfBlocksInY + y) * numOfBlocksInZ + z;
}

__global__ void CollectActiveBlocksKernel(int *activeParticles,
				int *exitCells,
				double *placesOfInterest,

				int *localTetIDs,
				int *blockLocations,

				int *interestingBlockMap,

				int *startOffsetsInLocalIDMap,
				int *blocksOfTets,
				int *localIDsOfTets,

				int *interestingBlockMarks,

				int *activeBlocks,
				int *activeBlockIndices,
				int *numOfActiveBlocks, // Initially 0

				int mark,
				int numOfActiveParticles, //int numOfStages,
				int numOfBlocksInX, int numOfBlocksInY, int numOfBlocksInZ,
				double globalMinX, double globalMinY, double globalMinZ,
				double blockSize,
				double epsilon) {
	int globalID = blockDim.x * blockIdx.x + threadIdx.x;

	if (globalID < numOfActiveParticles) {
		int particleID = activeParticles[globalID];
		double posX = placesOfInterest[particleID * 3];
		double posY = placesOfInterest[particleID * 3 + 1];
		double posZ = placesOfInterest[particleID * 3 + 2];

		int x = (int)((posX - globalMinX) / blockSize);
		int y = (int)((posY - globalMinY) / blockSize);
		int z = (int)((posZ - globalMinZ) / blockSize);

		// Intuitive block ID
		int blockID = GetBlockID(x, y, z, numOfBlocksInY, numOfBlocksInZ);
		int tetID = exitCells[particleID];

		int localTetID = GetLocalTetID(blockID, tetID, startOffsetsInLocalIDMap, blocksOfTets, localIDsOfTets);

		/// DEBUG ///
		/*
		if (particleID == 303)
			printf("x, y, z: %d %d %d\n", x, y, z);
		*/


		if (localTetID == -1) {
			int dx[3], dy[3], dz[3];
			int lx = 1, ly = 1, lz = 1;
			dx[0] = dy[0] = dz[0] = 0;

			double xLower = globalMinX + x * blockSize;
			double yLower = globalMinY + y * blockSize;
			double zLower = globalMinZ + z * blockSize;

			if (!Sign(xLower - posX, 10 * epsilon)) dx[lx++] = -1;
			if (!Sign(yLower - posY, 10 * epsilon)) dy[ly++] = -1;
			if (!Sign(zLower - posZ, 10 * epsilon)) dz[lz++] = -1;

			if (!Sign(xLower + blockSize - posX, 10 * epsilon)) dx[lx++] = 1;
			if (!Sign(yLower + blockSize - posY, 10 * epsilon)) dy[ly++] = 1;
			if (!Sign(zLower + blockSize - posZ, 10 * epsilon)) dz[lz++] = 1;

			// Check every necessary neightbor
			for (int i = 0; localTetID == -1 && i < lx; i++)
				for (int j = 0; localTetID == -1 && j < ly; j++)
					for (int k = 0; k < lz; k++) {
						if (i + j + k == 0) continue;
						int _x = x + dx[i];
						int _y = y + dy[j];
						int _z = z + dz[k];

						if (_x < 0 || _y < 0 || _z < 0 ||
						    _x >= numOfBlocksInX || _y >= numOfBlocksInY || _z >= numOfBlocksInZ)
							continue;

						blockID = GetBlockID(_x, _y, _z, numOfBlocksInY, numOfBlocksInZ);

						/// DEBUG ///
						// if (particleID == 303 && tetID == 6825504) printf("_x = %d, _y = %d, _z = %d, blockID = %d\n", _x, _y, _z, blockID); 

						localTetID = GetLocalTetID(blockID, tetID, startOffsetsInLocalIDMap,
									   blocksOfTets, localIDsOfTets);

						if (localTetID != -1) break;
					}

			/// DEBUG ///
			if (localTetID == -1) {
				/*
				if (particleID == 303) {
					printf("%lf %lf %lf\n", posX, posY, posZ);
					printf("tetID = %d\n", tetID);
					printf("%lf %lf %lf\n", xLower, yLower, zLower);
					for (int i = 0; i < lx; i++)
						printf(" %d", dx[i]);
					printf("\n");
					for (int i = 0; i < ly; i++)
						printf(" %d", dy[i]);
					printf("\n");
					for (int i = 0; i < lz; i++)
						printf(" %d", dz[i]);
					printf("\n");
				}
				return;
				*/
				while (1);
			}
		}

		// localTetID must not be -1 at that point.

		localTetIDs[particleID] = localTetID;

		int interestingBlockID = interestingBlockMap[blockID];
		blockLocations[particleID] = interestingBlockID;

		int oldMark = atomicAdd(interestingBlockMarks + interestingBlockID, 0);

		int index;

		if (oldMark < mark) {
			int delta = mark - oldMark;
			int newMark = atomicAdd(interestingBlockMarks + interestingBlockID, delta);

			if (newMark >= mark)
				atomicAdd(interestingBlockMarks + interestingBlockID, -delta);
			else {
				index = atomicAdd(numOfActiveBlocks, 1);
				activeBlocks[index] = interestingBlockID;
				activeBlockIndices[interestingBlockID] = index;
			}
		}

		// This one cannot be calculated in that kernel
		//activeBlockOfParticles[particleID] = index;
	}
}

__global__ void GetNumOfParticlesByStageInBlocksKernel(int *numOfParticlesByStageInBlocks,
					       int *particleOrders,
					       int *stages,
					       int *activeParticles,
					       
					       int *blockLocations,
					       int *activeBlockIndices,
					       int numOfStages, int numOfActiveParticles) {
	int globalID = blockDim.x * blockIdx.x + threadIdx.x;
	if (globalID < numOfActiveParticles) {
		int particleID = activeParticles[globalID];

		int posi = activeBlockIndices[blockLocations[particleID]] * numOfStages + stages[particleID];
		particleOrders[particleID] = atomicAdd(numOfParticlesByStageInBlocks + posi, 1);
	}
}

__global__ void CollectParticlesToBlocksKernel(int *numOfParticlesByStageInBlocks, // Now it is a prefix sum array.
				       int *particleOrders,
				       int *stages,
				       int *activeParticles,
				       int *blockLocations,
				       int *activeBlockIndices,

				       int *blockedParticleList,
				       int numOfStages, int numOfActiveParticles
				       ) {
	int globalID = blockDim.x * blockIdx.x + threadIdx.x;

	if (globalID < numOfActiveParticles) {
		int particleID = activeParticles[globalID];

		int interestingBlockID = blockLocations[particleID];
		int activeBlockID = activeBlockIndices[interestingBlockID];
		int stage = stages[particleID];

		int position = numOfParticlesByStageInBlocks[activeBlockID * numOfStages + stage] + particleOrders[particleID];

		blockedParticleList[position] = particleID;
	}
}

extern "C"
void CollectActiveBlocks(int *activeParticles,
				int *exitCells,
				double *placesOfInterest,

				int *localTetIDs,
				int *blockLocations,

				int *interestingBlockMap,

				int *startOffsetsInLocalIDMap,
				int *blocksOfTets,
				int *localIDsOfTets,

				int *interestingBlockMarks,

				int *activeBlocks,
				int *activeBlockIndices,
				int *numOfActiveBlocks, // Initially 0

				int mark,
				int numOfActiveParticles, //int numOfStages,
				int numOfBlocksInX, int numOfBlocksInY, int numOfBlocksInZ,
				double globalMinX, double globalMinY, double globalMinZ,
				double blockSize,
				double epsilon) {
	dim3 dimBlock(BLOCK_SIZE, 1, 1);
	dim3 dimGrid((numOfActiveParticles - 1) / dimBlock.x + 1, 1, 1);

	CollectActiveBlocksKernel<<<dimGrid, dimBlock>>>(activeParticles, exitCells, placesOfInterest, localTetIDs, blockLocations, interestingBlockMap,
							startOffsetsInLocalIDMap, blocksOfTets, localIDsOfTets, interestingBlockMarks, activeBlocks,
							activeBlockIndices, numOfActiveBlocks, // Initially 0
							mark, numOfActiveParticles, numOfBlocksInX, numOfBlocksInY, numOfBlocksInZ,
							globalMinX, globalMinY, globalMinZ, blockSize, epsilon);

	hipError_t err = hipDeviceSynchronize();
	if (err) {
		hipGetErrorString(err);
		exit(0);
	}
}

extern "C"
void GetNumOfParticlesByStageInBlocks(int *numOfParticlesByStageInBlocks,
					       int *particleOrders,
					       int *stages,
					       int *activeParticles,
					       
					       int *blockLocations,
					       int *activeBlockIndices,
					       int numOfStages, int numOfActiveParticles) {
	dim3 dimBlock(BLOCK_SIZE, 1, 1);
	dim3 dimGrid((numOfActiveParticles - 1) / dimBlock.x + 1, 1, 1);

	GetNumOfParticlesByStageInBlocksKernel<<<dimGrid, dimBlock>>>(numOfParticlesByStageInBlocks, particleOrders, stages, activeParticles, blockLocations,
									activeBlockIndices, numOfStages, numOfActiveParticles);

	hipError_t err = hipDeviceSynchronize();
	if (err) {
		hipGetErrorString(err);
		exit(0);
	}

}

extern "C"
void CollectParticlesToBlocks(int *numOfParticlesByStageInBlocks, // Now it is a prefix sum array.
				       int *particleOrders,
				       int *stages,
				       int *activeParticles,
				       int *blockLocations,
				       int *activeBlockIndices,

				       int *blockedParticleList,
				       int numOfStages, int numOfActiveParticles) {
	dim3 dimBlock(BLOCK_SIZE, 1, 1);
	dim3 dimGrid((numOfActiveParticles - 1 ) / dimBlock.x + 1, 1, 1);

	CollectParticlesToBlocksKernel<<<dimGrid, dimBlock>>>(numOfParticlesByStageInBlocks, // Now it is a prefix sum array.
								particleOrders, stages, activeParticles, blockLocations, activeBlockIndices, blockedParticleList,
								numOfStages, numOfActiveParticles);

	hipError_t err = hipDeviceSynchronize();
	if (err) {
		hipGetErrorString(err);
		exit(0);
	}
}

	.text
	.file	"lcsRedistributeParticles.hip"
	.globl	_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd # -- Begin function _Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.type	_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd,@function
_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd: # @_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.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	$336, %rsp                      # imm = 0x150
	.cfi_def_cfa_offset 384
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	104(%rsp), %r10
	movq	%rdi, (%r10)
	leaq	96(%rsp), %r11
	movq	%rsi, (%r11)
	leaq	88(%rsp), %r14
	movq	%rdx, (%r14)
	leaq	80(%rsp), %r15
	movq	%rcx, (%r15)
	leaq	72(%rsp), %r12
	movq	%r8, (%r12)
	leaq	64(%rsp), %r8
	movq	%r9, (%r8)
	leaq	56(%rsp), %rax
	movsd	%xmm0, (%rax)
	leaq	48(%rsp), %rcx
	movsd	%xmm1, (%rcx)
	leaq	40(%rsp), %rdx
	movsd	%xmm2, (%rdx)
	leaq	32(%rsp), %rsi
	movsd	%xmm3, (%rsi)
	leaq	24(%rsp), %rdi
	movsd	%xmm4, (%rdi)
	leaq	144(%rsp), %rbx
	movq	%r10, (%rbx)
	movq	%r11, 8(%rbx)
	movq	%r14, 16(%rbx)
	movq	%r15, 24(%rbx)
	movq	%r12, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	384(%rsp), %r8
	movq	%r8, 48(%rbx)
	leaq	392(%rsp), %r8
	movq	%r8, 56(%rbx)
	leaq	400(%rsp), %r8
	movq	%r8, 64(%rbx)
	leaq	408(%rsp), %r8
	movq	%r8, 72(%rbx)
	leaq	416(%rsp), %r8
	movq	%r8, 80(%rbx)
	leaq	424(%rsp), %r8
	movq	%r8, 88(%rbx)
	leaq	432(%rsp), %r8
	movq	%r8, 96(%rbx)
	leaq	440(%rsp), %r8
	movq	%r8, 104(%rbx)
	leaq	448(%rsp), %r8
	movq	%r8, 112(%rbx)
	leaq	456(%rsp), %r8
	movq	%r8, 120(%rbx)
	leaq	464(%rsp), %r8
	movq	%r8, 128(%rbx)
	leaq	472(%rsp), %r8
	movq	%r8, 136(%rbx)
	movq	%rax, 144(%rbx)
	movq	%rcx, 152(%rbx)
	movq	%rdx, 160(%rbx)
	movq	%rsi, 168(%rbx)
	movq	%rdi, 176(%rbx)
	leaq	128(%rsp), %r14
	leaq	112(%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	$_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$352, %rsp                      # imm = 0x160
	.cfi_adjust_cfa_offset -352
	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	_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, .Lfunc_end0-_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.cfi_endproc
                                        # -- End function
	.globl	_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii # -- Begin function _Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.type	_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii,@function
_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii: # @_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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_end1:
	.size	_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, .Lfunc_end1-_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii # -- Begin function _Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.type	_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii,@function
_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii: # @_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	224(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	232(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	240(%rsp), %rax
	movq	%rax, 64(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	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_end2:
	.size	_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, .Lfunc_end2-_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.cfi_endproc
                                        # -- End function
	.globl	CollectActiveBlocks             # -- Begin function CollectActiveBlocks
	.type	CollectActiveBlocks,@function
CollectActiveBlocks:                    # @CollectActiveBlocks
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movsd	%xmm4, 32(%rsp)                 # 8-byte Spill
	movsd	%xmm3, 24(%rsp)                 # 8-byte Spill
	movsd	%xmm2, 16(%rsp)                 # 8-byte Spill
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movq	%r9, %rbx
	movq	%r8, %r14
	movq	%rcx, %r15
	movq	%rdx, %r12
	movq	%rsi, %r13
	movq	%rdi, %rbp
	movl	160(%rsp), %eax
	decl	%eax
	shrl	$9, %eax
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	leaq	(%rdx,%rax), %rdi
	incq	%rdi
	orq	$512, %rdx                      # imm = 0x200
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_2
# %bb.1:
	movl	184(%rsp), %eax
	movl	176(%rsp), %r10d
	movl	168(%rsp), %r11d
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movq	%r15, %rcx
	movq	%r14, %r8
	movq	%rbx, %r9
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	16(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movsd	24(%rsp), %xmm3                 # 8-byte Reload
                                        # xmm3 = mem[0],zero
	movsd	32(%rsp), %xmm4                 # 8-byte Reload
                                        # xmm4 = mem[0],zero
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	movl	184(%rsp), %eax
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	movl	184(%rsp), %eax
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
.LBB3_2:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB3_4
# %bb.3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB3_4:
	.cfi_def_cfa_offset 96
	movl	%eax, %edi
	callq	hipGetErrorString
	xorl	%edi, %edi
	callq	exit
.Lfunc_end3:
	.size	CollectActiveBlocks, .Lfunc_end3-CollectActiveBlocks
	.cfi_endproc
                                        # -- End function
	.globl	GetNumOfParticlesByStageInBlocks # -- Begin function GetNumOfParticlesByStageInBlocks
	.type	GetNumOfParticlesByStageInBlocks,@function
GetNumOfParticlesByStageInBlocks:       # @GetNumOfParticlesByStageInBlocks
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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, %rbx
	movq	%r8, %r14
	movq	%rcx, %r15
	movq	%rdx, %r12
	movq	%rsi, %r13
	movq	%rdi, %rbp
	movl	72(%rsp), %eax
	decl	%eax
	shrl	$9, %eax
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	leaq	(%rdx,%rax), %rdi
	incq	%rdi
	orq	$512, %rdx                      # imm = 0x200
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_2
# %bb.1:
	movl	64(%rsp), %eax
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movq	%r15, %rcx
	movq	%r14, %r8
	movq	%rbx, %r9
	movl	72(%rsp), %r10d
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	callq	_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB4_2:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB4_4
# %bb.3:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB4_4:
	.cfi_def_cfa_offset 64
	movl	%eax, %edi
	callq	hipGetErrorString
	xorl	%edi, %edi
	callq	exit
.Lfunc_end4:
	.size	GetNumOfParticlesByStageInBlocks, .Lfunc_end4-GetNumOfParticlesByStageInBlocks
	.cfi_endproc
                                        # -- End function
	.globl	CollectParticlesToBlocks        # -- Begin function CollectParticlesToBlocks
	.type	CollectParticlesToBlocks,@function
CollectParticlesToBlocks:               # @CollectParticlesToBlocks
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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, %rbx
	movq	%r8, %r14
	movq	%rcx, %r15
	movq	%rdx, %r12
	movq	%rsi, %r13
	movq	%rdi, %rbp
	movl	80(%rsp), %eax
	decl	%eax
	shrl	$9, %eax
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	leaq	(%rdx,%rax), %rdi
	incq	%rdi
	orq	$512, %rdx                      # imm = 0x200
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_2
# %bb.1:
	movl	72(%rsp), %eax
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	%rbp, %rdi
	movq	%r13, %rsi
	movq	%r12, %rdx
	movq	%r15, %rcx
	movq	%r14, %r8
	movq	%rbx, %r9
	movl	88(%rsp), %r10d
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	88(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
.LBB5_2:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB5_4
# %bb.3:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB5_4:
	.cfi_def_cfa_offset 64
	movl	%eax, %edi
	callq	hipGetErrorString
	xorl	%edi, %edi
	callq	exit
.Lfunc_end5:
	.size	CollectParticlesToBlocks, .Lfunc_end5-CollectParticlesToBlocks
	.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
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, %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	$_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd,@object # @_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.section	.rodata,"a",@progbits
	.globl	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.p2align	3, 0x0
_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd:
	.quad	_Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.size	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, 8

	.type	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii,@object # @_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.globl	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.p2align	3, 0x0
_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii:
	.quad	_Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.size	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, 8

	.type	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii,@object # @_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.globl	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.p2align	3, 0x0
_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii:
	.quad	_Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.size	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, 8

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd"
	.size	.L__unnamed_1, 66

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii"
	.size	.L__unnamed_2, 57

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii"
	.size	.L__unnamed_3, 51

	.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 _Z40__device_stub__CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.addrsig_sym _Z53__device_stub__GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.addrsig_sym _Z45__device_stub__CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.addrsig_sym _Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.addrsig_sym _Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd ; -- Begin function _Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.globl	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
	.p2align	8
	.type	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd,@function
_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd: ; @_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0xb4
	s_load_b128 s[28:31], s[0:1], 0x68
	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 s29, v1
	s_cbranch_execz .LBB0_41
; %bb.1:
	s_load_b512 s[4:19], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b256 s[36:43], s[0:1], 0x80
	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 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	s_load_b32 s5, s[0:1], 0x78
                                        ; implicit-def: $sgpr4
	global_load_b32 v4, v[0:1], off
	s_waitcnt vmcnt(0)
	v_lshl_add_u32 v0, v4, 1, v4
	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], 3, v[0:1]
	v_add_co_u32 v5, vcc_lo, s8, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v6, vcc_lo, s9, v1, vcc_lo
                                        ; implicit-def: $sgpr9
                                        ; implicit-def: $sgpr8
	s_clause 0x1
	global_load_b128 v[0:3], v[5:6], off
	global_load_b64 v[16:17], v[5:6], off offset:16
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v6, vcc_lo, s6, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s7, v5, vcc_lo
	global_load_b32 v6, v[6:7], off
	s_waitcnt vmcnt(2)
	v_add_f64 v[9:10], v[0:1], -s[36:37]
	v_add_f64 v[11:12], v[2:3], -s[38:39]
	s_waitcnt vmcnt(1)
	v_add_f64 v[13:14], v[16:17], -s[40:41]
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v7, 31, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[6:7], 2, v[6:7]
	v_add_co_u32 v6, vcc_lo, s16, v6
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v7, vcc_lo, s17, v7, vcc_lo
	global_load_b32 v8, v[6:7], off
	v_div_scale_f64 v[18:19], null, s[42:43], s[42:43], v[9:10]
	v_div_scale_f64 v[20:21], null, s[42:43], s[42:43], v[11:12]
	v_div_scale_f64 v[22:23], null, s[42:43], s[42:43], v[13:14]
	v_div_scale_f64 v[36:37], vcc_lo, v[9:10], s[42:43], v[9:10]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_rcp_f64_e32 v[24:25], v[18:19]
	v_rcp_f64_e32 v[26:27], v[20:21]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(TRANS32_DEP_3)
	v_rcp_f64_e32 v[28:29], v[22:23]
	v_fma_f64 v[30:31], -v[18:19], v[24:25], 1.0
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[32:33], -v[20:21], v[26:27], 1.0
	v_fma_f64 v[34:35], -v[22:23], v[28:29], 1.0
	v_fma_f64 v[24:25], v[24:25], v[30:31], v[24:25]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[26:27], v[26:27], v[32:33], v[26:27]
	v_fma_f64 v[28:29], v[28:29], v[34:35], v[28:29]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[30:31], -v[18:19], v[24:25], 1.0
	v_fma_f64 v[32:33], -v[20:21], v[26:27], 1.0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[34:35], -v[22:23], v[28:29], 1.0
	v_fma_f64 v[24:25], v[24:25], v[30:31], v[24:25]
	v_div_scale_f64 v[30:31], s2, v[11:12], s[42:43], v[11:12]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_3) | instid1(VALU_DEP_4)
	v_fma_f64 v[26:27], v[26:27], v[32:33], v[26:27]
	v_div_scale_f64 v[32:33], s3, v[13:14], s[42:43], v[13:14]
	v_fma_f64 v[28:29], v[28:29], v[34:35], v[28:29]
	v_mul_f64 v[34:35], v[36:37], v[24:25]
	v_mul_f64 v[38:39], v[30:31], v[26:27]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mul_f64 v[40:41], v[32:33], v[28:29]
	v_fma_f64 v[18:19], -v[18:19], v[34:35], v[36:37]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[20:21], -v[20:21], v[38:39], v[30:31]
	v_fma_f64 v[22:23], -v[22:23], v[40:41], v[32:33]
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_div_fmas_f64 v[18:19], v[18:19], v[24:25], v[34:35]
	s_mov_b32 vcc_lo, s2
	v_div_fmas_f64 v[20:21], v[20:21], v[26:27], v[38:39]
	s_mov_b32 vcc_lo, s3
	s_clause 0x2
	s_load_b64 s[6:7], s[0:1], 0x60
	s_load_b256 s[20:27], s[0:1], 0x40
	s_load_b64 s[2:3], s[0:1], 0xa0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_div_fmas_f64 v[22:23], v[22:23], v[28:29], v[40:41]
	s_mov_b32 s1, 0
	v_div_fixup_f64 v[9:10], v[18:19], s[42:43], v[9:10]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_div_fixup_f64 v[11:12], v[20:21], s[42:43], v[11:12]
	v_div_fixup_f64 v[13:14], v[22:23], s[42:43], v[13:14]
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_cvt_i32_f64_e32 v24, v[9:10]
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v9, 31, v8
	v_cvt_i32_f64_e32 v12, v[11:12]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cvt_i32_f64_e32 v13, v[13:14]
	v_lshlrev_b64 v[10:11], 2, v[8:9]
	v_dual_mov_b32 v23, v9 :: v_dual_mov_b32 v22, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v14, vcc_lo, s18, v10
	v_add_co_ci_u32_e32 v15, vcc_lo, s19, v11, vcc_lo
	v_mad_u64_u32 v[18:19], null, v24, s31, v[12:13]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mad_u64_u32 v[10:11], null, v18, s5, v[13:14]
	v_mov_b32_e32 v19, v15
	v_dual_mov_b32 v11, -1 :: v_dual_mov_b32 v18, v14
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v25, v[18:19], off
	v_dual_mov_b32 v20, v22 :: v_dual_mov_b32 v21, v23
	s_or_b32 s8, s8, exec_lo
	s_or_b32 s9, s9, exec_lo
	s_mov_b32 s16, exec_lo
                                        ; implicit-def: $vgpr22_vgpr23
                                        ; implicit-def: $sgpr0
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 v25, v10
	s_cbranch_execz .LBB0_6
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 -1, v11
	s_cbranch_execz .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	global_load_b32 v11, v[6:7], off offset:4
.LBB0_5:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	v_add_co_u32 v22, vcc_lo, v20, 1
	v_add_co_ci_u32_e32 v23, vcc_lo, 0, v21, vcc_lo
	v_add_co_u32 v18, s0, v18, 4
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_3)
	v_cmp_ge_i32_e32 vcc_lo, v22, v11
	v_add_co_ci_u32_e64 v19, s0, 0, v19, s0
	s_and_not1_b32 s9, s9, exec_lo
	s_mov_b32 s0, -1
	s_and_b32 s17, vcc_lo, exec_lo
	s_and_not1_b32 s8, s8, exec_lo
	s_or_b32 s9, s9, s17
.LBB0_6:                                ; %Flow352
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_and_b32 s16, exec_lo, s9
	v_mov_b32_e32 v29, s0
	s_or_b32 s1, s16, s1
	s_and_not1_b32 s0, s4, exec_lo
	s_and_b32 s4, s8, exec_lo
	s_or_b32 s4, s0, s4
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_2
; %bb.7:                                ; %loop.exit.guard
	s_or_b32 exec_lo, exec_lo, s1
	s_and_saveexec_b32 s0, s4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_9
; %bb.8:
	v_lshlrev_b64 v[18:19], 2, v[20:21]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v18, vcc_lo, s20, v18
	v_add_co_ci_u32_e32 v19, vcc_lo, s21, v19, vcc_lo
	global_load_b32 v29, v[18:19], off
.LBB0_9:                                ; %_Z13GetLocalTetIDiiPiS_S_.exit
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mov_b32 s8, exec_lo
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u32_e32 -1, v29
	s_cbranch_execz .LBB0_34
; %bb.10:
	v_cvt_f64_i32_e32 v[18:19], v24
	v_cvt_f64_i32_e32 v[20:21], v12
	v_cvt_f64_i32_e32 v[22:23], v13
	v_mul_f64 v[31:32], 0x40240000, s[2:3]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_fma_f64 v[18:19], v[18:19], s[42:43], s[36:37]
	v_fma_f64 v[20:21], v[20:21], s[42:43], s[38:39]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f64 v[22:23], v[22:23], s[42:43], s[40:41]
	v_add_f64 v[25:26], v[18:19], s[42:43]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[27:28], v[20:21], s[42:43]
	v_add_f64 v[29:30], v[22:23], s[42:43]
	v_add_f64 v[18:19], v[18:19], -v[0:1]
	v_add_f64 v[20:21], v[20:21], -v[2:3]
	v_add_f64 v[22:23], v[22:23], -v[16:17]
	v_add_f64 v[0:1], v[25:26], -v[0:1]
	v_add_f64 v[2:3], v[27:28], -v[2:3]
	v_add_f64 v[16:17], v[29:30], -v[16:17]
	v_cmp_nlt_f64_e64 s9, v[18:19], -v[31:32]
	v_cmp_ngt_f64_e32 vcc_lo, v[18:19], v[31:32]
	v_cmp_nlt_f64_e64 s16, v[20:21], -v[31:32]
	v_cmp_ngt_f64_e64 s0, v[20:21], v[31:32]
	v_cmp_nlt_f64_e64 s17, v[22:23], -v[31:32]
	v_cmp_ngt_f64_e64 s1, v[22:23], v[31:32]
	v_cmp_nlt_f64_e64 s18, v[0:1], -v[31:32]
	v_cmp_ngt_f64_e64 s2, v[0:1], v[31:32]
	v_cmp_nlt_f64_e64 s19, v[2:3], -v[31:32]
	v_cmp_ngt_f64_e64 s3, v[2:3], v[31:32]
	v_cmp_nlt_f64_e64 s29, v[16:17], -v[31:32]
	v_cmp_ngt_f64_e64 s4, v[16:17], v[31:32]
	s_and_b32 s9, s9, vcc_lo
	s_and_b32 s0, s16, s0
	v_cndmask_b32_e64 v0, 1, 2, s9
	v_cndmask_b32_e64 v1, 1, 2, s0
	s_and_b32 s1, s17, s1
	v_cndmask_b32_e64 v3, 1, -1, s9
	v_cndmask_b32_e64 v2, 1, 2, s1
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	v_cndmask_b32_e64 v16, 1, -1, s0
	v_cndmask_b32_e64 v17, 1, -1, s1
	s_mov_b32 s9, 0
	v_cndmask_b32_e64 v20, 0, 1, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, 0, v1
	v_cndmask_b32_e64 v22, 0, 1, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, 0, v2
	v_cndmask_b32_e64 v25, 0, 1, vcc_lo
	s_and_b32 vcc_lo, s18, s2
	s_and_b32 s0, s19, s3
	v_dual_cndmask_b32 v11, -1, v3 :: v_dual_cndmask_b32 v20, 0, v20
	s_and_b32 s1, s29, s4
	v_cndmask_b32_e64 v18, -1, v16, s0
	v_cndmask_b32_e64 v19, -1, v17, s1
	v_add_co_ci_u32_e32 v21, vcc_lo, 0, v0, vcc_lo
	v_cndmask_b32_e64 v22, 0, v22, s0
	v_add_co_ci_u32_e64 v23, vcc_lo, 0, v1, s0
	v_cndmask_b32_e64 v25, 0, v25, s1
	v_add_co_ci_u32_e64 v26, vcc_lo, 0, v2, s1
	s_mov_b32 s4, 0
.LBB0_11:                               ; %.preheader224
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_12 Depth 2
                                        ;       Child Loop BB0_13 Depth 3
                                        ;         Child Loop BB0_16 Depth 4
	s_cmp_eq_u32 s9, 1
	s_mov_b32 s16, 0
	s_cselect_b32 vcc_lo, -1, 0
	s_cmp_eq_u32 s9, 2
	v_cndmask_b32_e32 v0, v20, v11, vcc_lo
	s_cselect_b32 s0, -1, 0
	s_mov_b32 s18, 0
                                        ; implicit-def: $sgpr17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v0, v0, 1, s0
	v_add_nc_u32_e32 v0, v0, v24
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_lo_u32 v27, v0, s31
	v_cmp_lt_i32_e32 vcc_lo, -1, v0
	v_cmp_gt_i32_e64 s0, s30, v0
.LBB0_12:                               ; %.preheader223
                                        ;   Parent Loop BB0_11 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_13 Depth 3
                                        ;         Child Loop BB0_16 Depth 4
	s_add_i32 s19, s18, s9
	s_cmp_eq_u32 s18, 1
	s_mov_b32 s29, 0
	s_cselect_b32 s1, -1, 0
	s_cmp_eq_u32 s18, 2
	v_cndmask_b32_e64 v0, v22, v18, s1
	s_cselect_b32 s1, -1, 0
	s_mov_b32 s34, 0
	v_mov_b32_e32 v29, -1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v0, v0, 1, s1
	v_add_nc_u32_e32 v0, v0, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v1, v0, v27
	v_cmp_lt_i32_e64 s2, -1, v0
	v_cmp_gt_i32_e64 s1, s31, v0
	v_mul_lo_u32 v28, v1, s5
	s_delay_alu instid0(VALU_DEP_3)
	s_and_b32 s33, vcc_lo, s2
.LBB0_13:                               ;   Parent Loop BB0_11 Depth=1
                                        ;     Parent Loop BB0_12 Depth=2
                                        ; =>    This Loop Header: Depth=3
                                        ;         Child Loop BB0_16 Depth 4
	s_sub_i32 s2, 0, s34
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s19, s2
	s_cbranch_scc1 .LBB0_27
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=3
	s_cmp_eq_u32 s34, 1
	s_cselect_b32 s2, -1, 0
	s_cmp_eq_u32 s34, 2
	v_cndmask_b32_e64 v0, v25, v19, s2
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cndmask_b32_e64 v0, v0, 1, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v0, 10 :: v_dual_add_nc_u32 v1, v0, v13
	v_cmp_lt_i32_e64 s2, -1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_and_b32 s3, s33, s2
	v_cmp_gt_i32_e64 s2, s5, v1
	s_and_b32 s3, s0, s3
	s_and_b32 s3, s3, s1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s3, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s35, s2
	s_cbranch_execz .LBB0_24
; %bb.15:                               ;   in Loop: Header=BB0_13 Depth=3
	v_add_nc_u32_e32 v10, v1, v28
	v_dual_mov_b32 v30, -1 :: v_dual_mov_b32 v17, v9
	v_dual_mov_b32 v0, v14 :: v_dual_mov_b32 v1, v15
	v_mov_b32_e32 v16, v8
	s_mov_b32 s36, 0
                                        ; implicit-def: $sgpr37
                                        ; implicit-def: $sgpr39
                                        ; implicit-def: $sgpr38
.LBB0_16:                               ;   Parent Loop BB0_11 Depth=1
                                        ;     Parent Loop BB0_12 Depth=2
                                        ;       Parent Loop BB0_13 Depth=3
                                        ; =>      This Inner Loop Header: Depth=4
	global_load_b32 v29, v[0:1], off
	v_dual_mov_b32 v2, v16 :: v_dual_mov_b32 v3, v17
	s_or_b32 s38, s38, exec_lo
	s_or_b32 s39, s39, exec_lo
	s_mov_b32 s40, exec_lo
                                        ; implicit-def: $vgpr16_vgpr17
                                        ; implicit-def: $sgpr3
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 v29, v10
	s_cbranch_execz .LBB0_20
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=4
	s_mov_b32 s3, exec_lo
	v_cmpx_eq_u32_e32 -1, v30
	s_cbranch_execz .LBB0_19
; %bb.18:                               ;   in Loop: Header=BB0_16 Depth=4
	global_load_b32 v30, v[6:7], off offset:4
.LBB0_19:                               ;   in Loop: Header=BB0_16 Depth=4
	s_or_b32 exec_lo, exec_lo, s3
	v_add_co_u32 v16, s2, v2, 1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v17, s2, 0, v3, s2
	v_add_co_u32 v0, s3, v0, 4
	s_waitcnt vmcnt(0)
	v_cmp_ge_i32_e64 s2, v16, v30
	v_add_co_ci_u32_e64 v1, s3, 0, v1, s3
	s_and_not1_b32 s39, s39, exec_lo
	s_mov_b32 s3, -1
	s_delay_alu instid0(VALU_DEP_2)
	s_and_b32 s2, s2, exec_lo
	s_and_not1_b32 s38, s38, exec_lo
	s_or_b32 s39, s39, s2
.LBB0_20:                               ; %Flow343
                                        ;   in Loop: Header=BB0_16 Depth=4
	s_or_b32 exec_lo, exec_lo, s40
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, exec_lo, s39
	v_mov_b32_e32 v29, s3
	s_or_b32 s36, s2, s36
	s_and_not1_b32 s2, s37, exec_lo
	s_and_b32 s3, s38, exec_lo
	s_or_b32 s37, s2, s3
	s_and_not1_b32 exec_lo, exec_lo, s36
	s_cbranch_execnz .LBB0_16
; %bb.21:                               ; %loop.exit.guard339
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s36
	s_and_saveexec_b32 s2, s37
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s3, exec_lo, s2
	s_cbranch_execz .LBB0_23
; %bb.22:                               ;   in Loop: Header=BB0_13 Depth=3
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v0, s2, s20, v0
	v_add_co_ci_u32_e64 v1, s2, s21, v1, s2
	global_load_b32 v29, v[0:1], off
.LBB0_23:                               ; %_Z13GetLocalTetIDiiPiS_S_.exit202
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s3
	s_waitcnt vmcnt(0)
	v_cmp_ne_u32_e64 s2, -1, v29
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v0, 0, 1, s2
	v_lshlrev_b32_e32 v0, 3, v0
.LBB0_24:                               ; %Flow344
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s35
	s_mov_b32 s3, -1
	s_mov_b32 s35, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e32 10, v0
; %bb.25:                               ; %LeafBlock
                                        ;   in Loop: Header=BB0_13 Depth=3
	v_cmp_eq_u32_e64 s2, 0, v0
	s_delay_alu instid0(VALU_DEP_1)
	s_or_not1_b32 s3, s2, exec_lo
; %bb.26:                               ; %Flow346
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s35
	s_branch .LBB0_28
.LBB0_27:                               ;   in Loop: Header=BB0_13 Depth=3
	s_mov_b32 s3, -1
.LBB0_28:                               ; %Flow345
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_mov_b32 s2, -1
	s_and_saveexec_b32 s35, s3
; %bb.29:                               ;   in Loop: Header=BB0_13 Depth=3
	s_add_i32 s34, s34, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_eq_u32_e64 s2, s34, v26
	s_or_not1_b32 s2, s2, exec_lo
; %bb.30:                               ; %Flow347
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s35
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, exec_lo, s2
	s_or_b32 s29, s2, s29
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s29
	s_cbranch_execnz .LBB0_13
; %bb.31:                               ;   in Loop: Header=BB0_12 Depth=2
	s_or_b32 exec_lo, exec_lo, s29
	s_add_i32 s18, s18, 1
	v_cmp_ne_u32_e64 s1, -1, v29
	v_cmp_ge_u32_e64 s2, s18, v23
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_or_b32 s2, s1, s2
	v_cmp_eq_u32_e64 s1, -1, v29
	s_and_b32 s2, exec_lo, s2
	s_or_b32 s16, s2, s16
	s_and_not1_b32 s2, s17, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s1, s1, exec_lo
	s_or_b32 s17, s2, s1
	s_and_not1_b32 exec_lo, exec_lo, s16
	s_cbranch_execnz .LBB0_12
; %bb.32:                               ;   in Loop: Header=BB0_11 Depth=1
	s_or_b32 exec_lo, exec_lo, s16
	s_add_i32 s9, s9, 1
	s_xor_b32 s0, s17, -1
	v_cmp_ge_u32_e32 vcc_lo, s9, v21
	s_or_b32 s0, s0, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, exec_lo, s0
	s_or_b32 s4, s0, s4
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s4
	s_cbranch_execnz .LBB0_11
; %bb.33:                               ; %Flow349
	s_or_b32 exec_lo, exec_lo, s4
.LBB0_34:                               ; %Flow350
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	s_or_b32 exec_lo, exec_lo, s8
	v_ashrrev_i32_e32 v11, 31, v10
	v_add_co_u32 v2, vcc_lo, s10, v4
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v5, vcc_lo
	v_lshlrev_b64 v[0:1], 2, v[10:11]
	global_store_b32 v[2:3], v29, off
	v_add_co_u32 v0, vcc_lo, s14, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s15, v1, vcc_lo
	v_add_co_u32 v6, vcc_lo, s12, v4
	v_add_co_ci_u32_e32 v7, vcc_lo, s13, v5, vcc_lo
	global_load_b32 v0, v[0:1], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v1, 31, v0
	global_store_b32 v[6:7], v0, off
	v_lshlrev_b64 v[1:2], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s22, v1
	v_add_co_ci_u32_e32 v4, vcc_lo, s23, v2, vcc_lo
	global_load_b32 v5, v[3:4], off glc
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, s28, v5
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_41
; %bb.35:
	v_sub_nc_u32_e32 v5, s28, v5
	s_mov_b32 s0, exec_lo
	global_atomic_add_u32 v6, v[3:4], v5, off glc
	s_waitcnt vmcnt(0)
	v_cmpx_le_i32_e64 s28, v6
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_37
; %bb.36:
	v_sub_nc_u32_e32 v0, 0, v5
                                        ; implicit-def: $vgpr1_vgpr2
	global_atomic_add_u32 v[3:4], v0, off
                                        ; implicit-def: $vgpr0
.LBB0_37:                               ; %Flow
	s_and_not1_saveexec_b32 s0, s0
	s_cbranch_execz .LBB0_41
; %bb.38:
	s_mov_b32 s1, exec_lo
	s_mov_b32 s0, exec_lo
	v_mbcnt_lo_u32_b32 v3, s1, 0
                                        ; implicit-def: $vgpr4
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v3
	s_cbranch_execz .LBB0_40
; %bb.39:
	s_bcnt1_i32_b32 s1, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v5, s1
	global_atomic_add_u32 v4, v4, v5, s[6:7] glc
.LBB0_40:
	s_or_b32 exec_lo, exec_lo, s0
	s_waitcnt vmcnt(0)
	v_readfirstlane_b32 s0, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v3, s0, v3
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 2, v[3:4]
	v_add_co_u32 v4, vcc_lo, s24, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s25, v5, vcc_lo
	v_add_co_u32 v1, vcc_lo, s26, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s27, v2, vcc_lo
	global_store_b32 v[4:5], v0, off
	global_store_b32 v[1:2], v3, off
.LBB0_41:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 424
		.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 42
		.amdhsa_next_free_sgpr 44
		.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	_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd, .Lfunc_end0-_Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2520
; NumSgprs: 46
; NumVgprs: 42
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 5
; VGPRBlocks: 5
; NumSGPRsForWavesPerEU: 46
; NumVGPRsForWavesPerEU: 42
; Occupancy: 16
; WaveLimiterHint : 1
; 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
	.protected	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii ; -- Begin function _Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.globl	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
	.p2align	8
	.type	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii,@function
_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii: ; @_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x44
	s_load_b64 s[2:3], s[0:1], 0x30
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_cmp_gt_i32_e32 vcc_lo, s3, v1
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b128 s[12:15], s[0:1], 0x20
	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 v0, vcc_lo, s10, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v1, vcc_lo
	global_load_b32 v0, v[0:1], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s12, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s13, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_add_co_u32 v2, vcc_lo, s14, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s15, v3, vcc_lo
	global_load_b32 v4, v[4:5], off
	global_load_b32 v5, v[2:3], off
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[2:3], null, v5, s2, v[4:5]
	v_mov_b32_e32 v4, 1
	s_delay_alu instid0(VALU_DEP_2) | 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 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_atomic_add_u32 v2, v[2:3], v4, off glc
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v2, off
.LBB1_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.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_end1:
	.size	_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii, .Lfunc_end1-_Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 312
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 1
; 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
	.protected	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii ; -- Begin function _Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.globl	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
	.p2align	8
	.type	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii,@function
_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii: ; @_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x4c
	s_load_b64 s[2:3], s[0:1], 0x38
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_cmp_gt_i32_e32 vcc_lo, s3, v1
	s_and_saveexec_b32 s3, vcc_lo
	s_cbranch_execz .LBB2_2
; %bb.1:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_load_b256 s[12:19], s[0:1], 0x20
	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 v0, vcc_lo, s10, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v1, vcc_lo
	global_load_b32 v0, v[0:1], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[1:2], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s12, v1
	v_add_co_ci_u32_e32 v4, vcc_lo, s13, v2, vcc_lo
	v_add_co_u32 v5, vcc_lo, s8, v1
	v_add_co_ci_u32_e32 v6, vcc_lo, s9, v2, vcc_lo
	global_load_b32 v3, v[3:4], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v4, 31, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	v_add_co_u32 v3, vcc_lo, s14, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s15, v4, vcc_lo
	v_add_co_u32 v1, vcc_lo, s6, v1
	global_load_b32 v5, v[5:6], off
	global_load_b32 v6, v[3:4], off
	v_add_co_ci_u32_e32 v2, vcc_lo, s7, v2, vcc_lo
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[3:4], null, v6, s2, v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v4, vcc_lo
	global_load_b32 v1, v[1:2], off
	global_load_b32 v2, v[3:4], off
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v1, v1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s16, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s17, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
.LBB2_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 320
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 20
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii, .Lfunc_end2-_Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 22
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 22
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 1
; 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
      - .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
      - .address_space:  global
        .offset:         88
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         96
        .size:           8
        .value_kind:     global_buffer
      - .offset:         104
        .size:           4
        .value_kind:     by_value
      - .offset:         108
        .size:           4
        .value_kind:     by_value
      - .offset:         112
        .size:           4
        .value_kind:     by_value
      - .offset:         116
        .size:           4
        .value_kind:     by_value
      - .offset:         120
        .size:           4
        .value_kind:     by_value
      - .offset:         128
        .size:           8
        .value_kind:     by_value
      - .offset:         136
        .size:           8
        .value_kind:     by_value
      - .offset:         144
        .size:           8
        .value_kind:     by_value
      - .offset:         152
        .size:           8
        .value_kind:     by_value
      - .offset:         160
        .size:           8
        .value_kind:     by_value
      - .offset:         168
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         172
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         176
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         180
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         182
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         184
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         186
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         188
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         190
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         208
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         216
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         224
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         232
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 424
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd
    .private_segment_fixed_size: 0
    .sgpr_count:     46
    .sgpr_spill_count: 0
    .symbol:         _Z25CollectActiveBlocksKernelPiS_PdS_S_S_S_S_S_S_S_S_S_iiiiiddddd.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     42
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .offset:         48
        .size:           4
        .value_kind:     by_value
      - .offset:         52
        .size:           4
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z38GetNumOfParticlesByStageInBlocksKernelPiS_S_S_S_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .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
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .offset:         60
        .size:           4
        .value_kind:     by_value
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         68
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         72
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         76
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         78
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         80
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         82
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         84
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         86
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         120
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         128
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 320
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     22
    .sgpr_spill_count: 0
    .symbol:         _Z30CollectParticlesToBlocksKernelPiS_S_S_S_S_S_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
