cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

bjang
Journeyman III

printf() function inside kernel

CUDA allows printf() function inside kernel in emulation mode. But it doesn't seem to be the case for Brook. I think debugging is very hard without this.

I am wondering how you debug Brook other than printing before and after streamRead() and streamWrite().

0 Likes
5 Replies
jski
Journeyman III

I've been wondering the same.  Some print routine would seem to be essential for debugging!

---jski

0 Likes
lpw
Journeyman III

I create a debug version of my kernel which takes additional output streams ("debug streams") to which I can write state information.  It ain't printf(), but it has worked for me so far.

0 Likes
josopait
Journeyman III

You can simply use printf (or cout) in the generated cpp file. It will be overwritten the next time you run brcc, but that's not a big problem if you want the output only for debugging purposes. It would be nice though if one could somehow pass c++ commands directly into the cpp file, bypassing brcc.

Ingo

0 Likes

I'll ask the Brook+ team to look into adding printf() support for CPU backend debugging.

Michael.
0 Likes

Originally posted by: josopait You can simply use printf (or cout) in the generated cpp file. Ingo


 

Could  You tell me how to do that? I compile brook file then add

std::cout << si.swizzle1(maskX) << " " << si.swizzle1(maskY) << " " << si.swizzle1(maskZ) <<'\n' ;

in void __SAD3D_cpu_inner function.

I put break point on cout line and it seems that this function isn't run because program doesn't stop on it.

My steps:

1) Compilation br file.

2) Adding line in generated cpp

3) Compilation cpp

4) Linking project

I use Brook 1.01 Driver 8.8 WinXp 32bit.

I realize that other sample programs  doesn't debug either so it may be not problem of my code insertion at all.

 

I found that there is an enviroment variable need to be set  BRT_RUNTIME = cpu , but I don't know where to do it so?

 

I use VS 2005 - Where can I set the variable?

I also found it

It has to be set in Windows enviroment variables

0 Likes