CUDA sprintf到全局/共享内存缓冲区 [英] cuda sprintf to global/shared memory buffer

查看:219
本文介绍了CUDA sprintf到全局/共享内存缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们现在可以在内核中执行printf了,



但是可以执行sprintf(buffer,format,arg,...)函数吗?



我正在做cuda加速OBJ文件写入,我需要将浮点数转换为ASCII字符串以进行写入。



编辑:Cuda当然并没有进行实际的编写=)只是从浮点列表中生成obj char缓冲区。

解决方案

va_list, Georges Menie 中的代码应该可以帮助您入门。另外,对于简单的参数列表,simplePrintf公开了一些@RobertCrovella提到的内容。



但是,最近的CUDA发行版的C ++ 11功能可能也有帮助。



但是,在GPU上并行执行此任务,并保持对象列表索引的一致性和一致的字符串格式(浮动)尤其重要)可能是您最大的问题。


We can do printf in kernels now,

but is it possible to do the sprintf(buffer, format, arg, ... ) function?

I'm doing cuda accelerated OBJ file writing, and I need to convert floats into ASCII strings for writing.

edit: Cuda is not doing the actual writing of course =) Just generating the obj char buffers from a list of floats.

解决方案

Besides the va_list, the code from Georges Menie should help you get started. Also, for simple argument list, simplePrintf exposed a few as @RobertCrovella mentioned. C++11 features of recent CUDA distributions might also help.

However, parallelisation of this task on the GPU and maintaining consistency in object list indices and consistent string formatting (floatting point especially) might be your biggest issue.

这篇关于CUDA sprintf到全局/共享内存缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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