Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    72
  • comments
    38
  • views
    22436

me

Sign in to follow this  
mozie

354 views

Oh Oh Oh, I couldnt wait for that mobo to go back in stock. I ordered everything else, except I spent about $20 more and got a gig of ddr insted if just 512. I dont plan to overclock at all, so I should be okay with the ram I purch. Geil Ultra Series Value for thoes of you who might be interisted. Besides that! I got a gF4 SLI chipset board. Newegg is currently selling it for about $270. I found it for $200, and I'm getting everything Thursday, my day off. And to top it all off, its going to snow from now thru Friday, so I wont be missing anything because I dont snowboard yet. Ya! Ya Ya! This is my first nVidia chipset. But I have heard so many good things about the nForce 3's and the A64. I really wanted to get my grubby fingers on a system with a nVidia chipset & GPU. And as far as I am concerned, its long overdue. My current system is a Socket A Athlon 1 GHZ @ 10x100 Mhz(FSB) , 256+256+128 MB of PC133, and my flakey Radion 9000 Pro. If you want to keep your hardware for more than 1 year, dont OC the stuff. Uless you really just need a reason to upgrade/replace something every now and then.

I know what you are thinking if you are running something older than my current Athlon, "Just shut-up already". Ok, on to something else.

While thinking about the processors and all, I had a thought. My program to preform a compare on a pair of files, and report the difference at offset.. could read 4 bytes at a time, thus filling the entire register. I could just compare the two filled registers, and if there is a difference.. determine the offset. Simple enough, it was reading in 64K of data, and then comparing each byte untill the end, then it loads another 64K of data and so on to the end of the file. Well I tried to impliment a 'faster' method, read in 32 bits from the 64K chunk, and if there is a difference, determine offset. else just read the next 4 from each files data and go on. So I should get a speed gain because I am now comparing 32 bits of data, not just 8. Guessing that it would be 4x faster is pretty bold, and thats not really a realistic expectation. But anyway, I should get to the point. I think what I am doing wrong, is really that I cant pull 32 bits of data from my array. I can only get 1 byte at a time, so I have to fill in the DWORD and I choose to shift to get it in place. Well it's not faster. I spent about 4 hours trying to get it to go faster. Right now its about 10% slower than it was before. If I can get the data in 32 bits at a time, then I dont have to do 4 adds and shifts for each byte that I am trying to just compare. In the end I'm spending time adding and shifting that I could just have compared the 4 bytes already. **sigh** Take a look if you like.

int winbdiff2::Form1::Compare(char* fna, char* fnb)
{
int n_sets = 0;
int set_n = 1;
int n_remain = 0;
int c_size = 0;
int ndiff = 0;
int sbarloc = 0;
int sbarcount = 0;
int sbar100th;
unsigned int diff_loc;
char hex_buff[14];
String * gobuffer;

DWORD sTime,fTime;
sTime = timeGetTime();

n_sets = (fsa / S64K);
n_remain = (fsa - (n_sets * S64K));

WriteMessage(S"Initilized\r\n");
gobuffer = String::Format(S"Using {0} KB sets\r\n", __box((S64K / 1024)) );
WriteMessage(gobuffer);
gobuffer = String::Format(S"{0} sets with {1} KB remaining\r\n", __box(n_sets), __box((n_remain / 1024)));
WriteMessage(gobuffer);

if(n_sets == 0)
c_size = fsa;
else
c_size = S64K;

WriteMessage(S"Comparing...\r\n");
WriteMessage(S"|OFFSETh|Ah:Bh\r\n");
/*
found number of 64K chunks
and remainder, loop for n_sets + 1;
*/

sbar100th = (fsa / 100);
progressBar1->Value = 0;

FileStream* inA = new FileStream(fna, FileMode::Open, FileAccess::Read);
FileStream* inB = new FileStream(fnb, FileMode::Open, FileAccess::Read);

DWORD* uDA;
DWORD* uDB;

int i4 = 0;
//unsigned long oa;
//unsigned long ob;

for(set_n = 1;set_n <= (n_sets + 1);++set_n)
{
c_size = S64K;
if(n_sets == 0 || set_n == ( n_sets + 1 )) // FILE IS SMALLER THAN S64K -or- LAST SET OF MULTI SETS
c_size = n_remain;

Byte pa[] = new Byte[c_size];
Byte pb[] = new Byte[c_size];

if( inA->Read(pa,0,c_size) == 0)
return -1;
if( inB->Read(pb,0,c_size) == 0)
return -1;

for(int i = 0;i < (c_size >> 2); ++i)
{
i4 = i << 2;

void *ppa = (void*)&pa;
uDA = (DWORD*)ppa + i4;
unsigned long DDa = *uDA;

uDA = uDB = 0x00000000;

// fill DWORDs
// still slow
for(int j = 0;j < 4;++j)
{
uDA += ((unsigned char)pa[i4 + j] << (j << 3));
uDB += ((unsigned char)pb[i4 + j] << (j << 3));
}

// compare DWORDs
if( uDA != uDB )
{
unsigned int offset = 0xFF000000;
for(int j = 0; j < 4; ++j)
{
if( (*uDA & offset) != (*uDB & offset) )
{
diff_loc = ((set_n - 1) * S64K) + i4 + j + 1;
sprintf(hex_buff,"%.8X|%.2X:%.2X", diff_loc,
(unsigned char)((*uDA & offset) >> (24 - (j << 3))),
(unsigned char)((*uDB & offset) >> (24 - (j << 3))));
gobuffer = String::Format("{0}\r\n", (String*)hex_buff);
WriteMessage(gobuffer);
++ndiff;
}
offset = offset >> 8;
++sbarcount;
}
}
else
{
sbarcount += 4;
}
if(sbarcount >= sbar100th)
{
++sbarloc; // move the bar up 1 position
sbarcount -= sbar100th; // reset the count
progressBar1->Value = sbarloc;
}
}
delete[] pa;
delete[] pb;
}
inA->Close();
inB->Close();

fTime = timeGetTime();
sprintf(hex_buff, "%d ms to scan.\r\n", (fTime-sTime));
gobuffer = String::Format("{0}\r\n", (String*)hex_buff);
WriteMessage(gobuffer);

return ndiff;
}




GO ALL OUT!
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!