如何设置Xcode以运行OpenCL代码,以及如何在构建之前验证内核 [英] How to set up Xcode to run OpenCL code, and how to verify the kernels before building

查看:97
本文介绍了如何设置Xcode以运行OpenCL代码,以及如何在构建之前验证内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看Apple网站上的官方文档,并且看到关于如何在Xcode上使用OpenCL的快速入门.

I am looking at the official documentation on the Apple site, and I see that there is a quickstart about how to use OpenCL on Xcode.

也许只是我一个人,但是我没有运气构建"hello world OCL"部分中提到的代码.

Maybe it is just me, but I had no luck building the code that is mentioned on the "hello world OCL" section.

我已经启动Xcode并创建了一个空项目;创建了main.c和.cl内核文件,将其粘贴在Apple开发人员站点上,即使添加了目标,我也无法构建任何东西.

I've started Xcode and created an empty project; created a main.c and a .cl kernel file, pasting what is on the Apple developer site, and I am not able to get anything to build, even after adding a target.

AD站点没有要下载的项目,所以我不知道失败的原因(这很可能是我的原因,或者该站点采取了步骤而未提及它们).

The AD site does not have a project to download, so I have no clue about the cause of the failure (it may be me most likely, or the site assume steps and does not mention them).

我也尝试了macresearch.org的示例项目,但是它们非常古老,第三课中的测试项目根本没有运行.

I've also tried the sample project from macresearch.org, but they are quite ancient, and the test project in the 3rd lesson is not running at all.

现在,我可以肯定其他人正在使用Xcode运行OCL代码,但是我找不到任何单个页面(除上述macresearch.org之外)提供了有关如何使用OCL运行Xcode项目的清晰设置.有没有人知道一个显示如何使用OCL和Xcode的教程?

Now, I am pretty sure that others are using Xcode to run OCL code, but I cannot find any single page (except the aforementioned macresearch.org) that gives a clear setup about how to run an Xcode project with OCL. Is there anyone aware of a tutorial that shows how to work with OCL and Xcode?

我已经购买了三本OCL(Gaster的OpenCL异构计算,Scarpino的OpenCL实际应用以及Munshi的OpenCL编程指南),但都没有提及如何设置Xcode,尽管它们详细介绍了Visual Studio的安装,甚至蚀设置.

I have purchased 3 books on OCL (Gaster's Heterogeneous computing with OpenCL, Scarpino's OpenCL in action and Munshi's OpenCL programming guide), and neither mention how to set up Xcode, while they go in detail for the visual studio setup and even for the eclipse setup.

在侧面;是否有任何应用程序能够在OCL应用程序中运行内核代码之前对其进行验证?

On the side; is there any application that is able to validate kernel code before running it in the OCL application?

预先感谢您提出的任何建议.

Thanks in advance for any suggestion that you may have.

推荐答案

看来我能够以这种方式部分解决此问题:

So seems that I was able to partially resolve the issue in this way:

  • 创建一个空项目,创建一个main.c文件和一个内核文件

  • Create an empty project, create a main.c file and a kernel file

将目标创建为控制台应用程序

create a target as console application

在构建设置中,添加OpenCL框架(如果正确添加,您会在左窗格的文件浏览器中看到它).

in the build settings, add the OpenCL framework (you will see it appearing on the file browser in the left pane, if it will be added correctly).

指定内核文件所在的位置,对路径进行硬编码(仅说"my kernel.cl"是不够的;出于某些原因,Xcode无法得到该信息) cl文件与主文件位于同一目录中,因此在加载内核文件时必须指定路径)

specify the location where the kernel file is located, hardcoding the path (it is not enough to just say "my kernel.cl"; Xcode for some reasons don't get that the cl file is in the same dir as the main, so you gotta specify the path when loading the kernel file)

在Apple开发人员网站上使用示例代码时,我成功使用了这些步骤.

I was successful using these steps, while using the example code on the Apple developer site.

我很确定还有其他方法可以做到这一点,但是至少这可以帮助像我一样不知道如何开始的人.

I am pretty sure that there are other ways to do this, but at least this may help whom, like me, had no clue about how to start.

这篇关于如何设置Xcode以运行OpenCL代码,以及如何在构建之前验证内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆