static float[] MultiplyScalar(OpenCL.Net.Environment env, float[] A, float scalar) { var len = (uint)A.Length; var bufferA = env.Context.CreateBuffer(A, MemFlags.ReadOnly); var bufferB = env.Context.CreateBuffer(Source(A.Length, _ => 0f), MemFlags.WriteOnly); var kernel = new Kernel.MultiplyScalar(env.Context); kernel.Compile("-cl-opt-disable"); kernel.Run(env.CommandQueues[0], bufferB, bufferA, scalar, len); // WTF: We should wait for run var results = new float[A.Length]; env.CommandQueues[0].ReadFromBuffer(bufferB, results); return results; }
static float[] MultiplyScalar(OpenCL.Net.Environment env, float[] A, float scalar) { var len = (uint)A.Length; var bufferA = env.Context.CreateBuffer(A, MemFlags.ReadOnly); var bufferB = env.Context.CreateBuffer(Source(A.Length, _ => 0f), MemFlags.WriteOnly); var kernel = new Kernel.MultiplyScalar(env.Context); kernel.Compile("-cl-opt-disable"); kernel.Run(env.CommandQueues[0], bufferB, bufferA, scalar, len); // WTF: We should wait for run var results = new float[A.Length]; env.CommandQueues[0].ReadFromBuffer(bufferB, results); return(results); }