Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sprintf-like function for CUDA device-side code?

Tags:

printf

cuda

I could not find anything in internet. Due to the fact that it is possible to use printf in a __device__ function I am wondering if there is a sprintf like function due to the fact that printf is "using" the result from sprintf to be displayed in stdout.

like image 926
Peter VARGA Avatar asked Dec 06 '15 21:12

Peter VARGA


People also ask

Can you printf from CUDA kernel?

It may come as a surprise, but we can actually print text to the standard output from directly within a CUDA kernel; not only that, each individual thread can print its own output.

Is Sprintf safe to use?

Security is less in sprintf as it does not protect the string if it is more than 255 characters. And if a null character is present, there is a chance of modification of string.

What means Sprintf?

sprintf stands for "string print". In C programming language, it is a file handling function that is used to send formatted output to the string. Instead of printing on console, sprintf() function stores the output on char buffer that is specified in sprintf.

What header is Sprintf?

The sprintf() function in C++ is used to write a formatted string to character string buffer. It is defined in the cstdio header file.


1 Answers

No there isn't anything built into CUDA for this.

Within CUDA the implementation of device printf is a special case and does not use the same mechanisms as the C library printf.

like image 50
Robert Crovella Avatar answered Nov 15 '22 08:11

Robert Crovella