I recently saw arrayfire demonstrated at GTC and I thought I would try it. Here are some questions I have run into while trying to use it. I am running Visual Studio 2013 on a Windows 7 system with OpenCL from the AMD App SDK 2.9-1.
我最近在GTC看到arrayfire演示,我想我可以试试。下面是我在尝试使用它时遇到的一些问题。我正在使用AMD应用SDK 2.9-1中的OpenCL在Windows 7系统上运行Visual Studio 2013。
-
The biggest frustration is that I cannot view the state of array objects in the debugger to see what data is in it. I must rely on the af_print statement. That is very annoying. Is there any way to configure the debugger to let me see the data in the array without having to print it out?
最大的问题是,我无法查看调试器中数组对象的状态,以查看其中的数据。我必须依赖af_print语句。这是很烦人的。有什么方法可以配置调试器,让我看到数组中的数据而不用打印出来吗?
-
Once I have my data in an array, how do I get back values as standard data types. An example is shown below. I am trying to get back element 5,0 as a double. The line in the example does not work, and I cannot cast it to any standard type. The only thing I can assign it to is another array. How do I get my data back out?
在数组中有数据后,如何将值作为标准数据类型返回。下面显示了一个示例。我试着把元素5,0作为双元素。示例中的行不起作用,我无法将它强制转换为任何标准类型。唯一可以赋值给它的是另一个数组。我该如何取回我的数据?
array test = constant(0, dim4(10, 2));
test(span, 1) = 10.5;
double val = test(5, 0); //This does not compile.
-
Is there an easy way to serialize/deserialize an array to disk? I did not see a way to do this, and since I cannot get the values back out as standard types I am unsure how to save it out.
是否有一种简单的方法将数组序列化/反序列化到磁盘?我没有找到这样做的方法,而且由于无法将值作为标准类型重新取出,所以我不确定如何保存它。
-
I was going through the rainfall tutorial sample you provide, but it appears to give incorrect results. For instance, line 52 has this print statement "af_print(rainfall);." It is supposed to print out the rainfall per site, but it has all 8's in it, which is not correct. I tried this with both the cpu and opencl versions and got the same results. A few of the other calculations are incorrect as well. The code looks like it be should be correct, so is this a bug or is the code wrong?
我正在浏览您提供的降雨教程示例,但它似乎给出了不正确的结果。例如,第52行有这个打印语句“af_print(rain);”。它应该打印出每个站点的降雨量,但是它包含了所有的8,这是不正确的。我在cpu和opencl版本中都尝试过,得到了相同的结果。其他一些计算也不正确。代码看起来应该是正确的,那么这是一个错误还是代码错误?
1 个解决方案
#1
4
Answers below:
答案如下:
-
Because all of ArrayFire's data resides on the GPU, it is not possible to show this on the VS debugger (without much more advance techniques that would involve NSight or other debugging tools). The alternate is to fetch the data back to the host and then check it in the debugger (as in answer 2).
因为ArrayFire的所有数据都驻留在GPU上,所以不可能在VS调试器上显示这些数据(如果没有更多涉及NSight或其他调试工具的高级技术)。另一种方法是将数据取回主机,然后在调试器中检查数据(如答案2)。
-
The host() function allows you to retrieve the data back to host. There are 2 ways of doing this:
函数的作用是:返回数据到主机。有两种方法可以做到这一点:
// Type 1 array a = randu(3, f32); float *host_a = a.host<float>(); // must call array::free() later printf("host_a[2] = %f\n", host_a[2]); // last element af::freeHost(host_a); // Type 2 array a = randu(3, f32); float *host_a = new float[3]; a.host(host_a); printf("host_a[2] = %f\n", host_a[2]); // last element delete [] host_a;
-
The << (ostream operator) is overloaded for arrays and dim4. So doing
std::cout << array << std::endl;
would print to screen. The same can be used with fstream objects.< (ostream操作符)对于数组和dim4是重载的。执行std::cout < array < std::endl;会打印到屏幕上。fstream对象也可以使用这种方法。
-
We're looking into rainfall and will get back. This should be fixed today. Keep a watch on our github page.
我们正在寻找降雨,并将回来。这应该在今天得到解决。在github上保持警惕。
--Edit-- 4. The problem seen in rainfall has been fixed by https://github.com/arrayfire/arrayfire/pull/531. We will be releasing a new build out soon.
——编辑——4。降雨中遇到的问题已被https://github.com/arrayfire/arrayfire/pull/531解决。我们将很快发布一个新的版本。
Edit 2: Change af::free to af::freeHost to delete host memory allocated by ArrayFire.
编辑2:修改af:::free to af: freeHost to delete host内存分配给ArrayFire。
#1
4
Answers below:
答案如下:
-
Because all of ArrayFire's data resides on the GPU, it is not possible to show this on the VS debugger (without much more advance techniques that would involve NSight or other debugging tools). The alternate is to fetch the data back to the host and then check it in the debugger (as in answer 2).
因为ArrayFire的所有数据都驻留在GPU上,所以不可能在VS调试器上显示这些数据(如果没有更多涉及NSight或其他调试工具的高级技术)。另一种方法是将数据取回主机,然后在调试器中检查数据(如答案2)。
-
The host() function allows you to retrieve the data back to host. There are 2 ways of doing this:
函数的作用是:返回数据到主机。有两种方法可以做到这一点:
// Type 1 array a = randu(3, f32); float *host_a = a.host<float>(); // must call array::free() later printf("host_a[2] = %f\n", host_a[2]); // last element af::freeHost(host_a); // Type 2 array a = randu(3, f32); float *host_a = new float[3]; a.host(host_a); printf("host_a[2] = %f\n", host_a[2]); // last element delete [] host_a;
-
The << (ostream operator) is overloaded for arrays and dim4. So doing
std::cout << array << std::endl;
would print to screen. The same can be used with fstream objects.< (ostream操作符)对于数组和dim4是重载的。执行std::cout < array < std::endl;会打印到屏幕上。fstream对象也可以使用这种方法。
-
We're looking into rainfall and will get back. This should be fixed today. Keep a watch on our github page.
我们正在寻找降雨,并将回来。这应该在今天得到解决。在github上保持警惕。
--Edit-- 4. The problem seen in rainfall has been fixed by https://github.com/arrayfire/arrayfire/pull/531. We will be releasing a new build out soon.
——编辑——4。降雨中遇到的问题已被https://github.com/arrayfire/arrayfire/pull/531解决。我们将很快发布一个新的版本。
Edit 2: Change af::free to af::freeHost to delete host memory allocated by ArrayFire.
编辑2:修改af:::free to af: freeHost to delete host内存分配给ArrayFire。