/// <summary> /// gets a platform from a list of platforms in "C" space using an index /// </summary> /// <param name="hPlatformList_">C space array with N platforms</param> /// <param name="index_">0 to N-1</param> public ClPlatform(IntPtr hPlatformList_, int index_) { platformIndex = index_; hPlatform = createPlatform(hPlatformList_, index_); selectedDevices = new List <ClDevice>(); // platform deletes these when disposed platformName = JsonCPPCS.readWithoutDispose(getPlatformNameString(hPlatform)); vendorName = JsonCPPCS.readWithoutDispose(getPlatformVendorNameString(hPlatform)); // platformName and vendorName are deleted when hPlatform is deleted }
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); } }