private static void CreateOclManagers() // Create an OpenCLManager for each platform { instances = new List <OpenCLManager>(); int nPlatforms = OpenCL.NumberOfPlatforms; Debug.Log("[OCLLOG]:Platform Count:" + nPlatforms); if (nPlatforms <= 0) { Debug.LogError("[OCLLOG]:OpenCLIs[NOT]Available"); return; } for (int pIdx = 0; pIdx < nPlatforms; pIdx++) { OpenCLNet.Platform platform = OpenCLNet.OpenCL.GetPlatform(pIdx); OpenCLNet.Device[] devices = platform.QueryDevices(OpenCLNet.DeviceType.ALL); int nDevices = devices.Length; if (nDevices <= 0) { Debug.LogError("[OCLLOG]:No OpenCL devices found that matched filter criteria on Platform_" + platform.Name); continue; } // We might use the whole devices as CreateContext para, but we don't do so. // Here create a oclMan for each device because // the same platform will build kernel for each device in its context and can be failed // (such as apple, failed in building kernel on HD6630M, succeeded on intel cpu) for (int dIdx = 0; dIdx < nDevices; dIdx++) { try{ Debug.Log("[OCLLOG]:Creating OCL on Platform_" + platform.Name + "+Device_" + devices[dIdx].Name); OpenCLManager oclMan = new OpenCLManager(); oclMan.SourcePath = OclSourcePath; oclMan.BinaryPath = OclBinaryPath; IntPtr[] properties = new IntPtr[] { (IntPtr)ContextProperties.PLATFORM, platform, IntPtr.Zero }; OpenCLNet.Device[] devicesEnum = new Device[] { devices[dIdx] }; oclMan.CreateContext(platform, properties, devicesEnum); instances.Add(oclMan); } catch (Exception e) { Debug.Log("[OCLLOG]Exception at Platform_" + platform.Name + "+Device_" + devices[dIdx].Name + ":" + e.Message); } } } }