コード例 #1
0
ファイル: Program.cs プロジェクト: splitice/OpenCL.Net
        static void Main(string[] args)
        {
            var env = "*Intel*".CreateCLEnvironment();

            var random = new Random();
            var a = env.Context.CreateBuffer((from i in Enumerable.Range(0, ArrayLength) select (float)random.NextDouble()).ToArray(), 
                MemFlags.ReadOnly);
            var b = env.Context.CreateBuffer((from i in Enumerable.Range(0, ArrayLength) select (float)random.NextDouble()).ToArray(), 
                MemFlags.WriteOnly);

            var kernel = new Kernel.doSomething(env.Context);

            kernel.Run(env.CommandQueues[0], a, b, 100, 10f, ArrayLength);
            var results = new float[ArrayLength];
            env.CommandQueues[0].ReadFromBuffer(b, results);

            env.Dispose();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var env = "*Intel*".CreateCLEnvironment();

            var random = new Random();
            var a      = env.Context.CreateBuffer((from i in Enumerable.Range(0, ArrayLength) select(float) random.NextDouble()).ToArray(),
                                                  MemFlags.ReadOnly);
            var b = env.Context.CreateBuffer((from i in Enumerable.Range(0, ArrayLength) select(float) random.NextDouble()).ToArray(),
                                             MemFlags.WriteOnly);

            var kernel = new Kernel.doSomething(env.Context);

            kernel.Compile(string.Format("-cl-opt-disable -g -s \"{0}\"", Kernel.Kernel_Source.OriginalKernelPath));

            var kernelRun = kernel.Run(env.CommandQueues[0], a, b, 100, 10f, ArrayLength);
            var results   = new float[ArrayLength];

            env.CommandQueues[0].ReadFromBuffer(b, results, waitFor: kernelRun);

            env.Dispose();
        }