Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Using a 64bit CPU...

hadipardishadipardis Posts: 134Member
I wrote a Delphi program in which we need to access to memory a lot.But unfortunately, it is very time consuming on my Pentium 4 (2.8GHz 512MB ) To speed up it someone advices me to a 64bit CPU. But do you agree with them? Thanks

Comments

  • zibadianzibadian Posts: 6,349Member
    : I wrote a Delphi program in which we need to access to memory a lot.But unfortunately, it is very time consuming on my Pentium 4 (2.8GHz 512MB ) To speed up it someone advices me to a 64bit CPU. But do you agree with them? Thanks
    :
    That won't help, because your program is probably getting slow due to the latency (http://en.wikipedia.org/wiki/RAM_latency) to get its data from the memory. The best way to tackly this problem is to design another algorithm, which doesn't need to access the memory so much.
  • hadipardishadipardis Posts: 134Member
    : : I wrote a Delphi program in which we need to access to memory a lot.But unfortunately, it is very time consuming on my Pentium 4 (2.8GHz 512MB ) To speed up it someone advices me to a 64bit CPU. But do you agree with them? Thanks
    : :
    : That won't help, because your program is probably getting slow due to the latency (http://en.wikipedia.org/wiki/RAM_latency) to get its data from the memory. The best way to tackly this problem is to design another algorithm, which doesn't need to access the memory so much.
    :
    Thanks. You are right. But please consider the following codes:
    [code]
    //Code #1
    var M,N:array of array of byte;
    T:integer;
    ...
    begin
    SetLength(M,640,640);
    SetLength(N,640,640);

    //Fill each array with some data
    FillMatrix(M);
    FillMatrix(N);

    T:=Gettickcount;
    //Do some operations with M
    Operate(M);

    //Do some operations with N
    Operate(N);

    showmessage(inttostr(Gettickcount-T)); // T=800 msec
    end;
    [/code]
    In the above code, the whole process takes about 800msec. Intresting is that if I change Operate(N) to Operate(M), the whole process takes about 650msec !!! In his case we have the following code:
    [code]
    //Code #1
    var M,N:array of array of byte;
    T:integer;
    ...
    begin
    SetLength(M,640,640);
    SetLength(N,640,640);

    //Fill each array with some data
    FillMatrix(M);
    FillMatrix(N);

    T:=Gettickcount;
    //Do some operations with M
    Operate(M);

    //Do some operations with M
    Operate(M);

    showmessage(inttostr(Gettickcount-T)); // T=650 msec
    end;
    [/code]
    But I am wondering why this happen?!! Do you know its reason? I have another question too. Please consider the following codes:
    [code]
    //code 3
    var i,t:integer;
    ...
    t:=i;
    [/code]
    [code]
    //code 4
    var t:integer;
    M:array[0..20] of array[0..20] of integer;
    ...
    t:=M[10,10];
    [/code]
    Which one is faster? (Code 3 or Code 4)
  • zibadianzibadian Posts: 6,349Member
    : : : I wrote a Delphi program in which we need to access to memory a lot.But unfortunately, it is very time consuming on my Pentium 4 (2.8GHz 512MB ) To speed up it someone advices me to a 64bit CPU. But do you agree with them? Thanks
    : : :
    : : That won't help, because your program is probably getting slow due to the latency (http://en.wikipedia.org/wiki/RAM_latency) to get its data from the memory. The best way to tackly this problem is to design another algorithm, which doesn't need to access the memory so much.
    : :
    : Thanks. You are right. But please consider the following codes:
    : [code]
    : //Code #1
    : var M,N:array of array of byte;
    : T:integer;
    : ...
    : begin
    : SetLength(M,640,640);
    : SetLength(N,640,640);
    :
    : //Fill each array with some data
    : FillMatrix(M);
    : FillMatrix(N);
    :
    : T:=Gettickcount;
    : //Do some operations with M
    : Operate(M);
    :
    : //Do some operations with N
    : Operate(N);
    :
    : showmessage(inttostr(Gettickcount-T)); // T=800 msec
    : end;
    : [/code]
    : In the above code, the whole process takes about 800msec. Intresting is that if I change Operate(N) to Operate(M), the whole process takes about 650msec !!! In his case we have the following code:
    : [code]
    : //Code #1
    : var M,N:array of array of byte;
    : T:integer;
    : ...
    : begin
    : SetLength(M,640,640);
    : SetLength(N,640,640);
    :
    : //Fill each array with some data
    : FillMatrix(M);
    : FillMatrix(N);
    :
    : T:=Gettickcount;
    : //Do some operations with M
    : Operate(M);
    :
    : //Do some operations with M
    : Operate(M);
    :
    : showmessage(inttostr(Gettickcount-T)); // T=650 msec
    : end;
    : [/code]
    : But I am wondering why this happen?!! Do you know its reason? I have another question too. Please consider the following codes:
    : [code]
    : //code 3
    : var i,t:integer;
    : ...
    : t:=i;
    : [/code]
    : [code]
    : //code 4
    : var t:integer;
    : M:array[0..20] of array[0..20] of integer;
    : ...
    : t:=M[10,10];
    : [/code]
    : Which one is faster? (Code 3 or Code 4)
    :
    I don't know the answer to the first question, but it might have to do with the L1 cache or with the optimalization of the compiler.
    The answer to your second question is: Code 3. Because in Code 4 the compiler needs to calculate the memory location based on the indexes. The assignment itself is equally fast.
  • IDKIDK Posts: 1,784Member
    : : : : I wrote a Delphi program in which we need to access to memory a lot.But unfortunately, it is very time consuming on my Pentium 4 (2.8GHz 512MB ) To speed up it someone advices me to a 64bit CPU. But do you agree with them? Thanks
    : : : :
    : : : That won't help, because your program is probably getting slow due to the latency (http://en.wikipedia.org/wiki/RAM_latency) to get its data from the memory. The best way to tackly this problem is to design another algorithm, which doesn't need to access the memory so much.
    : : :
    : : Thanks. You are right. But please consider the following codes:
    : : [code]
    : : //Code #1
    : : var M,N:array of array of byte;
    : : T:integer;
    : : ...
    : : begin
    : : SetLength(M,640,640);
    : : SetLength(N,640,640);
    : :
    : : //Fill each array with some data
    : : FillMatrix(M);
    : : FillMatrix(N);
    : :
    : : T:=Gettickcount;
    : : //Do some operations with M
    : : Operate(M);
    : :
    : : //Do some operations with N
    : : Operate(N);
    : :
    : : showmessage(inttostr(Gettickcount-T)); // T=800 msec
    : : end;
    : : [/code]
    : : In the above code, the whole process takes about 800msec. Intresting is that if I change Operate(N) to Operate(M), the whole process takes about 650msec !!! In his case we have the following code:

    It's becouse of the cache. The computer transparently loads ram memmory into cache that's a lot faster, but smaller than ram.

    I would recomend optimising operate.
Sign In or Register to comment.