/// Assignment 06: Local Register Memory
///
/// Author: Justin Renga

/// Two Kernels -- Same Operation
///
/// Operation: Take an integer (randomly generated) from two input arrays,
///            take their modulo (input1 % input2) and store the result.
///
/// Kernel 1: Use the global memory to perform the operation (using local memory as an
///           intermediate.

/// Kernel 2: Transfer the data from global memory to local memory, perform the operation,
///           then transfer back to global memory

// Bibliography (source-list):
// [1] register.cu
// [2] http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__EVENT.html
// [3] https://devblogs.nvidia.com/how-implement-performance-metrics-cuda-cc/

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

// Declare constant definitions here
#define UINT_SIZE sizeof(unsigned int)
#define INITIAL_DATA 0
#define THREAD_MIN 64
#define THREAD_MAX 4096

// Declare device constant memory here
__constant__ static unsigned int ADDITIVE_VALUES[16];

// Declare global host data here:
unsigned int initializedRNG;

// ---------------------------------------- DEVICE OPERATIONS -----------------------------------------

/// @brief GPU Kernel that utilizes only global data to perform a simple modular division operation. To
///        be used on conjunction with localModularDivide for comparison metrics. Algorithm performed:
///        output = input1 % input2
///
/// @param [ in] input1    The first of the two input arrays to be used in the modular division operation
/// @param [ in] input2    The second of the two input arrays to be used in the modular division operation
/// @param [out] output    The array containing the results of the modular division operation
__global__ void globalModularDivide(const unsigned int* const input1,
                                    const unsigned int* const input2,
                                          unsigned int* const output)
{
  // Compute the current thread index
  unsigned int thread_index = (blockIdx.x * blockDim.x) + threadIdx.x;
  
  // Perform the modular operation and store in the output array (without using local memory)
  output[thread_index] = input1[thread_index] % input2[thread_index];
}

/// @brief GPU Kernel that offloads the computations from global data completely, then re-inserts
///        the data back into global memory. To be used with globalModularDivide for comparison metrics.
///        Algorithm performed: output = input1 % input2
///
/// @param [ in] input1    The first of the two input arrays to be used in the modular division operation
/// @param [ in] input2    The second of the two input arrays to be used in the modular division operation
/// @param [out] output    The array containing the results of the modular division operation
__global__ void localModularDivide(const unsigned int* const input1,
                              const unsigned int* const input2,
                                    unsigned int* const output)
{
  // Compute the current thread index
  unsigned int thread_index = (blockIdx.x * blockDim.x) + threadIdx.x;
  
  // Create local registers to store the intermediate data for the algorithm
  unsigned int input1_local = input1[thread_index];
  unsigned int input2_local = input2[thread_index];
  
  // Create a local register that will store the result of the algorithm
  unsigned int output_local = input1_local % input2_local;
  
  // Store the result of the algorithm into the global array
  output[thread_index] = output_local;
}

__global__ void add_values_shared(unsigned int* deviceData, const unsigned int elementCount)
{
  // Declare externally defined shared memory
  __shared__ unsigned int sharedMemory[THREAD_MAX];
  
  // Compute the current thread index
  unsigned int threadIndex = (blockIdx.x * blockDim.x) + threadIdx.x;
  
  // Copy data from the device to the shared memory pool (and perform an operation using constant memory)
  sharedMemory[threadIndex] = deviceData[threadIndex];
  
  // Perform thread synchronization
  __syncthreads();
  
  unsigned int exponentPrimer = threadIndex % 2;
  
  for (unsigned int i = 0; i < 16; ++i)
  {
    unsigned int currentConstant =  ADDITIVE_VALUES[i];
    
    float value = powf(-1, exponentPrimer) * currentConstant;
    
    sharedMemory[threadIndex] += value;
  }
  
  __syncthreads();
  
  // Copy the data from the shared memory back to the device
  deviceData[threadIndex] = sharedMemory[elementCount - threadIndex - 1];
}

// ----------------------------------------- HOST OPERATIONS -----------------------------------------

// @brief Initialize the Random number generator and ensure it only initializes one time
__host__ void initializeRandomNumbers()
{
  if (initializedRNG == 0)
  {
    srand(time(NULL));
    initializedRNG = 1;
  }
}

// @brief Generates a series of random numbers for the provided array, given the number of desired numbers
//        and the maximum (exclusive) value.
//
// @param [inout] data         The data array that will contain the random numbers
// @param [   in] elementCount The number of elements to store in the data array
// @param [   in] max          The maximum random number to use (exclusive)
__host__ void generateRandomNumbers(      unsigned int* data,
                                    const unsigned int  elementCount,
                                    const unsigned int  max)
{
  // Check to make sure the RNG has been initialized
  if (initializedRNG == 0)
  {
    // If not, initialize the RNG
    initializeRandomNumbers();
  }
  
  // Generate random data between 0 and the provided maximum value
  for (unsigned int i = 0; i < elementCount; ++i)
  {
    data[i] = rand() % max;
  }
}

__host__ void run_gpu_algorithm(int blockCount, int threadCount)
{
  // Step 1: Compute the size of the device array based on the block and thread/per block counts
  unsigned int elementCount = threadCount * blockCount;
  unsigned int deviceSize   = UINT_SIZE   * elementCount;
  
  // Step 2: Allocate the necessary host memory (two input arrays and an output array
  //         (use malloc for the input, and calloc for the output since we want to modify
  //          the contents of the input PRIOR to executing the GPU kernels, but we want to
  //          initialize the output to 0 before copying the device output over)
  unsigned int* hostInput1 = (unsigned int*) malloc(deviceSize);
  unsigned int* hostInput2 = (unsigned int*) malloc(deviceSize);
  unsigned int* hostOutput = (unsigned int*) calloc(elementCount, UINT_SIZE);
  
  // Step 3: Populate the input arrays with random data, using the device size as the maximum value
  //         (the device size is used purely as a convenience number, and to ensure that the maximum
  //          value has the potential to change between each run)
  generateRandomNumbers(hostInput1, elementCount, deviceSize);
  generateRandomNumbers(hostInput2, elementCount, deviceSize);
  
  // Step 4: Allocate the GPU memory arrays
  unsigned int* deviceInput1;
  unsigned int* deviceInput2;
  unsigned int* deviceOutput;
  
  cudaMalloc((void**)&deviceInput1, deviceSize);
  cudaMalloc((void**)&deviceInput2, deviceSize);
  cudaMalloc((void**)&deviceOutput, deviceSize);
  
  // Step 5: Populate the GPU input with the host input data
  cudaMemcpy(deviceInput1, hostInput1, deviceSize, cudaMemcpyHostToDevice);
  cudaMemcpy(deviceInput2, hostInput2, deviceSize, cudaMemcpyHostToDevice);
  
  // Step 6: Set the GPU output with all zeros
  cudaMemset(deviceOutput, INITIAL_DATA, deviceSize);
  
  // Step 7: Initialize the CUDA event start/stop timers for benchmarking
  cudaEvent_t stopLocalEvent;
  cudaEvent_t stopGlobalEvent;
  cudaEvent_t stopSharedEvent;
  cudaEvent_t startLocalEvent;
  cudaEvent_t startGlobalEvent;
  cudaEvent_t startSharedEvent;

  cudaEventCreate(&stopLocalEvent);  
  cudaEventCreate(&stopGlobalEvent);
  cudaEventCreate(&stopSharedEvent);
  cudaEventCreate(&startLocalEvent);  
  cudaEventCreate(&startGlobalEvent);
  cudaEventCreate(&startSharedEvent);
  
  // Step 8: Invoke the global algorithm kernel with recording enabled
  cudaEventRecord(startGlobalEvent);
  globalModularDivide<<<blockCount, threadCount>>>(deviceInput1, deviceInput2, deviceOutput);
  cudaEventRecord(stopGlobalEvent);
  
  cudaThreadSynchronize();
  cudaGetLastError();
  
  // Step 9: Retrieve the output from the global algorithm kernel
  cudaMemcpy(hostOutput, deviceOutput, deviceSize, cudaMemcpyDeviceToHost);
  
  // Step 10: Obtain the ms duration for the global algorithm
  cudaEventSynchronize(stopGlobalEvent);
  
  float globalTimeMS = 0.0f;
  cudaEventElapsedTime(&globalTimeMS, startGlobalEvent, stopGlobalEvent);
  
  // Step 11: Invoke the local algorithm kernel with recording enabled
  cudaEventRecord(startLocalEvent);
  localModularDivide<<<blockCount, threadCount>>>(deviceInput1, deviceInput2, deviceOutput);
  cudaEventRecord(stopLocalEvent);
  
  cudaThreadSynchronize();
  cudaGetLastError();
  
  // Step 12: Retrieve the output from the local algorithm kernel
  cudaMemcpy(hostOutput, deviceOutput, deviceSize, cudaMemcpyDeviceToHost);
  
  // Step 13: Obtain the ms duration for the local algorithm
  cudaEventSynchronize(stopLocalEvent);
  
  float localTimeMS = 0.0f;
  cudaEventElapsedTime(&localTimeMS, startLocalEvent, stopLocalEvent);
  
  // Step 14: Upload the constant memory values to the device:
  unsigned int* constantMemory = (unsigned int*) malloc(deviceSize);
  generateRandomNumbers(constantMemory, elementCount, deviceSize);
  
  cudaMemcpyToSymbol(ADDITIVE_VALUES, constantMemory, UINT_SIZE * 16);
  
  // Step 15: Invoke the shared algorithm kernel with recording enabled
  cudaEventRecord(startSharedEvent);
  add_values_shared<<<blockCount, threadCount>>>(deviceOutput, elementCount);
  cudaEventRecord(stopSharedEvent);
  
  cudaThreadSynchronize();
  cudaGetLastError();
  
  // Step 16: Retrieve the output from the global algorithm kernel
  cudaMemcpy(hostOutput, deviceOutput, deviceSize, cudaMemcpyDeviceToHost);
  
  // Step 17: Obtain the ms duration for the global algorithm
  cudaEventSynchronize(stopSharedEvent);
  
  float sharedTimeMS = 0.0f;
  cudaEventElapsedTime(&sharedTimeMS, startSharedEvent, stopSharedEvent);

  // Step 18: Display the results of the two operations
  printf("Block Count: %d\t Threads Per Block: %d\t", blockCount, threadCount);
  printf("Global Duration: %2f ms\t", globalTimeMS);
  printf("Shared Duration: %2f ms\t", sharedTimeMS);
  printf("Local  Duration: %2f ms\n", localTimeMS );
  
  // Step 19: Free device memory:
  cudaFree(deviceInput1);
  cudaFree(deviceInput2);
  cudaFree(deviceOutput);
  
  // Step 20: Free host memory
  free(hostInput1);
  free(hostInput2);
  free(hostOutput);
  
  // Step 21: Free constant memory
  free(constantMemory);
}

/// @brief determine if the provided number is a power of two
///
/// @param [in] number   The number to validate
///
/// @return True if the provided number is a power of two, false otherwise
__host__ bool isPowerOfTwo(const int number)
{
  // Initialize a mask a 00000000 00000000 00000000 00000001 (on 32-bit machines)
  int mask = 0x1;
  
  // Iterate over each of the bits in the mask, left shifting by one to
  // iterate to the next power of two
  for (unsigned int i = 0; i < sizeof(int) * 8; ++i, mask = mask << 1)
  {
   
    // Compute the resulting masked value
    int maskedValue = number & mask;
    
    // If the computed value is non-zero and is not the provided number,
    // the provided number is not a power of two:
    //
    // For example, 3 would not be a power of two:
    //           3 = 00000000 00000000 00000000 00000011
    //        mask = 00000000 00000000 00000000 00000010
    // maskedValue = 00000000 00000000 00000000 00000010
    // makedValue is non-zero (2), but is also not provided number (2 != 3)
    if (maskedValue != 0 && maskedValue != number)
    {
      return false;
    }
    
    // If the maskedValue is the provided number, then we've confirmed that the
    // value is a power of two
    if (maskedValue == number)
    {
      return true;
    }
  }
  
  // Return false if we've exhausted all possible powers of two the computer can handle
  return false;
}

// @brief Display the proper program usage
__host__ void showUsage()
{
  printf("Invalid arguments provided. Please see the usage below:\n");
  printf("  module_6_jrenga2.exe <bc> <tpb>\n");
  printf("  bc  - The maximum number of blocks to run with. Must be a positive integer and a power of two.\n");
  printf("  tpb - The maximum number of threads per blocks. Must be a positive integer and a power of two.\n");
  printf("NOTE: The maximum number of threads (bc * tpb) must be greater than %d \n", THREAD_MIN);
  printf("      and less than %d.\n", THREAD_MAX);
  printf(" ** TERMINATING **\n");
}

// @brief Main Entry-Point
int main(int argc, char* argv[])
{
 // 1. Check the number of arguments.
  if (argc != 3)
  {
    showUsage();
    return EXIT_FAILURE;
  }

  // 2. Attempt to retrieve the integer values of the parameters
  //    (a value less than or equal to 0 is considered invalid)
  int numBlocks = atoi(argv[1]);
  if (numBlocks <= 0 || !isPowerOfTwo(numBlocks))
  {
    showUsage();
    return EXIT_FAILURE;
  }

  int numThreads = atoi(argv[2]);
  if (numThreads <= 0 || !isPowerOfTwo(numThreads))
  {
    showUsage();
    return EXIT_FAILURE;
  }
  
  int totalThreads = numBlocks * numThreads;

  // 2.5 Check to see if the minimum number of threads has been achieved (64)
  if (totalThreads < THREAD_MIN || totalThreads > THREAD_MAX)
  {
    showUsage();
    return EXIT_FAILURE;
  }
  
  // Do some pre-processing to set up the random number generation
  initializedRNG = false;
  
  // Initialize the random numbers
  initializeRandomNumbers();
  
  // Iterate from 1 -> numBlocks and 1 -> numThreads to perform metrics on numerous configurations
  for (unsigned int blockCount = 1; blockCount <= numBlocks; blockCount = blockCount << 1)
  {
    for (unsigned int threadCount = 1; threadCount <= numThreads; threadCount = threadCount << 1)
    {
      run_gpu_algorithm(blockCount, threadCount);
    }
  }
  
  return EXIT_SUCCESS;
}

	.file	"tmpxft_003003b9_00000000-6_module_6_jrenga2.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	_Z23initializeRandomNumbersv
	.type	_Z23initializeRandomNumbersv, @function
_Z23initializeRandomNumbersv:
.LFB2027:
	.cfi_startproc
	endbr64
	cmpl	$0, initializedRNG(%rip)
	jne	.L5
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%edi, %edi
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	movl	$1, initializedRNG(%rip)
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
.L5:
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z23initializeRandomNumbersv, .-_Z23initializeRandomNumbersv
	.globl	_Z21generateRandomNumbersPjjj
	.type	_Z21generateRandomNumbersPjjj, @function
_Z21generateRandomNumbersPjjj:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	cmpl	$0, initializedRNG(%rip)
	jne	.L10
	call	_Z23initializeRandomNumbersv
.L10:
	xorl	%ebp, %ebp
.L11:
	cmpq	%rbx, %rbp
	je	.L14
	call	rand@PLT
	xorl	%edx, %edx
	divl	%r12d
	movl	%edx, 0(%r13,%rbp,4)
	incq	%rbp
	jmp	.L11
.L14:
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z21generateRandomNumbersPjjj, .-_Z21generateRandomNumbersPjjj
	.globl	_Z12isPowerOfTwoi
	.type	_Z12isPowerOfTwoi, @function
_Z12isPowerOfTwoi:
.LFB2030:
	.cfi_startproc
	endbr64
	cmpl	$1, %edi
	seta	%al
	andb	%dil, %al
	jne	.L20
	cmpl	$1, %edi
	jbe	.L22
	movl	$32, %ecx
	movl	$1, %edx
.L17:
	addl	%edx, %edx
	decl	%ecx
	je	.L27
	movl	%edi, %esi
	andl	%edx, %esi
	je	.L23
	cmpl	%esi, %edi
	je	.L22
	ret
.L23:
	cmpl	%esi, %edi
	jne	.L17
	jmp	.L22
.L27:
	ret
.L20:
	xorl	%eax, %eax
	ret
.L22:
	movb	$1, %al
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z12isPowerOfTwoi, .-_Z12isPowerOfTwoi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Invalid arguments provided. Please see the usage below:\n"
.LC1:
	.string	"  module_6_jrenga2.exe <bc> <tpb>\n"
.LC2:
	.string	"  bc  - The maximum number of blocks to run with. Must be a positive integer and a power of two.\n"
.LC3:
	.string	"  tpb - The maximum number of threads per blocks. Must be a positive integer and a power of two.\n"
.LC4:
	.string	"NOTE: The maximum number of threads (bc * tpb) must be greater than %d \n"
.LC5:
	.string	"      and less than %d.\n"
.LC6:
	.string	" ** TERMINATING **\n"
	.text
	.globl	_Z9showUsagev
	.type	_Z9showUsagev, @function
_Z9showUsagev:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$64, %edx
	leaq	.LC4(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$4096, %edx
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	movl	$2, %edi
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2031:
	.size	_Z9showUsagev, .-_Z9showUsagev
	.globl	_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj
	.type	_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj, @function
_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z19globalModularDividePKjS0_Pj(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L30:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj, .-_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj
	.globl	_Z19globalModularDividePKjS0_Pj
	.type	_Z19globalModularDividePKjS0_Pj, @function
_Z19globalModularDividePKjS0_Pj:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj
	.cfi_endproc
.LFE2058:
	.size	_Z19globalModularDividePKjS0_Pj, .-_Z19globalModularDividePKjS0_Pj
	.globl	_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj
	.type	_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj, @function
_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z18localModularDividePKjS0_Pj(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L35:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj, .-_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj
	.globl	_Z18localModularDividePKjS0_Pj
	.type	_Z18localModularDividePKjS0_Pj, @function
_Z18localModularDividePKjS0_Pj:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj
	.cfi_endproc
.LFE2060:
	.size	_Z18localModularDividePKjS0_Pj, .-_Z18localModularDividePKjS0_Pj
	.globl	_Z38__device_stub__Z17add_values_sharedPjjPjj
	.type	_Z38__device_stub__Z17add_values_sharedPjjPjj, @function
_Z38__device_stub__Z17add_values_sharedPjjPjj:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z17add_values_sharedPjj(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L40:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z38__device_stub__Z17add_values_sharedPjjPjj, .-_Z38__device_stub__Z17add_values_sharedPjjPjj
	.globl	_Z17add_values_sharedPjj
	.type	_Z17add_values_sharedPjj, @function
_Z17add_values_sharedPjj:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z17add_values_sharedPjjPjj
	.cfi_endproc
.LFE2062:
	.size	_Z17add_values_sharedPjj, .-_Z17add_values_sharedPjj
	.section	.rodata.str1.1
.LC8:
	.string	"Block Count: %d\t Threads Per Block: %d\t"
.LC9:
	.string	"Global Duration: %2f ms\t"
.LC10:
	.string	"Shared Duration: %2f ms\t"
.LC11:
	.string	"Local  Duration: %2f ms\n"
	.text
	.globl	_Z17run_gpu_algorithmii
	.type	_Z17run_gpu_algorithmii, @function
_Z17run_gpu_algorithmii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%esi, %r13d
	imull	%edi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leal	0(,%r13,4), %ebx
	movq	%rbx, %rdi
	movq	%rbx, %r15
	subq	$152, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movl	%r13d, %edi
	movl	$4, %esi
	movq	%rax, 16(%rsp)
	call	calloc@PLT
	movl	%ebx, %edx
	movl	%r13d, %esi
	movq	%r14, %rdi
	movq	%rax, 8(%rsp)
	call	_Z21generateRandomNumbersPjjj
	movq	16(%rsp), %rdi
	movl	%ebx, %edx
	movl	%r13d, %esi
	call	_Z21generateRandomNumbersPjjj
	leaq	40(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rsi
	movq	48(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	movq	%rbx, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	88(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	96(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	104(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	96(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%r12d, 124(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	%ebp, 112(%rsp)
	movq	%rax, 128(%rsp)
	movl	132(%rsp), %ecx
	movq	%rax, 116(%rsp)
	movq	124(%rsp), %rdx
	movq	112(%rsp), %rdi
	movl	120(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z45__device_stub__Z19globalModularDividePKjS0_PjPKjS0_Pj
.L46:
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	cudaThreadSynchronize@PLT
	call	cudaGetLastError@PLT
	movq	56(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	72(%rsp), %rdx
	movq	96(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movl	$0x00000000, 32(%rsp)
	call	cudaEventElapsedTime@PLT
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%r12d, 124(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	%ebp, 112(%rsp)
	movq	%rax, 128(%rsp)
	movl	132(%rsp), %ecx
	movq	%rax, 116(%rsp)
	movq	124(%rsp), %rdx
	movq	112(%rsp), %rdi
	movl	120(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L47
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z44__device_stub__Z18localModularDividePKjS0_PjPKjS0_Pj
.L47:
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	cudaThreadSynchronize@PLT
	call	cudaGetLastError@PLT
	movq	56(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	64(%rsp), %rdx
	movq	88(%rsp), %rsi
	leaq	36(%rsp), %rdi
	movl	$0x00000000, 36(%rsp)
	call	cudaEventElapsedTime@PLT
	movq	%rbx, %rdi
	call	malloc@PLT
	movl	%r15d, %edx
	movl	%r13d, %esi
	movq	%rax, %rdi
	movq	%rax, 24(%rsp)
	call	_Z21generateRandomNumbersPjjj
	movq	24(%rsp), %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	movl	$64, %edx
	leaq	_ZL15ADDITIVE_VALUES(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	movq	104(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%r12d, 124(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	%ebp, 112(%rsp)
	movq	%rax, 128(%rsp)
	movl	132(%rsp), %ecx
	movq	%rax, 116(%rsp)
	movq	124(%rsp), %rdx
	movq	112(%rsp), %rdi
	movl	120(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L48
	movq	56(%rsp), %rdi
	movl	%r13d, %esi
	call	_Z38__device_stub__Z17add_values_sharedPjjPjj
.L48:
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	call	cudaThreadSynchronize@PLT
	call	cudaGetLastError@PLT
	movq	56(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	80(%rsp), %rdx
	movq	104(%rsp), %rsi
	leaq	124(%rsp), %rdi
	movl	$0x00000000, 124(%rsp)
	call	cudaEventElapsedTime@PLT
	movl	%r12d, %ecx
	movl	%ebp, %edx
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	32(%rsp), %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC10(%rip), %rsi
	cvtss2sd	124(%rsp), %xmm0
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	36(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L49
	call	__stack_chk_fail@PLT
.L49:
	movq	24(%rsp), %rdi
	addq	$152, %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
	jmp	free@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z17run_gpu_algorithmii, .-_Z17run_gpu_algorithmii
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r8
	.cfi_def_cfa_offset 48
	cmpl	$3, %edi
	je	.L53
.L55:
	call	_Z9showUsagev
	movl	$1, %eax
	jmp	.L52
.L53:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbp
	call	atoi@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	jle	.L55
	movl	%eax, %edi
	call	_Z12isPowerOfTwoi
	testb	%al, %al
	je	.L55
	movq	16(%rbp), %rdi
	call	atoi@PLT
	movl	%eax, %ebp
	testl	%eax, %eax
	jle	.L55
	movl	%eax, %edi
	call	_Z12isPowerOfTwoi
	testb	%al, %al
	je	.L55
	movl	%ebx, %eax
	imull	%ebp, %eax
	subl	$64, %eax
	cmpl	$4032, %eax
	ja	.L55
	xorl	%ecx, %ecx
	movl	$1, %r13d
	movl	%ecx, initializedRNG(%rip)
	call	_Z23initializeRandomNumbersv
.L56:
	movl	$1, %r12d
.L57:
	movl	%r12d, %esi
	movl	%r13d, %edi
	addl	%r12d, %r12d
	call	_Z17run_gpu_algorithmii
	cmpl	%r12d, %ebp
	jnb	.L57
	addl	%r13d, %r13d
	cmpl	%r13d, %ebx
	jnb	.L56
	xorl	%eax, %eax
.L52:
	popq	%rdx
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	main, .-main
	.section	.rodata.str1.1
.LC12:
	.string	"_Z17add_values_sharedPjj"
.LC13:
	.string	"_Z18localModularDividePKjS0_Pj"
.LC14:
	.string	"_Z19globalModularDividePKjS0_Pj"
.LC15:
	.string	"ADDITIVE_VALUES"
	.section	.text.startup
	.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	.LC12(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z17add_values_sharedPjj(%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	.LC13(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z18localModularDividePKjS0_Pj(%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	.LC14(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z19globalModularDividePKjS0_Pj(%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	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	movl	$64, %r9d
	leaq	_ZL15ADDITIVE_VALUES(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.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
	.globl	initializedRNG
	.bss
	.align 4
	.type	initializedRNG, @object
	.size	initializedRNG, 4
initializedRNG:
	.zero	4
	.local	_ZL15ADDITIVE_VALUES
	.comm	_ZL15ADDITIVE_VALUES,64,32
	.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:

/// Assignment 06: Local Register Memory
///
/// Author: Justin Renga

/// Two Kernels -- Same Operation
///
/// Operation: Take an integer (randomly generated) from two input arrays,
///            take their modulo (input1 % input2) and store the result.
///
/// Kernel 1: Use the global memory to perform the operation (using local memory as an
///           intermediate.

/// Kernel 2: Transfer the data from global memory to local memory, perform the operation,
///           then transfer back to global memory

// Bibliography (source-list):
// [1] register.cu
// [2] http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__EVENT.html
// [3] https://devblogs.nvidia.com/how-implement-performance-metrics-cuda-cc/


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

// Declare constant definitions here
#define UINT_SIZE sizeof(unsigned int)
#define INITIAL_DATA 0
#define THREAD_MIN 64
#define THREAD_MAX 4096

// Declare device constant memory here
__constant__ static unsigned int ADDITIVE_VALUES[16];

// Declare global host data here:
unsigned int initializedRNG;

// ---------------------------------------- DEVICE OPERATIONS -----------------------------------------

/// @brief GPU Kernel that utilizes only global data to perform a simple modular division operation. To
///        be used on conjunction with localModularDivide for comparison metrics. Algorithm performed:
///        output = input1 % input2
///
/// @param [ in] input1    The first of the two input arrays to be used in the modular division operation
/// @param [ in] input2    The second of the two input arrays to be used in the modular division operation
/// @param [out] output    The array containing the results of the modular division operation
__global__ void globalModularDivide(const unsigned int* const input1,
                                    const unsigned int* const input2,
                                          unsigned int* const output)
{
  // Compute the current thread index
  unsigned int thread_index = (blockIdx.x * blockDim.x) + threadIdx.x;
  
  // Perform the modular operation and store in the output array (without using local memory)
  output[thread_index] = input1[thread_index] % input2[thread_index];
}

/// @brief GPU Kernel that offloads the computations from global data completely, then re-inserts
///        the data back into global memory. To be used with globalModularDivide for comparison metrics.
///        Algorithm performed: output = input1 % input2
///
/// @param [ in] input1    The first of the two input arrays to be used in the modular division operation
/// @param [ in] input2    The second of the two input arrays to be used in the modular division operation
/// @param [out] output    The array containing the results of the modular division operation
__global__ void localModularDivide(const unsigned int* const input1,
                              const unsigned int* const input2,
                                    unsigned int* const output)
{
  // Compute the current thread index
  unsigned int thread_index = (blockIdx.x * blockDim.x) + threadIdx.x;
  
  // Create local registers to store the intermediate data for the algorithm
  unsigned int input1_local = input1[thread_index];
  unsigned int input2_local = input2[thread_index];
  
  // Create a local register that will store the result of the algorithm
  unsigned int output_local = input1_local % input2_local;
  
  // Store the result of the algorithm into the global array
  output[thread_index] = output_local;
}

__global__ void add_values_shared(unsigned int* deviceData, const unsigned int elementCount)
{
  // Declare externally defined shared memory
  __shared__ unsigned int sharedMemory[THREAD_MAX];
  
  // Compute the current thread index
  unsigned int threadIndex = (blockIdx.x * blockDim.x) + threadIdx.x;
  
  // Copy data from the device to the shared memory pool (and perform an operation using constant memory)
  sharedMemory[threadIndex] = deviceData[threadIndex];
  
  // Perform thread synchronization
  __syncthreads();
  
  unsigned int exponentPrimer = threadIndex % 2;
  
  for (unsigned int i = 0; i < 16; ++i)
  {
    unsigned int currentConstant =  ADDITIVE_VALUES[i];
    
    float value = powf(-1, exponentPrimer) * currentConstant;
    
    sharedMemory[threadIndex] += value;
  }
  
  __syncthreads();
  
  // Copy the data from the shared memory back to the device
  deviceData[threadIndex] = sharedMemory[elementCount - threadIndex - 1];
}

// ----------------------------------------- HOST OPERATIONS -----------------------------------------

// @brief Initialize the Random number generator and ensure it only initializes one time
__host__ void initializeRandomNumbers()
{
  if (initializedRNG == 0)
  {
    srand(time(NULL));
    initializedRNG = 1;
  }
}

// @brief Generates a series of random numbers for the provided array, given the number of desired numbers
//        and the maximum (exclusive) value.
//
// @param [inout] data         The data array that will contain the random numbers
// @param [   in] elementCount The number of elements to store in the data array
// @param [   in] max          The maximum random number to use (exclusive)
__host__ void generateRandomNumbers(      unsigned int* data,
                                    const unsigned int  elementCount,
                                    const unsigned int  max)
{
  // Check to make sure the RNG has been initialized
  if (initializedRNG == 0)
  {
    // If not, initialize the RNG
    initializeRandomNumbers();
  }
  
  // Generate random data between 0 and the provided maximum value
  for (unsigned int i = 0; i < elementCount; ++i)
  {
    data[i] = rand() % max;
  }
}

__host__ void run_gpu_algorithm(int blockCount, int threadCount)
{
  // Step 1: Compute the size of the device array based on the block and thread/per block counts
  unsigned int elementCount = threadCount * blockCount;
  unsigned int deviceSize   = UINT_SIZE   * elementCount;
  
  // Step 2: Allocate the necessary host memory (two input arrays and an output array
  //         (use malloc for the input, and calloc for the output since we want to modify
  //          the contents of the input PRIOR to executing the GPU kernels, but we want to
  //          initialize the output to 0 before copying the device output over)
  unsigned int* hostInput1 = (unsigned int*) malloc(deviceSize);
  unsigned int* hostInput2 = (unsigned int*) malloc(deviceSize);
  unsigned int* hostOutput = (unsigned int*) calloc(elementCount, UINT_SIZE);
  
  // Step 3: Populate the input arrays with random data, using the device size as the maximum value
  //         (the device size is used purely as a convenience number, and to ensure that the maximum
  //          value has the potential to change between each run)
  generateRandomNumbers(hostInput1, elementCount, deviceSize);
  generateRandomNumbers(hostInput2, elementCount, deviceSize);
  
  // Step 4: Allocate the GPU memory arrays
  unsigned int* deviceInput1;
  unsigned int* deviceInput2;
  unsigned int* deviceOutput;
  
  hipMalloc((void**)&deviceInput1, deviceSize);
  hipMalloc((void**)&deviceInput2, deviceSize);
  hipMalloc((void**)&deviceOutput, deviceSize);
  
  // Step 5: Populate the GPU input with the host input data
  hipMemcpy(deviceInput1, hostInput1, deviceSize, hipMemcpyHostToDevice);
  hipMemcpy(deviceInput2, hostInput2, deviceSize, hipMemcpyHostToDevice);
  
  // Step 6: Set the GPU output with all zeros
  hipMemset(deviceOutput, INITIAL_DATA, deviceSize);
  
  // Step 7: Initialize the CUDA event start/stop timers for benchmarking
  hipEvent_t stopLocalEvent;
  hipEvent_t stopGlobalEvent;
  hipEvent_t stopSharedEvent;
  hipEvent_t startLocalEvent;
  hipEvent_t startGlobalEvent;
  hipEvent_t startSharedEvent;

  hipEventCreate(&stopLocalEvent);  
  hipEventCreate(&stopGlobalEvent);
  hipEventCreate(&stopSharedEvent);
  hipEventCreate(&startLocalEvent);  
  hipEventCreate(&startGlobalEvent);
  hipEventCreate(&startSharedEvent);
  
  // Step 8: Invoke the global algorithm kernel with recording enabled
  hipEventRecord(startGlobalEvent);
  globalModularDivide<<<blockCount, threadCount>>>(deviceInput1, deviceInput2, deviceOutput);
  hipEventRecord(stopGlobalEvent);
  
  hipDeviceSynchronize();
  hipGetLastError();
  
  // Step 9: Retrieve the output from the global algorithm kernel
  hipMemcpy(hostOutput, deviceOutput, deviceSize, hipMemcpyDeviceToHost);
  
  // Step 10: Obtain the ms duration for the global algorithm
  hipEventSynchronize(stopGlobalEvent);
  
  float globalTimeMS = 0.0f;
  hipEventElapsedTime(&globalTimeMS, startGlobalEvent, stopGlobalEvent);
  
  // Step 11: Invoke the local algorithm kernel with recording enabled
  hipEventRecord(startLocalEvent);
  localModularDivide<<<blockCount, threadCount>>>(deviceInput1, deviceInput2, deviceOutput);
  hipEventRecord(stopLocalEvent);
  
  hipDeviceSynchronize();
  hipGetLastError();
  
  // Step 12: Retrieve the output from the local algorithm kernel
  hipMemcpy(hostOutput, deviceOutput, deviceSize, hipMemcpyDeviceToHost);
  
  // Step 13: Obtain the ms duration for the local algorithm
  hipEventSynchronize(stopLocalEvent);
  
  float localTimeMS = 0.0f;
  hipEventElapsedTime(&localTimeMS, startLocalEvent, stopLocalEvent);
  
  // Step 14: Upload the constant memory values to the device:
  unsigned int* constantMemory = (unsigned int*) malloc(deviceSize);
  generateRandomNumbers(constantMemory, elementCount, deviceSize);
  
  hipMemcpyToSymbol(HIP_SYMBOL(ADDITIVE_VALUES), constantMemory, UINT_SIZE * 16);
  
  // Step 15: Invoke the shared algorithm kernel with recording enabled
  hipEventRecord(startSharedEvent);
  add_values_shared<<<blockCount, threadCount>>>(deviceOutput, elementCount);
  hipEventRecord(stopSharedEvent);
  
  hipDeviceSynchronize();
  hipGetLastError();
  
  // Step 16: Retrieve the output from the global algorithm kernel
  hipMemcpy(hostOutput, deviceOutput, deviceSize, hipMemcpyDeviceToHost);
  
  // Step 17: Obtain the ms duration for the global algorithm
  hipEventSynchronize(stopSharedEvent);
  
  float sharedTimeMS = 0.0f;
  hipEventElapsedTime(&sharedTimeMS, startSharedEvent, stopSharedEvent);

  // Step 18: Display the results of the two operations
  printf("Block Count: %d\t Threads Per Block: %d\t", blockCount, threadCount);
  printf("Global Duration: %2f ms\t", globalTimeMS);
  printf("Shared Duration: %2f ms\t", sharedTimeMS);
  printf("Local  Duration: %2f ms\n", localTimeMS );
  
  // Step 19: Free device memory:
  hipFree(deviceInput1);
  hipFree(deviceInput2);
  hipFree(deviceOutput);
  
  // Step 20: Free host memory
  free(hostInput1);
  free(hostInput2);
  free(hostOutput);
  
  // Step 21: Free constant memory
  free(constantMemory);
}

/// @brief determine if the provided number is a power of two
///
/// @param [in] number   The number to validate
///
/// @return True if the provided number is a power of two, false otherwise
__host__ bool isPowerOfTwo(const int number)
{
  // Initialize a mask a 00000000 00000000 00000000 00000001 (on 32-bit machines)
  int mask = 0x1;
  
  // Iterate over each of the bits in the mask, left shifting by one to
  // iterate to the next power of two
  for (unsigned int i = 0; i < sizeof(int) * 8; ++i, mask = mask << 1)
  {
   
    // Compute the resulting masked value
    int maskedValue = number & mask;
    
    // If the computed value is non-zero and is not the provided number,
    // the provided number is not a power of two:
    //
    // For example, 3 would not be a power of two:
    //           3 = 00000000 00000000 00000000 00000011
    //        mask = 00000000 00000000 00000000 00000010
    // maskedValue = 00000000 00000000 00000000 00000010
    // makedValue is non-zero (2), but is also not provided number (2 != 3)
    if (maskedValue != 0 && maskedValue != number)
    {
      return false;
    }
    
    // If the maskedValue is the provided number, then we've confirmed that the
    // value is a power of two
    if (maskedValue == number)
    {
      return true;
    }
  }
  
  // Return false if we've exhausted all possible powers of two the computer can handle
  return false;
}

// @brief Display the proper program usage
__host__ void showUsage()
{
  printf("Invalid arguments provided. Please see the usage below:\n");
  printf("  module_6_jrenga2.exe <bc> <tpb>\n");
  printf("  bc  - The maximum number of blocks to run with. Must be a positive integer and a power of two.\n");
  printf("  tpb - The maximum number of threads per blocks. Must be a positive integer and a power of two.\n");
  printf("NOTE: The maximum number of threads (bc * tpb) must be greater than %d \n", THREAD_MIN);
  printf("      and less than %d.\n", THREAD_MAX);
  printf(" ** TERMINATING **\n");
}

// @brief Main Entry-Point
int main(int argc, char* argv[])
{
 // 1. Check the number of arguments.
  if (argc != 3)
  {
    showUsage();
    return EXIT_FAILURE;
  }

  // 2. Attempt to retrieve the integer values of the parameters
  //    (a value less than or equal to 0 is considered invalid)
  int numBlocks = atoi(argv[1]);
  if (numBlocks <= 0 || !isPowerOfTwo(numBlocks))
  {
    showUsage();
    return EXIT_FAILURE;
  }

  int numThreads = atoi(argv[2]);
  if (numThreads <= 0 || !isPowerOfTwo(numThreads))
  {
    showUsage();
    return EXIT_FAILURE;
  }
  
  int totalThreads = numBlocks * numThreads;

  // 2.5 Check to see if the minimum number of threads has been achieved (64)
  if (totalThreads < THREAD_MIN || totalThreads > THREAD_MAX)
  {
    showUsage();
    return EXIT_FAILURE;
  }
  
  // Do some pre-processing to set up the random number generation
  initializedRNG = false;
  
  // Initialize the random numbers
  initializeRandomNumbers();
  
  // Iterate from 1 -> numBlocks and 1 -> numThreads to perform metrics on numerous configurations
  for (unsigned int blockCount = 1; blockCount <= numBlocks; blockCount = blockCount << 1)
  {
    for (unsigned int threadCount = 1; threadCount <= numThreads; threadCount = threadCount << 1)
    {
      run_gpu_algorithm(blockCount, threadCount);
    }
  }
  
  return EXIT_SUCCESS;
}

	.text
	.file	"module_6_jrenga2.hip"
	.globl	_Z34__device_stub__globalModularDividePKjS0_Pj # -- Begin function _Z34__device_stub__globalModularDividePKjS0_Pj
	.type	_Z34__device_stub__globalModularDividePKjS0_Pj,@function
_Z34__device_stub__globalModularDividePKjS0_Pj: # @_Z34__device_stub__globalModularDividePKjS0_Pj
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z19globalModularDividePKjS0_Pj, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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	_Z34__device_stub__globalModularDividePKjS0_Pj, .Lfunc_end0-_Z34__device_stub__globalModularDividePKjS0_Pj
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__localModularDividePKjS0_Pj # -- Begin function _Z33__device_stub__localModularDividePKjS0_Pj
	.type	_Z33__device_stub__localModularDividePKjS0_Pj,@function
_Z33__device_stub__localModularDividePKjS0_Pj: # @_Z33__device_stub__localModularDividePKjS0_Pj
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z18localModularDividePKjS0_Pj, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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	_Z33__device_stub__localModularDividePKjS0_Pj, .Lfunc_end1-_Z33__device_stub__localModularDividePKjS0_Pj
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__add_values_sharedPjj # -- Begin function _Z32__device_stub__add_values_sharedPjj
	.type	_Z32__device_stub__add_values_sharedPjj,@function
_Z32__device_stub__add_values_sharedPjj: # @_Z32__device_stub__add_values_sharedPjj
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z17add_values_sharedPjj, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z32__device_stub__add_values_sharedPjj, .Lfunc_end2-_Z32__device_stub__add_values_sharedPjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z23initializeRandomNumbersv    # -- Begin function _Z23initializeRandomNumbersv
	.type	_Z23initializeRandomNumbersv,@function
_Z23initializeRandomNumbersv:           # @_Z23initializeRandomNumbersv
	.cfi_startproc
# %bb.0:
	cmpl	$0, initializedRNG(%rip)
	je	.LBB3_1
# %bb.2:
	retq
.LBB3_1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movl	$1, initializedRNG(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z23initializeRandomNumbersv, .Lfunc_end3-_Z23initializeRandomNumbersv
	.cfi_endproc
                                        # -- End function
	.globl	_Z21generateRandomNumbersPjjj   # -- Begin function _Z21generateRandomNumbersPjjj
	.type	_Z21generateRandomNumbersPjjj,@function
_Z21generateRandomNumbersPjjj:          # @_Z21generateRandomNumbersPjjj
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, %r14
	cmpl	$0, initializedRNG(%rip)
	jne	.LBB4_2
# %bb.1:
	callq	_Z23initializeRandomNumbersv
.LBB4_2:
	testl	%ebp, %ebp
	je	.LBB4_5
# %bb.3:                                # %.lr.ph.preheader
	movl	%ebp, %r15d
	xorl	%r12d, %r12d
.LBB4_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	xorl	%edx, %edx
	divl	%ebx
	movl	%edx, (%r14,%r12,4)
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB4_4
.LBB4_5:                                # %._crit_edge
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z21generateRandomNumbersPjjj, .Lfunc_end4-_Z21generateRandomNumbersPjjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z17run_gpu_algorithmii         # -- Begin function _Z17run_gpu_algorithmii
	.type	_Z17run_gpu_algorithmii,@function
_Z17run_gpu_algorithmii:                # @_Z17run_gpu_algorithmii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, 20(%rsp)                  # 4-byte Spill
	movl	%edi, 16(%rsp)                  # 4-byte Spill
	movl	%esi, %r14d
	imull	%edi, %r14d
	leal	(,%r14,4), %r13d
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %rbx
	movl	$4, %esi
	movq	%r14, %rdi
	callq	calloc
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	%r15, %rdi
	movl	%r14d, %esi
	movl	%r13d, %edx
	callq	_Z21generateRandomNumbersPjjj
	movq	%rbx, %rdi
	movq	%r14, 96(%rsp)                  # 8-byte Spill
	movl	%r14d, %esi
	movl	%r13d, %edx
	callq	_Z21generateRandomNumbersPjjj
	leaq	56(%rsp), %r14
	movq	%r14, %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	48(%rsp), %r12
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movq	(%r14), %rdi
	movq	%r15, 112(%rsp)                 # 8-byte Spill
	movq	%r15, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r12), %rdi
	movq	%rbx, 104(%rsp)                 # 8-byte Spill
	movq	%rbx, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	xorl	%esi, %esi
	movq	%r13, %rdx
	callq	hipMemset
	leaq	40(%rsp), %rdi
	callq	hipEventCreate
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	leaq	80(%rsp), %rdi
	callq	hipEventCreate
	leaq	120(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	72(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	16(%rsp), %r14d                 # 4-byte Reload
	btsq	$32, %r14
	movl	20(%rsp), %ebp                  # 4-byte Reload
	btsq	$32, %rbp
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_2
# %bb.1:
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	8(%rsp), %rdx
	callq	_Z34__device_stub__globalModularDividePKjS0_Pj
.LBB5_2:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	movq	8(%rsp), %rsi
	movq	88(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	callq	hipEventSynchronize
	leaq	68(%rsp), %rdi
	movl	$0, (%rdi)
	movq	120(%rsp), %rsi
	movq	32(%rsp), %rdx
	callq	hipEventElapsedTime
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_4
# %bb.3:
	movq	56(%rsp), %rdi
	movq	48(%rsp), %rsi
	movq	8(%rsp), %rdx
	callq	_Z33__device_stub__localModularDividePKjS0_Pj
.LBB5_4:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	callq	hipEventSynchronize
	leaq	64(%rsp), %rdi
	movl	$0, (%rdi)
	movq	80(%rsp), %rsi
	movq	40(%rsp), %rdx
	callq	hipEventElapsedTime
	movq	%r13, %rdi
	callq	malloc
	movq	%rax, %r12
	movq	%rax, %rdi
	movq	96(%rsp), %r15                  # 8-byte Reload
	movl	%r15d, %esi
	movl	%r13d, %edx
	callq	_Z21generateRandomNumbersPjjj
	movl	$_ZL15ADDITIVE_VALUES, %edi
	movl	$64, %edx
	movq	%r12, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.5:
	movq	8(%rsp), %rdi
	movl	%r15d, %esi
	callq	_Z32__device_stub__add_values_sharedPjj
.LBB5_6:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	callq	hipDeviceSynchronize
	callq	hipGetLastError
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	movq	%rbx, %r14
	leaq	132(%rsp), %rbx
	movl	$0, (%rbx)
	movq	72(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	%rbx, %rdi
	callq	hipEventElapsedTime
	movl	$.L.str, %edi
	movl	16(%rsp), %esi                  # 4-byte Reload
	movl	20(%rsp), %edx                  # 4-byte Reload
	xorl	%eax, %eax
	callq	printf
	cvtss2sd	68(%rsp), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx), %xmm0
	movl	$.L.str.2, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	64(%rsp), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	112(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	104(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r12, %rdi
	callq	free
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z17run_gpu_algorithmii, .Lfunc_end5-_Z17run_gpu_algorithmii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12isPowerOfTwoi               # -- Begin function _Z12isPowerOfTwoi
	.type	_Z12isPowerOfTwoi,@function
_Z12isPowerOfTwoi:                      # @_Z12isPowerOfTwoi
	.cfi_startproc
# %bb.0:
	movl	$1, %eax
	movl	$32, %ecx
.LBB6_1:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, %edx
	andl	%edi, %edx
	cmpl	%edi, %edx
	je	.LBB6_6
# %bb.2:                                #   in Loop: Header=BB6_1 Depth=1
	testl	%edx, %edx
	jne	.LBB6_6
# %bb.3:                                #   in Loop: Header=BB6_1 Depth=1
	addl	%eax, %eax
	decl	%ecx
	jne	.LBB6_1
# %bb.4:
	xorl	%eax, %eax
                                        # kill: def $al killed $al killed $eax
	retq
.LBB6_6:                                # %.thread.split.loop.exit
	cmpl	%edi, %edx
	sete	%cl
	testl	%edx, %edx
	sete	%al
	orb	%cl, %al
                                        # kill: def $al killed $al killed $eax
	retq
.Lfunc_end6:
	.size	_Z12isPowerOfTwoi, .Lfunc_end6-_Z12isPowerOfTwoi
	.cfi_endproc
                                        # -- End function
	.globl	_Z9showUsagev                   # -- Begin function _Z9showUsagev
	.type	_Z9showUsagev,@function
_Z9showUsagev:                          # @_Z9showUsagev
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.L.str.8, %edi
	movl	$64, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.9, %edi
	movl	$4096, %esi                     # imm = 0x1000
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr.4, %edi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end7:
	.size	_Z9showUsagev, .Lfunc_end7-_Z9showUsagev
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$3, %edi
	jne	.LBB8_10
# %bb.1:
	movq	%rsi, %r14
	movq	8(%rsi), %rdi
	callq	atoi
	testl	%eax, %eax
	jle	.LBB8_10
# %bb.2:                                # %.preheader39.preheader
	movl	%eax, %ebx
	movl	$1, %eax
	movl	$32, %ecx
.LBB8_3:                                # %.preheader39
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %edx
	andl	%ebx, %edx
	jne	.LBB8_5
# %bb.4:                                #   in Loop: Header=BB8_3 Depth=1
	addl	%eax, %eax
	decl	%ecx
	jne	.LBB8_3
	jmp	.LBB8_10
.LBB8_5:                                # %_Z12isPowerOfTwoi.exit
	cmpl	%ebx, %edx
	jne	.LBB8_10
# %bb.6:
	movq	16(%r14), %rdi
	callq	atoi
	testl	%eax, %eax
	jle	.LBB8_10
# %bb.7:                                # %.preheader38.preheader
	movl	%eax, %ebp
	movl	$1, %eax
	movl	$32, %ecx
.LBB8_8:                                # %.preheader38
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, %edx
	andl	%ebp, %edx
	jne	.LBB8_11
# %bb.9:                                #   in Loop: Header=BB8_8 Depth=1
	addl	%eax, %eax
	decl	%ecx
	jne	.LBB8_8
	jmp	.LBB8_10
.LBB8_11:                               # %_Z12isPowerOfTwoi.exit35
	cmpl	%ebp, %edx
	jne	.LBB8_10
# %bb.12:
	movl	%ebp, %eax
	imull	%ebx, %eax
	addl	$-4097, %eax                    # imm = 0xEFFF
	cmpl	$-4033, %eax                    # imm = 0xF03F
	jae	.LBB8_13
.LBB8_10:                               # %.loopexit.sink.split
	callq	_Z9showUsagev
	movl	$1, %eax
.LBB8_17:                               # %.loopexit
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB8_13:                               # %.preheader.lr.ph
	.cfi_def_cfa_offset 48
	movl	$0, initializedRNG(%rip)
	callq	_Z23initializeRandomNumbersv
	movl	$1, %r14d
.LBB8_14:                               # %.lr.ph.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_15 Depth 2
	movl	$1, %r15d
.LBB8_15:                               # %.lr.ph
                                        #   Parent Loop BB8_14 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%r14d, %edi
	movl	%r15d, %esi
	callq	_Z17run_gpu_algorithmii
	addl	%r15d, %r15d
	cmpl	%ebp, %r15d
	jbe	.LBB8_15
# %bb.16:                               # %._crit_edge
                                        #   in Loop: Header=BB8_14 Depth=1
	addl	%r14d, %r14d
	xorl	%eax, %eax
	cmpl	%ebx, %r14d
	jbe	.LBB8_14
	jmp	.LBB8_17
.Lfunc_end8:
	.size	main, .Lfunc_end8-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB9_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB9_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z19globalModularDividePKjS0_Pj, %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	$_Z18localModularDividePKjS0_Pj, %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	$_Z17add_values_sharedPjj, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$1, (%rsp)
	movl	$_ZL15ADDITIVE_VALUES, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$64, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end9:
	.size	__hip_module_ctor, .Lfunc_end9-__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	.LBB10_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
.LBB10_2:
	retq
.Lfunc_end10:
	.size	__hip_module_dtor, .Lfunc_end10-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	initializedRNG,@object          # @initializedRNG
	.bss
	.globl	initializedRNG
	.p2align	2, 0x0
initializedRNG:
	.long	0                               # 0x0
	.size	initializedRNG, 4

	.type	_Z19globalModularDividePKjS0_Pj,@object # @_Z19globalModularDividePKjS0_Pj
	.section	.rodata,"a",@progbits
	.globl	_Z19globalModularDividePKjS0_Pj
	.p2align	3, 0x0
_Z19globalModularDividePKjS0_Pj:
	.quad	_Z34__device_stub__globalModularDividePKjS0_Pj
	.size	_Z19globalModularDividePKjS0_Pj, 8

	.type	_Z18localModularDividePKjS0_Pj,@object # @_Z18localModularDividePKjS0_Pj
	.globl	_Z18localModularDividePKjS0_Pj
	.p2align	3, 0x0
_Z18localModularDividePKjS0_Pj:
	.quad	_Z33__device_stub__localModularDividePKjS0_Pj
	.size	_Z18localModularDividePKjS0_Pj, 8

	.type	_Z17add_values_sharedPjj,@object # @_Z17add_values_sharedPjj
	.globl	_Z17add_values_sharedPjj
	.p2align	3, 0x0
_Z17add_values_sharedPjj:
	.quad	_Z32__device_stub__add_values_sharedPjj
	.size	_Z17add_values_sharedPjj, 8

	.type	_ZL15ADDITIVE_VALUES,@object    # @_ZL15ADDITIVE_VALUES
	.local	_ZL15ADDITIVE_VALUES
	.comm	_ZL15ADDITIVE_VALUES,64,16
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Block Count: %d\t Threads Per Block: %d\t"
	.size	.L.str, 40

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Global Duration: %2f ms\t"
	.size	.L.str.1, 25

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Shared Duration: %2f ms\t"
	.size	.L.str.2, 25

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Local  Duration: %2f ms\n"
	.size	.L.str.3, 25

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"NOTE: The maximum number of threads (bc * tpb) must be greater than %d \n"
	.size	.L.str.8, 73

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"      and less than %d.\n"
	.size	.L.str.9, 25

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z19globalModularDividePKjS0_Pj"
	.size	.L__unnamed_1, 32

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z18localModularDividePKjS0_Pj"
	.size	.L__unnamed_2, 31

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z17add_values_sharedPjj"
	.size	.L__unnamed_3, 25

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_ZL15ADDITIVE_VALUES"
	.size	.L__unnamed_4, 21

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Invalid arguments provided. Please see the usage below:"
	.size	.Lstr, 56

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"  module_6_jrenga2.exe <bc> <tpb>"
	.size	.Lstr.1, 34

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"  bc  - The maximum number of blocks to run with. Must be a positive integer and a power of two."
	.size	.Lstr.2, 97

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"  tpb - The maximum number of threads per blocks. Must be a positive integer and a power of two."
	.size	.Lstr.3, 97

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	" ** TERMINATING **"
	.size	.Lstr.4, 19

	.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 _Z34__device_stub__globalModularDividePKjS0_Pj
	.addrsig_sym _Z33__device_stub__localModularDividePKjS0_Pj
	.addrsig_sym _Z32__device_stub__add_values_sharedPjj
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z19globalModularDividePKjS0_Pj
	.addrsig_sym _Z18localModularDividePKjS0_Pj
	.addrsig_sym _Z17add_values_sharedPjj
	.addrsig_sym _ZL15ADDITIVE_VALUES
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z19globalModularDividePKjS0_Pj ; -- Begin function _Z19globalModularDividePKjS0_Pj
	.globl	_Z19globalModularDividePKjS0_Pj
	.p2align	8
	.type	_Z19globalModularDividePKjS0_Pj,@function
_Z19globalModularDividePKjS0_Pj:        ; @_Z19globalModularDividePKjS0_Pj
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_mov_b32_e32 v2, 0
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo
	global_load_b32 v4, v[2:3], off
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(1)
	v_cvt_f32_u32_e32 v3, v4
	v_sub_nc_u32_e32 v5, 0, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v3, v3
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v3, 0x4f7ffffe, v3
	v_cvt_u32_f32_e32 v3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v5, v5, v3
	v_mul_hi_u32 v5, v3, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v3, v3, v5
	s_waitcnt vmcnt(0)
	v_mul_hi_u32 v3, v2, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v3, v3, v4
	v_sub_nc_u32_e32 v2, v2, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v3, v2, v4
	v_cmp_ge_u32_e32 vcc_lo, v2, v4
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v3, v2, v4
	v_cmp_ge_u32_e32 vcc_lo, v2, v4
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z19globalModularDividePKjS0_Pj
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z19globalModularDividePKjS0_Pj, .Lfunc_end0-_Z19globalModularDividePKjS0_Pj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 264
; 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 : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z18localModularDividePKjS0_Pj ; -- Begin function _Z18localModularDividePKjS0_Pj
	.globl	_Z18localModularDividePKjS0_Pj
	.p2align	8
	.type	_Z18localModularDividePKjS0_Pj,@function
_Z18localModularDividePKjS0_Pj:         ; @_Z18localModularDividePKjS0_Pj
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_mov_b32_e32 v2, 0
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo
	global_load_b32 v4, v[2:3], off
	v_add_co_u32 v2, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(1)
	v_cvt_f32_u32_e32 v3, v4
	v_sub_nc_u32_e32 v5, 0, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v3, v3
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v3, 0x4f7ffffe, v3
	v_cvt_u32_f32_e32 v3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v5, v5, v3
	v_mul_hi_u32 v5, v3, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v3, v3, v5
	s_waitcnt vmcnt(0)
	v_mul_hi_u32 v3, v2, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v3, v3, v4
	v_sub_nc_u32_e32 v2, v2, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v3, v2, v4
	v_cmp_ge_u32_e32 vcc_lo, v2, v4
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v3, v2, v4
	v_cmp_ge_u32_e32 vcc_lo, v2, v4
	v_cndmask_b32_e32 v2, v2, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18localModularDividePKjS0_Pj
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z18localModularDividePKjS0_Pj, .Lfunc_end1-_Z18localModularDividePKjS0_Pj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 264
; 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 : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z17add_values_sharedPjj ; -- Begin function _Z17add_values_sharedPjj
	.globl	_Z17add_values_sharedPjj
	.p2align	8
	.type	_Z17add_values_sharedPjj,@function
_Z17add_values_sharedPjj:               ; @_Z17add_values_sharedPjj
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b64 s[2:3], s[0:1], 0x0
	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[2:3], null, s15, s4, v[0:1]
	v_and_b32_e32 v5, 1, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f32_ubyte0_e32 v6, v5
	v_dual_mov_b32 v3, 0 :: v_dual_mul_f32 v6, 0.5, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	v_lshlrev_b32_e32 v3, 2, v2
	v_trunc_f32_e32 v7, v6
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, 0, v5
	s_mov_b64 s[2:3], 0
	global_load_b32 v4, v[0:1], off
	v_cndmask_b32_e64 v5, -1.0, 1.0, vcc_lo
	v_cmp_neq_f32_e32 vcc_lo, v7, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v5, 1.0, v5, vcc_lo
	v_bfi_b32 v5, 0x7fffffff, 1.0, v5
	s_waitcnt vmcnt(0)
	ds_store_b32 v3, v4
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b32 v4, v3
.LBB2_1:                                ; =>This Inner Loop Header: Depth=1
	s_getpc_b64 s[4:5]
	s_add_u32 s4, s4, _ZL15ADDITIVE_VALUES@gotpcrel32@lo+4
	s_addc_u32 s5, s5, _ZL15ADDITIVE_VALUES@gotpcrel32@hi+12
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v4, v4
	s_load_b64 s[4:5], s[4:5], 0x0
	s_waitcnt lgkmcnt(0)
	s_add_u32 s4, s4, s2
	s_addc_u32 s5, s5, s3
	s_add_u32 s2, s2, 4
	s_load_b32 s4, s[4:5], 0x0
	s_addc_u32 s3, s3, 0
	s_cmp_eq_u32 s2, 64
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v6, s4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v4, v5, v6
	v_cvt_u32_f32_e32 v4, v4
	s_cbranch_scc0 .LBB2_1
; %bb.2:
	s_load_b32 s0, s[0:1], 0x8
	v_not_b32_e32 v2, v2
	ds_store_b32 v3, v4
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_add_lshl_u32 v2, v2, s0, 2
	ds_load_b32 v2, v2
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17add_values_sharedPjj
		.amdhsa_group_segment_fixed_size 16384
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 16
		.amdhsa_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	_Z17add_values_sharedPjj, .Lfunc_end2-_Z17add_values_sharedPjj
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 16384 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	_ZL15ADDITIVE_VALUES,@object    ; @_ZL15ADDITIVE_VALUES
	.section	.bss,"aw",@nobits
	.globl	_ZL15ADDITIVE_VALUES
	.p2align	4, 0x0
_ZL15ADDITIVE_VALUES:
	.zero	64
	.size	_ZL15ADDITIVE_VALUES, 64

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 _ZL15ADDITIVE_VALUES
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z19globalModularDividePKjS0_Pj
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z19globalModularDividePKjS0_Pj.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
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18localModularDividePKjS0_Pj
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18localModularDividePKjS0_Pj.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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 16384
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17add_values_sharedPjj
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17add_values_sharedPjj.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
