public GPURadixSort( ComputeCommandQueue commandQue, ComputeContext context, ComputeDevice device ) { gpuConstants = new GPUConstants(); gpuConstants.L = radix_BitsL; gpuConstants.numGroupsPerBlock = NumGroupsPerBlock; gpuConstants.R = R; gpuConstants.numThreadsPerGroup = numThreadsPerBlock / NumGroupsPerBlock; gpuConstants.numThreadsPerBlock = numThreadsPerBlock; gpuConstants.numBlocks = numBlocks; gpuConstants.numRadices = num_Radices; gpuConstants.numRadicesPerBlock = num_Radices / numBlocks; gpuConstants.bitMask = BIT_MASK_START; counters.Initialize(); ComputeErrorCode error; cxGPUContext = context.Handle; cqCommandQueue = commandQue.Handle; _device = device.Handle; //Create a command queue, where all of the commands for execution will be added /*cqCommandQueue = CL10.CreateCommandQueue(cxGPUContext, _device, (CommandQueueProperties)0, out error); * CheckErr(error, "CL10.CreateCommandQueue");*/ string programSource = System.IO.File.ReadAllText(programPath); IntPtr[] progSize = new IntPtr[] { (IntPtr)programSource.Length }; string flags = "-cl-fast-relaxed-math"; ComputeProgram prog = new ComputeProgram(context, programSource); prog.Build(new List <ComputeDevice>() { device }, flags, null, IntPtr.Zero); if (prog.GetBuildStatus(device) != ComputeProgramBuildStatus.Success) { Debug.WriteLine(prog.GetBuildLog(device)); throw new ArgumentException("UNABLE to build programm"); } // ComputeProgram clProgramRadix = CL10.CreateProgramWithSource(cxGPUContext, 1, new[] { programSource },progSize, // out error); CLProgramHandle clProgramRadix = prog.Handle; ckSetupAndCount = CL10.CreateKernel(clProgramRadix, "SetupAndCount", out error); CheckErr(error, "CL10.CreateKernel"); ckSumIt = CL10.CreateKernel(clProgramRadix, "SumIt", out error); CheckErr(error, "CL10.CreateKernel"); ckReorderingKeysOnly = CL10.CreateKernel(clProgramRadix, "ReorderingKeysOnly", out error); CheckErr(error, "CL10.CreateKernel"); ckReorderingKeyValue = CL10.CreateKernel(clProgramRadix, "ReorderingKeyValue", out error); CheckErr(error, "CL10.CreateKernel"); }
public GPURadixSort( CommandQueue commandQue, Context context, Device device ) { gpuConstants = new GPUConstants(); gpuConstants.L = radix_BitsL; gpuConstants.numGroupsPerBlock = NumGroupsPerBlock; gpuConstants.R = R; gpuConstants.numThreadsPerGroup = numThreadsPerBlock/NumGroupsPerBlock; gpuConstants.numThreadsPerBlock = numThreadsPerBlock; gpuConstants.numBlocks = numBlocks; gpuConstants.numRadices = num_Radices; gpuConstants.numRadicesPerBlock = num_Radices/numBlocks; gpuConstants.bitMask = BIT_MASK_START; counters.Initialize(); OpenCL.Net.ErrorCode error; cxGPUContext = context; cqCommandQueue = commandQue; _device = device; //Create a command queue, where all of the commands for execution will be added /*cqCommandQueue = Cl.CreateCommandQueue(cxGPUContext, _device, (CommandQueueProperties)0, out error); CheckErr(error, "Cl.CreateCommandQueue");*/ string programSource = System.IO.File.ReadAllText(programPath1); IntPtr[] progSize = new IntPtr[] { (IntPtr)programSource.Length }; OpenCL.Net.Program clProgramRadix = Cl.CreateProgramWithSource(cxGPUContext, 1, new[] { programSource },progSize, out error); CheckErr(error,"createProgramm"); string flags = "-cl-fast-relaxed-math"; error = Cl.BuildProgram(clProgramRadix, 1, new[] { _device }, flags, null, IntPtr.Zero); CheckErr(error, "Cl.BuildProgram"); //Check for any compilation errors if (Cl.GetProgramBuildInfo(clProgramRadix, _device, ProgramBuildInfo.Status, out error).CastTo<BuildStatus>() != BuildStatus.Success) { CheckErr(error, "Cl.GetProgramBuildInfo"); Console.WriteLine("Cl.GetProgramBuildInfo != Success"); Console.WriteLine(Cl.GetProgramBuildInfo(clProgramRadix, _device, ProgramBuildInfo.Log, out error)); return; } int ciErrNum; ckSetupAndCount = Cl.CreateKernel(clProgramRadix, "SetupAndCount", out error); CheckErr(error, "Cl.CreateKernel"); ckSumIt = Cl.CreateKernel(clProgramRadix, "SumIt", out error); CheckErr(error, "Cl.CreateKernel"); ckReorderingKeysOnly = Cl.CreateKernel(clProgramRadix, "ReorderingKeysOnly", out error); CheckErr(error, "Cl.CreateKernel"); ckReorderingKeyValue = Cl.CreateKernel(clProgramRadix, "ReorderingKeyValue", out error); CheckErr(error, "Cl.CreateKernel"); }