/**
 * @file   : params_kernelf.cu
 * @brief  : Modified implementation of njuffa's; 
 * 				CUDA kernel functions as parameters with CUDA C++14, CUDA Unified Memory Management
 * @details : Modified implementation of njuffa's,  
 * 				std::function vs. function pointer in C++11, C++14, and now in CUDA
 * 				std::function vs. function pointer for CUDA kernel functions (i.e. __global__ )
 * 
 * @author : Ernest Yeung <ernestyalumni@gmail.com>
 * @date   : 20171020  
 * @ref    : https://devtalk.nvidia.com/default/topic/487190/kernel-functions-as-parameters-/
 * https://stackoverflow.com/questions/16498969/how-do-i-typedef-a-function-pointer-with-the-c11-using-syntax
 * 
 * https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ernestsaveschristmas%2bpaypal%40gmail%2ecom&lc=US&item_name=ernestyalumni&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted 
 * 
 * which won't go through a 3rd. party such as indiegogo, kickstarter, patreon.  
 * Otherwise, I receive emails and messages on how all my (free) material on 
 * physics, math, and engineering have helped students with their studies, 
 * and I know what it's like to not have money as a student, but love physics 
 * (or math, sciences, etc.), so I am committed to keeping all my material 
 * open-source and free, whether or not 
 * sufficiently crowdfunded, under the open-source MIT license: 
 * 	feel free to copy, edit, paste, make your own versions, share, use as you wish.  
 *  Just don't be an asshole and not give credit where credit is due.  
 * Peace out, never give up! -EY
 * 
 * */
/* 
 * COMPILATION TIP
 * nvcc -std=c++14 params_kernelf.cu -o params_kernelf.exe
 * 
 * */
#include <iostream>
#include <functional> 	// std::function
#include <type_traits> 	// std::add_pointer

#include <map>			// std::map


#include <stdio.h>

#include <vector> // std::vector

#include <memory> // std::unique_ptr

#define BLOCK_COUNT  240
#define THREAD_COUNT 128

/** @brief function pointer example, pf = "processing function"
 * @ref Scott Meyers, Effective Modern C++, pp. 63, Item 9
 * @details pointer to a function of 2 floats
 * */
// this WORKS
// using pf = float (*)(float, float);

using pf = std::add_pointer<float(float,float)>::type;

__device__ float minimum(float a, float b)
{
    return fminf(a,b);
};

__device__ float maximum(float a, float b)
{
    return fmaxf(a,b);
};

/**
 * @ref http://www.cplusplus.com/forum/beginner/4844/
 * 
 * @details From jsmith 
 * The ! operator is the logical-NOT operator.  
 * In C/C++, integers can be implicitly cast to boolean values according to the rule that 0 is false and anything else is true. The boolean false has "value" 0 and true has "value" 1.
 * Programmers sometimes take advantage of the implicit boolean conversion to perform the conversion:
 * f(x) = { 0, iff x == 0, and 1 iff x != 0 }
 * So given an integer x, !!x is 1 iff x is not zero and 0 otherwise.
 * 
 * */

/**
 * @brief 
 * @ref Scott Meyers, Effective Modern C++, pp. 63, Item 9
*/
__device__ pf func_d[2] = { maximum, minimum };


/* this will be inputted in with the following parameters  
 * x = x_d \in \mathbb{R}^n
 * res = res_d \in \mathbb{R}^{N_x}  
 * n = n = total length or size of the problem array  
 * pf func = func_d[findmin]
 */
__device__ void minmax(float *x, float *res, int n, pf func)
{
	int Mx = blockDim.x; // "THREAD_COUNT" or number of threads in a (single) block, in x-direction

//	__shared__ float partExtr[Mx];  // error: expression must have a constant value
 	__shared__ float partExtr[THREAD_COUNT];  // error: expression must have a constant value
  
    int i;	
    int tid = threadIdx.x; // 0,1,... Mx-1

	int kx = threadIdx.x + blockDim.x*blockIdx.x; // kx=0,1,.. Mx*Nx-1

	int Nx = gridDim.x ; 


    float extr = x[0];

	// i=kx, kx + Nx*Mx, kx + 2*Nx*Mx, ... < n 
	// the big idea is to make sure all values of x=x[i], i=0,1,...n-1, gets calculated
	// this is because we worry about the case when n > Nx*Mx (or perhaps n >> Nx*Mx !!!)
    for (i = kx; i < n; i += Nx*Mx) {
        extr = func(extr, x[i]);
    }
	// tid \in 0,1,...Mx-1; kx = tid + blockDim.x*blockIdx.x
    partExtr[tid] = extr;

	// Mx >> 1 = Mx/2; i= Mx/2, Mx/4, ... 2,1
    for (i = Mx >> 1; i > 0; i >>= 1) {
        __syncthreads(); 
		
		// tid \in 0,1,...Mx-1
		// assuming Mx % 2 = 0, 
		// i= Mx/2, Mx/4 ... 2,1
        if (tid < i) {
			// tid \in 0,1,...Mx-1
			// tid+i, so i < tid+i and Mx/2 < (tid + Mx/2), Mx/4 < (tid+ Mx/4) ... 1 < (tid +1)
			// i.e. we're grabbing the "other half", computing against the "other half" in a 
			// thread block, each time we're accessing tid+i
            partExtr[tid] = func(partExtr[tid], partExtr[tid+i]);
        }
    }

    if (tid == 0) {
        res[blockIdx.x] = partExtr[tid];
    }
}

__global__ void minmax_kernel(float *x, float *res, int n, int findmin)
{
    minmax(x, res, n, func_d[findmin]);
}

/**
 *	@fn findExtremum
 * 	@param int findmin - 0 for fmaxf, 1 for fminf
 * 
 * */
float findExtremum(float *x, int n, int findmin)
{
    pf func_h[2] = { fmaxf, fminf };

    float *res_d;	// result of minmax on device GPU; res_d \in \mathbb{R}^{ N_x }
    //float *res_h;	// result of minmax on host CPU
	std::vector<float> h_resultvec( BLOCK_COUNT, 0.f);  // h_resultvec \in \mathbb{R}^{ N_x}
    float *x_d;		// x array on device GPU, of size n, x \in \mathbb{R}^n
    float r;

    if (n < 1) return sqrtf(-1.0f); // NaN

    cudaMalloc((void**)&res_d, BLOCK_COUNT*sizeof(res_d[0]));
    cudaMalloc((void**)&x_d, n * sizeof(x_d[0]));

    cudaMemcpy(x_d, x, n * sizeof(x_d[0]), cudaMemcpyHostToDevice);

	// ! is logical NOT, and so !! makes a boolean, which is just 0 or 1
    minmax_kernel<<<BLOCK_COUNT,THREAD_COUNT>>>(x_d, res_d, n, !!findmin);
/*
    if (!res_h) {
		fprintf(stderr, "res_h allocation failed\n");
		exit(EXIT_FAILURE);
    }
*/
    cudaMemcpy( h_resultvec.data(), res_d, BLOCK_COUNT * sizeof(res_d[0]), cudaMemcpyDeviceToHost);

    cudaFree(res_d);
    cudaFree(x_d);

    r = h_resultvec[0];

	// i=1,2,...N_x-1; and h_resultvec \in \mathbb{R}^{N_x}
    for (int i = 1; i < BLOCK_COUNT; i++) {
		// int findmin =0,1; func_h[0]=fmaxf, func_h[1]=fminf
		r = func_h[findmin](r, h_resultvec[i]);
	}


    return r;
}

/* =============== sunburntfish's increment, decrement test function =============== */
// @ref https://stackoverflow.com/questions/25848690/should-i-use-stdfunction-or-a-function-pointer-in-c
// @ref pp. 39, Item 5 of Scott Meyers, Effective Modern C++  

// doesn't work, error: dynamic initialization not supported for __device__  
//using funcpf = std::function<float(float,float)>;

//  error: dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.
//__device__ funcpf funcfunc_d[2] = { maximum, minimum };

/**
 * @ref https://stackoverflow.com/questions/16498969/how-do-i-typedef-a-function-pointer-with-the-c11-using-syntax
 * How do I typedef a function pointer with the C++11 using syntax?  answer from 0x499602D2
 * */
using pf1 = std::add_pointer<int(int)>::type;  

__device__ int increment_k(int t) {
	return t+ 1;
}

__device__ int decrement_k(int t) {
	return t-1;
}

/**
 * @fn incdecops
 * @ref Stanley B. Lippman, Josee Lajoie, Barbara E. Moo. C++ Primer 
 * */
//  error: dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.
/* __device__ std::map<int, pf1> incdecops = {
	{0, increment_k}, 
	{1, decrement_k} };
*/

__device__ pf1 d_func[2] = { increment_k, decrement_k };

__global__ void test_k(int *testArray, int funcId, uint numPoints ) {
	unsigned int index = threadIdx.x + __umul24(blockIdx.x,blockDim.x); 
	
	if (index >= numPoints) { return ; }
	
	pf1 func = d_func[funcId];

	// i=kx, kx + Nx*Mx, kx + 2*Nx*Mx, ... < n 
	// the big idea is to make sure all values of x=x[i], i=0,1,...n-1, gets calculated
	// this is because we worry about the case when n > Nx*Mx (or perhaps n >> Nx*Mx !!!)
	int Mx = blockDim.x; 
	int Nx = gridDim.x; 
	for (int idx = index; idx < numPoints; idx += Nx*Mx) {
		int temp = func(testArray[idx]);
		testArray[idx] = temp;
	}
		
}

void test(int *testArray, int funcId, unsigned int numPoints, int numThreadsPerBlock) {
	// define grid and block size
	unsigned int numBlocks = (numPoints + numThreadsPerBlock -1)/numThreadsPerBlock;
//	computeGridSize(numPoints, 256, numBlocks, numThreadsPerBlock);

	test_k<<<numBlocks, numThreadsPerBlock>>>( testArray, funcId, numPoints); 
}

int main (void)
{
	// sanity check
	constexpr const int Mx = THREAD_COUNT;
	std::cout << " Mx >> 1 : " << ( Mx >> 1) << std::endl;
	for (int test_i = Mx >> 1; test_i >0; test_i >>= 1) { std::cout << test_i << " " ; } std::cout << std::endl;

	constexpr const int ELEM_COUNT = 8 ;
    float x[ELEM_COUNT] = {-1.3f, 2.4f, 3.5f, -2.3f, 4.5f, 0.4f, -5.3f, -1.6f};

    float minimum = findExtremum(x, ELEM_COUNT, 1);
    float maximum = findExtremum(x, ELEM_COUNT, 0);

    printf("min=% 13.6e  max=% 13.6e\n", minimum, maximum);

	std::cout << std::endl << "increment, decrement " << std::endl ;

	int numPoints = 10;
	
	// on host
	std::vector<int> testArray(numPoints,0);
	for (uint i=0; i<numPoints;i++) { testArray[i] = i; }
	
	auto deleterZZ_lambda=[&](int* ptr){ cudaFree(ptr); };
	std::unique_ptr<int[], decltype(deleterZZ_lambda)> d_test(new int[numPoints], deleterZZ_lambda); // u for unique and unified
	cudaMallocManaged((void **) &d_test, numPoints*sizeof(float));

	std::cout << " Before : " << std::endl;
	for (auto ele : testArray) { std::cout << ele << " " ; } std::cout << std::endl;

	cudaMemcpy(d_test.get(),testArray.data(),numPoints*sizeof(int),cudaMemcpyHostToDevice); 
	
	test(d_test.get(), 0, numPoints, 16);
	
	cudaMemcpy(testArray.data(),d_test.get(), numPoints*sizeof(int),cudaMemcpyDeviceToHost); 
	 
	std::cout << " After : " << std::endl; 
	for (auto ele : testArray) { std::cout << ele << " " ; } std::cout << std::endl;


    return EXIT_SUCCESS;
}


	.file	"tmpxft_003437f1_00000000-6_params_kernelf.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB5820:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE5820:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z7minimumff
	.type	_Z7minimumff, @function
_Z7minimumff:
.LFB5801:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE5801:
	.size	_Z7minimumff, .-_Z7minimumff
	.globl	_Z7maximumff
	.type	_Z7maximumff, @function
_Z7maximumff:
.LFB6711:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z7minimumff
	.cfi_endproc
.LFE6711:
	.size	_Z7maximumff, .-_Z7maximumff
	.globl	_Z6minmaxPfS_iPFfffE
	.type	_Z6minmaxPfS_iPFfffE, @function
_Z6minmaxPfS_iPFfffE:
.LFB5803:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE5803:
	.size	_Z6minmaxPfS_iPFfffE, .-_Z6minmaxPfS_iPFfffE
	.globl	_Z11increment_ki
	.type	_Z11increment_ki, @function
_Z11increment_ki:
.LFB5805:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE5805:
	.size	_Z11increment_ki, .-_Z11increment_ki
	.globl	_Z11decrement_ki
	.type	_Z11decrement_ki, @function
_Z11decrement_ki:
.LFB6713:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z11increment_ki
	.cfi_endproc
.LFE6713:
	.size	_Z11decrement_ki, .-_Z11decrement_ki
	.globl	_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii
	.type	_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii, @function
_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii:
.LFB5842:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13minmax_kernelPfS_ii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L12:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5842:
	.size	_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii, .-_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii
	.globl	_Z13minmax_kernelPfS_ii
	.type	_Z13minmax_kernelPfS_ii, @function
_Z13minmax_kernelPfS_ii:
.LFB5843:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii
	.cfi_endproc
.LFE5843:
	.size	_Z13minmax_kernelPfS_ii, .-_Z13minmax_kernelPfS_ii
	.globl	_Z27__device_stub__Z6test_kPiijPiij
	.type	_Z27__device_stub__Z6test_kPiijPiij, @function
_Z27__device_stub__Z6test_kPiijPiij:
.LFB5844:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z6test_kPiij(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L18:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5844:
	.size	_Z27__device_stub__Z6test_kPiijPiij, .-_Z27__device_stub__Z6test_kPiijPiij
	.globl	_Z6test_kPiij
	.type	_Z6test_kPiij, @function
_Z6test_kPiij:
.LFB5845:
	.cfi_startproc
	endbr64
	jmp	_Z27__device_stub__Z6test_kPiijPiij
	.cfi_endproc
.LFE5845:
	.size	_Z6test_kPiij, .-_Z6test_kPiij
	.globl	_Z4testPiiji
	.type	_Z4testPiiji, @function
_Z4testPiiji:
.LFB5807:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leal	-1(%rdx,%rcx), %eax
	movl	%esi, %r12d
	xorl	%r9d, %r9d
	movabsq	$4294967297, %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	xorl	%r8d, %r8d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edx, %ebx
	xorl	%edx, %edx
	divl	%ecx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%rsi, 24(%rsp)
	movl	%ecx, 20(%rsp)
	movl	28(%rsp), %ecx
	movq	%rsi, 12(%rsp)
	movq	20(%rsp), %rdx
	movl	16(%rsp), %esi
	movl	%eax, 8(%rsp)
	movq	8(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	%ebx, %edx
	movl	%r12d, %esi
	movq	%rbp, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	_Z27__device_stub__Z6test_kPiijPiij
.L23:
	.cfi_restore_state
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5807:
	.size	_Z4testPiiji, .-_Z4testPiiji
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z6test_kPiij"
.LC1:
	.string	"_Z13minmax_kernelPfS_ii"
.LC2:
	.string	"func_d"
.LC3:
	.string	"d_func"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB5847:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z6test_kPiij(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13minmax_kernelPfS_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC2(%rip), %rdx
	movl	$16, %r9d
	leaq	_ZL6func_d(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC3(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$16, %r9d
	leaq	_ZL6d_func(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.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
.LFE5847:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIiSaIiEED2Ev,"axG",@progbits,_ZNSt6vectorIiSaIiEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIiSaIiEED2Ev
	.type	_ZNSt6vectorIiSaIiEED2Ev, @function
_ZNSt6vectorIiSaIiEED2Ev:
.LFB6186:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L28
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L28:
	ret
	.cfi_endproc
.LFE6186:
	.size	_ZNSt6vectorIiSaIiEED2Ev, .-_ZNSt6vectorIiSaIiEED2Ev
	.weak	_ZNSt6vectorIiSaIiEED1Ev
	.set	_ZNSt6vectorIiSaIiEED1Ev,_ZNSt6vectorIiSaIiEED2Ev
	.section	.text._ZNSt12_Vector_baseIfSaIfEED2Ev,"axG",@progbits,_ZNSt12_Vector_baseIfSaIfEED5Ev,comdat
	.align 2
	.weak	_ZNSt12_Vector_baseIfSaIfEED2Ev
	.type	_ZNSt12_Vector_baseIfSaIfEED2Ev, @function
_ZNSt12_Vector_baseIfSaIfEED2Ev:
.LFB6372:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L30
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L30:
	ret
	.cfi_endproc
.LFE6372:
	.size	_ZNSt12_Vector_baseIfSaIfEED2Ev, .-_ZNSt12_Vector_baseIfSaIfEED2Ev
	.weak	_ZNSt12_Vector_baseIfSaIfEED1Ev
	.set	_ZNSt12_Vector_baseIfSaIfEED1Ev,_ZNSt12_Vector_baseIfSaIfEED2Ev
	.text
	.globl	_Z12findExtremumPfii
	.type	_Z12findExtremumPfii, @function
_Z12findExtremumPfii:
.LFB5804:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA5804
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rdi, %r14
	movl	$960, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movslq	%edx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	movq	fmaxf@GOTPCREL(%rip), %rax
	movq	%rax, 88(%rsp)
	movq	fminf@GOTPCREL(%rip), %rax
	movq	%rax, 96(%rsp)
.LEHB0:
	call	_Znwm@PLT
.LEHE0:
	leaq	960(%rax), %rdx
	movq	%rax, 64(%rsp)
	movq	%rax, %rbx
	xorl	%eax, %eax
	movq	%rdx, 80(%rsp)
.L33:
	movl	$0x00000000, (%rbx,%rax)
	addq	$4, %rax
	cmpq	$960, %rax
	jne	.L33
	movq	%rdx, 72(%rsp)
	testl	%r12d, %r12d
	jg	.L34
	movss	.LC5(%rip), %xmm0
	call	sqrtf@PLT
	jmp	.L35
.L34:
	leaq	24(%rsp), %rdi
	movl	$960, %esi
.LEHB1:
	call	cudaMalloc@PLT
	movslq	%r12d, %r13
	leaq	32(%rsp), %rdi
	salq	$2, %r13
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%r14, %rsi
	call	cudaMemcpy@PLT
	movl	$33554433, %edx
	movl	$268435471, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$7, %rdx
	salq	$4, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 52(%rsp)
	movl	$1, 60(%rsp)
	movq	%rdi, 40(%rsp)
	movl	$1, 48(%rsp)
	call	__cudaPushCallConfiguration@PLT
	movq	24(%rsp), %rsi
	testl	%eax, %eax
	jne	.L36
	xorl	%ecx, %ecx
	movq	32(%rsp), %rdi
	testl	%ebp, %ebp
	movl	%r12d, %edx
	setne	%cl
	call	_Z37__device_stub__Z13minmax_kernelPfS_iiPfS_ii
.L36:
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movl	$960, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movss	(%rbx), %xmm0
	movl	$1, %r12d
.L37:
	movss	(%rbx,%r12,4), %xmm1
	call	*88(%rsp,%rbp,8)
.LEHE1:
	incq	%r12
	cmpq	$240, %r12
	jne	.L37
.L35:
	leaq	64(%rsp), %rdi
	movss	%xmm0, 12(%rsp)
	call	_ZNSt12_Vector_baseIfSaIfEED2Ev
	movss	12(%rsp), %xmm0
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L40
	jmp	.L44
.L41:
	endbr64
	movq	%rax, %rbx
.L38:
	leaq	64(%rsp), %rdi
	call	_ZNSt12_Vector_baseIfSaIfEED2Ev
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L44
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L44:
	call	__stack_chk_fail@PLT
.L40:
	addq	$112, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5804:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA5804:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE5804-.LLSDACSB5804
.LLSDACSB5804:
	.uleb128 .LEHB0-.LFB5804
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB5804
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L41-.LFB5804
	.uleb128 0
	.uleb128 .LEHB2-.LFB5804
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE5804:
	.text
	.size	_Z12findExtremumPfii, .-_Z12findExtremumPfii
	.section	.rodata.str1.1
.LC6:
	.string	" Mx >> 1 : "
.LC7:
	.string	" "
.LC8:
	.string	"min=% 13.6e  max=% 13.6e\n"
.LC9:
	.string	"increment, decrement "
.LC10:
	.string	" Before : "
.LC11:
	.string	" After : "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB5808:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA5808
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC6(%rip), %rsi
	movl	$64, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	.LC7(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$7, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	_ZSt4cout(%rip), %rbx
	movq	%rbx, %rdi
	subq	$88, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
.LEHB3:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$64, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
.L47:
	movl	%r13d, %esi
	movq	%rbx, %rdi
	sarl	%r13d
	call	_ZNSolsEi@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	decl	%ebp
	jne	.L47
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rbx, %rdi
	leaq	40(%rsp), %r13
	call	_ZNSolsEPFRSoS_E@PLT
	movl	$1, %edx
	movl	$8, %esi
	movq	%r13, %rdi
	movabsq	$4618891782764521062, %rax
	movq	%rax, 40(%rsp)
	movabsq	$-4606281698653503488, %rax
	movq	%rax, 48(%rsp)
	movabsq	$4525216907524046848, %rax
	movq	%rax, 56(%rsp)
	movabsq	$-4626097533143639654, %rax
	movq	%rax, 64(%rsp)
	call	_Z12findExtremumPfii
	xorl	%edx, %edx
	movl	$8, %esi
	movq	%r13, %rdi
	movd	%xmm0, %ebp
	call	_Z12findExtremumPfii
	movd	%ebp, %xmm2
	movl	$2, %edi
	movb	$2, %al
	movaps	%xmm0, %xmm1
	leaq	.LC8(%rip), %rsi
	cvtss2sd	%xmm2, %xmm0
	cvtss2sd	%xmm1, %xmm1
	call	__printf_chk@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movl	$40, %edi
	call	_Znwm@PLT
.LEHE3:
	leaq	40(%rax), %rdx
	movq	%rax, 16(%rsp)
	movq	%rax, %rbp
	xorl	%eax, %eax
	movq	%rdx, 32(%rsp)
.L48:
	xorl	%ecx, %ecx
	movl	%ecx, 0(%rbp,%rax)
	addq	$4, %rax
	cmpq	$40, %rax
	jne	.L48
	movq	%rdx, 24(%rsp)
	xorl	%eax, %eax
.L49:
	movl	%eax, 0(%rbp,%rax,4)
	incq	%rax
	cmpq	$10, %rax
	jne	.L49
	movl	$40, %edi
.LEHB4:
	call	_Znam@PLT
.LEHE4:
	leaq	8(%rsp), %rdi
	movl	$1, %edx
	movl	$40, %esi
	movq	%rax, 8(%rsp)
.LEHB5:
	call	cudaMallocManaged@PLT
	leaq	.LC10(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	xorl	%r13d, %r13d
.L50:
	movl	0(%rbp,%r13), %esi
	movq	%rbx, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movq	%r12, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	addq	$4, %r13
	cmpq	$40, %r13
	jne	.L50
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$40, %edx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	movl	$16, %ecx
	movl	$10, %edx
	xorl	%esi, %esi
	call	_Z4testPiiji
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movl	$40, %edx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	xorl	%r13d, %r13d
.L51:
	movl	0(%rbp,%r13), %esi
	movq	%rbx, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movq	%r12, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	addq	$4, %r13
	cmpq	$40, %r13
	jne	.L51
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
.LEHE5:
	movq	8(%rsp), %rdi
	testq	%rdi, %rdi
	je	.L52
	call	cudaFree@PLT
.L52:
	leaq	16(%rsp), %rdi
	call	_ZNSt6vectorIiSaIiEED1Ev
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	jmp	.L71
.L59:
	endbr64
	movq	%rax, %rbx
.L53:
	movq	8(%rsp), %rdi
	testq	%rdi, %rdi
	je	.L55
	call	cudaFree@PLT
	jmp	.L55
.L58:
	endbr64
	movq	%rax, %rbx
.L55:
	leaq	16(%rsp), %rdi
	call	_ZNSt6vectorIiSaIiEED1Ev
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L71
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L71:
	call	__stack_chk_fail@PLT
.L57:
	addq	$88, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.LFE5808:
	.section	.gcc_except_table
.LLSDA5808:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE5808-.LLSDACSB5808
.LLSDACSB5808:
	.uleb128 .LEHB3-.LFB5808
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB4-.LFB5808
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L58-.LFB5808
	.uleb128 0
	.uleb128 .LEHB5-.LFB5808
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L59-.LFB5808
	.uleb128 0
	.uleb128 .LEHB6-.LFB5808
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE5808:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL6d_func
	.comm	_ZL6d_func,16,16
	.local	_ZL6func_d
	.comm	_ZL6func_d,16,16
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	-1082130432
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

/**
 * @file   : params_kernelf.cu
 * @brief  : Modified implementation of njuffa's; 
 * 				CUDA kernel functions as parameters with CUDA C++14, CUDA Unified Memory Management
 * @details : Modified implementation of njuffa's,  
 * 				std::function vs. function pointer in C++11, C++14, and now in CUDA
 * 				std::function vs. function pointer for CUDA kernel functions (i.e. __global__ )
 * 
 * @author : Ernest Yeung <ernestyalumni@gmail.com>
 * @date   : 20171020  
 * @ref    : https://devtalk.nvidia.com/default/topic/487190/kernel-functions-as-parameters-/
 * https://stackoverflow.com/questions/16498969/how-do-i-typedef-a-function-pointer-with-the-c11-using-syntax
 * 
 * https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ernestsaveschristmas%2bpaypal%40gmail%2ecom&lc=US&item_name=ernestyalumni&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted 
 * 
 * which won't go through a 3rd. party such as indiegogo, kickstarter, patreon.  
 * Otherwise, I receive emails and messages on how all my (free) material on 
 * physics, math, and engineering have helped students with their studies, 
 * and I know what it's like to not have money as a student, but love physics 
 * (or math, sciences, etc.), so I am committed to keeping all my material 
 * open-source and free, whether or not 
 * sufficiently crowdfunded, under the open-source MIT license: 
 * 	feel free to copy, edit, paste, make your own versions, share, use as you wish.  
 *  Just don't be an asshole and not give credit where credit is due.  
 * Peace out, never give up! -EY
 * 
 * */
/* 
 * COMPILATION TIP
 * nvcc -std=c++14 params_kernelf.cu -o params_kernelf.exe
 * 
 * */

#include <hip/hip_runtime.h>
#include <iostream>
#include <functional> 	// std::function
#include <type_traits> 	// std::add_pointer

#include <map>			// std::map


#include <stdio.h>

#include <vector> // std::vector

#include <memory> // std::unique_ptr

#define BLOCK_COUNT  240
#define THREAD_COUNT 128

/** @brief function pointer example, pf = "processing function"
 * @ref Scott Meyers, Effective Modern C++, pp. 63, Item 9
 * @details pointer to a function of 2 floats
 * */
// this WORKS
// using pf = float (*)(float, float);

using pf = std::add_pointer<float(float,float)>::type;

__device__ float minimum(float a, float b)
{
    return fminf(a,b);
};

__device__ float maximum(float a, float b)
{
    return fmaxf(a,b);
};

/**
 * @ref http://www.cplusplus.com/forum/beginner/4844/
 * 
 * @details From jsmith 
 * The ! operator is the logical-NOT operator.  
 * In C/C++, integers can be implicitly cast to boolean values according to the rule that 0 is false and anything else is true. The boolean false has "value" 0 and true has "value" 1.
 * Programmers sometimes take advantage of the implicit boolean conversion to perform the conversion:
 * f(x) = { 0, iff x == 0, and 1 iff x != 0 }
 * So given an integer x, !!x is 1 iff x is not zero and 0 otherwise.
 * 
 * */

/**
 * @brief 
 * @ref Scott Meyers, Effective Modern C++, pp. 63, Item 9
*/
__device__ pf func_d[2] = { maximum, minimum };


/* this will be inputted in with the following parameters  
 * x = x_d \in \mathbb{R}^n
 * res = res_d \in \mathbb{R}^{N_x}  
 * n = n = total length or size of the problem array  
 * pf func = func_d[findmin]
 */
__device__ void minmax(float *x, float *res, int n, pf func)
{
	int Mx = blockDim.x; // "THREAD_COUNT" or number of threads in a (single) block, in x-direction

//	__shared__ float partExtr[Mx];  // error: expression must have a constant value
 	__shared__ float partExtr[THREAD_COUNT];  // error: expression must have a constant value
  
    int i;	
    int tid = threadIdx.x; // 0,1,... Mx-1

	int kx = threadIdx.x + blockDim.x*blockIdx.x; // kx=0,1,.. Mx*Nx-1

	int Nx = gridDim.x ; 


    float extr = x[0];

	// i=kx, kx + Nx*Mx, kx + 2*Nx*Mx, ... < n 
	// the big idea is to make sure all values of x=x[i], i=0,1,...n-1, gets calculated
	// this is because we worry about the case when n > Nx*Mx (or perhaps n >> Nx*Mx !!!)
    for (i = kx; i < n; i += Nx*Mx) {
        extr = func(extr, x[i]);
    }
	// tid \in 0,1,...Mx-1; kx = tid + blockDim.x*blockIdx.x
    partExtr[tid] = extr;

	// Mx >> 1 = Mx/2; i= Mx/2, Mx/4, ... 2,1
    for (i = Mx >> 1; i > 0; i >>= 1) {
        __syncthreads(); 
		
		// tid \in 0,1,...Mx-1
		// assuming Mx % 2 = 0, 
		// i= Mx/2, Mx/4 ... 2,1
        if (tid < i) {
			// tid \in 0,1,...Mx-1
			// tid+i, so i < tid+i and Mx/2 < (tid + Mx/2), Mx/4 < (tid+ Mx/4) ... 1 < (tid +1)
			// i.e. we're grabbing the "other half", computing against the "other half" in a 
			// thread block, each time we're accessing tid+i
            partExtr[tid] = func(partExtr[tid], partExtr[tid+i]);
        }
    }

    if (tid == 0) {
        res[blockIdx.x] = partExtr[tid];
    }
}

__global__ void minmax_kernel(float *x, float *res, int n, int findmin)
{
    minmax(x, res, n, func_d[findmin]);
}

/**
 *	@fn findExtremum
 * 	@param int findmin - 0 for fmaxf, 1 for fminf
 * 
 * */
float findExtremum(float *x, int n, int findmin)
{
    pf func_h[2] = { fmaxf, fminf };

    float *res_d;	// result of minmax on device GPU; res_d \in \mathbb{R}^{ N_x }
    //float *res_h;	// result of minmax on host CPU
	std::vector<float> h_resultvec( BLOCK_COUNT, 0.f);  // h_resultvec \in \mathbb{R}^{ N_x}
    float *x_d;		// x array on device GPU, of size n, x \in \mathbb{R}^n
    float r;

    if (n < 1) return sqrtf(-1.0f); // NaN

    hipMalloc((void**)&res_d, BLOCK_COUNT*sizeof(res_d[0]));
    hipMalloc((void**)&x_d, n * sizeof(x_d[0]));

    hipMemcpy(x_d, x, n * sizeof(x_d[0]), hipMemcpyHostToDevice);

	// ! is logical NOT, and so !! makes a boolean, which is just 0 or 1
    minmax_kernel<<<BLOCK_COUNT,THREAD_COUNT>>>(x_d, res_d, n, !!findmin);
/*
    if (!res_h) {
		fprintf(stderr, "res_h allocation failed\n");
		exit(EXIT_FAILURE);
    }
*/
    hipMemcpy( h_resultvec.data(), res_d, BLOCK_COUNT * sizeof(res_d[0]), hipMemcpyDeviceToHost);

    hipFree(res_d);
    hipFree(x_d);

    r = h_resultvec[0];

	// i=1,2,...N_x-1; and h_resultvec \in \mathbb{R}^{N_x}
    for (int i = 1; i < BLOCK_COUNT; i++) {
		// int findmin =0,1; func_h[0]=fmaxf, func_h[1]=fminf
		r = func_h[findmin](r, h_resultvec[i]);
	}


    return r;
}

/* =============== sunburntfish's increment, decrement test function =============== */
// @ref https://stackoverflow.com/questions/25848690/should-i-use-stdfunction-or-a-function-pointer-in-c
// @ref pp. 39, Item 5 of Scott Meyers, Effective Modern C++  

// doesn't work, error: dynamic initialization not supported for __device__  
//using funcpf = std::function<float(float,float)>;

//  error: dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.
//__device__ funcpf funcfunc_d[2] = { maximum, minimum };

/**
 * @ref https://stackoverflow.com/questions/16498969/how-do-i-typedef-a-function-pointer-with-the-c11-using-syntax
 * How do I typedef a function pointer with the C++11 using syntax?  answer from 0x499602D2
 * */
using pf1 = std::add_pointer<int(int)>::type;  

__device__ int increment_k(int t) {
	return t+ 1;
}

__device__ int decrement_k(int t) {
	return t-1;
}

/**
 * @fn incdecops
 * @ref Stanley B. Lippman, Josee Lajoie, Barbara E. Moo. C++ Primer 
 * */
//  error: dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.
/* __device__ std::map<int, pf1> incdecops = {
	{0, increment_k}, 
	{1, decrement_k} };
*/

__device__ pf1 d_func[2] = { increment_k, decrement_k };

__global__ void test_k(int *testArray, int funcId, uint numPoints ) {
	unsigned int index = threadIdx.x + __umul24(blockIdx.x,blockDim.x); 
	
	if (index >= numPoints) { return ; }
	
	pf1 func = d_func[funcId];

	// i=kx, kx + Nx*Mx, kx + 2*Nx*Mx, ... < n 
	// the big idea is to make sure all values of x=x[i], i=0,1,...n-1, gets calculated
	// this is because we worry about the case when n > Nx*Mx (or perhaps n >> Nx*Mx !!!)
	int Mx = blockDim.x; 
	int Nx = gridDim.x; 
	for (int idx = index; idx < numPoints; idx += Nx*Mx) {
		int temp = func(testArray[idx]);
		testArray[idx] = temp;
	}
		
}

void test(int *testArray, int funcId, unsigned int numPoints, int numThreadsPerBlock) {
	// define grid and block size
	unsigned int numBlocks = (numPoints + numThreadsPerBlock -1)/numThreadsPerBlock;
//	computeGridSize(numPoints, 256, numBlocks, numThreadsPerBlock);

	test_k<<<numBlocks, numThreadsPerBlock>>>( testArray, funcId, numPoints); 
}

int main (void)
{
	// sanity check
	constexpr const int Mx = THREAD_COUNT;
	std::cout << " Mx >> 1 : " << ( Mx >> 1) << std::endl;
	for (int test_i = Mx >> 1; test_i >0; test_i >>= 1) { std::cout << test_i << " " ; } std::cout << std::endl;

	constexpr const int ELEM_COUNT = 8 ;
    float x[ELEM_COUNT] = {-1.3f, 2.4f, 3.5f, -2.3f, 4.5f, 0.4f, -5.3f, -1.6f};

    float minimum = findExtremum(x, ELEM_COUNT, 1);
    float maximum = findExtremum(x, ELEM_COUNT, 0);

    printf("min=% 13.6e  max=% 13.6e\n", minimum, maximum);

	std::cout << std::endl << "increment, decrement " << std::endl ;

	int numPoints = 10;
	
	// on host
	std::vector<int> testArray(numPoints,0);
	for (uint i=0; i<numPoints;i++) { testArray[i] = i; }
	
	auto deleterZZ_lambda=[&](int* ptr){ hipFree(ptr); };
	std::unique_ptr<int[], decltype(deleterZZ_lambda)> d_test(new int[numPoints], deleterZZ_lambda); // u for unique and unified
	hipMallocManaged((void **) &d_test, numPoints*sizeof(float));

	std::cout << " Before : " << std::endl;
	for (auto ele : testArray) { std::cout << ele << " " ; } std::cout << std::endl;

	hipMemcpy(d_test.get(),testArray.data(),numPoints*sizeof(int),hipMemcpyHostToDevice); 
	
	test(d_test.get(), 0, numPoints, 16);
	
	hipMemcpy(testArray.data(),d_test.get(), numPoints*sizeof(int),hipMemcpyDeviceToHost); 
	 
	std::cout << " After : " << std::endl; 
	for (auto ele : testArray) { std::cout << ele << " " ; } std::cout << std::endl;


    return EXIT_SUCCESS;
}


	.text
	.file	"params_kernelf.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__minmax_kernelPfS_ii # -- Begin function _Z28__device_stub__minmax_kernelPfS_ii
	.type	_Z28__device_stub__minmax_kernelPfS_ii,@function
_Z28__device_stub__minmax_kernelPfS_ii: # @_Z28__device_stub__minmax_kernelPfS_ii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$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), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z13minmax_kernelPfS_ii, %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	_Z28__device_stub__minmax_kernelPfS_ii, .Lfunc_end0-_Z28__device_stub__minmax_kernelPfS_ii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z12findExtremumPfii
.LCPI1_0:
	.long	0xbf800000                      # float -1
	.text
	.globl	_Z12findExtremumPfii
	.type	_Z12findExtremumPfii,@function
_Z12findExtremumPfii:                   # @_Z12findExtremumPfii
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:                                # %.noexc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movl	%esi, %r14d
	movq	%rdi, %r15
	movq	$fmaxf, 32(%rsp)
	movq	$fminf, 40(%rsp)
	movl	$960, %edi                      # imm = 0x3C0
	callq	_Znwm
	movq	%rax, %rbx
	movl	$960, %edx                      # imm = 0x3C0
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	testl	%r14d, %r14d
	jle	.LBB1_1
# %bb.2:
.Ltmp0:
	leaq	16(%rsp), %rdi
	movl	$960, %esi                      # imm = 0x3C0
	callq	hipMalloc
.Ltmp1:
# %bb.3:
	movl	%r14d, %r12d
	shlq	$2, %r12
.Ltmp2:
	leaq	8(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
.Ltmp3:
# %bb.4:
	movq	8(%rsp), %rdi
.Ltmp4:
	movq	%r15, %rsi
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp5:
# %bb.5:
.Ltmp6:
	movabsq	$4294967536, %rdi               # imm = 0x1000000F0
	movabsq	$4294967424, %rdx               # imm = 0x100000080
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp7:
# %bb.6:
	testl	%eax, %eax
	jne	.LBB1_8
# %bb.7:
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	xorl	%ecx, %ecx
	testl	%ebp, %ebp
	setne	%cl
.Ltmp8:
	movl	%r14d, %edx
	callq	_Z28__device_stub__minmax_kernelPfS_ii
.Ltmp9:
.LBB1_8:
	movq	16(%rsp), %rsi
.Ltmp10:
	movl	$960, %edx                      # imm = 0x3C0
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp11:
# %bb.9:
	movq	16(%rsp), %rdi
.Ltmp12:
	callq	hipFree
.Ltmp13:
# %bb.10:
	movq	8(%rsp), %rdi
.Ltmp14:
	callq	hipFree
.Ltmp15:
# %bb.11:
	movss	(%rbx), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movslq	%ebp, %rax
	movq	32(%rsp,%rax,8), %r14
	movl	$1, %r15d
.LBB1_12:                               # =>This Inner Loop Header: Depth=1
	movss	(%rbx,%r15,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
.Ltmp17:
	callq	*%r14
.Ltmp18:
# %bb.13:                               #   in Loop: Header=BB1_12 Depth=1
	incq	%r15
	cmpq	$240, %r15
	jne	.LBB1_12
	jmp	.LBB1_14
.LBB1_1:                                # %call.sqrt
	movss	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	callq	sqrtf
.LBB1_14:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit
	movss	%xmm0, 28(%rsp)                 # 4-byte Spill
	movq	%rbx, %rdi
	callq	_ZdlPv
	movss	28(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB1_15:
	.cfi_def_cfa_offset 96
.Ltmp16:
	jmp	.LBB1_16
.LBB1_17:
.Ltmp19:
.LBB1_16:                               # %_ZNSt6vectorIfSaIfEED2Ev.exit25
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	_Z12findExtremumPfii, .Lfunc_end1-_Z12findExtremumPfii
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp15-.Ltmp0                 #   Call between .Ltmp0 and .Ltmp15
	.uleb128 .Ltmp16-.Lfunc_begin0          #     jumps to .Ltmp16
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp17-.Lfunc_begin0          # >> Call Site 3 <<
	.uleb128 .Ltmp18-.Ltmp17                #   Call between .Ltmp17 and .Ltmp18
	.uleb128 .Ltmp19-.Lfunc_begin0          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Lfunc_end1-.Ltmp18            #   Call between .Ltmp18 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z21__device_stub__test_kPiij   # -- Begin function _Z21__device_stub__test_kPiij
	.type	_Z21__device_stub__test_kPiij,@function
_Z21__device_stub__test_kPiij:          # @_Z21__device_stub__test_kPiij
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%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	$_Z6test_kPiij, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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	_Z21__device_stub__test_kPiij, .Lfunc_end2-_Z21__device_stub__test_kPiij
	.cfi_endproc
                                        # -- End function
	.globl	_Z4testPiiji                    # -- Begin function _Z4testPiiji
	.type	_Z4testPiiji,@function
_Z4testPiiji:                           # @_Z4testPiiji
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %rbp, -16
                                        # kill: def $ecx killed $ecx def $rcx
	movl	%edx, %ebx
	movl	%esi, %ebp
	movq	%rdi, %r14
	leal	(%rbx,%rcx), %eax
	decl	%eax
	xorl	%edx, %edx
	divl	%ecx
                                        # kill: def $eax killed $eax def $rax
	btsq	$32, %rax
	movl	%ecx, %edx
	btsq	$32, %rdx
	movq	%rax, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB3_2
# %bb.1:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB3_2:
	.cfi_def_cfa_offset 32
	movq	%r14, %rdi
	movl	%ebp, %esi
	movl	%ebx, %edx
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z21__device_stub__test_kPiij   # TAILCALL
.Lfunc_end3:
	.size	_Z4testPiiji, .Lfunc_end3-_Z4testPiiji
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI4_0:
	.long	0xbfa66666                      # float -1.29999995
	.long	0x4019999a                      # float 2.4000001
	.long	0x40600000                      # float 3.5
	.long	0xc0133333                      # float -2.29999995
.LCPI4_1:
	.long	0x40900000                      # float 4.5
	.long	0x3ecccccd                      # float 0.400000006
	.long	0xc0a9999a                      # float -5.30000019
	.long	0xbfcccccd                      # float -1.60000002
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$64, %ebx
	movl	$_ZSt4cout, %edi
	movl	$64, %esi
	callq	_ZNSolsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$64, %ebp
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	shrl	%ebp
	cmpl	$2, %ebx
	movl	%ebp, %ebx
	jae	.LBB4_1
# %bb.2:                                # %.noexc
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %r15d
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movaps	.LCPI4_0(%rip), %xmm0           # xmm0 = [-1.29999995E+0,2.4000001E+0,3.5E+0,-2.29999995E+0]
	leaq	16(%rsp), %rbx
	movaps	%xmm0, (%rbx)
	movaps	.LCPI4_1(%rip), %xmm0           # xmm0 = [4.5E+0,4.00000006E-1,-5.30000019E+0,-1.60000002E+0]
	movaps	%xmm0, 16(%rbx)
	movq	%rbx, %rdi
	movl	$8, %esi
	movl	$1, %edx
	callq	_Z12findExtremumPfii
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	xorl	%r14d, %r14d
	movq	%rbx, %rdi
	movl	$8, %esi
	xorl	%edx, %edx
	callq	_Z12findExtremumPfii
	cvtss2sd	12(%rsp), %xmm2                 # 4-byte Folded Reload
	cvtss2sd	%xmm0, %xmm1
	movl	$.L.str.2, %edi
	movaps	%xmm2, %xmm0
	movb	$2, %al
	callq	printf
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	%rax, %rbx
	movl	$.L.str.3, %esi
	movl	$21, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$40, %edi
	callq	_Znwm
	movq	%rax, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rax)
	movups	%xmm0, 16(%rax)
	movq	$0, 32(%rax)
.LBB4_3:                                # %_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_.exit
                                        # =>This Inner Loop Header: Depth=1
	movl	%r14d, (%rbx,%r14,4)
	incq	%r14
	cmpq	$10, %r14
	jne	.LBB4_3
# %bb.4:
.Ltmp20:
	movl	$40, %edi
	callq	_Znam
.Ltmp21:
# %bb.5:
	movq	%rsp, %rdi
	movq	%rax, (%rdi)
.Ltmp23:
	movl	$40, %esi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp24:
# %bb.6:
.Ltmp25:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$10, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp26:
# %bb.7:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %r14
.Ltmp27:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp28:
# %bb.8:                                # %.noexc49
.Ltmp29:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp30:
# %bb.9:                                # %.noexc50
.Ltmp31:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp32:
# %bb.10:                               # %_ZNSolsEPFRSoS_E.exit.preheader.preheader
	xorl	%r14d, %r14d
.LBB4_11:                               # %_ZNSolsEPFRSoS_E.exit.preheader
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r14), %esi
.Ltmp33:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp34:
# %bb.12:                               #   in Loop: Header=BB4_11 Depth=1
.Ltmp35:
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp36:
# %bb.13:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit37
                                        #   in Loop: Header=BB4_11 Depth=1
	addq	$4, %r14
	cmpq	$40, %r14
	jne	.LBB4_11
# %bb.14:
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp38:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp39:
# %bb.15:                               # %.noexc52
.Ltmp40:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp41:
# %bb.16:                               # %.noexc53
.Ltmp42:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp43:
# %bb.17:                               # %_ZNSolsEPFRSoS_E.exit35
	movq	(%rsp), %rdi
.Ltmp44:
	movl	$40, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp45:
# %bb.18:
	movq	(%rsp), %rdi
.Ltmp46:
	xorl	%esi, %esi
	movl	$10, %edx
	movl	$16, %ecx
	callq	_Z4testPiiji
.Ltmp47:
# %bb.19:
	movq	(%rsp), %rsi
.Ltmp48:
	movl	$40, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp49:
# %bb.20:
.Ltmp50:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp51:
# %bb.21:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit39
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %r14
.Ltmp52:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp53:
# %bb.22:                               # %.noexc56
.Ltmp54:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp55:
# %bb.23:                               # %.noexc57
.Ltmp56:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp57:
# %bb.24:                               # %_ZNSolsEPFRSoS_E.exit41.preheader.preheader
	xorl	%r14d, %r14d
.LBB4_25:                               # %_ZNSolsEPFRSoS_E.exit41.preheader
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r14), %esi
.Ltmp58:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp59:
# %bb.26:                               #   in Loop: Header=BB4_25 Depth=1
.Ltmp60:
	movl	$.L.str.1, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp61:
# %bb.27:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit45
                                        #   in Loop: Header=BB4_25 Depth=1
	addq	$4, %r14
	cmpq	$40, %r14
	jne	.LBB4_25
# %bb.28:
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp63:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp64:
# %bb.29:                               # %.noexc60
.Ltmp65:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp66:
# %bb.30:                               # %.noexc61
.Ltmp67:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp68:
# %bb.31:                               # %_ZNSt6vectorIiSaIiEED2Ev.exit
	movq	%rsp, %rdi
	callq	_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev
	movq	%rbx, %rdi
	callq	_ZdlPv
	xorl	%eax, %eax
	addq	$56, %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
.LBB4_32:
	.cfi_def_cfa_offset 96
.Ltmp22:
	movq	%rax, %r14
	jmp	.LBB4_36
.LBB4_34:
.Ltmp69:
	jmp	.LBB4_35
.LBB4_37:
.Ltmp62:
	jmp	.LBB4_35
.LBB4_33:
.Ltmp37:
.LBB4_35:
	movq	%rax, %r14
	movq	%rsp, %rdi
	callq	_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev
.LBB4_36:                               # %_ZNSt6vectorIiSaIiEED2Ev.exit47
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table4:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp20-.Lfunc_begin1          #   Call between .Lfunc_begin1 and .Ltmp20
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin1          # >> Call Site 2 <<
	.uleb128 .Ltmp21-.Ltmp20                #   Call between .Ltmp20 and .Ltmp21
	.uleb128 .Ltmp22-.Lfunc_begin1          #     jumps to .Ltmp22
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp23-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp32-.Ltmp23                #   Call between .Ltmp23 and .Ltmp32
	.uleb128 .Ltmp69-.Lfunc_begin1          #     jumps to .Ltmp69
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp33-.Lfunc_begin1          # >> Call Site 4 <<
	.uleb128 .Ltmp36-.Ltmp33                #   Call between .Ltmp33 and .Ltmp36
	.uleb128 .Ltmp37-.Lfunc_begin1          #     jumps to .Ltmp37
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp38-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Ltmp57-.Ltmp38                #   Call between .Ltmp38 and .Ltmp57
	.uleb128 .Ltmp69-.Lfunc_begin1          #     jumps to .Ltmp69
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp58-.Lfunc_begin1          # >> Call Site 6 <<
	.uleb128 .Ltmp61-.Ltmp58                #   Call between .Ltmp58 and .Ltmp61
	.uleb128 .Ltmp62-.Lfunc_begin1          #     jumps to .Ltmp62
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp63-.Lfunc_begin1          # >> Call Site 7 <<
	.uleb128 .Ltmp68-.Ltmp63                #   Call between .Ltmp63 and .Ltmp68
	.uleb128 .Ltmp69-.Lfunc_begin1          #     jumps to .Ltmp69
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp68-.Lfunc_begin1          # >> Call Site 8 <<
	.uleb128 .Lfunc_end4-.Ltmp68            #   Call between .Ltmp68 and .Lfunc_end4
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.p2align	1, 0x90                         # -- Begin function _ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev
	.type	_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev,@function
_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev: # @_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev
.Lfunc_begin2:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception2
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	je	.LBB5_2
# %bb.1:
.Ltmp70:
	callq	hipFree
.Ltmp71:
.LBB5_2:                                # %_ZZ4mainENKUlPiE_clES_.exit
	movq	$0, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB5_3:
	.cfi_def_cfa_offset 16
.Ltmp72:
	movq	%rax, %rdi
	callq	__clang_call_terminate
.Lfunc_end5:
	.size	_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev, .Lfunc_end5-_ZNSt10unique_ptrIA_iZ4mainEUlPiE_ED2Ev
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table5:
.Lexception2:
	.byte	255                             # @LPStart Encoding = omit
	.byte	3                               # @TType Encoding = udata4
	.uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0:
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end2-.Lcst_begin2
.Lcst_begin2:
	.uleb128 .Ltmp70-.Lfunc_begin2          # >> Call Site 1 <<
	.uleb128 .Ltmp71-.Ltmp70                #   Call between .Ltmp70 and .Ltmp71
	.uleb128 .Ltmp72-.Lfunc_begin2          #     jumps to .Ltmp72
	.byte	1                               #   On action: 1
.Lcst_end2:
	.byte	1                               # >> Action Record 1 <<
                                        #   Catch TypeInfo 1
	.byte	0                               #   No further actions
	.p2align	2, 0x0
                                        # >> Catch TypeInfos <<
	.long	0                               # TypeInfo 1
.Lttbase0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text.__clang_call_terminate,"axG",@progbits,__clang_call_terminate,comdat
	.hidden	__clang_call_terminate          # -- Begin function __clang_call_terminate
	.weak	__clang_call_terminate
	.type	__clang_call_terminate,@function
__clang_call_terminate:                 # @__clang_call_terminate
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__cxa_begin_catch
	callq	_ZSt9terminatev
.Lfunc_end6:
	.size	__clang_call_terminate, .Lfunc_end6-__clang_call_terminate
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13minmax_kernelPfS_ii, %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	$_Z6test_kPiij, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$func_d, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movl	$16, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$d_func, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movl	$16, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	func_d,@object                  # @func_d
	.local	func_d
	.comm	func_d,16,16
	.type	_Z13minmax_kernelPfS_ii,@object # @_Z13minmax_kernelPfS_ii
	.section	.rodata,"a",@progbits
	.globl	_Z13minmax_kernelPfS_ii
	.p2align	3, 0x0
_Z13minmax_kernelPfS_ii:
	.quad	_Z28__device_stub__minmax_kernelPfS_ii
	.size	_Z13minmax_kernelPfS_ii, 8

	.type	d_func,@object                  # @d_func
	.local	d_func
	.comm	d_func,16,16
	.type	_Z6test_kPiij,@object           # @_Z6test_kPiij
	.globl	_Z6test_kPiij
	.p2align	3, 0x0
_Z6test_kPiij:
	.quad	_Z21__device_stub__test_kPiij
	.size	_Z6test_kPiij, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" Mx >> 1 : "
	.size	.L.str, 12

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" "
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"min=% 13.6e  max=% 13.6e\n"
	.size	.L.str.2, 26

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"increment, decrement "
	.size	.L.str.3, 22

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	" After : "
	.size	.L.str.5, 10

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13minmax_kernelPfS_ii"
	.size	.L__unnamed_1, 24

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z6test_kPiij"
	.size	.L__unnamed_2, 14

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"func_d"
	.size	.L__unnamed_3, 7

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"d_func"
	.size	.L__unnamed_4, 7

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z28__device_stub__minmax_kernelPfS_ii
	.addrsig_sym fmaxf
	.addrsig_sym fminf
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym _Z21__device_stub__test_kPiij
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym func_d
	.addrsig_sym _Z13minmax_kernelPfS_ii
	.addrsig_sym d_func
	.addrsig_sym _Z6test_kPiij
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.p2align	2                               ; -- Begin function _Z7minimumff
	.type	_Z7minimumff,@function
_Z7minimumff:                           ; @_Z7minimumff
; %bb.0:
	s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
	v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v0, v0, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_min_f32_e32 v0, v0, v1
	s_setpc_b64 s[30:31]
.Lfunc_end0:
	.size	_Z7minimumff, .Lfunc_end0-_Z7minimumff
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Function info:
; codeLenInByte = 24
; NumSgprs: 32
; NumVgprs: 2
; ScratchSize: 0
; MemoryBound: 0
	.text
	.p2align	2                               ; -- Begin function _Z7maximumff
	.type	_Z7maximumff,@function
_Z7maximumff:                           ; @_Z7maximumff
; %bb.0:
	s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
	v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v0, v0, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_max_f32_e32 v0, v0, v1
	s_setpc_b64 s[30:31]
.Lfunc_end1:
	.size	_Z7maximumff, .Lfunc_end1-_Z7maximumff
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Function info:
; codeLenInByte = 24
; NumSgprs: 32
; NumVgprs: 2
; ScratchSize: 0
; MemoryBound: 0
	.text
	.protected	_Z13minmax_kernelPfS_ii ; -- Begin function _Z13minmax_kernelPfS_ii
	.globl	_Z13minmax_kernelPfS_ii
	.p2align	8
	.type	_Z13minmax_kernelPfS_ii,@function
_Z13minmax_kernelPfS_ii:                ; @_Z13minmax_kernelPfS_ii
; %bb.0:
	s_mov_b64 s[40:41], s[0:1]
	s_clause 0x1
	s_load_b64 s[48:49], s[2:3], 0x10
	s_load_b32 s0, s[2:3], 0x18
	s_mov_b64 s[36:37], s[2:3]
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, func_d@rel32@lo+4
	s_addc_u32 s3, s3, func_d@rel32@hi+12
	s_mov_b64 s[38:39], s[4:5]
	v_mov_b32_e32 v40, v0
	s_load_b128 s[44:47], s[36:37], 0x0
	s_mov_b32 s34, s13
	s_mov_b32 s33, s15
	s_mov_b32 s35, s14
	s_mov_b32 s52, exec_lo
	s_mov_b32 s32, 0
	v_and_b32_e32 v41, 0x3ff, v40
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s5, s49, 31
	s_mov_b32 s4, s49
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[4:5], s[4:5], 3
	s_add_u32 s2, s4, s2
	s_addc_u32 s3, s5, s3
	s_add_u32 s4, s36, 24
	s_addc_u32 s5, s37, 0
	s_cmp_lt_u32 s13, s0
	s_cselect_b32 s1, 12, 18
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v0, s1
	global_load_u16 v0, v0, s[4:5]
	s_load_b32 s1, s[44:45], 0x0
	s_load_b64 s[42:43], s[2:3], 0x0
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[42:43], null, s34, v0, v[41:42]
	v_readfirstlane_b32 s49, v0
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v0, s1
	s_delay_alu instid0(VALU_DEP_3)
	v_cmpx_gt_i32_e64 s48, v42
	s_cbranch_execz .LBB2_4
; %bb.1:                                ; %.lr.ph.i
	v_ashrrev_i32_e32 v43, 31, v42
	s_mul_i32 s50, s0, s49
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_ashr_i32 s51, s50, 31
	v_lshlrev_b64 v[0:1], 2, v[42:43]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v43, vcc_lo, s44, v0
	v_add_co_ci_u32_e32 v44, vcc_lo, s45, v1, vcc_lo
	v_mov_b32_e32 v0, s1
	s_lshl_b64 s[44:45], s[50:51], 2
	s_mov_b32 s51, 0
.LBB2_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v1, v[43:44], off
	v_mov_b32_e32 v31, v40
	s_add_u32 s8, s36, 24
	s_addc_u32 s9, s37, 0
	s_mov_b64 s[4:5], s[40:41]
	s_mov_b64 s[10:11], s[38:39]
	s_mov_b32 s12, s34
	s_mov_b32 s13, s35
	s_mov_b32 s14, s33
	s_swappc_b64 s[30:31], s[42:43]
	v_add_nc_u32_e32 v42, s50, v42
	v_add_co_u32 v43, s0, v43, s44
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e64 v44, s0, s45, v44, s0
	v_cmp_le_i32_e32 vcc_lo, s48, v42
	s_or_b32 s51, vcc_lo, s51
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s51
	s_cbranch_execnz .LBB2_2
; %bb.3:                                ; %Flow18
	s_or_b32 exec_lo, exec_lo, s51
.LBB2_4:                                ; %Flow19
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s52
	v_lshlrev_b32_e32 v42, 2, v41
	s_cmp_lt_u32 s49, 2
	ds_store_b32 v42, v0
	s_cbranch_scc1 .LBB2_8
.LBB2_5:                                ; %.lr.ph33.i
                                        ; =>This Inner Loop Header: Depth=1
	s_lshr_b32 s44, s49, 1
	s_mov_b32 s45, exec_lo
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e64 s44, v41
	s_cbranch_execz .LBB2_7
; %bb.6:                                ;   in Loop: Header=BB2_5 Depth=1
	v_lshl_add_u32 v1, s44, 2, v42
	v_mov_b32_e32 v31, v40
	s_add_u32 s8, s36, 24
	s_addc_u32 s9, s37, 0
	ds_load_b32 v0, v42
	ds_load_b32 v1, v1
	s_mov_b64 s[4:5], s[40:41]
	s_mov_b64 s[10:11], s[38:39]
	s_mov_b32 s12, s34
	s_mov_b32 s13, s35
	s_mov_b32 s14, s33
	s_swappc_b64 s[30:31], s[42:43]
	ds_store_b32 v42, v0
.LBB2_7:                                ;   in Loop: Header=BB2_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s45
	s_cmp_gt_u32 s49, 3
	s_mov_b32 s49, s44
	s_cbranch_scc1 .LBB2_5
.LBB2_8:                                ; %._crit_edge34.i
	s_mov_b32 s35, 0
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v41
	s_cbranch_execz .LBB2_10
; %bb.9:
	ds_load_b32 v0, v42
	s_lshl_b64 s[0:1], s[34:35], 2
	v_mov_b32_e32 v1, 0
	s_add_u32 s0, s46, s0
	s_addc_u32 s1, s47, s1
	s_waitcnt lgkmcnt(0)
	global_store_b32 v1, v0, s[0:1]
.LBB2_10:                               ; %_Z6minmaxPfS_iPFfffE.exit
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13minmax_kernelPfS_ii
		.amdhsa_group_segment_fixed_size 512
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 13
		.amdhsa_user_sgpr_dispatch_ptr 1
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 1
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 1
		.amdhsa_enable_private_segment 1
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 1
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 2
		.amdhsa_next_free_vgpr 45
		.amdhsa_next_free_sgpr 53
		.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	_Z13minmax_kernelPfS_ii, .Lfunc_end2-_Z13minmax_kernelPfS_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 560
; NumSgprs: 55
; NumVgprs: 45
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 512 bytes/workgroup (compile time only)
; SGPRBlocks: 6
; VGPRBlocks: 5
; NumSGPRsForWavesPerEU: 55
; NumVGPRsForWavesPerEU: 45
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; COMPUTE_PGM_RSRC2:USER_SGPR: 13
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 1
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 2
	.text
	.p2align	2                               ; -- Begin function _Z11increment_ki
	.type	_Z11increment_ki,@function
_Z11increment_ki:                       ; @_Z11increment_ki
; %bb.0:
	s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
	v_add_nc_u32_e32 v0, 1, v0
	s_setpc_b64 s[30:31]
.Lfunc_end3:
	.size	_Z11increment_ki, .Lfunc_end3-_Z11increment_ki
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Function info:
; codeLenInByte = 12
; NumSgprs: 32
; NumVgprs: 1
; ScratchSize: 0
; MemoryBound: 0
	.text
	.p2align	2                               ; -- Begin function _Z11decrement_ki
	.type	_Z11decrement_ki,@function
_Z11decrement_ki:                       ; @_Z11decrement_ki
; %bb.0:
	s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
	v_add_nc_u32_e32 v0, -1, v0
	s_setpc_b64 s[30:31]
.Lfunc_end4:
	.size	_Z11decrement_ki, .Lfunc_end4-_Z11decrement_ki
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Function info:
; codeLenInByte = 12
; NumSgprs: 32
; NumVgprs: 1
; ScratchSize: 0
; MemoryBound: 0
	.text
	.protected	_Z6test_kPiij           ; -- Begin function _Z6test_kPiij
	.globl	_Z6test_kPiij
	.p2align	8
	.type	_Z6test_kPiij,@function
_Z6test_kPiij:                          ; @_Z6test_kPiij
; %bb.0:
	s_mov_b64 s[34:35], s[2:3]
	s_load_b32 s2, s[2:3], 0x1c
	s_load_b64 s[42:43], s[34:35], 0x8
	v_mov_b32_e32 v40, v0
	s_mov_b64 s[38:39], s[0:1]
	s_add_u32 s0, s34, 16
	s_addc_u32 s1, s35, 0
	s_and_b32 s3, s13, 0xffffff
	v_and_b32_e32 v0, 0x3ff, v40
	s_mov_b32 s32, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[41:42], null, s3, s2, v[0:1]
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e64 s43, v41
	s_cbranch_execz .LBB5_3
; %bb.1:
	s_mov_b64 s[36:37], s[4:5]
	s_load_b64 s[4:5], s[34:35], 0x0
	s_load_b32 s3, s[0:1], 0x0
	s_ashr_i32 s1, s42, 31
	s_mov_b32 s0, s42
	s_getpc_b64 s[6:7]
	s_add_u32 s6, s6, d_func@rel32@lo+4
	s_addc_u32 s7, s7, d_func@rel32@hi+12
	s_lshl_b64 s[0:1], s[0:1], 3
	v_ashrrev_i32_e32 v42, 31, v41
	s_add_u32 s0, s0, s6
	s_addc_u32 s1, s1, s7
	s_mov_b32 s33, s15
	s_load_b64 s[44:45], s[0:1], 0x0
	v_lshlrev_b64 v[0:1], 2, v[41:42]
	s_mov_b32 s40, s13
	s_mov_b32 s41, s14
	s_mov_b32 s42, 0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_add_co_u32 v42, vcc_lo, s4, v0
	s_mul_i32 s46, s3, s2
	v_add_co_ci_u32_e32 v43, vcc_lo, s5, v1, vcc_lo
	s_ashr_i32 s47, s46, 31
	s_lshl_b64 s[48:49], s[46:47], 2
.LBB5_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v0, v[42:43], off
	v_mov_b32_e32 v31, v40
	s_add_u32 s8, s34, 16
	s_addc_u32 s9, s35, 0
	s_mov_b64 s[4:5], s[38:39]
	s_mov_b64 s[10:11], s[36:37]
	s_mov_b32 s12, s40
	s_mov_b32 s13, s41
	s_mov_b32 s14, s33
	s_swappc_b64 s[30:31], s[44:45]
	v_add_nc_u32_e32 v41, s46, v41
	global_store_b32 v[42:43], v0, off
	v_add_co_u32 v42, s0, v42, s48
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e64 v43, s0, s49, v43, s0
	v_cmp_le_u32_e32 vcc_lo, s43, v41
	s_or_b32 s42, vcc_lo, s42
	s_and_not1_b32 exec_lo, exec_lo, s42
	s_cbranch_execnz .LBB5_2
.LBB5_3:                                ; %.loopexit
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6test_kPiij
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 13
		.amdhsa_user_sgpr_dispatch_ptr 1
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 1
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 1
		.amdhsa_enable_private_segment 1
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 1
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 2
		.amdhsa_next_free_vgpr 44
		.amdhsa_next_free_sgpr 50
		.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_end5:
	.size	_Z6test_kPiij, .Lfunc_end5-_Z6test_kPiij
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 324
; NumSgprs: 52
; NumVgprs: 44
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 6
; VGPRBlocks: 5
; NumSGPRsForWavesPerEU: 52
; NumVGPRsForWavesPerEU: 44
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; COMPUTE_PGM_RSRC2:USER_SGPR: 13
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 1
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 2
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	func_d                  ; @func_d
	.type	func_d,@object
	.data
	.globl	func_d
	.p2align	4, 0x0
func_d:
	.quad	_Z7maximumff
	.quad	_Z7minimumff
	.size	func_d, 16

	.protected	d_func                  ; @d_func
	.type	d_func,@object
	.globl	d_func
	.p2align	4, 0x0
d_func:
	.quad	_Z11increment_ki
	.quad	_Z11decrement_ki
	.size	d_func, 16

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z7minimumff
	.addrsig_sym _Z7maximumff
	.addrsig_sym _Z11increment_ki
	.addrsig_sym _Z11decrement_ki
	.addrsig_sym func_d
	.addrsig_sym d_func
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           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
      - .offset:         104
        .size:           8
        .value_kind:     hidden_hostcall_buffer
      - .offset:         112
        .size:           8
        .value_kind:     hidden_multigrid_sync_arg
      - .offset:         120
        .size:           8
        .value_kind:     hidden_heap_v1
      - .offset:         128
        .size:           8
        .value_kind:     hidden_default_queue
      - .offset:         224
        .size:           8
        .value_kind:     hidden_queue_ptr
    .group_segment_fixed_size: 512
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13minmax_kernelPfS_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     55
    .sgpr_spill_count: 0
    .symbol:         _Z13minmax_kernelPfS_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: true
    .vgpr_count:     45
    .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:         12
        .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
      - .offset:         96
        .size:           8
        .value_kind:     hidden_hostcall_buffer
      - .offset:         104
        .size:           8
        .value_kind:     hidden_multigrid_sync_arg
      - .offset:         112
        .size:           8
        .value_kind:     hidden_heap_v1
      - .offset:         120
        .size:           8
        .value_kind:     hidden_default_queue
      - .offset:         216
        .size:           8
        .value_kind:     hidden_queue_ptr
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6test_kPiij
    .private_segment_fixed_size: 0
    .sgpr_count:     52
    .sgpr_spill_count: 0
    .symbol:         _Z6test_kPiij.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: true
    .vgpr_count:     44
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
