cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

dar
Journeyman III

SDK 1.3 Feedback

bug report

Scientific Linux 5.1 (RHEL 5.1 clone) x86_64

problems with int4, questioncolon - there are three related issues.

consider the simple kernel below:

kernel void test_int4_gpu_kern( int n, int4 s_src<>, out int4 s_dst<> )
{

   const int4 zero4 = int4(0,0,0,0);
   int4 imask = int4(n+2,n-2,n,n);
   int4 tmp = s_src;
 
   /* fails */
// tmp = (imask == tmp)? zero4 : tmp;
 
   /* works with brtvector.hpp patch */
   tmp = ((int4)(imask == tmp))? zero4 : tmp;
 
   s_dst = tmp; 
}

First, brook+ will produce the following error for this kernel,

g++ -O3 -I/usr/local/amdbrook/sdk/include -c test_int4.cpp
/usr/local/amdbrook/sdk/include/brook/CPU/brtvector.hpp: In function ‘T singlequestioncolon(const B&, const T&, const T& [with T = int, B = int]’:
/usr/local/amdbrook/sdk/include/brook/CPU/brtvector.hpp:479:   instantiated from ‘vec<typename BRT_TYPE::TYPE, LUB<BRT_TYPE::size,tsize>::size> vec<VALUE, tsize>:uestioncolon(const BRT_TYPE&, const BRT_TYPE& const [with BRT_TYPE = __BrtInt4, VALUE = int, unsigned int tsize = 4u]’
test_int4.cpp:18:   instantiated from here
/usr/local/amdbrook/sdk/include/brook/CPU/brtvector.hpp:59: error: request for member ‘questioncolon’ in ‘a’, which is of non-class type ‘const int’
make: *** [test_int4.o] Error 1
rm test_int4.cpp

However, this can be fixed with the following patch,

--- brtvector.hpp~      2008-12-16 12:00:52.000000000 -0500
+++ brtvector.hpp       2008-12-16 12:04:54.000000000 -0500
@@ -58,6 +58,17 @@
                                                           const T&c){
     return a.questioncolon(b,c);
 };
+
+
+
+/* XXX added by DAR */
+template <> inline int singlequestioncolon (const int &a,
+                                              const int &b,
+                                              const int &c) {
+    return a?b:c;
+}
+
+
 template <> inline float singlequestioncolon (const char &a,
                                               const float &b,
                                               const float &c) {

Second, issue is that it should not be necessary to perform a cast in,

tmp = ((int4)(imask == tmp))? zero4 : tmp;

When the (int4) cast is removed, the following error is generated,

/usr/local/amdbrook/sdk/include/brook/CPU/brtvector.hpp:59: error: request for member ‘questioncolon’ in ‘a’, which is of non-class type ‘const char’

The equivalent expression for float4 does not require the equivalent cast.

Third issue is minor.  The compiler produces warning that,

test_int4.br(37) : WARN--1: conditional expression must have scalar type. On short vectors, assumes x components as condition
                 Statement: (int4 ) (imask == tmp) in tmp = ((int4 ) (imask == tmp)) ? (zero4) : (tmp)

However, this does not appear correct.  For float4 the conditional expression correctly applied component-wise, and with the patch above, the same is true for int4.  In the simple kernel, values are masked out component-wise to zero.

 

0 Likes
gaurav_garg
Adept I

SDK 1.3 Feedback

Thanks dar for the bug report. I will send this patch to the concerned engineer to look at.

0 Likes
Ceq
Journeyman III

SDK 1.3 Feedback

Hi, previously gaurav.garg told me how to use structs in Brook+, however I've found a problem:


1. Open example in BROOK\samples\CPP\tutorials\SimpleKernel
(I'm using Visual Studio 2005)


2. Edit file "copy.br" and add the following lines:

typedef struct PairRec {
float first;
float second;
} Pair;


3. Rebuild

1>simple_kernel.cpp
1>c:\hd1\brook\samples\cpp\tutorials\simplekernel\brookgenfiles/copy.h(37) : error C2146: syntax error : missing ';' before identifier 'first'
1>c:\hd1\brook\samples\cpp\tutorials\simplekernel\brookgenfiles/copy.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\hd1\brook\samples\cpp\tutorials\simplekernel\brookgenfiles/copy.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
...


What's wrong? Is this a bug? Is there any workaround?
0 Likes
Ceq
Journeyman III

SDK 1.3 Feedback

0 Likes
gaurav_garg
Adept I

SDK 1.3 Feedback

Hi Ceq,

 

It looks like a bug in code-generation where a header file required for compilation is missing.

As a workaround you can include "brook\CPU\brtvector.hpp" in simple_kernel.cpp before including "brookgenfiles/copy.h".

 

Hope it helps.

0 Likes
gaurav_garg
Adept I

SDK 1.3 Feedback

Hi Ceq,

Thanks for pointing out memory leak issues. Looks like there are memory leaks for reduction kernels. I did try the regular kernels and everything looks OK. But, reduction kernel shows the behavior mentioned by you.

0 Likes
nberger
Adept I

SDK 1.3 Feedback

BUG REPORT: Kernel calls getting slower
Hi!
With some effort I have managed to move my partial wave analysis framework to the 1.3 SDK and
the good news is that it now works (as opposed to the attempts with the 1.2 and 1.1 versions) and
produces correct results. I found however that if I call a kernel multiple times, it becomes slower.
In an attempt to make sure that the problem is not somewhere with my code, I went to the simpleKernel
example and just placed a loop around the kernel call - and also here the execution time increases for every
additional kernel call. Unfortunately this behavior just about kills my application - any tips for workarounds
or patches are warmly welcome.

Thanks

Nik
0 Likes
nberger
Adept I

SDK 1.3 Feedback

0 Likes
gaurav_garg
Adept I

SDK 1.3 Feedback

Hi nberger,

 

Are you using a reduction kernel? It seems that there are some meory leaks in reduction path.

0 Likes
nberger
Adept I

SDK 1.3 Feedback

No. The scary thing is that this behavior is also seen with the simplest of all kernels, namely the copy kernel form the
simpleKernel example, which just does output = input...

Cheers

Nik
0 Likes