Solved

Help Debugging- Really StucK!!

Posted on 2009-07-11
11
261 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:jmckennon
  • 6
  • 3
  • 2
11 Comments
 
LVL 4

Expert Comment

by:khyer123
ID: 24832916
How about some help on what the errors are, and what lines?
0
 

Author Comment

by:jmckennon
ID: 24832924
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




0
 

Author Comment

by:jmckennon
ID: 24832926
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
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 4

Expert Comment

by:khyer123
ID: 24832934
I'm not familiar with that at all, so I'm afraid I can't help - sorry
0
 

Author Comment

by:jmckennon
ID: 24832942
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 =(!!
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24832949
>> 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 ?
0
 

Author Comment

by:jmckennon
ID: 24832988
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

0
 

Author Comment

by:jmckennon
ID: 24833012
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! =(
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 24833017
>> but there's still two more left.

Well, what does the compiler say ? Literally.


>> Can you tell us how __fdividef is defined ?

When I asked that, I meant to show me the code, or at least the declaration of __fdividef


>> What was the original code that worked ?

How about that ?


A few more things I spotted :

(a) You have this in there line 5 :

        (r - rp)(r-rp)

    Did you forget the * operator ?

(b) At that same line, you are using __fdivdef instead of __fdividef



This would be a whole lot easier (and faster) if you would just post the exact compiler output, and the other data I asked for.
0
 

Author Comment

by:jmckennon
ID: 24833027
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!!
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24833033
>> 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 !
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question