Ejemplo n.º 1
0
 private void CheckErr(Cl.ErrorCode err, string name)
 {
     if (err != Cl.ErrorCode.Success)
     {
         Console.WriteLine("ERROR: " + name + " (" + err.ToString() + ")");
         MessageBox.Show("ERROR: " + name + " (" + err.ToString() + ")");
     }
 }
Ejemplo n.º 2
0
 public static void CheckErr(CL.ErrorCode err, string name)
 {
     //Console.WriteLine($"{name}...");
     if (err != CL.ErrorCode.Success)
     {
         Console.WriteLine("ERROR: " + name + " (" + err.ToString() + ")");
     }
 }
Ejemplo n.º 3
0
        /*
        private void Setup()
        {
            OpenCL.Net.ErrorCode error;
            var platforms = Cl.GetPlatformIDs(out error);
            List<Device> devicesList = new List<Device>();

            CheckErr(error, "Cl.GetPlatformIDs");

            foreach (Platform platform in platforms)
            {
                string platformName = Cl.GetPlatformInfo(platform, PlatformInfo.Name, out error).ToString();
                Console.WriteLine("Platform: " + platformName);
                CheckErr(error, "Cl.GetPlatformInfo");
                //We will be looking only for GPU devices
                foreach (Device device in Cl.GetDeviceIDs(platform, DeviceType.Gpu, out error))
                {
                    CheckErr(error, "Cl.GetDeviceIDs");

                    var vendor = Cl.GetDeviceInfo(device, DeviceInfo.Vendor, out error);
                    var name = Cl.GetDeviceInfo(device, DeviceInfo.Name, out error);
                    var worksize = Cl.GetDeviceInfo(device, DeviceInfo.LocalMemSize, out error);
                    Console.WriteLine("Vendor: " + vendor + " , " + name);

                    Console.WriteLine("Device: " + device.GetType());
                    Console.WriteLine("localMemsizr: " + worksize.CastTo<long>());
                    devicesList.Add(device);
                }
            }

            if (devicesList.Count <= 0)
            {
                Console.WriteLine("No devices found.");
                return;
            }

            _device = devicesList[0];

            if (Cl.GetDeviceInfo(_device, DeviceInfo.ImageSupport, out
                error).CastTo<Bool>() == Bool.False)
            {
                Console.WriteLine("No image support.");
                return;
            }
            cxGPUContext
                = Cl.CreateContext(null, 1, new[] {_device}, ContextNotify,
                    IntPtr.Zero, out error); //Second parameter is amount of devices
            CheckErr(error, "Cl.CreateContext");

            cqCommandQueue = Cl.CreateCommandQueue(cxGPUContext, _device, (CommandQueueProperties) 0, out error);
            CheckErr(error, "Cl.CreateCommandQueue");

        }
        */
        private void CheckErr(ErrorCode err, string name)
        {
            if (err != ErrorCode.Success)
            {
                Console.WriteLine("error: " + name + " (" + err.ToString() + ")");
                Console.WriteLine("error: " + name + " (" + err + ")");
                using (StreamWriter sw = File.AppendText(@"D:\Projects\gpu\GPGPUCollisionDetection\GPGPUCollisionDetection\OpenCLDebugLog.txt"))
                {
                    sw.WriteLine("error: " + name + " (" + err + ")");
                }
            }
        }