[pooma-dev] RFA: delete_test1 Modifications
Jeffrey Oldham
oldham at codesourcery.com
Fri May 25 01:32:48 UTC 2001
On Thu, May 24, 2001 at 04:17:54PM -0700, James Crotinger wrote:
> copy doesn't have the same semantics as memmove and so it is potentially
> faster (it can only copy overlapping regions if the destination is before
> the source, which is the case in the shift-up copies, which almost always
> involve overlapping regions). However, I did a lot of testing with KCC on
> the SGI and found that for larger moves, memmove was faster. This is why I
> put a test into the delete_shiftup algorithm to use copy only if the length
> of the copy was less than 100 (a good round number). Someone (named julianc)
> has since commented out that code without leaving a comment in the source as
> to the reason. Looking at the log I see that it was due to VC++ not having a
> proper std::advance. This should have just been coded around. At any rate, I
> didn't add this complication lightly. Now perhaps KCC has since written copy
> to use memmove so I don't know if my investigations from early 2000 are
> still valid.
>
> Jim
>
> > For those skipping intermediary emails, the discussion is whether
> > memmove() is faster than copy().
> >
> > Attached is a program that constructs a vector, copies its contents to
> > another vector, and then checks the copy for correctness. On
> > Linux/gcc3.0 and Irix6.5/KCC, I cannot find any significant speed
> > difference between std::copy and std::memmove for vectors of doubles.
> > Given this result, may we use std::copy() everywhere since it is
> > guaranteed to compile?
OK, I am not going to argue with your timing data even though I cannot
reproduce them. Let's just end up with a program that compiles and
uses std::memmove.
OK to commit this patch?
Compiling src/Utilities/tests/delete_test1.cpp showed that the vector
type `Array_t' was declared to store doubles but actually stored
integers. Also, arguments for a call to std::memmove() was modified
to permit compilation.
2001 May 24 Jeffrey D. Oldham <oldham at codesourcery.com>
* delete_test1.cpp (Array_t): s/vector<double>/vector<int>/
(delete_shiftup_test2): Modify memmove operands to permit compilation.
Tested on sequential Linux using gcc 3.0 by compiling the program
Approved by ???you???
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: delete_test1.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/src/Utilities/tests/delete_test1.cpp,v
retrieving revision 1.7
diff -c -p -r1.7 delete_test1.cpp
*** delete_test1.cpp 2001/03/21 00:56:09 1.7
--- delete_test1.cpp 2001/05/25 01:28:27
*************** void delete_shiftup_test2(Array_t &data,
*** 596,601 ****
--- 596,602 ----
const int size = data.size();
const std::vector<Array_t::value_type>::iterator data_begin = data.begin();
+ const Array_t::pointer data_begin_ptr = &(data[0]);
// Now loop through the data and destroy the values
*************** void delete_shiftup_test2(Array_t &data,
*** 625,632 ****
data_begin + copy_end_index,
data_begin + insert_index);
else
! std::memmove(data_begin + insert_index,
! data_begin + copy_begin_index,
sizeof(Array_t::value_type)*length);
insert_index += length;
--- 626,636 ----
data_begin + copy_end_index,
data_begin + insert_index);
else
! // Jim Crotinger, in early 2000, measured significant
! // speedup using KCC by using std::memmove rather than
! // std::copy.
! std::memmove(data_begin_ptr + insert_index,
! data_begin_ptr + copy_begin_index,
sizeof(Array_t::value_type)*length);
insert_index += length;
More information about the pooma-dev
mailing list