2013-08-15 8 views
0

Я пытаюсь получить this демо, чтобы построить, но я получаю эту ошибкуНеверно включая cloo в C#?

enter image description here

Я попытался это с моно и Visual Studio 2010 такая же проблема

ошибка происходит на линия

program.Build(null, null, null, IntPtr.Zero); 

EDIT

C#

using System; 
using Cloo; 
using System.Collections.Concurrent; 
using System.Threading.Tasks; 
using System.IO; 

namespace ClooTest 
{ 
    class MainClass 
    { 
     public static void Main (string[] args) 
     { 
      // pick first platform 
      ComputePlatform platform = ComputePlatform.Platforms[0]; 

      // create context with all gpu devices 
      ComputeContext context = new ComputeContext(ComputeDeviceTypes.Gpu, 
                 new ComputeContextPropertyList(platform), null, IntPtr.Zero); 

      // create a command queue with first gpu found 
      ComputeCommandQueue queue = new ComputeCommandQueue 
      (
       context, 
       context.Devices[0], 
       ComputeCommandQueueFlags.None 
      ); 

      // load opencl source 
      StreamReader streamReader = new StreamReader("kernels.cl"); 
      string clSource = streamReader.ReadToEnd(); 
      streamReader.Close(); 

      // create program with opencl source 
      ComputeProgram program = new ComputeProgram(context, clSource); 

      // compile opencl source 
      program.Build(null, null, null, IntPtr.Zero); 

      // load chosen kernel from program 
      ComputeKernel kernel = program.CreateKernel("helloWorld"); 

      // create a ten integer array and its length 
      int[] message = new int[] { 1, 2, 3, 4, 5 }; 
      int messageSize = message.Length; 

      // allocate a memory buffer with the message (the int array) 
      ComputeBuffer<int> messageBuffer = new ComputeBuffer<int>(context, 
                     ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.UseHostPointer, message); 

      kernel.SetMemoryArgument(0, messageBuffer); // set the integer array 
      kernel.SetValueArgument(1, messageSize); // set the array size 

      // execute kernel 
      queue.ExecuteTask(kernel, null); 

      // wait for completion 
      queue.Finish(); 
     } 
    } 
} 

OpenCL

kernel void helloWorld(global read_only int* message, int messageSize) { 
    for (int i = 0; i < messageSize; i++) { 
     printf("%d", message[i]); 
    } 
} 

EDIT debug

+1

Поддерживает ли ваше оборудование openCL? –

+0

Я использую opencl на этом компьютере через OpenCL.net. Я тоже хотел попробовать Клоо. OpenCL.Net, похоже, работает нормально, есть ли что-нибудь еще, что я должен проверить? – sav

+0

Ваш вопрос должен «предоставить конкретный код для воспроизведения проблемы», а не ссылку на пример где-то – Sayse

ответ

2

Да печати, вероятно, не очень хорошо поддерживается. Я бы предложил выполнить ваш «Hello world» с помощью некоторого простого хруста. Возможно, что-то вроде:

kernel void IncrementNumber(global float4 *celldata_in, global float4 *celldata_out) { 
    int index = get_global_id(0); 

    float4 a = celldata_in[index]; 
    a.w = a.w + 1; 

    celldata_out[index] = a; 
}