예제 #1
0
        private OpenCLProgram LoadProgram(string resourceName)
        {
            var source  = GetProgramSourceFromResource(Assembly.GetExecutingAssembly(), resourceName);
            var program = new OpenCLProgram(Context, source);

            try
            {
                var optionsList = new[]
                {
                    "-cl-fast-relaxed-math",
                    "-cl-mad-enable",
                    "-cl-no-signed-zeros",
                    "-cl-strict-aliasing",
                    "-Werror"
                };
                var options = string.Join(" ", optionsList);
                program.Build(new List <OpenCLDevice> {
                    CommandQueue.Device
                }, options, null, IntPtr.Zero);
            }
            catch (BuildProgramFailureOpenCLException)
            {
                var buildLog = program.GetBuildLog(CommandQueue.Device);
                throw new ApplicationException($"Error building program \"{resourceName}\":{Environment.NewLine}{buildLog}");
            }

            return(program);
        }
예제 #2
0
        private static OpenCLProgram LoadProgram(OpenCLContext context, OpenCLDevice device, string resourceName)
        {
            var source  = GetProgramSourceFromResource(Assembly.GetExecutingAssembly(), resourceName);
            var program = new OpenCLProgram(context, source);

            try
            {
                program.Build(new List <OpenCLDevice> {
                    device
                }, string.Empty, null, IntPtr.Zero);
            }
            catch (BuildProgramFailureOpenCLException)
            {
                var buildLog = program.GetBuildLog(device);
                throw new ApplicationException($"Error building program \"{resourceName}\":{Environment.NewLine}{buildLog}");
            }

            return(program);
        }