3
votes

I am trying to debug an application using cuda-memcheck. What I want to do is to redirect output from my app to one file, but on the other hand, redirect stdout and stderr of the cuda-memcheck into another file. But I cannot get it working. This:

cuda-memcheck "app.exe > stdout1.txt" > memcheck.log 2>&1

does absolutely nothing. But if I delete the redirection inside the quotes (ignoring my app output), it executes. So the question is, how to redirect subcommand's stdout?

1
Have you tried the cmd option --log-file and/or --save of cuda-memcheck?kangshiyin
That redirects memcheck output, but not the output of the app it launches.Jofo

1 Answers

1
votes

According to your comment on cuda-memcheck's behavior, you could use the following command.

cuda-memcheck --log-file memcheck.log app.exe >app.stdout.txt

Edit

Here's my test on CentOS. It may work for Win32 console application but not for Win32 application.

a.cu

#include <iostream>
int main () {
    std::cout<< "hello world to stdout!" <<std::endl;
    std::cerr<< "hello world to stderr!" <<std::endl;
    return 0;
}

Compile command:

$ nvcc -O3 -o a a.cu 

Run command:

$ cuda-memcheck --log-file mem.log a >a.stdout.log 2>a.stderr.log

Result files:

$ cat mem.log 
========= CUDA-MEMCHECK
========= ERROR SUMMARY: 0 errors

$ cat a.stdout.log 
hello world to stdout!

$ cat a.stderr.log 
hello world to stderr!