 	return verification_scalar;
 }
 
-__global__ void xs_lookup_kernel_optimization_4(Inputs in, SimulationData GSD, int is_fuel )
+__global__ void xs_lookup_kernel_optimization_4(Inputs in, SimulationData GSD, int m )
 {
 	// The lookup ID. Used to set the seed, and to store the verification value
 	const int i = blockIdx.x *blockDim.x + threadIdx.x;



////////////////////////////////////////////////////////////////////////////////////
// Optimization 4 -- Kernel Splitting + Fuel or Not-Fuel Lookups + Fuel or Not_fuel
//                   Pre-Sort
////////////////////////////////////////////////////////////////////////////////////
// This optimization builds on optimization 3, adding in a "fuel/other" sort before
// hand so that the warps should be densely packed together. This should maximize
// SIMD efficiency of the kernel, but may incur an added cost for the sort.
////////////////////////////////////////////////////////////////////////////////////
unsigned long long run_event_based_simulation_optimization_4(Inputs in, SimulationData GSD, int mype)
{
	char * optimization_name = "Optimization 4 - Fuel or Other Lookup Kernels + Full Sort";
	
	if( mype == 0)	printf("Simulation Kernel:\"%s\"\n", optimization_name);
	

	gpuErrchk( cudaDeviceSynchronize() );

	// Count the number of fuel material lookups that need to be performed (fuel id = 0)
	int n_lookups_per_material[12];
	for( int m = 0; m < 12; m++ )
		n_lookups_per_material[m] = thrust::count(thrust::device, GSD.mat_samples, GSD.mat_samples + in.lookups, m);

	//int n_fuel_lookups = thrust::count(thrust::device, GSD.mat_samples, GSD.mat_samples + in.lookups, 0);
	//printf("Going to perform %d fuel lookups...\n", n_fuel_lookups);
	thrust::sort_by_key(thrust::device, GSD.mat_samples, GSD.mat_samples + in.lookups, GSD.p_energy_samples);
	
	// Launch all material kernels individually
	for( int m = 0; m < 12; m++ )
	{
		nthreads = 32;
		nblocks = ceil((double) n_lookups_per_material[m] / (double) nthreads);
		xs_lookup_kernel_optimization_4<<<nblocks, nthreads>>>( in, GSD, m );
	}
	gpuErrchk( cudaPeekAtLastError() );
	gpuErrchk( cudaDeviceSynchronize() );

	// Launch all material kernels individually (asynchronous is allowed)
	/*
	xs_lookup_kernel_optimization_4<<<nblocks, nthreads>>>( in, GSD, 1 );
	xs_lookup_kernel_optimization_4<<<nblocks, nthreads>>>( in, GSD, 0 );
	gpuErrchk( cudaPeekAtLastError() );
	gpuErrchk( cudaDeviceSynchronize() );
	*/
	
	////////////////////////////////////////////////////////////////////////////////
	// Reduce Verification Results
