1 2 3 4 5 | wmb@p5sys:~> ls -l -d /libhugetlbfs/ drwxrwx--- 2 root libhuge 0 2006-12-18 21:26 /libhugetlbfs/ wmb@p5sys:~> id uid=1000(wmb) gid=100(users) groups=16(dialout),33(video),100(users),1000(libhuge) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #define ELEMENTS 1024*1024*128 static double bss_array_from[ELEMENTS]; static double bss_array_to[ELEMENTS]; static double *malloc_array_from; static double *malloc_array_to; int main() { int i; malloc_array_from = (double *)malloc(ELEMENTS*sizeof(double)); malloc_array_to = (double *)malloc(ELEMENTS*sizeof(double)); /* initialize and touch all of the pages */ for (i = 1; i < ELEMENTS; i++) { bss_array_to = 1.0; bss_array_from = 2.0; malloc_array_to = 3.0; malloc_array_from = 4.0; } /* copy "from" "to" */ for (i = 1; i < ELEMENTS; i++) { bss_array_to = bss_array_from; malloc_array_to = malloc_array_from; } return; } |
1 2 | # echo 200 > /proc/sys/vm/nr_hugepages # watch cat /proc/meminfo |
1 2 3 4 5 6 7 | wmb@p5sys:~> cc -O3 -m64 copy_arrays.c -o copy_arrays wmb@p5sys:~> time ./copy_arrays real 0m6.844s user 0m2.149s sys 0m2.649s |
1 2 3 4 5 | wmb@p5sys:~> time HUGETLB_MORECORE=yes LD_PRELOAD=libhugetlbfs.so ./copy_arrays real 0m6.480s user 0m2.483s sys 0m1.645s |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |