• Stars
    star
    551
  • Rank 77,983 (Top 2 %)
  • Language
    C
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Speed-up over 50% in average vs traditional memcpy in gcc 4.9 or vc2012

Build SSE

with gcc:

gcc -O3 -msse2 FastMemcpy.c -o FastMemcpy

with msvc:

cl -nologo -arch:SSE2 -O2 FastMemcpy.c

Build AVX

with gcc:

gcc -O3 -mavx FastMemcpy_Avx.c -o FastMemcpy_Avx

with msvc:

cl -nologo -arch:AVX -O2 FastMemcpy_Avx.c

Features

  • 50% speedup in avg. vs traditional memcpy in msvc 2012 or gcc 4.9
  • small size copy optimized with jump table
  • medium size copy optimized with sse2 vector copy
  • huge size copy optimized with cache prefetch & movntdq

Reference

Using Block Prefetch for Optimized Memory Performance

The artical only focused on aligned huge memory copy. You need handle other cases by your self.

Results

result: gcc4.9 (msvc 2012 got a similar result):
 
benchmark(size=32 bytes, times=16777216):
result(dst aligned, src aligned): memcpy_fast=81ms memcpy=281 ms
result(dst aligned, src unalign): memcpy_fast=88ms memcpy=254 ms
result(dst unalign, src aligned): memcpy_fast=87ms memcpy=245 ms
result(dst unalign, src unalign): memcpy_fast=81ms memcpy=258 ms

benchmark(size=64 bytes, times=16777216):
result(dst aligned, src aligned): memcpy_fast=91ms memcpy=364 ms
result(dst aligned, src unalign): memcpy_fast=95ms memcpy=336 ms
result(dst unalign, src aligned): memcpy_fast=96ms memcpy=353 ms
result(dst unalign, src unalign): memcpy_fast=99ms memcpy=346 ms

benchmark(size=512 bytes, times=8388608):
result(dst aligned, src aligned): memcpy_fast=124ms memcpy=242 ms
result(dst aligned, src unalign): memcpy_fast=166ms memcpy=555 ms
result(dst unalign, src aligned): memcpy_fast=168ms memcpy=602 ms
result(dst unalign, src unalign): memcpy_fast=174ms memcpy=614 ms

benchmark(size=1024 bytes, times=4194304):
result(dst aligned, src aligned): memcpy_fast=119ms memcpy=171 ms
result(dst aligned, src unalign): memcpy_fast=182ms memcpy=442 ms
result(dst unalign, src aligned): memcpy_fast=163ms memcpy=466 ms
result(dst unalign, src unalign): memcpy_fast=168ms memcpy=472 ms

benchmark(size=4096 bytes, times=524288):
result(dst aligned, src aligned): memcpy_fast=68ms memcpy=82 ms
result(dst aligned, src unalign): memcpy_fast=94ms memcpy=226 ms
result(dst unalign, src aligned): memcpy_fast=134ms memcpy=216 ms
result(dst unalign, src unalign): memcpy_fast=84ms memcpy=188 ms

benchmark(size=8192 bytes, times=262144):
result(dst aligned, src aligned): memcpy_fast=55ms memcpy=70 ms
result(dst aligned, src unalign): memcpy_fast=75ms memcpy=192 ms
result(dst unalign, src aligned): memcpy_fast=79ms memcpy=223 ms
result(dst unalign, src unalign): memcpy_fast=91ms memcpy=219 ms

benchmark(size=1048576 bytes, times=2048):
result(dst aligned, src aligned): memcpy_fast=181ms memcpy=165 ms
result(dst aligned, src unalign): memcpy_fast=192ms memcpy=303 ms
result(dst unalign, src aligned): memcpy_fast=218ms memcpy=310 ms
result(dst unalign, src unalign): memcpy_fast=183ms memcpy=307 ms

benchmark(size=4194304 bytes, times=512):
result(dst aligned, src aligned): memcpy_fast=263ms memcpy=398 ms
result(dst aligned, src unalign): memcpy_fast=269ms memcpy=433 ms
result(dst unalign, src aligned): memcpy_fast=306ms memcpy=497 ms
result(dst unalign, src unalign): memcpy_fast=285ms memcpy=417 ms

benchmark(size=8388608 bytes, times=256):
result(dst aligned, src aligned): memcpy_fast=287ms memcpy=421 ms
result(dst aligned, src unalign): memcpy_fast=288ms memcpy=430 ms
result(dst unalign, src aligned): memcpy_fast=285ms memcpy=510 ms
result(dst unalign, src unalign): memcpy_fast=291ms memcpy=440 ms

benchmark random access:
memcpy_fast=487ms memcpy=1000ms

About

skywind

http://www.skywind.me

More Repositories

1

kcp

⚡ KCP - A Fast and Reliable ARQ Protocol
C
14,566
star
2

awesome-cheatsheets

超级速查表 - 编程语言、框架和开发工具的速查表,单个文件包含一切你需要知道的东西 ⚡
Shell
10,779
star
3

ECDICT

Free English to Chinese Dictionary Database
Python
5,495
star
4

preserve-cd

Game Preservation Project
3,483
star
5

z.lua

⚡ A new cd command that helps you navigate faster by learning your habits.
Lua
2,910
star
6

mini3d

3D Software Renderer in 700 Lines !!
C
2,131
star
7

asyncrun.vim

🚀 Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
Vim Script
1,815
star
8

RenderHelp

⚡ 可编程渲染管线实现,帮助初学者学习渲染
C++
1,260
star
9

vim-quickui

The missing UI extensions for Vim 9 (and NeoVim) !! 😎
Vim Script
1,061
star
10

vim

Personal Vim Profile
Vim Script
895
star
11

vim-init

轻量级 Vim 配置框架,全中文注释
Vim Script
883
star
12

asynctasks.vim

🚀 Modern Task System for Project Building, Testing and Deploying !!
Vim Script
875
star
13

emake

你见过的最简单的 GCC/CLANG 项目构建工具,定义式构建,比命令式更简单
Python
666
star
14

PyStand

🚀 Python Standalone Deploy Environment !!
C++
543
star
15

preserve-iso

绝版软件保护工程
412
star
16

avlmini

AVL implementation which is as fast/compact as linux's rbtree
C
333
star
17

quickmenu.vim

A nice customizable popup menu for vim
Vim Script
275
star
18

vim-auto-popmenu

😎 Display the Completion Menu Automantically (next AutoComplPop) !!
Vim Script
268
star
19

gutentags_plus

The right way to use gtags with gutentags
Vim Script
258
star
20

vim-terminal-help

Small changes make vim/nvim's internal terminal great again !!
Vim Script
241
star
21

translator

命令行聚合翻译工具,支持谷歌,必应,有道,百度,词霸,360
Python
226
star
22

ECDICT-ultimate

Ultimate ECDICT Database
210
star
23

vim-preview

The missing preview window for vim
Vim Script
166
star
24

pixellib

High Quality 2D Graphics Library
C
155
star
25

images

Static Page
C++
144
star
26

KanaQuiz

Hiragana/Katakana Speed Reading Quiz in Command Line !! 😎
Python
142
star
27

BasicBitmap

Simple and high-performance and platform independent Bitmap class (34% faster than GDI/GDI+, 40% faster than DDraw)
C++
130
star
28

vim-rt-format

😎 Prettify Current Line on Enter !!
Vim Script
113
star
29

AsyncNet

AsyncNet
C
113
star
30

vim-keysound

🍷 Play typewriter sound in Vim when you are typing a letter
Vim Script
111
star
31

Intel2GAS

Convert MSVC Style Inline Assembly to GCC Style Inline Assembly
Python
104
star
32

gobang

Gobang game with artificial intelligence in 900 Lines !!
Python
90
star
33

CloudClip

Your own clipboard in the cloud, copy and paste text with gist between systems !!
Python
76
star
34

googauth

The Python Command-line Reimplementaion of Google Authenticator
Python
74
star
35

LIBLR

Parser Generator for LR(1) and LALR
Python
64
star
36

markpress

Write WordPress in Markdown in Your Favorite Text Editor !! 😎 😎
Python
64
star
37

vim-dict

没办法,被逼的,重新整理一个词典补全的数据库
Vim Script
57
star
38

terminal

Open Terminal Window to execute command in Windows / Cygwin / Ubuntu / OS X
Python
49
star
39

LeaderF-snippet

Intuitive Way to Use Snippet
Vim Script
46
star
40

nanolib

Cross-Platform Networking Library
C
44
star
41

czmod

🚀 Native Module Written in C to Boost z.lua !!
C
43
star
42

collection

没地方放的代码,懒得开新项目了,放这里吧。
Python
38
star
43

vim-gpt-commit

🚀 Generate git commit message using ChatGPT in Vim (and NeoVim) !!
Python
38
star
44

atom-shell-commands

Execute user defined shell commands (looking for new maintainers)
JavaScript
36
star
45

vim-navigator

🚀 Navigate Your Commands Easily !!
Vim Script
28
star
46

ml

Machine Learning From Scratch
C
27
star
47

asyncrun.extra

Extra runners for asyncrun to run your command in Tmux/Gnome-terminal panel, xterm, Floaterm and more.
Vim Script
27
star
48

memslab

Slab Memory Allocator in Application Layer
C
25
star
49

lemma.en

English Lemma Database - Compiled by Referencing British National Corpus
25
star
50

vim-color-patch

🌈 Load colorscheme patch script automatically !!
Vim Script
22
star
51

vim-color-export

🌈 A tool to backport NeoVim colorschemes to Vim !!
Vim Script
19
star
52

zvi

🚀 Smallest Vi-clone Text Editor for Windows CLI and SSH session (only 62KB) !!
17
star
53

asmpure

Asmpure is a library written in C for compiling assembly code at run-time
C
16
star
54

QuickNet

UDP Networking Library
C
16
star
55

docker

Docker Images
Python
16
star
56

VmBasic

基于虚拟机的仿 QuickBasic 语言
C++
14
star
57

vim-cppman

Read Cppman/Man pages right inside your vim.
Vim Script
14
star
58

skywind3000.github.io

Pages of Skywind
Python
12
star
59

language

Language Collection
Python
11
star
60

tcz_cd

Autojump for Total Commander !!
Python
10
star
61

LanguageMark

Native Language Benchmark in Numerous Algorithms
C
10
star
62

vim-proposal

Collection of Proposals for Vim
TypeScript
7
star
63

shell-scripts

常用的命令行脚本合集,让你每天的命令行生活更加高效
Shell
6
star
64

pyp2p

Python P2P Framework
Python
6
star
65

cannon

Cross Platform Network Framework
C
5
star
66

SimdVector

Cross Platform SIMD Vector Math In A Single Header File (SimdVector.h)
C++
5
star
67

crtzero

Zero Dependent on CRT (libc)
C
5
star
68

gosub

Golang Sub-routines for Network Development
Go
5
star
69

support

plugin collections for vim
Python
4
star
70

asyncredis

Async Redis Client for Python
Python
3
star
71

skywind

Personal Blog
HTML
3
star
72

directx9-samples

samples
C++
3
star
73

gfx

Just Another Toy yet !!
C++
3
star
74

treasure

Single-file MIT Licensed C/C++ Portable Libraries
C
3
star
75

winxp-editors

🍷 Text Editors Preservation Project for Windows XP+
Batchfile
3
star
76

colors-from-neovim.vim

🌈 Backported NeoVim Colors for Vim
Vim Script
3
star
77

ones

One single file MIT licensed C/C++ Libraries
2
star
78

asclib

Basic Java Network Lib
Java
2
star
79

toys

My PyQt Desktop Toys
Python
2
star
80

transmod

Automatically exported from code.google.com/p/transmod
C
2
star
81

rust

Rust Learning Repository
1
star
82

vile

Vile the vi-clone text editor
C
1
star
83

xvi

A portable multi-file text editor and the smallest full-function vi clone
C
1
star
84

emacs

Personal Emacs Profile
Emacs Lisp
1
star