【问题标题】:C# GPGPU Library Hybrid ErrorC# GPGPU 库混合错误
【发布时间】:2013-08-27 12:35:10
【问题描述】:

我是 GPGPU 计算的新手。我找到了这个名为Hybrid 的在线图书馆。他们说

“Hybrid.Net 使 .NET 开发人员能够利用 GPU 的强大功能,使用众所周知的简单构造:Parallel.For”来处理数据和计算密集型应用程序”

我下载了库,当我运行他们提供的 helloworld 应用程序时,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hybrid.Gpu;
using Hybrid.MsilToOpenCL;
using Hybrid;
using OpenCLNet;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
                        //define vectors a, b and c
            int vectorLength = 1024;
            int[] a = new int[vectorLength];
            int[] b = new int[vectorLength];
            int[] c = new int[vectorLength];

            //initialize vectors a, b and c

            //execute vector addition on GPU
            Hybrid.Parallel.For(Execute.OnSingleGpu, 0, vectorLength, delegate(int i)
            {
                c[i] = a[i] + b[i];
            });
        }
    }
}

我明白了

   An unhandled exception of type 'System.TypeInitializationException' occurred in Hybrid.MsilToOpenCL.dll

Additional information: The type initializer for 'OpenCLNet.OpenCL' threw an exception.

谁能告诉我这里发生了什么?

(只是让您知道我是 StackOverflow 的新手。)

【问题讨论】:

    标签: c# gpgpu


    【解决方案1】:

    检查内部异常。它将包含您需要的详细信息。

    【讨论】:

    • 你的意思是像try catch一样吗?我什么都没试过,我得到了我上面给你看的信息。
    • @KamalRathnayake 当你说“我明白了”时,你正在放下异常消息。但是那个异常对象有一个“InnerException”属性。该属性有时为 null,但当发生类型初始化异常时,它会将原始异常存储在 InnerException 属性中。它应该为您提供有关该类型初始化失败的更多信息。
    猜你喜欢
    • 2013-07-28
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-13
    • 2012-02-14
    • 2017-08-17
    相关资源
    最近更新 更多