Link to home
Start Free TrialLog in
Avatar of jmckennon
jmckennon

asked on

Help Debugging- Really StucK!!

Somewhere in this chunk of code sits 11 errors. I've been sitting here for about 3 hours now trying to find them and not having any luck. Can someone please help me?
DelR =
           __fdividef( 1.0 , sqrt (2.0 * pie)) *__fdividef( exp(__fdividef(__fdividef(-(r - rp)^2 , 2.0) , wr^2)) , wr);
          DelR1 =__fdividef( -(r - rp) , wr^2) * DelR;
          DelR2 =
            (__fdividef(__fdividef(-1.0, wr^2) + (r - rp)^2 , wr^4)) * DelR;
 
 
              stheta =__sinf(th);
              ctheta =__cosf(th);
 
              DelTH =
                __fdividef(1.0 , sqrt (2.0 * pie)) *__fdividef( exp(__fdividef(-(th - tp)^2,2.0) wt^2) , wt);
              DelTH1 = __fdividef(__fdividef(-(th - tp) , wt) , wt) * DelTH;
              DelTH2 =__fdividef(-1.0 , wt^2) +
                 __fdividef((th - tp)^2 , wt^4) * DelTH;

Open in new window

Avatar of khyer123
khyer123

How about some help on what the errors are, and what lines?
Avatar of jmckennon

ASKER

Everything worked perfectly until substituted all the division with __fdividef() in an effort to speed up the running of my program. I'm using CUDA in linux so debugging is pretty tough. The original equations were written as:

    DelTH = 1.0/sqrt(2.0*pie)*exp(-(th-tp)^2/2.0/wt^2)/wt
      DelTH1 = -(th-tp)/wt^2*DelTH
      DelTH2 = (-1.0/wt^2+(th-tp)^2/wt^4)*DelTH

      DelR = 1.0/sqrt(2.0*pie)*exp(-(r-rp)^2/2.0/wr^2)/wr
      DelR1 = -(r-rp)/wr^2*DelR
      DelR2 = (-1.0/wr^2+(r-rp)^2/wr^4)*DelR




khyer123, i'm using the nvcc compiler in Linux, so it doesn't explicitly tell me which lines the errors are on, only that there are some in the file. The only changes that were made were with the __fdividef() function
I'm not familiar with that at all, so I'm afraid I can't help - sorry
It has nothing to do with the errors though. The program is written in C. The __fdividef() function takes in two arguments, the divisor and dividend. It's a pretty simple set up, I just can't figure out where the errors are =(!!
Avatar of Infinity08
>> i'm using the nvcc compiler in Linux, so it doesn't explicitly tell me which lines the errors are on, only that there are some in the file.

That's not very helpful. Can you copy paste the exact output the compiler gives ?

Can you tell us how __fdividef is defined ?

I see that you are using the ^ operator in there. Are you aware that that is the binary XOR operator, and does not take the power of two numbers ?

What was the original code that worked ?
I wasnt aware of the ^ being the XOR operator. That cleared up alot of the errors, but there's still two more left.

__fdividef(x,y) is simply a faster division function for any x/y type equation. It's arguments are passed in as (x,y).

The errors are probably something like an extra parenthesis some where but I can't seem to find it.

Below is the code as I have it now, with only two errors left.
 DelR =__fdividef( 1.0,(sqrt(2.0*pie)))*__fdividef(exp(__fdividef(__fdividef(-((r-rp)*(r-rp)),2.0),(wr*wr))),wr);
 
          DelR1 =__fdividef( -(r - rp) ,( wr*wr)) * DelR;
          DelR2 =
            __fdividef(-1.0,( wr*wr)) + __fdivdef(((r - rp)(r-rp)) ,( wr*wr*wr*wr)) * DelR;
 
 
              stheta =__sinf(th);
              ctheta =__cosf(th);
 
              DelTH =
                __fdividef(1.0 , sqrt (2.0 * pie)) *__fdividef( exp(__fdividef(__fdividef(-((th - tp)*(th-tp)),2.0),( wt*wt))) , wt);
              DelTH1 = __fdividef(-(th - tp) ,(wt* wt)) * DelTH;
              DelTH2 =__fdividef(-1.0 ,( wt*wt)) +
                 __fdividef(((th - tp)*(th-tp)) ,( wt*wt*wt*wr)) * DelTH;

Open in new window

Okay, I've narrowed it down to one line, with both errors ( I commented out the line and the program did a successful build)

 /*DelR2 =
            __fdividef(-1.0,( wr*wr)) + __fdivdef(((r - rp)(r-rp)) ,( wr*wr*wr*wr)) * DelR;*/
They're some where in here, but I just don't see them! =(
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't think you need it, you spotted the errors in the line without it!!

your (a) and (b) turned out to be them! Thanks!!
>> I don't think you need it, you spotted the errors in the line without it!!

Heh :) Well that's good then ...

But what I meant is that I would have been able to spot the problems faster if the information I asked for was available ... ;) Maybe just seeing that information together would have made the problems obvious to you without help ...

Anyway, I'm glad your problem is solved !