|
nothing, no error, no warning.
|
|
|
|
|
Try setting compiler warning level to 4 (/W4) in the C/C++ General properties of the project.
|
|
|
|
|
yes, I just did:
#pragma warning (push, 4)
|
|
|
|
|
better use the project setting, so it works in all files.
Check to what the UINT macro resolves.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi
I have a strange situation. My simulation written in VS 2008 return wrong results for release version of program run from HDD. When I run this program for the same set of parameters from the VS using release or debug version, or when I run debug version from HDD, I get correct results.
What's more interesting I can interpret wrong results. They look like they were generated by wrong parameter or wrong conditional expression in one single line.
Here is the correct code:
double temp = generator.getUpLinkRandom(staAddress);
t += temp;
cntr++;
if (temp < upLinkRatio){
msdu->DA = 0;
msdu->TA = msdu->SA = staAddress;
}else{
msdu->SA = msdu->TA = 0;
msdu->DA = staAddress;
}
I set the upLinkRatio to 0.2, but wrong results look like upLinkRatio was set to 0.8 or optimiser changed conditional expression to:
if (temp > upLinkRatio)
I tested the generator's average and it's correct (0.5, this is uniform generator, return values from 0 to 1). I cleaned project, deleted all object files. I made sure that all files with parameters are exactly the same. And still can't find the reason.
Edit:
There's something even more interesting. Just for curosity I changed this conditional expression to the wrong version and now the situation is exactly opposite. Relaese version run from HDD returns correct results, whereas all other wrong (which is what I expect - code is wrong).
So it looks like there is something wrong with compiler/builder... But what? Please help.
|
|
|
|
|
i'd start checking for uninitialized variables.
|
|
|
|
|
There are no uninitialized variables in this block of code. I don't think there are any in whole program. I can't understand how uninitialized variables could result in such a behaviour of program.
|
|
|
|
|
mass85 wrote: There are no uninitialized variables in this block of code. I don't think there are any in whole program.
But are you sure?
mass85 wrote: I can't understand how uninitialized variables could result in such a behaviour of program.
I think in DEBUG code all stack space is initialised to 0xCCCCCCCC (or similar) on entry to a function, which helps the debugger to diagnose exactly this problem. It certainly sounds like a value is being set wrongly or mis-computed somewhere.
|
|
|
|
|
 But do you think I can look for the uninitialized variable within the function part of which I presented here and all objects that are used by this function? Or maybe I should look through whole code?
This is the code of the function:
void BEload::execute(){
MSDU *msdu = new MSDU();
msdu->ac = 2;
msdu->type = DATA;
msdu->arrivalTime = msdu->staArrivalTime = clock;
msdu->id = id++;
double temp = generator.getUpLinkRandom(staAddress);
t += temp;
cntr++;
if (temp < upLinkRatio){
msdu->DA = 0;
msdu->TA = msdu->SA = staAddress;
}else{
msdu->SA = msdu->TA = 0;
msdu->DA = staAddress;
}
Mac *s = sta[msdu->SA];
msdu->RA = s->routing[msdu->DA];
msdu->bitrate = s->bitrate[msdu->RA];
msdu->size = packetSize;
if (msdu->size + overhead > s->fragmTSH){
double fragments = double (msdu->size)/(s->fragmTSH - overhead);
if (fragments != int(fragments)) fragments = int (fragments + 1);
msdu->fragments = int(fragments);
msdu->lastFragmSize = int(msdu->size - (s->fragmTSH - overhead)*(fragments - 1));
}else
msdu->fragments = 1;
s->bufOUT[2].insertLast(msdu);
time = clock + generator.getTimeBE(staAddress, intensity);
agenda.schedule(this);
}
double Generator::getUpLinkRandom(int staAddress){
int x = uniform(coreUpLinkRatio[staAddress]);
coreUpLinkRatio[staAddress] = x;
return double(x)/m;
}
Constructor of MSDU initializes all of MSDU's variables. t, cntr and upLinkRatio are members of BEload and are initialized by BEload's constructor and upLinkRatio is later changed to the value of global upLinkRatio variable (this global variable is not needed anymore, but could it cause any problems? I don't think so.). All variables in Generator class are initialized too.
|
|
|
|
|
From your earlier message you implied that this statement
if (temp < upLinkRatio)
may be the problem. Are you sure the value of the temp variable is consistent in DEBUG and RELEASE modes? As I do not really understand how all of this code works I can't speculate as to any other places to look.
|
|
|
|
|
There is just one version of code and I just change Solution configuration from debug to release, so temp is consistent.
Whole program simulates WLAN with EDCA (802.11e). BEload:execute() function generates packets MSDU for one single station, which means it generates offered traffic = offered load. It decides (draws) whether just arrived packet will be sent in UPLINK or DOWNLINK. upLinkRatio variable states what % of all packets generated by BEload:execute() function will be sent in UPLINK. When the random double temp that varies from 0 to 1 is smaller than upLinkRatio (let's say smaller than 0.2 - let's assume upLinkRatio = 0.2), generated packet will be sent in UPLINK. It means address of source and transmitter will be set to address of station, and destination address to 0 (which is the address of access point - AP):
if (temp < upLinkRatio){
msdu->DA = 0;
msdu->TA = msdu->SA = staAddress;
}
Otherwise source and transmitter addresses will be set to address of AP (0) and destination adress to address of station.
else{
msdu->SA = msdu->TA = 0;
msdu->DA = staAddress;
}
So the problem is that proportion of offered traffic in UPLINK and DOWNLINK for RELEASE version are inverted. 80% of packets are offered in UPLINK, instead of 20%.
After changing statement you quoted to:
if (temp > upLinkRatio){
20% of packets are offered in UPLINK instead of 80% (of course just inthis case, when conditional statement is "inverted").
|
|
|
|
|
mass85 wrote: There is just one version of code and I just change Solution configuration from debug to release, so temp is consistent.
So you're saying that somehow the values of the '<' and '>' operators are being inverted by the compiler! I would suggest that it is much more likely that either the value of temp or upLinkRatio takes a different value depending on whether or not DEBUG is set. Try putting some extra code in there to see exactly what values are being used.
|
|
|
|
|
OK. I've changed conditional statement, so there's no upLinkRatio variable just constant value 0.2. And I also added cout<<temp;
the result="" is="" quite="" strange.="" most="" of="" the="" temp="" values="" are="" 0...="" which="" course="" incorrect.="" do="" you="" know,="" what="" might="" be="" reason="" for="" that?="" i="" will="" looking="" anything="" suspicious="" in="" generator,="" but="" it="" hard="" to="" find...="" example="" function="" gettimebe="" returns="" correct="" values.
here="" parts="" code="" that="" can="" affect="" beload="" from="" generator="" (this="" class="" used="" generate="" pseudo="" random="" numbers):
<pre="">
class Generator{
private:
int a, h, q, r, m;
int *coreCRC;
int **coreCW;
int *coreTimeBE;
int *coreTimeBK;
int *coreUpLinkRatio;
int *coreBurst;
int *corePacket;
int uniform(int X){
h = int ( double (X) / q );
X = a*(X - q*h) - r*h;
if (X < 0) X = X + m;
return X;
}
public:
double getTimeBE(int staAddress, double intensity){
int x = uniform(coreTimeBE[staAddress]);
coreTimeBE[staAddress] = x;
return (-1/intensity * log(double(x)/m));
}
double getUpLinkRandom(int staAddress){
int x = uniform(coreUpLinkRatio[staAddress]);
coreUpLinkRatio[staAddress] = x;
return double(x)/m;
}
void initialize(){
coreCW = new int*[staNr];
coreUpLinkRatio = new int[staNr];
coreBurst = new int[staNr];
coreTimeBE = new int[staNr];
coreTimeBK = new int[staNr];
corePacket = new int[staNr];
for(int i = 0; i < staNr; i++) coreCW[i] = new int[AC];
coreCRC = new int[staNr];
int x = 17;
int msgs = int (5*msgsToObserve*(1 + transientPhase/simTime));
for (int i = 0; i < staNr; i++){
for(int j = 0; j < AC; j++){
coreCW[i][j] = x;
for(int k = 0; k < (runsNr*(10*msgs + 3*shift + runShift)); k++)
x = uniform(x);
}
}
////////////////
// code omitted
///////////////
for(int i = 0; i < AC; i++){
coreUpLinkRatio[i] = x;
for(int j = 0; j < (runsNr*(2*beMsgsToObserve + shift + runShift)); j++)
x = uniform(x);
}
}
Generator() : a(69621), q(30845), r(23902), m(2147483647) {}
};
|
|
|
|
|
You know, it's very hard to find mistakes in snippet of code that may also be error-free (the mistake may be, for instance in the omitted code). Your best bet is a uninitialized variable (in the posted code, for instance m appears to be such).
BTW have a look the classical article "Surviving the Release Version".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thx for the link.
a, q, r, m are initialized in constructor.
|
|
|
|
|
mass85 wrote: Most of the temp values are 0... which is of course incorrect. Do you know, what might be the reason for that?
No idea whatever, but obviously some part of your randomiser is incorrect.
mass85 wrote: int uniform(int X){
h = int ( double (X) / q );
X = a*(X - q*h) - r*h;
if (X < 0) X = X + m;
return X;
}
Try using more meaningful variable names as it can often aid in problem diagnosis.
|
|
|
|
|
This function is an implementation of a math formula...
I have finally found the bug!
And it was in the part of code pasted here. You couldn't find it, because you don't know whole design of this simulator In fact not whole coreUpLinkRatio array was initialized because of wrong for loop parameters after copying and pasting blocks of code without proper check of all details...
It should be this:
for(int i = 1 + repeaters; i < staNr; i++){
coreUpLinkRatio[i] = x;
for(int j = 0; j < (runsNr*(2*beMsgsToObserve + shift + runShift)); j++)
x = uniform(x);
}
...instead of this:
for(int i = 0; i < AC; i++){
coreUpLinkRatio[i] = x;
for(int j = 0; j < (runsNr*(2*beMsgsToObserve + shift + runShift)); j++)
x = uniform(x);
}
Thank you for your help!
|
|
|
|
|
mass85 wrote: I have finally found the bug!
Congratulations!
So when you wrote: There are no uninitialized variables in this block of code. I don't think there are any in whole program.
You did not realize that: In fact not whole coreUpLinkRatio array was initialized.
A good lesson to be learned here, methinks.
mass85 wrote: Thank you for your help!
My pleasure; I just wish my own bugs were as easy to find!
|
|
|
|
|
Developing this project learned me a lot, believe me. I found all the bugs I noticed (it hadn't been always like that before) and the more bugs I noticed and found the faster debugging was in the future. But this bug was a little bit different, that's why I wouldn't have found that without you insisting on uninitialized variable to be the problem.
But what was the problem in fact? Was the uninitialized part of array filled with zeros? It would explain why getUpLinkRatio returned zeros for most of the staAddresses. Core of the multiplicative generator can't be equal to 0, because it would return always 0.
Good luck in your debugging! 
|
|
|
|
|
Hi, i am not familiar to win32 api so this may seen a easy question, i have a handle to a menu item, how can i action (virtual press that menu) and run it's method. I want to do this from other program ,from my programm i want to control menus from other apps(i already read the menus,i have handles to them).
Thx.
I found that it will work in most cases with WM_command
simion314
modified on Sunday, September 20, 2009 7:02 AM
|
|
|
|
|
Use FindWindow() to find the other program and use SendMessage()/PostMessage() (probably a WM_COMMAND message) to "press" the button.
|
|
|
|
|
How do you bind a Microsoft Forms TextBox in a Access 2002 Memo Field in VC++ 6? I am using this but just get a blank field
CWnd* pDSC = GetDlgItem(IDC_ADODC1);
pEdit = GetDlgItem(IDC_TEXTBOX1);
pEdit->BindDefaultProperty(0x16,VT_BSTR, _T("Synopsis"), pDSC);
|
|
|
|
|
|
Please must delete this post and re-post in the C# forum yourself.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Why didn't you post this question here[^] the first place?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|