我可以将OpenCL代码编译成普通的OpenCL免费二进制文件吗? [英] Can I compile OpenCL code into ordinary, OpenCL-free binaries?

查看:417
本文介绍了我可以将OpenCL代码编译成普通的OpenCL免费二进制文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为了我的目的评估OpenCL。在我看来,你不能假定它在Windows或Mac上的开箱即用,因为:

I am evaluating OpenCL for my purposes. It occurred to me that you can't assume it working out-of-the-box on either Windows or Mac because:


  • Windows需要一个OpenCL驱动程序(当然可以安装)

  • MacOS仅在MacOS上支持OpenCL> = 10.6

所以我必须分别编写FPU / SSE / AVX代码和OpenCL来生成两个二进制文件:一个没有和一个支持OpenCL。

So I'd have to code FPU/SSE/AVX code and OpenCL separately to produce two binaries: one without and one with OpenCL support.

如果我可以在 compiletime 中将OpenCL编译成SSE / AVX,然后在其中发送一个二进制而不使用 OpenCL,这将会好得多。这样,我不需要为FPU / SSE / AVX单独实现!

It would be much better, if I could compile OpenCL at compiletime into SSE/AVX and then ship a binary without OpenCL in it. This way I wouldn't need a separate implementation for FPU/SSE/AVX!

有办法吗?

Cheers,
- clemens

Cheers, - clemens

推荐答案

一种实现方法是安装英特尔OpenCL SDK,并使用包含的OpenCL脱机编译器工具为您的OpenCL内核生成汇编代码,并将该汇编代码直接编译/链接到您的应用程序。然而,它可能是一些工作,以找出正确的调用约定等为了手动调用生成的汇编代码,然后你自己负责将你的工作分成多个线程。

One way to achieve this would be to install the Intel OpenCL SDK on your development machine and use the contained OpenCL Offline Compiler tool to generate Assembly code for your OpenCL kernel and directly compile / link that Assembly code to your application. However, it might be some work to figure out the correct calling conventions etc. in order to call the generated Assembly code manually, and you'd then be yourself responsible for splitting up your work into multiple threads.

因此,虽然这不是你一直在问的,至少在Windows上它可能会更容易发运您的应用程序与intelocl.dll及其依赖(如果许可证允许;我还没有检查),从那里动态加载OpenCL函数入口点,使用OpenCL运行时编译您的OpenCL内核到程序集并执行它。

Therefore, although that's not what you have been asking for, at least on Windows it would probably easier to ship your application with intelocl.dll and its dependencies (if the license permits that; I have not checked), dynamically load the OpenCL function entry points from there, compile your OpenCL kernel to Assembly on the fly and execute it using the OpenCL runtime.

这篇关于我可以将OpenCL代码编译成普通的OpenCL免费二进制文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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