Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Faster than memcpy()...

Faster than memcpy()...

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestionannouncement
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bulg
    wrote on last edited by
    #1

    Has anyone here ever had the need to use something faster than memcpy() to move a large amount of data in physcal memory? I have a suspicion that memcpy is copying only a few bytes at a time, depending on what compiler is used. Any information floating around here? (I'm also googling, and I'll update this thread if I find something..)

    B C 2 Replies Last reply
    0
    • B bulg

      Has anyone here ever had the need to use something faster than memcpy() to move a large amount of data in physcal memory? I have a suspicion that memcpy is copying only a few bytes at a time, depending on what compiler is used. Any information floating around here? (I'm also googling, and I'll update this thread if I find something..)

      B Offline
      B Offline
      BobInNJ
      wrote on last edited by
      #2

      I certainly agree that the performance of memcpy is dependent on the compiler. I took a quick look at the memcpy that came with my version of Visual C++ and it looks well written. That is, it should run fast for large data blocks. You wrote that memcpy only copies a few bytes at a time. The code I saw was using a block move instructions to do most of the work. However, we may not be looking at the same code. Which compiler are you using? Bob

      P 1 Reply Last reply
      0
      • B BobInNJ

        I certainly agree that the performance of memcpy is dependent on the compiler. I took a quick look at the memcpy that came with my version of Visual C++ and it looks well written. That is, it should run fast for large data blocks. You wrote that memcpy only copies a few bytes at a time. The code I saw was using a block move instructions to do most of the work. However, we may not be looking at the same code. Which compiler are you using? Bob

        P Offline
        P Offline
        PJ Arends
        wrote on last edited by
        #3

        VS 2005 - memcpy.c

            while (count--) {
                    \*(char \*)dst = \*(char \*)src;
                    dst = (char \*)dst + 1;
                    src = (char \*)src + 1;
            }
        

        definitely not a block copy. Which version do you have and can you post the relevant code?


        You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

        L B 2 Replies Last reply
        0
        • B bulg

          Has anyone here ever had the need to use something faster than memcpy() to move a large amount of data in physcal memory? I have a suspicion that memcpy is copying only a few bytes at a time, depending on what compiler is used. Any information floating around here? (I'm also googling, and I'll update this thread if I find something..)

          C Offline
          C Offline
          cmk
          wrote on last edited by
          #4

          With VS your release build will likely use the intrinsic version. http://msdn.microsoft.com/en-us/library/26td21ds(VS.80).aspx[^]

          ...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack

          1 Reply Last reply
          0
          • P PJ Arends

            VS 2005 - memcpy.c

                while (count--) {
                        \*(char \*)dst = \*(char \*)src;
                        dst = (char \*)dst + 1;
                        src = (char \*)src + 1;
                }
            

            definitely not a block copy. Which version do you have and can you post the relevant code?


            You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            I believe he is referring to the Intel optimized memcpy located at: Program Files\Microsoft Visual Studio 8\VC\crt\src\intel\memcpy.asm or Program Files\Microsoft Visual Studio 9\VC\crt\src\intel\memcpy.asm Best Wishes, -David Delaune

            1 Reply Last reply
            0
            • P PJ Arends

              VS 2005 - memcpy.c

                  while (count--) {
                          \*(char \*)dst = \*(char \*)src;
                          dst = (char \*)dst + 1;
                          src = (char \*)src + 1;
                  }
              

              definitely not a block copy. Which version do you have and can you post the relevant code?


              You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

              B Offline
              B Offline
              BobInNJ
              wrote on last edited by
              #6

              I have VS 2008, version 3.5. I believe that this code is copy righted so, I cannot post it. Sorry. Bob Sherry

              L 1 Reply Last reply
              0
              • B BobInNJ

                I have VS 2008, version 3.5. I believe that this code is copy righted so, I cannot post it. Sorry. Bob Sherry

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                The memcpy source files are the same in both VS2005/VS2008 all service packs. Best Wishes, -David Delaune

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups