示例#1
0
 /// <summary>
 /// takes program and a kernel name and prepares a kernel to be used.
 /// </summary>
 /// <param name="program">opencl wrapper of cl::program</param>
 /// <param name="kernelName">string wrapper of kernel name</param>
 public ClKernel(ClProgram program, ClString kernelName)
 {
     hProgram       = program.h();
     hString        = kernelName.h();
     hKernel        = createKernel(hProgram, hString);
     intKernelError = getKernelErr(hKernel);
 }
示例#2
0
 /// <summary>
 /// creates a program from kernel string and context
 /// </summary>
 /// <param name="context"></param>
 /// <param name="clKernelString">kernel string to compile</param>
 public ClProgram(ClContext context, ClString clKernelString)
 {
     hContext        = context.h();
     hDevice         = context.hd();
     hString         = clKernelString.h();
     hProgram        = createProgram(hContext, hDevice, hString);
     intProgramError = getProgramErr(hProgram);
     // strHata = Encoding.UTF8.GetString(programHataStringiOku(hProgram));
     strProgramError = new StringBuilder(readProgramErrString(hProgram)).ToString();
 }
示例#3
0
        public ClDevice(ClPlatform clPlatform, int deviceTypeCodeInClPlatform, int i, bool devicePartition, bool GPU_STREAM, int MAX_CPU)
        {
            clPlatformForCopy = clPlatform;
            deviceTypeCodeInClPlatformForCopy = deviceTypeCodeInClPlatform;
            iForCopy = i;
            devicePartitionForCopy   = devicePartition;
            GPU_STREAMForCopy        = GPU_STREAM;
            MAX_CPUForCopy           = MAX_CPU;
            deviceNameClString       = new ClString(" ");
            deviceVendorNameClString = new ClString(" ");
            hPlatform = clPlatform.h();
            if (deviceTypeCodeInClPlatform == ClPlatform.CODE_CPU() && devicePartition)
            {
                int epc1 = Environment.ProcessorCount - 1;
                if (MAX_CPU != -1)
                {
                    epc1 = Math.Max(Math.Min(MAX_CPU, epc1), 1);
                }
                Console.WriteLine(epc1 + " cores are chosen for compute(equals to device partition cores).");

                hDevice = createDeviceAsPartition(hPlatform, deviceTypeCodeInClPlatform, i, epc1);
            }
            else
            {
                hDevice = createDevice(hPlatform, deviceTypeCodeInClPlatform, i);
            }
            getDeviceName(hDevice, deviceNameClString.h());
            getDeviceVendorName(hDevice, deviceVendorNameClString.h());
            numberOfComputeUnitsPrivate            = deviceComputeUnits(hDevice);
            memorySizePrivate                      = deviceMemSize(hDevice);
            deviceNameStringFromOpenclCSpace       = JsonCPPCS.readWithDispose(deviceNameClString.h());
            deviceVendorNameStringFromOpenclCSpace = JsonCPPCS.readWithDispose(deviceVendorNameClString.h());
            typeOfUsedDeviceInClPlatform           = deviceTypeCodeInClPlatform;
            if (GPU_STREAM)
            {
                GDDR = false;
            }
            else
            {
                GDDR = deviceGDDR(hDevice);
            }
        }