We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(8)
所以最近英特尔发布了 ISPC 这正是我在问这个问题时所寻找的。它是一种可以与普通 C 代码链接的语言,具有隐式执行模型,并支持开始帖子中提到的所有功能(混合运算符、分支、数据结构、矢量操作、着色器等)并针对 SSE2、SSE4 进行编译, AVX、AVX2 和 Xeon Phi 矢量指令。
So recently Intel released ISPC which is exactly what I was looking for when asking this question. It's a language that can link with normal C code, has and implicit execution model, and support for all the features mentioned in the start post (swizzle operators, branching, data structs, vector ops, shader like) and compiles for SSE2, SSE4, AVX, AVX2, and Xeon Phi vector instructions.
你最好的选择可能是 OpenCL。我知道它主要被宣传为在 GPU 上运行代码的一种方式,但 OpenCL 内核也可以在 CPU 上编译和运行。 OpenCL 基本上是 C,但有一些限制:
和一堆添加。特别是向量类型:
需要注意的是,代码必须完全可操作,OpenCL 无法调用任意库等。但是,如果您的计算内核相当独立,那么您基本上会得到一个向量增强的 C,而您不需要不需要使用内在函数。
这里是包含所有扩展的快速参考/备忘单。
Your best bet is probably OpenCL. I know it has mostly been hyped as a way to run code on GPUs, but OpenCL kernels can also be compiled and run on CPUs. OpenCL is basically C with a few restrictions:
and a bunch of additions. In particular vector types:
On big caveat is that the code has to be cleanly sperable, OpenCL can't call out to arbitrary libraries, etc. But if your compute kernels are reasonably independent then you basically get a vector enhanced C where you don't need to use intrinsics.
Here is a quick reference/cheatsheet with all of the extensions.
它并不是真正的语言本身,但有一个 Mono 库(Mono.Simd),它将向您公开向量,并尽可能将它们的操作优化到 SSE 中:
It's not really the language itself, but there is a library for Mono (Mono.Simd) that will expose the vectors to you and optimise the operations on them into SSE whenever possible:
它是一个 C++ 库,而不是内置于该语言中,但是一旦声明了变量,Eigen 就几乎不可见了。
It's a library for C++, rather than built into the language, but Eigen is pretty invisible once your variables are declared.
目前最好的解决方案是自己为 Nvidia 发布的开源 Cg 前端创建一个后端,但我想节省自己的精力,所以我很好奇以前是否有人这样做过。我最好立即开始使用它。
Currently the best solution is to do it myself by creating a back-end for the open-source Cg frontend that Nvidia released, but I'd like to save myself the effort so I'm curious if it's been done before. Preferably I'd start using it right away.
D 编程语言还以与 Mono.SIMD 类似的方式提供对 SIMD 的访问。
The D programming language also provides access to SIMD in a similar way than Mono.SIMD.
这就是您正在寻找的 Fortran。如果内存足够,即使是开源编译器(g95、gfortran)也会利用 SSE(如果它是在您的硬件上实现的)。
That would be Fortran that you are looking for. If memory serves even the open-source compilers (g95, gfortran) will take advantage of SSE if it's implemented on your hardware.
我知道这个问题有点老了,但我发现自己处于类似的困境,并决定我应该自己做。
我还没有走得太远,但如果你对我正在探索的方向感兴趣,可能值得一看。 :)
https://github.com/HappMacDonald/MasterBlaster
MasterBlaster 是一种函数式编程语言,但它是将编译成字节码,最终是它自己的更简单的基于堆栈的语言,称为 Crude。然后直接编译成程序集。
我的策略是 SIMD 优先:未优化的可执行文件将几乎完全使用 SIMD,然后潜在的优化之一是将无法从 SIMD 受益的代码简化为仅使用通用寄存器。
Crude 已达到图灵完备阶段,但目前仅以几十个 GAS 宏的形式存在。我正在为其开发一个独立的编译器,并构建迭代器/生成器功能,这些功能是 SIMD 加速方面的明星。
目前还没有矢量矩阵等支持,但这已经在路线图上,在编写该语法时我可能会记住您的描述。 :)
I know this question is a bit old, but I found myself in a similar predicament and decided I should just make my own.
I haven't gotten very far yet in the slightest, but if you're interested in the directions that I'm exploring it might be worth a look. :)
https://github.com/HappMacDonald/MasterBlaster
MasterBlaster is a functional programming language, but it's going to compile down into a bytecode that is ultimately it's own much simpler stack-based language called Crude. Crude then compiles directly into assembly.
My strategy is a SIMD-first one: unoptimized executables will use almost entirely SIMD, and then one of the potential optimizations will be to simplify code that isn't benefiting from SIMD into using only general registers instead.
Crude is up to the turing-complete stage, but only exists as a few dozen GAS macros presently. I'm working towards a self-contained compiler for it, and building out the iterator/generator features that are the stars of the show when it comes to SIMD acceleration.
No vector-matrix-etc support just yet, but that is on the roadmap and I'll probably bear your description in mind when writing up that syntax. :)