在不使用cuda或opencl等任何库的情况下对GPU进行编程? [英] programming a gpu without using any library like cuda or opencl?

查看:85
本文介绍了在不使用cuda或opencl等任何库的情况下对GPU进行编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有一种方法可以使用GPU进行计算(例如,两个矩阵的乘法)而无需使用任何库或API.我只想用C编写程序,并且不想使用CUDA或OpenCL或类似的东西.

I want to know is there a way that we can use GPU for computing (for example multiplication of two matrix ) without using any library or API . I just want to write a program in C and I don't want to use CUDA or OpenCL or anything like that.

推荐答案

最简短的答案是,不是,您不能这样做.我熟悉的所有标准"C或C ++类" GPU编程模型都要求您使用API​​(如OpenCL或OpenCL等计算API,或诸如OpenGL和Direct3D之类的图形API)来管理设备以及加载和执行着色器或在目标GPU上并行计算内核.

The really short answer, is no, you can't do that. All of the standard "C or C++ like" GPU programming models I am familiar with require you to use an API (compute APIs like OpenCL or OpenCL, or graphics APIs like OpenGL and Direct3D) to manage the device and load and execute a shader or compute kernel in parallel on the target GPU.

关于废除使用底层硬件API的需求的最接近的(可能是唯一的)事情是针对GPU的编译辅助并行性,例如 OpenACC .在这里,您可以使用预处理器指令来修饰C,C ++或Fortran代码,并依靠编译器为设备生成并行代码.基础的计算或图形API和驱动程序仍然存在并且仍在使用,但是您看不到它们.

About the closest (probably only) thing which abrogates the need to use the underlying hardware APIs is compiled assisted parallelism for GPUs, like OpenACC. There, you can use pre-processor directives to decorate C, C++, or Fortran code and rely on the compiler to generate parallel code for the device. The underlying compute or graphics APIs and drivers are still there and still used, but you don't see them.

这篇关于在不使用cuda或opencl等任何库的情况下对GPU进行编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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