├── unittest ├── .gitignore └── Makefile ├── include ├── .gitignore ├── timestone2.h └── mvrlu.h ├── lib-nv-jemalloc ├── config.stamp.in ├── test │ ├── src │ │ ├── math.c │ │ ├── btalloc_0.c │ │ ├── btalloc_1.c │ │ ├── btalloc.c │ │ ├── mq.c │ │ ├── thd.c │ │ ├── timer.c │ │ └── mtx.c │ ├── unit │ │ ├── junk_alloc.c │ │ ├── junk_free.c │ │ ├── a0.c │ │ ├── mtx.c │ │ ├── fork.c │ │ ├── prof_idump.c │ │ ├── zero.c │ │ └── mq.c │ ├── include │ │ └── test │ │ │ ├── thd.h │ │ │ ├── jemalloc_test_defs.h.in │ │ │ ├── timer.h │ │ │ ├── mtx.h │ │ │ └── btalloc.h │ ├── test.sh.in │ └── integration │ │ ├── sdallocx.c │ │ ├── overflow.c │ │ ├── MALLOCX_ARENA.c │ │ └── thread_arena.c ├── src │ ├── hash.c │ ├── mb.c │ ├── prng.c │ ├── spin.c │ ├── atomic.c │ └── ticker.c ├── msvc │ ├── projects │ │ └── vc2015 │ │ │ └── test_threads │ │ │ ├── test_threads.h │ │ │ ├── test_threads_main.cpp │ │ │ └── test_threads.vcxproj.filters │ └── ReadMe.txt ├── include │ ├── jemalloc │ │ ├── internal │ │ │ ├── private_unnamespace.sh │ │ │ ├── private_namespace.sh │ │ │ ├── public_unnamespace.sh │ │ │ ├── public_namespace.sh │ │ │ ├── public_unnamespace.h │ │ │ ├── public_symbols.txt │ │ │ ├── extent_mmap.h │ │ │ ├── base.h │ │ │ ├── public_namespace.h │ │ │ ├── assert.h │ │ │ ├── spin.h │ │ │ ├── extent_dss.h │ │ │ ├── pages.h │ │ │ ├── jemalloc_internal_decls.h │ │ │ ├── jemalloc_internal_macros.h │ │ │ ├── nstime.h │ │ │ ├── large.h │ │ │ └── ticker.h │ │ ├── jemalloc_rename.sh │ │ ├── jemalloc.sh │ │ ├── jemalloc_rename.h │ │ ├── jemalloc_defs.h.in │ │ ├── jemalloc_defs.h │ │ └── jemalloc_mangle.sh │ └── msvc_compat │ │ ├── windows_extra.h │ │ ├── C99 │ │ └── stdbool.h │ │ └── strings.h ├── bin │ ├── jemalloc.sh.in │ └── jemalloc-config.in ├── doc │ ├── manpages.xsl.in │ ├── html.xsl.in │ └── stylesheet.xsl ├── autogen.sh ├── coverage.sh ├── jemalloc.pc.in ├── README └── COPYING ├── benchmark ├── versioning │ ├── rlu.c │ ├── rlu.h │ ├── README.md │ ├── eval │ │ ├── ts-bst10k-u2-dram-ark.ops │ │ ├── ts-bst10k-u20-dram-ark.ops │ │ ├── ts-bst10k-u80-dram-ark.ops │ │ └── ts-bst10k-u50-dram-ark.ops │ ├── swisstm │ │ ├── src │ │ │ ├── stm │ │ │ │ ├── transaction.cc │ │ │ │ ├── memory.h │ │ │ │ ├── transaction.h │ │ │ │ ├── profiling.h │ │ │ │ ├── perfcnt │ │ │ │ │ └── perf_cnt.h │ │ │ │ ├── version_lock.h │ │ │ │ ├── privatization_tree.cc │ │ │ │ ├── transaction_mixinv.cc │ │ │ │ ├── large_lock_set.h │ │ │ │ ├── constants.h │ │ │ │ └── timestamp.h │ │ │ ├── epochstm │ │ │ │ ├── configuration.h │ │ │ │ ├── memory.h │ │ │ │ ├── constants.h │ │ │ │ └── transaction.cc │ │ │ ├── rw │ │ │ │ ├── memory.h │ │ │ │ ├── transaction.cc │ │ │ │ └── constants.h │ │ │ ├── dynamic │ │ │ │ ├── memory.h │ │ │ │ ├── api_linkage.h │ │ │ │ ├── lazy │ │ │ │ │ └── lazy_static.h │ │ │ │ ├── version_lock.h │ │ │ │ ├── transaction.cc │ │ │ │ ├── constants.h │ │ │ │ ├── timestamp.h │ │ │ │ └── perf_cnt.h │ │ │ ├── tlrw │ │ │ │ ├── memory.h │ │ │ │ ├── transaction.cc │ │ │ │ └── constants.h │ │ │ ├── p-tlrw │ │ │ │ ├── memory.h │ │ │ │ ├── transaction.cc │ │ │ │ └── constants.h │ │ │ ├── common │ │ │ │ ├── perfcnt │ │ │ │ │ └── perf_cnt_impl.h │ │ │ │ ├── word.h │ │ │ │ ├── tm_impl_const.h │ │ │ │ ├── random.h │ │ │ │ ├── padded.h │ │ │ │ ├── energy.h │ │ │ │ ├── print_utils.h │ │ │ │ ├── jmp.h │ │ │ │ ├── tid.h │ │ │ │ ├── preemptive_utils.h │ │ │ │ ├── alloc.h │ │ │ │ ├── arch.h │ │ │ │ ├── lock.h │ │ │ │ ├── cache_aligned_alloc.h │ │ │ │ ├── timing.h │ │ │ │ ├── membar.h │ │ │ │ ├── constants.h │ │ │ │ └── profiling │ │ │ │ │ └── base.h │ │ │ ├── intel │ │ │ │ ├── icc_memory.h │ │ │ │ ├── jmp.h │ │ │ │ ├── memory.cc │ │ │ │ └── jmp.s.backup │ │ │ ├── stm_api │ │ │ │ └── wlpdstm_malloc.h │ │ │ ├── tanger │ │ │ │ ├── tanger_stdlib.cc │ │ │ │ ├── tanger_stack_area.h │ │ │ │ └── tanger_string.cc │ │ │ ├── README │ │ │ ├── mubench │ │ │ │ ├── barrier.h │ │ │ │ ├── intset-rbtree.c │ │ │ │ └── time.h │ │ │ └── include │ │ │ │ └── stm.h │ │ ├── Makefile.rw.in │ │ ├── Makefile.p-tlrw.in │ │ ├── Makefile.tlrw.in │ │ ├── Makefile.intel.in │ │ ├── README │ │ ├── Makefile.intel │ │ ├── LICENSE │ │ ├── Makefile.tanger.in │ │ └── Makefile.epochstm.in │ ├── zipf │ │ ├── README │ │ ├── types.h │ │ ├── minmax.h │ │ └── zipf.h │ ├── results │ │ └── temp │ │ │ ├── test10k │ │ │ ├── u0 │ │ │ │ ├── tree_tot_ops_u0_i10000.png │ │ │ │ └── tree_abrt_ratio_u0_i10000.png │ │ │ ├── u20 │ │ │ │ ├── tree_tot_ops_u20_i10000.png │ │ │ │ └── tree_abrt_ratio_u20_i10000.png │ │ │ ├── u200 │ │ │ │ ├── tree_tot_ops_u200_i10000.png │ │ │ │ └── tree_abrt_ratio_u200_i10000.png │ │ │ └── u500 │ │ │ │ ├── tree_tot_ops_u500_i10000.png │ │ │ │ └── tree_abrt_ratio_u500_i10000.png │ │ │ └── test100k │ │ │ ├── u0 │ │ │ ├── tree_tot_ops_u0_i100000.png │ │ │ └── tree_abrt_ratio_u0_i100000.png │ │ │ ├── u20 │ │ │ ├── tree_tot_ops_u20_i100000.png │ │ │ └── tree_abrt_ratio_u20_i100000.png │ │ │ ├── u200 │ │ │ ├── tree_tot_ops_u200_i100000.png │ │ │ └── tree_abrt_ratio_u200_i100000.png │ │ │ └── u500 │ │ │ ├── tree_tot_ops_u500_i100000.png │ │ │ └── tree_abrt_ratio_u500_i100000.png │ ├── NOTE.md │ ├── util.h │ ├── config-tree.json │ ├── qsbr.h │ ├── .gitignore │ ├── config.json │ ├── run-tree.sh │ ├── benchmark_list_move.h │ ├── benchmark_list.h │ ├── runtest.sh │ └── config-list.json └── rlu │ ├── qsbr.c │ ├── qsbr.h │ ├── util.h │ ├── zipf │ ├── README │ ├── types.h │ ├── minmax.h │ └── zipf.h │ ├── .gitignore │ ├── eval │ └── ops │ │ ├── list1k-u20-pmdk-tmpfs-ark.ops │ │ ├── list1k-pmdk-ark.ops │ │ ├── list1k-dram-ark.ops │ │ ├── list10k-dram-ark.ops │ │ ├── list10k-mvrlu-ark.ops │ │ ├── list1k-u20-pmdk-emul-ark.ops │ │ ├── hash10k-dram-ark.ops │ │ ├── list1k-mvrlu-ark.ops │ │ ├── hash10k-mvrlu-ark.ops │ │ ├── hash1k-dram-ark.ops │ │ ├── hash1k-mvrlu-ark.ops │ │ └── list10k-pmdk-ark.ops │ ├── run-vary-tvlog.sh │ ├── run-list.sh │ ├── run-hash.sh │ ├── LICENSE │ ├── hazard_ptrs.c │ ├── types.h │ ├── list_vlist.h │ └── hazard_ptrs.h ├── tools ├── ordo │ ├── config.h │ ├── gen_table_files.py │ ├── Makefile │ ├── cc.py │ ├── parse.py │ ├── cpuseq.h │ ├── gen_table.py │ ├── bench.c │ └── gen_cpuseq.py ├── mnt-host.sh ├── config.sh ├── utils.py ├── setup.sh └── colors.py ├── lib++ ├── timestone++.cpp └── Makefile ├── lib ├── port.h ├── recovery.h ├── recycle.h ├── qp.h ├── oplog.h ├── nvm.h ├── ckptlog.h ├── nvlog.h ├── nvm-nv-jemalloc.c ├── tvlog.h ├── Makefile └── config.h ├── LICENSE ├── Makefile.inc └── README.md /unittest/.gitignore: -------------------------------------------------------------------------------- 1 | ut-ts -------------------------------------------------------------------------------- /include/.gitignore: -------------------------------------------------------------------------------- 1 | numa-config.h -------------------------------------------------------------------------------- /lib-nv-jemalloc/config.stamp.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /benchmark/versioning/rlu.c: -------------------------------------------------------------------------------- 1 | ../rlu/rlu.c -------------------------------------------------------------------------------- /benchmark/versioning/rlu.h: -------------------------------------------------------------------------------- 1 | ../rlu/rlu.h -------------------------------------------------------------------------------- /benchmark/rlu/qsbr.c: -------------------------------------------------------------------------------- 1 | ../versioning/qsbr.c -------------------------------------------------------------------------------- /benchmark/rlu/qsbr.h: -------------------------------------------------------------------------------- 1 | ../versioning/qsbr.h -------------------------------------------------------------------------------- /benchmark/rlu/util.h: -------------------------------------------------------------------------------- 1 | ../versioning/util.h -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/math.c: -------------------------------------------------------------------------------- 1 | #define MATH_C_ 2 | #include "test/jemalloc_test.h" 3 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/btalloc_0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(0) 4 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/btalloc_1.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(1) 4 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/src/hash.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_HASH_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/src/mb.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MB_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/src/prng.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_PRNG_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/src/spin.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_SPIN_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/msvc/projects/vc2015/test_threads/test_threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int test_threads(); 4 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/src/atomic.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_ATOMIC_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/src/ticker.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TICKER_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /benchmark/versioning/README.md: -------------------------------------------------------------------------------- 1 | # versioning 2 | Framework for creating simple, efficient, and composable lock-free data structures 3 | -------------------------------------------------------------------------------- /benchmark/rlu/zipf/README: -------------------------------------------------------------------------------- 1 | * How to compile 2 | - gcc zipf.c rand.c test.c -lm 3 | 4 | * How to run 5 | - ./a.out zipf-theata-value 6 | 7 | -------------------------------------------------------------------------------- /benchmark/versioning/eval/ts-bst10k-u2-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # thread Mops 2 | 3 | 2 4.299 4 | 8 16.28 5 | 28 51.2 6 | 56 87.9 7 | 84 110.5 8 | 9 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/junk_alloc.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TEST_JUNK_OPT "junk:alloc" 2 | #include "junk.c" 3 | #undef JEMALLOC_TEST_JUNK_OPT 4 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/junk_free.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TEST_JUNK_OPT "junk:free" 2 | #include "junk.c" 3 | #undef JEMALLOC_TEST_JUNK_OPT 4 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/private_unnamespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for symbol in `cat $1` ; do 4 | echo "#undef ${symbol}" 5 | done 6 | -------------------------------------------------------------------------------- /benchmark/versioning/eval/ts-bst10k-u20-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # thread Mops 2 | 3 | 2 2.4 4 | 8 8.5 5 | 14 10.4 6 | 28 14.9 7 | 56 14.9 8 | 84 16.1 9 | 140 22.02 10 | 11 | -------------------------------------------------------------------------------- /benchmark/versioning/eval/ts-bst10k-u80-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # thread Mops 2 | 3 | 2 0.78 4 | 8 2.47 5 | 14 3.12 6 | 28 3.35 7 | 56 4.36 8 | 84 4.18 9 | 140 5.93 10 | 11 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/private_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for symbol in `cat $1` ; do 4 | echo "#define ${symbol} JEMALLOC_N(${symbol})" 5 | done 6 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/transaction.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | */ 4 | 5 | #include "transaction_mixinv.cc" 6 | 7 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/btalloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void * 4 | btalloc(size_t size, unsigned bits) 5 | { 6 | 7 | return (btalloc_0(size, bits)); 8 | } 9 | -------------------------------------------------------------------------------- /benchmark/versioning/zipf/README: -------------------------------------------------------------------------------- 1 | * How to compile 2 | - gcc zipf.c rand.c test.c -lm 3 | 4 | * How to run 5 | - ./a.out zipf-theata-value 6 | - e.g., ./a.out zipf-theata-value 7 | 8 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/public_unnamespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#undef je_${n}" 6 | done 7 | -------------------------------------------------------------------------------- /benchmark/rlu/zipf/types.h: -------------------------------------------------------------------------------- 1 | #ifndef FIO_TYPES_H 2 | #define FIO_TYPES_H 3 | 4 | #ifndef false 5 | #define false 0 6 | #endif 7 | #ifndef true 8 | #define true 1 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u0/tree_tot_ops_u0_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u0/tree_tot_ops_u0_i10000.png -------------------------------------------------------------------------------- /benchmark/rlu/.gitignore: -------------------------------------------------------------------------------- 1 | numa-config.h 2 | bench-harris 3 | bench-hp-harris 4 | bench-rcu 5 | bench-rlu 6 | bench-rlu-ordo 7 | bench-version 8 | bench-mvrlu-gclk 9 | bench-mvrlu 10 | bench-timestone -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u0/tree_tot_ops_u0_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u0/tree_tot_ops_u0_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u20/tree_tot_ops_u20_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u20/tree_tot_ops_u20_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u0/tree_abrt_ratio_u0_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u0/tree_abrt_ratio_u0_i10000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u20/tree_tot_ops_u20_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u20/tree_tot_ops_u20_i10000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u200/tree_tot_ops_u200_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u200/tree_tot_ops_u200_i10000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u500/tree_tot_ops_u500_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u500/tree_tot_ops_u500_i10000.png -------------------------------------------------------------------------------- /benchmark/versioning/eval/ts-bst10k-u50-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # thread ops 2 | 3 | 2 1182521 4 | 8 3996666 5 | 14 5347082 6 | 28 5250468 7 | 56 6373981 8 | 84 6420112 9 | 140 9538767 10 | 196 9955274 11 | 12 | -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u0/tree_abrt_ratio_u0_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u0/tree_abrt_ratio_u0_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u200/tree_tot_ops_u200_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u200/tree_tot_ops_u200_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u500/tree_tot_ops_u500_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u500/tree_tot_ops_u500_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u20/tree_abrt_ratio_u20_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u20/tree_abrt_ratio_u20_i10000.png -------------------------------------------------------------------------------- /benchmark/versioning/zipf/types.h: -------------------------------------------------------------------------------- 1 | #ifndef FIO_TYPES_H 2 | #define FIO_TYPES_H 3 | 4 | #ifndef false 5 | #define false 0 6 | #endif 7 | #ifndef true 8 | #define true 1 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/msvc_compat/windows_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef MSVC_COMPAT_WINDOWS_EXTRA_H 2 | #define MSVC_COMPAT_WINDOWS_EXTRA_H 3 | 4 | #include 5 | 6 | #endif /* MSVC_COMPAT_WINDOWS_EXTRA_H */ 7 | -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u20/tree_abrt_ratio_u20_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u20/tree_abrt_ratio_u20_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u200/tree_abrt_ratio_u200_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u200/tree_abrt_ratio_u200_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test100k/u500/tree_abrt_ratio_u500_i100000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test100k/u500/tree_abrt_ratio_u500_i100000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u200/tree_abrt_ratio_u200_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u200/tree_abrt_ratio_u200_i10000.png -------------------------------------------------------------------------------- /benchmark/versioning/results/temp/test10k/u500/tree_abrt_ratio_u500_i10000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmoss-jigu/timestone/HEAD/benchmark/versioning/results/temp/test10k/u500/tree_abrt_ratio_u500_i10000.png -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/public_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#define je_${n} JEMALLOC_N(${n})" 6 | done 7 | -------------------------------------------------------------------------------- /tools/ordo/config.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #define CACHE_BYTES 64 5 | #define MAX_CPU 256 6 | #define ENABLE_PMC 0 7 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/epochstm/configuration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * configuration.h 3 | * wlpdstm 4 | * 5 | * Created by Aleksandar Dragojevic on 10/23/09. 6 | * Copyright 2009 EPFL. All rights reserved. 7 | * 8 | */ 9 | 10 | -------------------------------------------------------------------------------- /tools/mnt-host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | mkdir -p $HOME/host 7 | sudo mount -t 9p -o trans=virtio,version=9p2000.L /dev/host $HOME/host 8 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /benchmark/versioning/NOTE.md: -------------------------------------------------------------------------------- 1 | # Note for versioning/ 2 | 3 | ## Stats 4 | ### Need to forcely call stat_thread_merge(self) in ts_thread_finish() 5 | - just tricks, add stat_thread_merge(self) at the end of function to call whenever 6 | - don't know why it isn't called with tree_bench 7 | 8 | 9 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.rw.in: -------------------------------------------------------------------------------- 1 | ######################################## 2 | # contention manager 3 | CM_CPPFLAGS_timid = -D CM_TIMID 4 | CM_CPPFLAGS_greedy = -D CM_GREEDY 5 | 6 | ifeq ($(CM), ) 7 | CM = greedy 8 | endif 9 | 10 | CPPFLAGS += $(CM_CPPFLAGS_${CM}) 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.p-tlrw.in: -------------------------------------------------------------------------------- 1 | ######################################## 2 | # contention manager 3 | CM_CPPFLAGS_timid = -D CM_TIMID 4 | CM_CPPFLAGS_greedy = -D CM_GREEDY 5 | 6 | ifeq ($(CM), ) 7 | CM = greedy 8 | endif 9 | 10 | CPPFLAGS += $(CM_CPPFLAGS_${CM}) 11 | 12 | 13 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.tlrw.in: -------------------------------------------------------------------------------- 1 | ######################################## 2 | # contention manager 3 | CM_CPPFLAGS_timid = -D CM_TIMID 4 | CM_CPPFLAGS_greedy = -D CM_GREEDY 5 | 6 | ifeq ($(CM), ) 7 | CM = greedy 8 | endif 9 | 10 | CPPFLAGS += $(CM_CPPFLAGS_${CM}) 11 | 12 | 13 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list1k-u20-pmdk-tmpfs-ark.ops: -------------------------------------------------------------------------------- 1 | # #thread throughput 2 | 3 | 4 | 1 68407.559244 5 | 8 473225.100000 6 | 14 828900.20000 7 | 28 1428640.40000 8 | 56 2646216.70000 9 | 84 3620482.10000 10 | 140 6173326.7000 11 | 196 7773941.00000 12 | 280 8262565.60000 13 | 448 9147669.40000 14 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/rw/memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_RW_MEMORY_H_ 7 | #define WLPDSTM_RW_MEMORY_H_ 8 | 9 | #include "memory/memory_txend.h" 10 | 11 | #endif /* WLPDSTM_RW_MEMORY_H_ */ 12 | 13 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_MEMORY_H_ 2 | #define WLPDSTM_MEMORY_H_ 3 | 4 | #ifdef MM_PRIVATIZATION 5 | #include "memory/memory_impl_priv.h" 6 | #elif defined MM_EPOCH 7 | #include "memory/memory_impl.h" 8 | #endif /* mm */ 9 | 10 | #endif /* WLPDSTM_MEMORY_H_ */ 11 | -------------------------------------------------------------------------------- /benchmark/versioning/util.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTIL_H 2 | #define __UTIL_H 3 | 4 | #define CAS(addr, oldv, newv) __sync_bool_compare_and_swap((addr), (oldv), (newv)) 5 | 6 | #define MEMBARSTLD() __sync_synchronize() 7 | 8 | #define FETCH_AND_ADD(addr, v) __sync_fetch_and_add((addr), (v)) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/include/test/thd.h: -------------------------------------------------------------------------------- 1 | /* Abstraction layer for threading in tests. */ 2 | #ifdef _WIN32 3 | typedef HANDLE thd_t; 4 | #else 5 | typedef pthread_t thd_t; 6 | #endif 7 | 8 | void thd_create(thd_t *thd, void *(*proc)(void *), void *arg); 9 | void thd_join(thd_t thd, void **ret); 10 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_MEMORY_H_ 2 | #define WLPDSTM_MEMORY_H_ 3 | 4 | #ifdef MM_PRIVATIZATION 5 | #include "memory/memory_impl_priv.h" 6 | #elif defined MM_EPOCH 7 | #include "memory/memory_impl.h" 8 | #endif /* mm */ 9 | 10 | #endif /* WLPDSTM_MEMORY_H_ */ 11 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/tlrw/memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_TLRW_MEMORY_H_ 7 | #define WLPDSTM_TLRW_MEMORY_H_ 8 | 9 | #include "memory/memory_txend.h" 10 | 11 | #endif /* WLPDSTM_TLRW_MEMORY_H_ */ 12 | 13 | -------------------------------------------------------------------------------- /lib++/timestone++.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | 6 | using namespace ts; 7 | 8 | thread_local ::ts_thread_struct_t *ts_thread::self; 9 | thread_local std::jmp_buf ts_thread::bots; 10 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list1k-pmdk-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 1k nodes on Ark 2 | 3 | 1 110854.8000 4 | 8 625372.9000 5 | 14 979950.700 6 | 28 1454453.900 7 | 56 1834614.000 8 | 84 1659968.900 9 | 140 1281937.100 10 | 196 1072247.000 11 | 280 814422.600 12 | 392 581802.400 13 | 448 419703.200 14 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/p-tlrw/memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_TLRW_MEMORY_H_ 7 | #define WLPDSTM_TLRW_MEMORY_H_ 8 | 9 | #include "memory/memory_txend.h" 10 | 11 | #endif /* WLPDSTM_TLRW_MEMORY_H_ */ 12 | 13 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list1k-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 1k nodes on Ark 2 | 3 | 1 128093.000 4 | 8 504843.9000 5 | 14 871143.500 6 | 28 1580718.2000 7 | 56 2666363.5000 8 | 84 3730423.9000 9 | 140 5473808.900 10 | 196 7470703.200 11 | 280 9983250.500 12 | 392 12439728.000 13 | 448 14014490.400 14 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list10k-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 4 | 1 8114.20000 5 | 8 36124.48755 6 | 14 51107.7000 7 | 28 86058.0000 8 | 56 142458.8000 9 | 84 195916.7000 10 | 140 268410.600 11 | 196 396937.5000 12 | 280 599143.8000 13 | 392 864408.4000 14 | 448 1022943.7000 15 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list10k-mvrlu-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 1 22688.50000 4 | 8 92139.50000 5 | 14 142475.9000 6 | 28 212304.700 7 | 56 353397.2000 8 | 84 357788.9000 9 | 140 595367.6000 10 | 196 781805.6000 11 | 280 1006108.3000 12 | 392 1274022.8000 13 | 448 1248943.60000 14 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list1k-u20-pmdk-emul-ark.ops: -------------------------------------------------------------------------------- 1 | # #thread throughput 2 | 3 | 1 113010.80000 4 | 8 657946.10000 5 | 14 1029395.9000 6 | 28 1605728.0000 7 | 56 1511226.30000 8 | 84 1367709.90000 9 | 140 1215665.6000 10 | 196 1090385.9000 11 | 280 1170751.9000 12 | 392 1174054.1000 13 | 448 930373.20000 14 | 15 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/msvc/projects/vc2015/test_threads/test_threads_main.cpp: -------------------------------------------------------------------------------- 1 | #include "test_threads.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std::chrono_literals; 7 | 8 | int main(int argc, char** argv) 9 | { 10 | int rc = test_threads(); 11 | return rc; 12 | } 13 | -------------------------------------------------------------------------------- /tools/config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | CUR_DIR=$(realpath $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/) 7 | export PROJ_DIR=$(realpath $CUR_DIR/..) 8 | export BIN_DIR=$PROJ_DIR/bin 9 | export KNL_DIR=$PROJ_DIR/linux 10 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/hash10k-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 1 1944430.80000 4 | 8 12987716.9000 5 | 14 16920395.700 6 | 28 24477077.9000 7 | 56 72682521.8000 8 | 84 93790098.10000 9 | 140 191607343.400 10 | 196 221059854.0000 11 | 280 329967479.2000 12 | 392 458647334.5000 13 | 448 519916056.7000 14 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list1k-mvrlu-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 1 168856.8000 4 | 8 943394.4000 5 | 14 1485527.600 6 | 28 3151416.9000 7 | 56 6627508.5000 8 | 84 10717915.200 9 | 140 16271055.9000 10 | 196 21824967.2000 11 | 280 29865061.5000 12 | 392 34134109.4000 13 | 448 41854777.0000 14 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/a0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_a0) 4 | { 5 | void *p; 6 | 7 | p = a0malloc(1); 8 | assert_ptr_not_null(p, "Unexpected a0malloc() error"); 9 | a0dalloc(p); 10 | } 11 | TEST_END 12 | 13 | int 14 | main(void) 15 | { 16 | 17 | return (test_no_malloc_init( 18 | test_a0)); 19 | } 20 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/hash10k-mvrlu-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 1 5584045.500000 4 | 8 41546532.1000 5 | 14 56651749.5000 6 | 28 136955969.10000 7 | 56 204989251.70000 8 | 84 282414272.60000 9 | 140 471761152.4000 10 | 196 628484077.1000 11 | 280 683808781.7000 12 | 392 1370515247.400 13 | 448 1316890641.2000 14 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/hash1k-dram-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 1 977299.00000 4 | 8 72402059.20000 5 | 14 122589650.000 6 | 28 192354408.10000 7 | 56 362526325.60000 8 | 84 784784387.60000 9 | 140 1339916449.900 10 | 196 1603590469.300 11 | 280 2218495074.400 12 | 392 2749167766.200 13 | 448 3009142914.500 14 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/hash1k-mvrlu-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 4 | 1 15367339.9000 5 | 8 93817483.00000 6 | 14 164111514.700 7 | 28 299991231.3000 8 | 56 564839808.4000 9 | 84 866439015.0000 10 | 140 1426512610.700 11 | 196 1916179890.100 12 | 280 2407552163.600 13 | 392 3200537198.700 14 | 448 3321551811.100 15 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/transaction.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | */ 4 | 5 | #ifndef WLPDSTM_TRANSACTION_H_ 6 | #define WLPDSTM_TRANSACTION_H_ 7 | 8 | #include "transaction_mixinv.h" 9 | 10 | namespace wlpdstm { 11 | 12 | typedef TxMixinv TransactionImpl; 13 | } 14 | 15 | #endif // WLPDSTM_TRANSACTION_H_ 16 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/include/test/jemalloc_test_defs.h.in: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_internal_defs.h" 2 | #include "jemalloc/internal/jemalloc_internal_decls.h" 3 | 4 | /* 5 | * For use by SFMT. configure.ac doesn't actually define HAVE_SSE2 because its 6 | * dependencies are notoriously unportable in practice. 7 | */ 8 | #undef HAVE_SSE2 9 | #undef HAVE_ALTIVEC 10 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/perfcnt/perf_cnt_impl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifdef WLPDSTM_SOLARIS 7 | 8 | #include "perf_cnt_solaris.h" 9 | 10 | #elif defined WLPDSTM_LINUXOS 11 | 12 | // this assumes papi is installed and working 13 | #include "perf_cnt_papi.h" 14 | 15 | #endif /* WLPDSTM_SOLARIS */ 16 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/include/test/timer.h: -------------------------------------------------------------------------------- 1 | /* Simple timer, for use in benchmark reporting. */ 2 | 3 | typedef struct { 4 | nstime_t t0; 5 | nstime_t t1; 6 | } timedelta_t; 7 | 8 | void timer_start(timedelta_t *timer); 9 | void timer_stop(timedelta_t *timer); 10 | uint64_t timer_usec(const timedelta_t *timer); 11 | void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen); 12 | -------------------------------------------------------------------------------- /benchmark/rlu/eval/ops/list10k-pmdk-ark.ops: -------------------------------------------------------------------------------- 1 | # throughput(ops) ./bench-mvrlu 10k nodes on Ark 2 | 3 | 1 5817.5000 4 | 4 17946.9000 5 | 8 32428.300 6 | 14 52634.600 7 | 28 92458.500 8 | 56 171036.69 9 | 84 237780.100 10 | 112 296367.700 11 | 140 347130.100 12 | 168 417418.700 13 | 196 468694.800 14 | 224 547357.100 15 | 280 640678.132 16 | 336 633760.300 17 | 392 772872.200 18 | 448 786050.900 19 | # 20 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | objdir=$1 6 | suffix=$2 7 | shift 2 8 | objs=$@ 9 | 10 | gcov -b -p -f -o "${objdir}" ${objs} 11 | 12 | # Move gcov outputs so that subsequent gcov invocations won't clobber results 13 | # for the same sources with different compilation flags. 14 | for f in `find . -maxdepth 1 -type f -name '*.gcov'` ; do 15 | mv "${f}" "${f}.${suffix}" 16 | done 17 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/word.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_WORD_H_ 7 | #define WLPDSTM_WORD_H_ 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | typedef uintptr_t Word; 15 | #ifdef __cplusplus 16 | } 17 | #endif /* __cplusplus */ 18 | 19 | #endif /* WLPDSTM_WORD_H_ */ 20 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/api_linkage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_DYNAMIC_API_LINKAGE_H_ 7 | #define WLPDSTM_DYNAMIC_API_LINKAGE_H_ 8 | 9 | #ifdef DYNAMIC_INLINE 10 | #define API_LINKAGE inline 11 | #elif defined DYNAMIC_STATIC 12 | #define API_LINKAGE 13 | #endif /* DYNAMIC_INLINE */ 14 | 15 | #endif /* WLPDSTM_DYNAMIC_API_LINKAGE_H_ */ 16 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/tm_impl_const.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Constants used to refer to various tm implementations. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_TM_IMPL_CONST_H_ 9 | #define WLPDSTM_TM_IMPL_CONST_H_ 10 | 11 | enum TmImplementation { 12 | TM_MIXED = 0, 13 | TM_LAZY, 14 | TM_EAGER, 15 | TM_IMPLEMENTATION_COUNT 16 | }; 17 | 18 | #endif /* WLPDSTM_TM_IMPL_CONST_H_ */ 19 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/jemalloc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | install_suffix=@install_suffix@ 6 | 7 | Name: jemalloc 8 | Description: A general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. 9 | URL: http://jemalloc.net/ 10 | Version: @jemalloc_version@ 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -ljemalloc${install_suffix} 13 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | 6 | 7 | 8 | "" 9 | 10 | 11 | -------------------------------------------------------------------------------- /lib/port.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _PORT_H 5 | #define _PORT_H 6 | 7 | #include "arch.h" 8 | #include "port-user.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | static inline void *port_alloc(size_t size) 15 | { 16 | return port_alloc_x(size, PORT_DEFAULT_ALLOC_FLAG); 17 | } 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* _PORT_H */ 23 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/epochstm/memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_EPOCHSTM_MEMORY_H_ 7 | #define WLPDSTM_EPOCHSTM_MEMORY_H_ 8 | 9 | #ifdef MM_LEAK 10 | #include "memory/memory_leak.h" 11 | #elif defined MM_TXEND 12 | #include "memory/memory_txend.h" 13 | #elif defined MM_EPOCH 14 | #include "memory/memory_epoch.h" 15 | #endif 16 | 17 | #endif /* WLPDSTM_EPOCHSTM_MEMORY_H_ */ 18 | 19 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/random.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | */ 4 | 5 | #ifndef WLPDSTM_RANDOM_H_ 6 | #define WLPDSTM_RANDOM_H_ 7 | 8 | #include 9 | 10 | namespace wlpdstm { 11 | 12 | class Random { 13 | public: 14 | int Get() { 15 | unsigned ret = rand_r(&seed); 16 | return ret; 17 | } 18 | 19 | private: 20 | unsigned seed; 21 | }; 22 | } 23 | 24 | #endif /* WLPDSTM_RANDOM_H_ */ 25 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/rw/transaction.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include "transaction.h" 7 | 8 | CACHE_LINE_ALIGNED wlpdstm::TransactionRw::OwnershipRecord wlpdstm::TransactionRw::orec_table[OWNERSHIP_TABLE_SIZE]; 9 | 10 | CACHE_LINE_ALIGNED wlpdstm::TransactionRw *wlpdstm::TransactionRw::transactions[MAX_THREADS]; 11 | 12 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionRw::thread_count; 13 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/p-tlrw/transaction.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include "transaction.h" 7 | 8 | CACHE_LINE_ALIGNED wlpdstm::TransactionTlrw::OwnershipRecord wlpdstm::TransactionTlrw::orec_table[OWNERSHIP_TABLE_SIZE]; 9 | 10 | CACHE_LINE_ALIGNED wlpdstm::TransactionTlrw *wlpdstm::TransactionTlrw::transactions[MAX_THREADS]; 11 | 12 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionTlrw::thread_count; 13 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/tlrw/transaction.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include "transaction.h" 7 | 8 | CACHE_LINE_ALIGNED wlpdstm::TransactionTlrw::OwnershipRecord wlpdstm::TransactionTlrw::orec_table[OWNERSHIP_TABLE_SIZE]; 9 | 10 | CACHE_LINE_ALIGNED wlpdstm::TransactionTlrw *wlpdstm::TransactionTlrw::transactions[MAX_THREADS]; 11 | 12 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionTlrw::thread_count; 13 | -------------------------------------------------------------------------------- /lib/recovery.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _RECOVERY_H 5 | #define _RECOVERY_H 6 | 7 | #include "timestone_i.h" 8 | #include "nvlog.h" 9 | #include "util.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | int ckptlog_recovery(ts_recovery_t *); 16 | int oplog_recovery(ts_recovery_t *); 17 | int perform_recovery(ts_recovery_t *); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /tools/utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import os 7 | import subprocess 8 | 9 | def port_number(): 10 | out = subprocess.check_output(["id -u %s" % os.environ['USER'], "-a"], 11 | stderr=subprocess.STDOUT, 12 | bufsize=1, 13 | universal_newlines=True, 14 | shell=True) 15 | return out.strip() 16 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/intel/icc_memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_ICC_MEMORY_H_ 7 | #define WLPDSTM_ICC_MEMORY_H_ 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | __attribute__((tm_wrapping(malloc))) void *wlpdstm_icc_malloc(size_t size); 17 | __attribute__((tm_wrapping(free))) void wlpdstm_icc_free(void *ptr); 18 | 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif /* WLPDSTM_ICC_MEMORY_H_ */ 25 | -------------------------------------------------------------------------------- /include/timestone2.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _TIMESTONE2_H 5 | #define _TIMESTONE2_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define TS_AHS_SIZE (40) 12 | 13 | int _ts_try_lock(ts_thread_struct_t *self, void **p_p_obj, size_t size); 14 | int _ts_try_lock_const(ts_thread_struct_t *self, void *obj, size_t size); 15 | void _ts_assign_pointer(void **p_ptr, void *p_obj); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | #endif /* _TIMESTONE2_H */ 21 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/msvc_compat/C99/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef stdbool_h 2 | #define stdbool_h 3 | 4 | #include 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | /* Clang-cl uses MSVC headers, so needs msvc_compat, but has _Bool as 9 | * a built-in type. */ 10 | #ifndef __clang__ 11 | typedef BOOL _Bool; 12 | #endif 13 | 14 | #define bool _Bool 15 | #define true 1 16 | #define false 0 17 | 18 | #define __bool_true_false_are_defined 1 19 | 20 | #endif /* stdbool_h */ 21 | -------------------------------------------------------------------------------- /lib/recycle.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _RECYCLE_H 5 | #define _RECYCLE_H 6 | 7 | #include "timestone_i.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | int nvm_recycle_init(ts_nvm_recycle_t *recycle); 14 | void nvm_recycle_deinit(ts_nvm_recycle_t *recycle); 15 | void *nvm_recycle_alloc(ts_nvm_recycle_t *recycle, size_t size); 16 | void nvm_recycle_free(ts_nvm_recycle_t *recycle, void *ptr, size_t size); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /benchmark/rlu/zipf/minmax.h: -------------------------------------------------------------------------------- 1 | #ifndef FIO_MIN_MAX_H 2 | #define FIO_MIN_MAX_H 3 | 4 | #ifndef min 5 | #define min(x,y) ({ \ 6 | typeof(x) _x = (x); \ 7 | typeof(y) _y = (y); \ 8 | (void) (&_x == &_y); \ 9 | _x < _y ? _x : _y; }) 10 | #endif 11 | 12 | #ifndef max 13 | #define max(x,y) ({ \ 14 | typeof(x) _x = (x); \ 15 | typeof(y) _y = (y); \ 16 | (void) (&_x == &_y); \ 17 | _x > _y ? _x : _y; }) 18 | #endif 19 | 20 | #define min_not_zero(x, y) ({ \ 21 | typeof(x) __x = (x); \ 22 | typeof(y) __y = (y); \ 23 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/jemalloc_rename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | public_symbols_txt=$1 4 | 5 | cat < _y ? _x : _y; }) 18 | #endif 19 | 20 | #define min_not_zero(x, y) ({ \ 21 | typeof(x) __x = (x); \ 22 | typeof(y) __y = (y); \ 23 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019-2021 Virginia Tech 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /benchmark/rlu/run-vary-tvlog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | benchs="x1 div2 div4 div8 div16" 4 | threads="1 8 16 24 32 40 48 60 78 96" 5 | thread="96" 6 | size="10000" 7 | buckets="10000" 8 | range=`echo "2*${size}" | bc` 9 | duration="70000" 10 | seed="100" 11 | 12 | echo "####################################" 13 | echo "####################################" 14 | echo "Evaluation Vary TVLog Hash10K " 15 | for bench in ${benchs} 16 | do 17 | echo "Run bench-timestone-${bench} thread ${thread}" 18 | ./bench-timestone-tvlog${bench} -b${buckets} -i${size} -r${range} -d${duration} -n${thread} -s${seed} 19 | done 20 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.intel.in: -------------------------------------------------------------------------------- 1 | ifeq ($(STACK_PROTECT), ) 2 | STACK_PROTECT = on_read_write 3 | endif 4 | 5 | ifeq ($(STACK_PROTECT_BOUND), ) 6 | STACK_PROTECT_BOUND = icc 7 | endif 8 | 9 | COMPILER = intel 10 | # for some reason -DNDEBUG causes problems 11 | PROFILE = normal 12 | 13 | include Makefile.in 14 | 15 | AS = as 16 | 17 | INTEL_OBJ_DIR = $(TARGET_DIR)/intel_obj 18 | INTEL_LIB_DIR = /home/dragojev/work/wlpdstm/lib 19 | INTEL_LIB = $(INTEL_LIB_DIR)/libitm 20 | 21 | ICC_INCLUDE_DIR = /localhome/dragojev/install/icc-stm/include 22 | 23 | CPPFLAGS += -DWLPDSTM_ICC -I$(ICC_INCLUDE_DIR) 24 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/padded.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_PADDED_H_ 7 | #define WLPDSTM_PADDED_H_ 8 | 9 | namespace wlpdstm { 10 | 11 | union PaddedUnsigned { 12 | volatile unsigned val; 13 | char padding[CACHE_LINE_SIZE_BYTES]; 14 | }; 15 | 16 | union PaddedWord { 17 | volatile Word val; 18 | char padding[CACHE_LINE_SIZE_BYTES]; 19 | }; 20 | 21 | union PaddedBool { 22 | volatile Word val; 23 | char padding[CACHE_LINE_SIZE_BYTES]; 24 | }; 25 | } 26 | 27 | #endif /* WLPDSTM_PADDED_H_ */ 28 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/mq.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | /* 4 | * Sleep for approximately ns nanoseconds. No lower *nor* upper bound on sleep 5 | * time is guaranteed. 6 | */ 7 | void 8 | mq_nanosleep(unsigned ns) 9 | { 10 | 11 | assert(ns <= 1000*1000*1000); 12 | 13 | #ifdef _WIN32 14 | Sleep(ns / 1000); 15 | #else 16 | { 17 | struct timespec timeout; 18 | 19 | if (ns < 1000*1000*1000) { 20 | timeout.tv_sec = 0; 21 | timeout.tv_nsec = ns; 22 | } else { 23 | timeout.tv_sec = 1; 24 | timeout.tv_nsec = 0; 25 | } 26 | nanosleep(&timeout, NULL); 27 | } 28 | #endif 29 | } 30 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/rw/constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_RW_CONSTANTS_H_ 7 | #define WLPDSTM_RW_CONSTANTS_H_ 8 | 9 | #include "../common/constants.h" 10 | 11 | namespace wlpdstm { 12 | 13 | // this depends on the number of available hw threads 14 | // it can safely be a lower number than the number of 15 | // hw threads, as some background threads need to execute too 16 | // (e.g. 60 or maybe even 56 is enough on Niagara) 17 | const unsigned MAX_THREADS = 64; 18 | } 19 | 20 | #endif /* WLPDSTM_RW_CONSTANTS_H_ */ 21 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/public_unnamespace.h: -------------------------------------------------------------------------------- 1 | #undef je_malloc_conf 2 | #undef je_malloc_message 3 | #undef je_malloc 4 | #undef je_calloc 5 | #undef je_posix_memalign 6 | #undef je_aligned_alloc 7 | #undef je_realloc 8 | #undef je_free 9 | #undef je_mallocx 10 | #undef je_nextx 11 | #undef je_rallocx 12 | #undef je_xallocx 13 | #undef je_sallocx 14 | #undef je_dallocx 15 | #undef je_sdallocx 16 | #undef je_nallocx 17 | #undef je_mallctl 18 | #undef je_mallctlnametomib 19 | #undef je_mallctlbymib 20 | #undef je_malloc_stats_print 21 | #undef je_malloc_usable_size 22 | #undef je_memalign 23 | #undef je_valloc 24 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/p-tlrw/constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_TLRW_CONSTANTS_H_ 7 | #define WLPDSTM_TLRW_CONSTANTS_H_ 8 | 9 | #include "../common/constants.h" 10 | 11 | namespace wlpdstm { 12 | 13 | // this depends on the number of available hw threads 14 | // it can safely be a lower number than the number of 15 | // hw threads, as some background threads need to execute too 16 | // (e.g. 60 or maybe even 56 is enough on Niagara) 17 | const unsigned MAX_THREADS = 64; 18 | } 19 | 20 | #endif /* WLPDSTM_TLRW_CONSTANTS_H_ */ 21 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/tlrw/constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_TLRW_CONSTANTS_H_ 7 | #define WLPDSTM_TLRW_CONSTANTS_H_ 8 | 9 | #include "../common/constants.h" 10 | 11 | namespace wlpdstm { 12 | 13 | // this depends on the number of available hw threads 14 | // it can safely be a lower number than the number of 15 | // hw threads, as some background threads need to execute too 16 | // (e.g. 60 or maybe even 56 is enough on Niagara) 17 | const unsigned MAX_THREADS = 64; 18 | } 19 | 20 | #endif /* WLPDSTM_TLRW_CONSTANTS_H_ */ 21 | -------------------------------------------------------------------------------- /lib/qp.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _QP_H 5 | #define _QP_H 6 | 7 | #include "timestone_i.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | int init_qp(void); 14 | void deinit_qp(void); 15 | void register_thread(ts_thread_struct_t *); 16 | void deregister_thread(ts_thread_struct_t *); 17 | void zombinize_thread(ts_thread_struct_t *); 18 | int request_tvlog_reclaim(unsigned char); 19 | int request_ckptlog_reclaim(unsigned char); 20 | void reset_all_stats(void); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/include/test/mtx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mtx is a slightly simplified version of malloc_mutex. This code duplication 3 | * is unfortunate, but there are allocator bootstrapping considerations that 4 | * would leak into the test infrastructure if malloc_mutex were used directly 5 | * in tests. 6 | */ 7 | 8 | typedef struct { 9 | #ifdef _WIN32 10 | CRITICAL_SECTION lock; 11 | #elif (defined(JEMALLOC_OSSPIN)) 12 | OSSpinLock lock; 13 | #else 14 | pthread_mutex_t lock; 15 | #endif 16 | } mtx_t; 17 | 18 | bool mtx_init(mtx_t *mtx); 19 | void mtx_fini(mtx_t *mtx); 20 | void mtx_lock(mtx_t *mtx); 21 | void mtx_unlock(mtx_t *mtx); 22 | -------------------------------------------------------------------------------- /tools/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | CUR_DIR=$(realpath $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/) 7 | source $CUR_DIR/config.sh 8 | 9 | [[ ":$PATH:" != *":${BIN_DIR}/bin:"* ]] && export PATH=$BIN_DIR/bin:$PATH 10 | alias vm-boot='make -C $PROJ_DIR vm-boot' 11 | alias vm-fboot='make -C $PROJ_DIR vm-fboot' 12 | alias vm-oboot='make -C $PROJ_DIR vm-oboot' 13 | alias vm-ssh='make -C $PROJ_DIR vm-ssh' 14 | alias vm-off='make -C $PROJ_DIR vm-off' 15 | alias vm-gdb='make -C $PROJ_DIR vm-gdb' 16 | alias vm-dmesg='make -C $PROJ_DIR vm-dmesg' 17 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/msvc/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | How to build jemalloc for Windows 3 | ================================= 4 | 5 | 1. Install Cygwin with at least the following packages: 6 | * autoconf 7 | * autogen 8 | * gawk 9 | * grep 10 | * sed 11 | 12 | 2. Install Visual Studio 2015 with Visual C++ 13 | 14 | 3. Add Cygwin\bin to the PATH environment variable 15 | 16 | 4. Open "VS2015 x86 Native Tools Command Prompt" 17 | (note: x86/x64 doesn't matter at this point) 18 | 19 | 5. Generate header files: 20 | sh -c "CC=cl ./autogen.sh" 21 | 22 | 6. Now the project can be opened and built in Visual Studio: 23 | msvc\jemalloc_vc2015.sln 24 | 25 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm_api/wlpdstm_malloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Definitions for various memory management functions are here. They can be simply 3 | * used by different compiler wrappers. 4 | * 5 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 6 | * 7 | */ 8 | 9 | #ifndef WLPDSTM_MALLOC_H_ 10 | #define WLPDSTM_MALLOC_H_ 11 | 12 | #include "transaction.h" 13 | 14 | void *wlpdstm_malloc_tx_malloc(size_t size) { 15 | return wlpdstm::CurrentTransaction::TxMalloc(size); 16 | } 17 | 18 | void wlpdstm_malloc_tx_free(void *ptr, size_t size) { 19 | wlpdstm::CurrentTransaction::TxFree(ptr, size); 20 | } 21 | 22 | #endif /* WLPDSTM_MALLOC_H_ */ 23 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | objroot=$1 4 | 5 | cat < 4 | 5 | #define QSBR_N_EPOCHS 3 6 | 7 | #define QSBR_PADDING 16 8 | 9 | #define QSBR_FREELIST_SIZE 32768 10 | 11 | typedef struct qsbr_pthread_data { 12 | int epoch; 13 | int in_critical; 14 | long qsbr_padding[QSBR_PADDING]; 15 | size_t freelist_count[QSBR_N_EPOCHS]; 16 | void *freelist[QSBR_N_EPOCHS][QSBR_FREELIST_SIZE]; 17 | } qsbr_pthread_data_t; 18 | 19 | void qsbr_init(void); 20 | 21 | void qsbr_pthread_init(qsbr_pthread_data_t *qsbr_data); 22 | 23 | void qsbr_quiescent_state(qsbr_pthread_data_t *qsbr_data); 24 | 25 | void qsbr_free_ptr(void *ptr, qsbr_pthread_data_t *qsbr_data); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/tanger/tanger_stdlib.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include 7 | 8 | #include "tanger-stm-std-stdlib.h" 9 | 10 | #include "../stm/read_write.h" 11 | #include "../stm/transaction.h" 12 | 13 | extern "C" { 14 | extern void tanger_stm_std_qsort(void *base, size_t nel, size_t width, 15 | int (*compar)(const void *, const void *)) __attribute__((weak)); 16 | extern void tanger_stm_std_qsort(void *base, size_t nel, size_t width, 17 | int (*compar)(const void *, const void *)) { 18 | wlpdstm::qsort_tx(wlpdstm::CurrentTransaction::Get(), base, nel, width, compar); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /benchmark/versioning/.gitignore: -------------------------------------------------------------------------------- 1 | benchmark_list_harris 2 | benchmark_list_move_rlu 3 | benchmark_list_move_spinlock 4 | benchmark_list_move_swisstm 5 | benchmark_list_move_vlist 6 | benchmark_list_rcu 7 | benchmark_list_rlu 8 | benchmark_list_spinlock 9 | benchmark_list_swisstm 10 | benchmark_list_vlist 11 | benchmark_tree_bonsai 12 | benchmark_tree_prcu_d 13 | benchmark_tree_prcu_deer 14 | benchmark_tree_prcu_eer 15 | benchmark_tree_rcu 16 | benchmark_tree_rlu 17 | benchmark_tree_swisstm 18 | benchmark_tree_vrbtree 19 | benchmark_tree_vtree 20 | benchmark_tree_mvrlu 21 | benchmark_tree_citrus_mvrlu 22 | benchmark_tree_citrus_rlu 23 | benchmark_tree_mvrlu 24 | swisstm/include/ 25 | swisstm/lib/ 26 | swisstm/target/ -------------------------------------------------------------------------------- /benchmark/versioning/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "tree10k-aug10": [ 3 | { 4 | "data_structure": "tree", 5 | "runs_per_test": 1, 6 | "rlu_max_ws" : 1, 7 | "buckets" : 1, 8 | "duration" : 20000, 9 | "alg_type" : ["mvrlu"], 10 | "update_rate" : [20, 200, 800], 11 | "initial_size" : 10000, 12 | "range_size" : 20000, 13 | "zipf_dist_val" : 0, 14 | "threads" : [1, 4, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/energy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Energy related stuff. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_ENERGY_H_ 9 | #define WLPDSTM_ENERGY_H_ 10 | 11 | #include 12 | 13 | #include "random.h" 14 | 15 | namespace wlpdstm { 16 | 17 | class Energy { 18 | public: 19 | void start_measurement(); 20 | uint64_t get_consumed_energy(); 21 | 22 | protected: 23 | Random random; 24 | }; 25 | } 26 | 27 | inline void wlpdstm::Energy::start_measurement() { 28 | // TODO 29 | } 30 | 31 | inline uint64_t wlpdstm::Energy::get_consumed_energy() { 32 | return random.Get(); 33 | } 34 | 35 | #endif /* WLPDSTM_ENERGY_H_ */ 36 | -------------------------------------------------------------------------------- /benchmark/rlu/zipf/zipf.h: -------------------------------------------------------------------------------- 1 | #ifndef FIO_ZIPF_H 2 | #define FIO_ZIPF_H 3 | 4 | #include 5 | #include "rand.h" 6 | #include "types.h" 7 | 8 | struct zipf_state { 9 | uint64_t nranges; 10 | double theta; 11 | double zeta2; 12 | double zetan; 13 | double pareto_pow; 14 | struct frand_state rand; 15 | uint64_t rand_off; 16 | int disable_hash; 17 | }; 18 | 19 | void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, unsigned int seed); 20 | unsigned long long zipf_next(struct zipf_state *zs); 21 | 22 | void pareto_init(struct zipf_state *zs, unsigned long nranges, double h, unsigned int seed); 23 | unsigned long long pareto_next(struct zipf_state *zs); 24 | void zipf_disable_hash(struct zipf_state *zs); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/profiling.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Choose profiling implementation. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_PROFILING_H_ 9 | #define WLPDSTM_PROFILING_H_ 10 | 11 | #include "stats.h" 12 | 13 | #ifdef WLPDSTM_TX_PROFILING_NO 14 | 15 | #include "../common/profiling/base.h" 16 | 17 | namespace wlpdstm { 18 | typedef BaseProfiling Profiling; 19 | } 20 | 21 | #elif defined WLPDSTM_TX_PROFILING_SIMPLE 22 | 23 | #include "../common/profiling/simple.h" 24 | 25 | namespace wlpdstm { 26 | typedef SimpleProfiling Profiling; 27 | } 28 | 29 | #endif /* profiling class */ 30 | 31 | #endif /* WLPDSTM_PROFILING_H_ */ 32 | -------------------------------------------------------------------------------- /benchmark/versioning/zipf/zipf.h: -------------------------------------------------------------------------------- 1 | #ifndef FIO_ZIPF_H 2 | #define FIO_ZIPF_H 3 | 4 | #include 5 | #include "rand.h" 6 | #include "types.h" 7 | 8 | struct zipf_state { 9 | uint64_t nranges; 10 | double theta; 11 | double zeta2; 12 | double zetan; 13 | double pareto_pow; 14 | struct frand_state rand; 15 | uint64_t rand_off; 16 | int disable_hash; 17 | }; 18 | 19 | void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, unsigned int seed); 20 | unsigned long long zipf_next(struct zipf_state *zs); 21 | 22 | void pareto_init(struct zipf_state *zs, unsigned long nranges, double h, unsigned int seed); 23 | unsigned long long pareto_next(struct zipf_state *zs); 24 | void zipf_disable_hash(struct zipf_state *zs); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/print_utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_PRINT_UTILS_H_ 7 | #define WLPDSTM_PRINT_UTILS_H_ 8 | 9 | #include 10 | #include 11 | 12 | #ifndef PRIu64 13 | 14 | #ifdef WLPDSTM_32 15 | #define PRIu64 "llu" 16 | #elif defined WLPDSTM_64 17 | #define PRIu64 "lu" 18 | #endif /* ARCH */ 19 | 20 | #endif /* PRIu64 */ 21 | 22 | namespace wlpdstm { 23 | 24 | void print_indent(FILE *out_file, unsigned indent); 25 | } 26 | 27 | inline void wlpdstm::print_indent(FILE *out_file, unsigned indent) { 28 | for(unsigned u = 0;u < indent;u++) { 29 | fprintf(out_file, "\t"); 30 | } 31 | } 32 | 33 | #endif /* WLPDSTM_PRINT_UTILS_H_ */ 34 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/README: -------------------------------------------------------------------------------- 1 | Directory structure is organized as follows: 2 | api - Definition of API used for manual instrumentation. 3 | common - Files common to different STM implementations. This includes handling tls, various 4 | constants etc. 5 | epochstm - Implementation of EpochSTM algorithm. 6 | include - Base include file used for manual instrumentation. 7 | intel - Files for libitm.a used by transactional icc. 8 | mubench - Red-black tree microbenchmark. 9 | stm - Implementation of SwissTM algorithm. 10 | stm_api - Boilerplate code for reading data of different sizes. Used by api, intel and tanger. 11 | tanger - Tanger support. 12 | 13 | 14 | Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 15 | 16 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/jmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Mask differences related to long_jmp functions on different platforms. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_JMP_H_ 9 | #define WLPDSTM_JMP_H_ 10 | 11 | #ifdef WLPDSTM_ICC 12 | 13 | #include "../../intel/jmp.h" 14 | #define LONG_JMP_BUF begin_transaction_jmpbuf 15 | 16 | #else 17 | 18 | #include 19 | 20 | #ifdef WLPDSTM_MACOS 21 | #define LONG_JMP_BUF sigjmp_buf 22 | #elif defined WLPDSTM_LINUXOS || defined WLPDSTM_SOLARIS 23 | #define LONG_JMP_BUF jmp_buf 24 | #endif /* MACOS */ 25 | 26 | #endif /* WLPDSTM_ICC */ 27 | 28 | #define LONG_JMP_FIRST_FLAG 0 29 | #define LONG_JMP_RESTART_FLAG 1 30 | #define LONG_JMP_ABORT_FLAG 2 31 | 32 | #endif /* WLPDSTM_JMP_H_ */ 33 | 34 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/tid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tid.h 3 | * 4 | * Declaration of elements required for thread identifier management 5 | * are in this file. 6 | * 7 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 8 | */ 9 | 10 | #ifndef WLPDSTM_TID_H_ 11 | #define WLPDSTM_TID_H_ 12 | 13 | #include "atomic.h" 14 | 15 | namespace wlpdstm { 16 | 17 | class Tid { 18 | public: 19 | Tid() : tid(GetCounter().getNext()) { 20 | // do nothing 21 | } 22 | 23 | unsigned Get() { 24 | return tid; 25 | } 26 | 27 | private: 28 | const unsigned tid; 29 | 30 | // avoid uninitialized data use 31 | static CounterOF &GetCounter() { 32 | // global tid counter 33 | static CounterOF counter; 34 | return counter; 35 | } 36 | }; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/preemptive_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef PREEMPTIVE_UTILS_H_ 2 | #define PREEMPTIVE_UTILS_H_ 3 | 4 | #ifdef WLPDSTM_LINUXOS 5 | #define WLPDSTM_PTHREAD_YIELD 6 | #elif defined WLPDSTM_MACOS 7 | #define WLPDSTM_SCHED_YIELD 8 | #elif defined WLPDSTM_SOLARIS 9 | #define WLPDSTM_SCHED_YIELD 10 | #endif 11 | 12 | #ifdef WLPDSTM_PTHREAD_YIELD 13 | #include 14 | 15 | namespace wlpdstm { 16 | 17 | // give up on this processor slice 18 | inline void pre_yield() { 19 | ::pthread_yield(); 20 | } 21 | } 22 | 23 | #elif defined WLPDSTM_SCHED_YIELD 24 | 25 | #include 26 | 27 | namespace wlpdstm { 28 | 29 | // give up on this processor slice 30 | inline void pre_yield() { 31 | ::sched_yield(); 32 | } 33 | } 34 | 35 | #endif /* WLPDSTM_LINUXOS */ 36 | 37 | #endif // PREEMPTIVE_UTILS_H_ 38 | 39 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/intel/jmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This code currently works only for 32 bit jumps. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | */ 6 | 7 | #ifndef WLPDSTM_ICC_JMP_H_ 8 | #define WLPDSTM_ICC_JMP_H_ 9 | 10 | #include 11 | #include 12 | 13 | typedef struct begin_transaction_jmpbuf { 14 | uint32_t ebx; 15 | uint32_t esp; 16 | uint32_t ebp; 17 | uint32_t esi; 18 | uint32_t edi; 19 | uint32_t ret_addr; 20 | } my_jmpbuf; 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | //_ITM_CALL_CONVENTION int _ITM_beginTransaction(begin_transaction_jmpbuf *td, uint32 __properties, const _ITM_srcLocation *__src); 26 | _ITM_CALL_CONVENTION void jmp_to_begin_transaction(begin_transaction_jmpbuf *td); 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* WLPDSTM_ICC_JMP_H_ */ 32 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/mubench/barrier.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_BARRIER_H_ 7 | #define WLPDSTM_BARRIER_H_ 8 | 9 | #include 10 | 11 | #include "../common/atomic.h" 12 | #include "../common/constants.h" 13 | 14 | union barrier_t { 15 | volatile uintptr_t counter; 16 | char padding[CACHE_LINE_SIZE_BYTES]; 17 | }; 18 | 19 | inline void init_barrier(barrier_t *b, uintptr_t v) { 20 | b->counter = v; 21 | } 22 | 23 | inline void enter_barrier(barrier_t *b) { 24 | uintptr_t old_v, new_v; 25 | 26 | do { 27 | old_v = b->counter; 28 | new_v = old_v - 1; 29 | } while(!atomic_cas_full(&b->counter, old_v, new_v)); 30 | 31 | while(b->counter > 0) { 32 | // spin 33 | } 34 | } 35 | 36 | #endif /* WLPDSTM_BARRIER_H_ */ 37 | -------------------------------------------------------------------------------- /tools/ordo/gen_table_files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import subprocess 7 | import sys 8 | import os 9 | 10 | from itertools import combinations 11 | 12 | iters = 1000000 13 | 14 | 15 | def __get_values(filename): 16 | tok = open(filename, 'r').readlines() 17 | tok = map(lambda x: int(x), tok) 18 | return min(tok) 19 | 20 | max_offset = 0 21 | files=[f for f in os.listdir(sys.argv[1]) if os.path.isfile(os.path.join(sys.argv[1], f))] 22 | 23 | cores = [x for x in range(int(sys.argv[2]))] 24 | 25 | for i in range(len(cores)): 26 | for j in range(len(cores)): 27 | if i == j: 28 | print ("0 "), 29 | continue 30 | print("%d " % __get_values("%s/%d-%d.txt" % (sys.argv[1], i, j))), 31 | print("") 32 | 33 | -------------------------------------------------------------------------------- /lib/oplog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _OPLOG_H 5 | #define _OPLOG_H 6 | 7 | #include "nvlog.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | int oplog_create(ts_thread_struct_t *, ts_oplog_t *, unsigned long, 14 | unsigned short); 15 | void oplog_destroy(ts_nvlog_t *); 16 | ts_op_entry_t *oplog_enq(ts_oplog_t *, unsigned long, unsigned long, 17 | ts_op_info_t *); 18 | ts_op_entry_t *oplog_deq(ts_oplog_t *); 19 | void oplog_enq_persist(ts_oplog_t *); 20 | void oplog_deq_persist(ts_oplog_t *); 21 | int oplog_reclaim(ts_oplog_t *, int); 22 | int oplog_try_request_ckpt_if_needed(ts_oplog_t *); 23 | 24 | static inline unsigned long oplog_used(ts_oplog_t *oplog) 25 | { 26 | return nvlog_used(oplog); 27 | } 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | #endif 33 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/mubench/intset-rbtree.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: 3 | * intset-rbtree.h 4 | * Author(s): 5 | * Pascal Felber 6 | * Description: 7 | * Set macro to compile red-black tree version of integer set. 8 | * 9 | * Copyright (c) 2007-2008. 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation, version 2 14 | * of the License. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | */ 21 | 22 | #ifndef USE_RBTREE 23 | //#define USE_RBTREE 24 | #endif 25 | 26 | #include "intset.c" 27 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/include/stm.h: -------------------------------------------------------------------------------- 1 | #include "../src/api/wlpdstm.h" 2 | 3 | #define BEGIN_TRANSACTION \ 4 | if(sigsetjmp(*wlpdstm_get_long_jmp_buf(), 0) != LONG_JMP_ABORT_FLAG) { \ 5 | wlpdstm_start_tx() 6 | 7 | #define BEGIN_TRANSACTION_ID(TX_ID) \ 8 | if(sigsetjmp(*wlpdstm_get_long_jmp_buf(), 0) != LONG_JMP_ABORT_FLAG) { \ 9 | wlpdstm_start_tx_id(TX_ID) 10 | 11 | #define END_TRANSACTION \ 12 | wlpdstm_commit_tx(); \ 13 | } 14 | 15 | #define BEGIN_TRANSACTION_DESC \ 16 | if(sigsetjmp(*wlpdstm_get_long_jmp_buf_desc(tx), 0) != LONG_JMP_ABORT_FLAG) { \ 17 | wlpdstm_start_tx_desc(tx) 18 | 19 | #define BEGIN_TRANSACTION_DESC_ID(TX_ID) \ 20 | if(sigsetjmp(*wlpdstm_get_long_jmp_buf_desc(tx), 0) != LONG_JMP_ABORT_FLAG) { \ 21 | wlpdstm_start_tx_id_desc(tx, TX_ID) 22 | 23 | #define END_TRANSACTION_DESC \ 24 | wlpdstm_commit_tx_desc(tx); \ 25 | } 26 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/perfcnt/perf_cnt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * The implementing classes should implement the following interface: 3 | * 4 | * - GlobalInit() 5 | * - ThreadInit() 6 | * - TxStart() 7 | * - TxEnd() 8 | * valid after TxEnd() is called: 9 | * - uint64_t GetElapsedCycles() 10 | * - uint64_t GetRetiredInstructions() 11 | * 12 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 13 | */ 14 | 15 | #ifdef PERFORMANCE_COUNTING 16 | 17 | #ifndef WLPDSTM_PERF_CNT_H_ 18 | #define WLPDSTM_PERF_CNT_H_ 19 | 20 | #ifdef WLPDSTM_SOLARIS 21 | 22 | #include "perf_cnt_solaris.h" 23 | 24 | #elif defined WLPDSTM_LINUXOS 25 | 26 | // this assumes papi is installed and working 27 | #include "perf_cnt_papi.h" 28 | 29 | #else 30 | 31 | #undef PERFORMANCE_COUNTING 32 | 33 | #endif /* WLPDSTM_SOLARIS */ 34 | 35 | #endif /* WLPDSTM_PERF_CNT_H_ */ 36 | 37 | #endif /* PERFORMANCE_COUNTING */ 38 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/intel/memory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include 7 | 8 | #include "memory.h" 9 | #include "../stm/transaction.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | // NOTE: this works only on linux, so be careful 17 | #if defined WLPDSTM_LINUXOS 18 | #include 19 | 20 | inline size_t malloc_mem_size(void *ptr) { 21 | return malloc_usable_size(ptr); 22 | } 23 | #endif /* WLPDSTM_LINUXOS */ 24 | 25 | void *wlpdstm_icc_malloc(size_t size) { 26 | wlpdstm::TxMixinv *tx = (wlpdstm::TxMixinv *)_ITM_getTransaction(); 27 | return tx->TxMalloc(size); 28 | } 29 | 30 | void wlpdstm_icc_free(void *ptr) { 31 | wlpdstm::TxMixinv *tx = (wlpdstm::TxMixinv *)_ITM_getTransaction(); 32 | tx->TxFree(ptr, malloc_mem_size(ptr)); 33 | } 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/extent_mmap.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | void *extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, 13 | bool *zero, bool *commit); 14 | bool extent_dalloc_mmap(void *addr, size_t size); 15 | 16 | #endif /* JEMALLOC_H_EXTERNS */ 17 | /******************************************************************************/ 18 | #ifdef JEMALLOC_H_INLINES 19 | 20 | #endif /* JEMALLOC_H_INLINES */ 21 | /******************************************************************************/ 22 | -------------------------------------------------------------------------------- /benchmark/rlu/run-list.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #threads="1 4 8 14 28 56 84 112 140 168 196 224 280 336 392 448" 4 | threads="2 8 14 28 56 84 140 196 280 392 448" 5 | data="10000" 6 | 7 | echo "####################################" 8 | echo "####################################" 9 | echo "Evaluation List 10K " 10 | for thread in ${threads} 11 | do 12 | echo "run bench-timestone num thread ${thread}" 13 | #./bench-timestone -i1000 -r2000 -d10000 -n${thread} 14 | ./bench-timestone -j/mnt/pmem/nvheap -k24 -i10000 -r20000 -d7000 -n${thread} 15 | done 16 | 17 | echo "####################################" 18 | echo "####################################" 19 | echo "Evaluation List 100K " 20 | for thread in ${threads} 21 | do 22 | echo "run bench-timestone num thread ${thread}" 23 | #./bench-timestone -i1000 -r2000 -d10000 -n${thread} 24 | ./bench-timestone -j/mnt/pmem/nvheap -k24 -i100000 -r200000 -d7000 -n${thread} 25 | done 26 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/thd.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifdef _WIN32 4 | void 5 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) 6 | { 7 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; 8 | *thd = CreateThread(NULL, 0, routine, arg, 0, NULL); 9 | if (*thd == NULL) 10 | test_fail("Error in CreateThread()\n"); 11 | } 12 | 13 | void 14 | thd_join(thd_t thd, void **ret) 15 | { 16 | 17 | if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) { 18 | DWORD exit_code; 19 | GetExitCodeThread(thd, (LPDWORD) &exit_code); 20 | *ret = (void *)(uintptr_t)exit_code; 21 | } 22 | } 23 | 24 | #else 25 | void 26 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) 27 | { 28 | 29 | if (pthread_create(thd, NULL, proc, arg) != 0) 30 | test_fail("Error in pthread_create()\n"); 31 | } 32 | 33 | void 34 | thd_join(thd_t thd, void **ret) 35 | { 36 | 37 | pthread_join(thd, ret); 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /tools/ordo/Makefile: -------------------------------------------------------------------------------- 1 | # Quiet compile, unset for verbose output 2 | Q = @ 3 | 4 | O = o 5 | CC = gcc 6 | 7 | CWARNS = -Wformat=2 -Wextra -Wmissing-noreturn -Wwrite-strings -Wshadow \ 8 | -Wno-unused-parameter -Wmissing-format-attribute -fno-builtin \ 9 | -Wswitch-default -Wmissing-prototypes \ 10 | -Wmissing-declarations 11 | CFLAGS = $(DEFS) -Wall -Werror -fno-strict-aliasing $(CWARNS) \ 12 | -g -O0 -D_GNU_SOURCE 13 | 14 | LDFLAGS = -lrt -lm 15 | 16 | LIBS = bench.c 17 | DEPS = bench.h config.h 18 | 19 | BINS = tttable reftable membandwidthtable cc 20 | BINS := $(addprefix $(O)/, $(BINS)) 21 | 22 | 23 | all: CPUSEQ $(BINS) 24 | 25 | CPUSEQ: 26 | @echo "generating sequential cpu" 27 | $(Q)./gen_cpuseq.py 28 | 29 | $(O)/%: %.c $(DEPS) $(CPUSEQ) 30 | @mkdir -p $(@D) 31 | @echo "CC $@" 32 | $(Q)$(CC) $(CFLAGS) -o $@ $< $(LIBS) -lpthread $(LDFLAGS) 33 | 34 | clean: 35 | @echo "CLEAN" 36 | $(Q)rm -rf $(O) && rm -rf cpuseq.h 37 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/version_lock.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_VERSION_LOCK_H_ 2 | #define WLPDSTM_VERSION_LOCK_H_ 3 | 4 | #include "constants.h" 5 | 6 | namespace wlpdstm { 7 | 8 | typedef Word VersionLock; 9 | 10 | inline bool is_locked(VersionLock lock) { 11 | return (unsigned)lock & LSB; 12 | } 13 | 14 | inline bool is_read_locked(VersionLock lock) { 15 | return (unsigned)lock & LSB; 16 | } 17 | 18 | inline bool is_write_locked(VersionLock lock) { 19 | return lock != WRITE_LOCK_CLEAR; 20 | } 21 | 22 | inline Word get_value(VersionLock lock) { 23 | return lock >> LOCK_RESERVED_BITS; 24 | } 25 | 26 | inline VersionLock get_version_lock(Word ts) { 27 | return ts << LOCK_RESERVED_BITS; 28 | } 29 | 30 | inline VersionLock get_locked(Word thread) { 31 | return thread | LSB; 32 | } 33 | 34 | inline Word get_ptr(VersionLock lock) { 35 | return lock & ~LSB; 36 | } 37 | } 38 | 39 | #endif // WLPDSTM_VERSION_LOCK_H_ 40 | -------------------------------------------------------------------------------- /benchmark/rlu/run-hash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #threads="1 4 8 14 28 56 84 112 140 168 196 224 280 336 392 448" 4 | threads="1 8 16 24 32 40 48 60 78 96" 5 | data="10000" 6 | 7 | echo "####################################" 8 | echo "####################################" 9 | echo "Evaluation Hash 10K " 10 | for thread in ${threads} 11 | do 12 | echo "run bench-timestone num thread ${thread}" 13 | #./bench-timestone -b1000 -i10000 -r20000 -d10000 -n${thread} 14 | ./bench-timestone -j/mnt/pmem/nvheap -k24 -b1000 -i10000 -r20000 -d10000 -n${thread} 15 | done 16 | 17 | echo "####################################" 18 | echo "####################################" 19 | echo "Evaluation Hash 100K " 20 | for thread in ${threads} 21 | do 22 | echo "run bench-timestone num thread ${thread}" 23 | #./bench-timestone -i1000 -r2000 -d10000 -n${thread} 24 | #./bench-timestone -j/mnt/pmem/nvheap -k24 -b10000 -i100000 -r200000 -d7000 -n${thread} 25 | done 26 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/alloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_ALLOC_H_ 7 | #define WLPDSTM_ALLOC_H_ 8 | 9 | namespace wlpdstm { 10 | 11 | class Alloc { 12 | public: 13 | static void *Malloc(size_t size) { 14 | return ::malloc(size); 15 | } 16 | 17 | static void Free(void *ptr) { 18 | ::free(ptr); 19 | } 20 | }; 21 | 22 | /** 23 | * Use non-tx free/malloc provided by wlpdstm. 24 | */ 25 | class WlpdstmAlloced { 26 | public: 27 | void* operator new(size_t size) { 28 | return Alloc::Malloc(size); 29 | } 30 | 31 | void* operator new[](size_t size) { 32 | return Alloc::Malloc(size); 33 | } 34 | 35 | void operator delete(void* ptr) { 36 | Alloc::Free(ptr); 37 | } 38 | 39 | void operator delete[](void *ptr) { 40 | return Alloc::Free(ptr); 41 | } 42 | }; 43 | } 44 | 45 | #endif /* WLPDSTM_ALLOC_H_ */ 46 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/tanger/tanger_stack_area.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This class (and all of stack handling) is based on tinySTM-0.9.9. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_TANGER_STACK_AREA_H_ 9 | #define WLPDSTM_TANGER_STACK_AREA_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include "../stm/common/tls.h" 15 | #include "../stm/common/cache_aligned_alloc.h" 16 | 17 | namespace wlpdstm { 18 | 19 | class StackArea : public CacheAlignedAlloc { 20 | public: 21 | void ThreadInit() { 22 | low = high = 0; 23 | data = NULL; 24 | size = 0; 25 | } 26 | 27 | uintptr_t low; 28 | uintptr_t high; 29 | void *data; 30 | size_t size; 31 | }; 32 | 33 | class ThreadStackArea : public Tls { 34 | }; 35 | } 36 | 37 | #define TLS_STACK_AREA wlpdstm::ThreadStackArea::Get() 38 | 39 | #endif /* WLPDSTM_TANGER_STACK_AREA_H_ */ 40 | -------------------------------------------------------------------------------- /benchmark/versioning/run-tree.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #threads="1 4 8 14 28 56 84 112 140 168 196 224 280 336 392 448" 4 | threads="2 8 14 28 56 84 140 196 280 392 448" 5 | data="10000" 6 | 7 | echo "####################################" 8 | echo "Evaluation Tree 10K " 9 | for thread in ${threads} 10 | do 11 | echo "run bench-timestone num thread ${thread}" 12 | # ./benchmark_tree_mvrlu -i10000 -r20000 -d5000 -u20 -n${thread} 13 | done 14 | 15 | echo "####################################" 16 | echo "Evaluation Tree 10K " 17 | for thread in ${threads} 18 | do 19 | echo "run bench-timestone num thread ${thread}" 20 | # ./benchmark_tree_mvrlu -i10000 -r20000 -d5000 -u200 -n${thread} 21 | done 22 | 23 | echo "####################################" 24 | echo "Evaluation Tree 10K " 25 | for thread in ${threads} 26 | do 27 | echo "run bench-timestone num thread ${thread}" 28 | ./benchmark_tree_mvrlu -i10000 -r20000 -d5000 -u800 -n${thread} 29 | done 30 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/arch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Functions that depend on CPU architecture. Reading stack pointer for example. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_ARCH_H_ 9 | #define WLPDSTM_ARCH_H_ 10 | 11 | #include 12 | 13 | namespace wlpdstm { 14 | 15 | uintptr_t read_sp(); 16 | 17 | uintptr_t read_bp(); 18 | 19 | } 20 | 21 | inline uintptr_t wlpdstm::read_sp() { 22 | #ifdef WLPDSTM_X86 23 | uintptr_t ret; 24 | __asm__ volatile ("mov %%esp, %0" : "=A" (ret) : : "%eax"); 25 | return ret; 26 | #else 27 | #error Target not supported yet. 28 | #endif /* arch */ 29 | } 30 | 31 | inline uintptr_t wlpdstm::read_bp() { 32 | #ifdef WLPDSTM_X86 33 | uintptr_t ret; 34 | __asm__ volatile ("mov %%ebp, %0" : "=A" (ret) : : "%eax"); 35 | return ret; 36 | #else 37 | #error Target not supported yet. 38 | #endif /* arch */ 39 | } 40 | 41 | #endif /* WLPDSTM_ARCH_H_ */ 42 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/lock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Lock implementation. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | * 6 | */ 7 | 8 | #ifndef WLPDSTM_LOCK_H_ 9 | #define WLPDSTM_LOCK_H_ 10 | 11 | #include "word.h" 12 | #include "atomic.h" 13 | 14 | namespace wlpdstm { 15 | 16 | class cas_lock { 17 | const static Word CLEAR = 0; 18 | const static Word TAKEN = 1; 19 | 20 | public: 21 | void init() volatile { 22 | flag = CLEAR; 23 | } 24 | 25 | void release() volatile { 26 | atomic_store_release(&flag, CLEAR); 27 | } 28 | 29 | bool try_lock() volatile { 30 | return atomic_cas_acquire(&flag, CLEAR, TAKEN); 31 | } 32 | 33 | void lock() volatile { 34 | while(!atomic_cas_acquire(&flag, CLEAR, TAKEN)) { 35 | if(flag == TAKEN) { 36 | continue; 37 | } 38 | } 39 | } 40 | 41 | protected: 42 | volatile Word flag; 43 | }; 44 | } 45 | 46 | #endif /* WLPDSTM_LOCK_H_ */ 47 | -------------------------------------------------------------------------------- /tools/ordo/cc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | 5 | offset_table = [] 6 | 7 | 8 | def get_freq(a): 9 | v = {} 10 | for i in a: 11 | if i in v: 12 | v[i] += 1 13 | else: 14 | v.update({i: 1}) 15 | return v 16 | 17 | 18 | def process_file(filename): 19 | freq = {} 20 | a = [] 21 | median = 0 22 | with open(filename, "r") as f: 23 | a = f.readlines() 24 | for i in range(0, len(a)): 25 | a[i] = int(a[i]) 26 | a.sort() 27 | s = int(len(a)) 28 | if s % 2 == 0: 29 | median = (a[int(s/2) -1] + a[int(s/2)]) / 2 30 | else: 31 | median = a[int(s/2)-1] 32 | print("min: %d max: %d median: %d" % (a[0], a[int(s)-1], median)) 33 | 34 | 35 | def main(): 36 | if len(sys.argv) < 2: 37 | print("%s filename" % sys.argv[0]) 38 | return -1 39 | 40 | process_file(sys.argv[1]) 41 | 42 | 43 | if __name__ == '__main__': 44 | main() 45 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/include/test/btalloc.h: -------------------------------------------------------------------------------- 1 | /* btalloc() provides a mechanism for allocating via permuted backtraces. */ 2 | void *btalloc(size_t size, unsigned bits); 3 | 4 | #define btalloc_n_proto(n) \ 5 | void *btalloc_##n(size_t size, unsigned bits); 6 | btalloc_n_proto(0) 7 | btalloc_n_proto(1) 8 | 9 | #define btalloc_n_gen(n) \ 10 | void * \ 11 | btalloc_##n(size_t size, unsigned bits) \ 12 | { \ 13 | void *p; \ 14 | \ 15 | if (bits == 0) \ 16 | p = mallocx(size, 0); \ 17 | else { \ 18 | switch (bits & 0x1U) { \ 19 | case 0: \ 20 | p = (btalloc_0(size, bits >> 1)); \ 21 | break; \ 22 | case 1: \ 23 | p = (btalloc_1(size, bits >> 1)); \ 24 | break; \ 25 | default: not_reached(); \ 26 | } \ 27 | } \ 28 | /* Intentionally sabotage tail call optimization. */ \ 29 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); \ 30 | return (p); \ 31 | } 32 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/lazy/lazy_static.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_DYNAMIC_LAZY_STATIC_H_ 7 | #define WLPDSTM_DYNAMIC_LAZY_STATIC_H_ 8 | 9 | #include "../api_linkage.h" 10 | 11 | API_LINKAGE void wlpdstm::TxLazy::TxCommitStatic(TransactionDynamic *desc) { 12 | TryCommitResult result = TxTryCommitStatic(desc); 13 | TxCommitAfterTry(desc, result); 14 | } 15 | 16 | API_LINKAGE void wlpdstm::TxLazy::RollbackRunningStatic(TransactionDynamic *desc) { 17 | RollbackRunningInline(desc); 18 | } 19 | 20 | API_LINKAGE Word wlpdstm::TxLazy::ReadWordStatic(TransactionDynamic *desc, Word *addr) { 21 | return ReadWordInline(desc, addr); 22 | } 23 | 24 | API_LINKAGE wlpdstm::WriteLogEntry *wlpdstm::TxLazy::LockMemoryStripeStatic(TransactionDynamic *desc, WriteLock *write_lock, Word *address) { 25 | return LockMemoryStripeInline(desc, write_lock); 26 | } 27 | 28 | #endif /* WLPDSTM_DYNAMIC_EAGER_STATIC_H_ */ 29 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/version_lock.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_VERSION_LOCK_H_ 2 | #define WLPDSTM_VERSION_LOCK_H_ 3 | 4 | #include "constants.h" 5 | 6 | namespace wlpdstm { 7 | 8 | typedef Word VersionLock; 9 | 10 | inline bool is_locked(VersionLock lock) { 11 | return (unsigned)lock & LSB; 12 | } 13 | 14 | inline bool is_read_locked(VersionLock lock) { 15 | return (unsigned)lock & LSB; 16 | } 17 | 18 | inline bool is_write_locked(VersionLock lock) { 19 | return lock != WRITE_LOCK_CLEAR; 20 | } 21 | 22 | inline Word get_value(VersionLock lock) { 23 | return lock >> LOCK_RESERVED_BITS; 24 | } 25 | 26 | inline VersionLock get_version_lock(Word ts) { 27 | return ts << LOCK_RESERVED_BITS; 28 | } 29 | 30 | inline VersionLock get_locked(Word thread) { 31 | return thread | LSB; 32 | } 33 | 34 | inline Word get_ptr(VersionLock lock) { 35 | return lock & ~LSB; 36 | } 37 | 38 | typedef VersionLock WriteLock; 39 | } 40 | 41 | #endif // WLPDSTM_VERSION_LOCK_H_ 42 | -------------------------------------------------------------------------------- /tools/ordo/parse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import os 7 | import sys 8 | 9 | 10 | offset_table = [] 11 | 12 | 13 | def get_freq(a): 14 | v = {} 15 | for i in a: 16 | if i in v: 17 | v[i] += 1 18 | else: 19 | v.update({i: 1}) 20 | return v 21 | 22 | 23 | def get_freq_table(filename, outfilename): 24 | a = [] 25 | with open(filename, "r") as f: 26 | a = f.readlines() 27 | for i in range(0, len(a)): 28 | a[i] = int(a[i]) 29 | freq_table = get_freq(a) 30 | with open(outfilename, "w") as f: 31 | for k, v in sorted(freq_table.items()): 32 | f.write("%s, %s\n" % (str(k), str(v))) 33 | 34 | 35 | def main(): 36 | if len(sys.argv) < 3: 37 | print("%s filename output" % sys.argv[0]) 38 | return -1 39 | 40 | get_freq_table(sys.argv[1], sys.argv[2]) 41 | 42 | if __name__ == '__main__': 43 | main() 44 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/base.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | void *base_alloc(tsdn_t *tsdn, size_t size); 13 | void base_stats_get(tsdn_t *tsdn, size_t *allocated, size_t *resident, 14 | size_t *mapped); 15 | bool base_boot(void); 16 | void base_prefork(tsdn_t *tsdn); 17 | void base_postfork_parent(tsdn_t *tsdn); 18 | void base_postfork_child(tsdn_t *tsdn); 19 | 20 | #endif /* JEMALLOC_H_EXTERNS */ 21 | /******************************************************************************/ 22 | #ifdef JEMALLOC_H_INLINES 23 | 24 | #endif /* JEMALLOC_H_INLINES */ 25 | /******************************************************************************/ 26 | -------------------------------------------------------------------------------- /lib/nvm.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _NVMEM_H 5 | #define _NVMEM_H 6 | 7 | #include "timestone_i.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | unsigned long nvm_get_gen_id(void); 14 | ts_nvm_root_obj_t *nvm_load_heap(const char *, size_t, int *); 15 | ts_nvm_root_obj_t *nvm_init_heap(const char *, size_t, int *); 16 | void nvm_heap_destroy(void); 17 | void *nvm_alloc(size_t size); 18 | void *nvm_aligned_alloc(size_t alignment, size_t size); 19 | void nvm_free(void *ptr); 20 | 21 | static inline void flush_to_nvm(void *dst, unsigned int size) 22 | { 23 | unsigned int i; 24 | 25 | for (i = 0; i < size; i += TS_CACHE_LINE_SIZE) { 26 | clwb(((char *)dst) + i); 27 | } 28 | } 29 | 30 | static inline void memcpy_to_nvm(void *dst, void *src, unsigned int size) 31 | { 32 | ts_assert(dst && src && size); 33 | 34 | memcpy(dst, src, size); 35 | flush_to_nvm(dst, size); 36 | } 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif 42 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/privatization_tree.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | */ 4 | 5 | #include "privatization_tree.h" 6 | 7 | // this is const, but should be aligned and occupy whole cache lines 8 | CACHE_LINE_ALIGNED unsigned wlpdstm::PrivatizationTree::map_count_to_root_idx[MAX_THREADS]; 9 | 10 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::PrivatizationTree::tree_nodes[PRIVATIZATION_TREE_NODE_COUNT]; 11 | 12 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::PrivatizationTree::proxy_nodes[PRIVATIZATION_TREE_PROXY_COUNT]; 13 | 14 | // for debug 15 | CACHE_LINE_ALIGNED wlpdstm::PaddedSpinTryLock wlpdstm::PrivatizationTree::tree_node_locks[PRIVATIZATION_TREE_NODE_COUNT]; 16 | CACHE_LINE_ALIGNED wlpdstm::PaddedSpinTryLock wlpdstm::PrivatizationTree::proxy_node_locks[PRIVATIZATION_TREE_PROXY_COUNT]; 17 | 18 | Word wlpdstm::PrivatizationTree::last_sibling_ts[MAX_THREADS]; 19 | Word wlpdstm::PrivatizationTree::last_my_ts[MAX_THREADS]; 20 | Word wlpdstm::PrivatizationTree::last_parent_ts[MAX_THREADS]; 21 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /lib/ckptlog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _CKPTLOG_H 5 | #define _CKPTLOG_H 6 | 7 | #include "nvlog.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | int ckptlog_create(ts_thread_struct_t *, ts_ckptlog_t *, unsigned long, 14 | unsigned short); 15 | void ckptlog_destroy(ts_ckptlog_t *); 16 | ts_ckpt_entry_t *ckptlog_enq(ts_ckptlog_t *, unsigned long, unsigned long, 17 | ts_cpy_hdr_struct_t *); 18 | ts_ckpt_entry_t *ckptlog_enq_tombstone(ts_ckptlog_t *, unsigned long, 19 | unsigned long, ts_cpy_hdr_struct_t *); 20 | ts_ckpt_entry_t *ckptlog_deq(ts_ckptlog_t *); 21 | void ckptlog_enq_persist(ts_ckptlog_t *); 22 | void ckptlog_deq_persist(ts_ckptlog_t *); 23 | void ckptlog_reclaim(ts_ckptlog_t *); 24 | void ckptlog_flush(ts_ckptlog_t *); 25 | void ckptlog_cleanup(ts_ckptlog_t *, unsigned long); 26 | 27 | static inline unsigned long ckptlog_used(ts_ckptlog_t *ckptlog) 28 | { 29 | return nvlog_used(ckptlog); 30 | } 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /tools/colors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | class Color: 7 | reset='\033[0m' 8 | bold='\033[01m' 9 | disable='\033[02m' 10 | underline='\033[04m' 11 | reverse='\033[07m' 12 | strikethrough='\033[09m' 13 | invisible='\033[08m' 14 | 15 | class fg: 16 | black='\033[30m' 17 | red='\033[31m' 18 | green='\033[32m' 19 | orange='\033[33m' 20 | blue='\033[34m' 21 | purple='\033[35m' 22 | cyan='\033[36m' 23 | lightgrey='\033[37m' 24 | darkgrey='\033[90m' 25 | lightred='\033[91m' 26 | lightgreen='\033[92m' 27 | yellow='\033[93m' 28 | lightblue='\033[94m' 29 | pink='\033[95m' 30 | lightcyan='\033[96m' 31 | 32 | class bg: 33 | black='\033[40m' 34 | red='\033[41m' 35 | green='\033[42m' 36 | orange='\033[43m' 37 | blue='\033[44m' 38 | purple='\033[45m' 39 | cyan='\033[46m' 40 | lightgrey='\033[47m' 41 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/README: -------------------------------------------------------------------------------- 1 | jemalloc is a general purpose malloc(3) implementation that emphasizes 2 | fragmentation avoidance and scalable concurrency support. jemalloc first came 3 | into use as the FreeBSD libc allocator in 2005, and since then it has found its 4 | way into numerous applications that rely on its predictable behavior. In 2010 5 | jemalloc development efforts broadened to include developer support features 6 | such as heap profiling and extensive monitoring/tuning hooks. Modern jemalloc 7 | releases continue to be integrated back into FreeBSD, and therefore versatility 8 | remains critical. Ongoing development efforts trend toward making jemalloc 9 | among the best allocators for a broad range of demanding applications, and 10 | eliminating/mitigating weaknesses that have practical repercussions for real 11 | world applications. 12 | 13 | The COPYING file contains copyright and licensing information. 14 | 15 | The INSTALL file contains information on how to configure, build, and install 16 | jemalloc. 17 | 18 | The ChangeLog file contains a brief summary of changes for each release. 19 | 20 | URL: http://jemalloc.net/ 21 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/public_namespace.h: -------------------------------------------------------------------------------- 1 | #define je_malloc_conf JEMALLOC_N(malloc_conf) 2 | #define je_malloc_message JEMALLOC_N(malloc_message) 3 | #define je_malloc JEMALLOC_N(malloc) 4 | #define je_calloc JEMALLOC_N(calloc) 5 | #define je_posix_memalign JEMALLOC_N(posix_memalign) 6 | #define je_aligned_alloc JEMALLOC_N(aligned_alloc) 7 | #define je_realloc JEMALLOC_N(realloc) 8 | #define je_free JEMALLOC_N(free) 9 | #define je_mallocx JEMALLOC_N(mallocx) 10 | #define je_nextx JEMALLOC_N(nextx) 11 | #define je_rallocx JEMALLOC_N(rallocx) 12 | #define je_xallocx JEMALLOC_N(xallocx) 13 | #define je_sallocx JEMALLOC_N(sallocx) 14 | #define je_dallocx JEMALLOC_N(dallocx) 15 | #define je_sdallocx JEMALLOC_N(sdallocx) 16 | #define je_nallocx JEMALLOC_N(nallocx) 17 | #define je_mallctl JEMALLOC_N(mallctl) 18 | #define je_mallctlnametomib JEMALLOC_N(mallctlnametomib) 19 | #define je_mallctlbymib JEMALLOC_N(mallctlbymib) 20 | #define je_malloc_stats_print JEMALLOC_N(malloc_stats_print) 21 | #define je_malloc_usable_size JEMALLOC_N(malloc_usable_size) 22 | #define je_memalign JEMALLOC_N(memalign) 23 | #define je_valloc JEMALLOC_N(valloc) 24 | -------------------------------------------------------------------------------- /lib/nvlog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _NVLOG_H 5 | #define _NVLOG_H 6 | 7 | #include "timestone_i.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | int nvlog_init(ts_nvm_root_obj_t *); 14 | int nvlog_create(ts_thread_struct_t *, ts_nvlog_t *, unsigned long, 15 | unsigned short, unsigned short); 16 | void nvlog_load(ts_nvlog_store_t *, ts_nvlog_t *); 17 | void nvlog_destroy(ts_nvlog_t *); 18 | ts_nvlog_entry_hdr_t *nvlog_enq(ts_nvlog_t *, unsigned int); 19 | ts_nvlog_entry_hdr_t *nvlog_deq(ts_nvlog_t *); 20 | void nvlog_enq_persist(ts_nvlog_t *); 21 | void nvlog_deq_persist(ts_nvlog_t *); 22 | ts_nvlog_entry_hdr_t *nvlog_peek_head(ts_nvlog_t *); 23 | void nvlog_set_last_ckpt_clk(unsigned long); 24 | unsigned long nvlog_get_last_ckpt_clk(void); 25 | void nvlog_truncate_tail(ts_nvlog_t *, unsigned long); 26 | void nvlog_truncate_head(ts_nvlog_t *, unsigned long); 27 | 28 | static inline unsigned long nvlog_used(ts_nvlog_t *nvlog) 29 | { 30 | return nvlog->tail_cnt - nvlog->head_cnt; 31 | } 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/transaction_mixinv.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | */ 4 | 5 | #include "transaction_mixinv.h" 6 | 7 | wlpdstm::VersionLock wlpdstm::TxMixinv::version_lock_table[FULL_VERSION_LOCK_TABLE_SIZE]; 8 | 9 | CACHE_LINE_ALIGNED wlpdstm::GlobalTimestamp wlpdstm::TxMixinv::commit_ts; 10 | 11 | CACHE_LINE_ALIGNED wlpdstm::GlobalTimestamp wlpdstm::TxMixinv::cm_ts; 12 | 13 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TxMixinv::minimum_observed_ts; 14 | 15 | CACHE_LINE_ALIGNED wlpdstm::PaddedSpinTryLock wlpdstm::TxMixinv::minimum_observed_ts_lock; 16 | 17 | wlpdstm::TxMixinv *wlpdstm::TxMixinv::transactions[MAX_THREADS]; 18 | 19 | Word wlpdstm::TxMixinv::thread_count; 20 | 21 | CACHE_LINE_ALIGNED wlpdstm::PaddedBool wlpdstm::TxMixinv::synchronization_in_progress; 22 | 23 | #ifdef PRIVATIZATION_QUIESCENCE 24 | CACHE_LINE_ALIGNED volatile Word wlpdstm::TxMixinv::quiescence_timestamp_array[MAX_THREADS]; 25 | #endif /* PRIVATIZATION_QUIESCENCE */ 26 | 27 | #ifdef SIGNALING 28 | CACHE_LINE_ALIGNED volatile wlpdstm::PaddedWord wlpdstm::TxMixinv::signaling_array[MAX_THREADS]; 29 | #endif /* SIGNALING */ 30 | -------------------------------------------------------------------------------- /benchmark/rlu/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Read-Log-Update authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /benchmark/versioning/benchmark_list_move.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_LIST_H 2 | #define BENCHMARK_LIST_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | typedef struct barrier { 10 | pthread_cond_t complete; 11 | pthread_mutex_t mutex; 12 | int count; 13 | int crossing; 14 | } barrier_t; 15 | 16 | #define CACHE_ALIGN (64) 17 | 18 | #define CACHE_ALIGN_SIZE(size) ((((size - 1) / CACHE_ALIGN) + 1) * CACHE_ALIGN) 19 | 20 | #define PTHREAD_PADDING (16) 21 | 22 | typedef struct pthread_data { 23 | long pthread_padding[PTHREAD_PADDING]; 24 | long id; 25 | unsigned long nr_move; 26 | unsigned long nr_txn; 27 | int range; 28 | unsigned int seed; 29 | barrier_t *barrier; 30 | void *list; 31 | void *ds_data; // data structure specific data 32 | } pthread_data_t; 33 | 34 | pthread_data_t *alloc_pthread_data(void); 35 | 36 | void free_pthread_data(pthread_data_t *d); 37 | 38 | void *list_global_init(int init_size, int value_range); 39 | 40 | int list_thread_init(pthread_data_t *data, pthread_data_t **sync_data, int nr_threads); 41 | 42 | void list_global_exit(void *list); 43 | 44 | int list_move(int key, pthread_data_t *data, int from); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /tools/ordo/cpuseq.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | int online_cpus = 224; 5 | int cpuseq[] = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446 }; 6 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/jemalloc_rename.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Name mangling for public symbols is controlled by --with-mangling and 3 | * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by 4 | * these macro definitions. 5 | */ 6 | #ifndef JEMALLOC_NO_RENAME 7 | # define je_malloc_conf nv_malloc_conf 8 | # define je_malloc_message nv_malloc_message 9 | # define je_malloc nv_malloc 10 | # define je_calloc nv_calloc 11 | # define je_posix_memalign nv_posix_memalign 12 | # define je_aligned_alloc nv_aligned_alloc 13 | # define je_realloc nv_realloc 14 | # define je_free nv_free 15 | # define je_mallocx nv_mallocx 16 | # define je_nextx nv_nextx 17 | # define je_rallocx nv_rallocx 18 | # define je_xallocx nv_xallocx 19 | # define je_sallocx nv_sallocx 20 | # define je_dallocx nv_dallocx 21 | # define je_sdallocx nv_sdallocx 22 | # define je_nallocx nv_nallocx 23 | # define je_mallctl nv_mallctl 24 | # define je_mallctlnametomib nv_mallctlnametomib 25 | # define je_mallctlbymib nv_mallctlbymib 26 | # define je_malloc_stats_print nv_malloc_stats_print 27 | # define je_malloc_usable_size nv_malloc_usable_size 28 | # define je_memalign nv_memalign 29 | # define je_valloc nv_valloc 30 | #endif 31 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case @abi@ in 4 | macho) 5 | export DYLD_FALLBACK_LIBRARY_PATH="@objroot@lib" 6 | ;; 7 | pecoff) 8 | export PATH="${PATH}:@objroot@lib" 9 | ;; 10 | *) 11 | ;; 12 | esac 13 | 14 | # Corresponds to test_status_t. 15 | pass_code=0 16 | skip_code=1 17 | fail_code=2 18 | 19 | pass_count=0 20 | skip_count=0 21 | fail_count=0 22 | for t in $@; do 23 | if [ $pass_count -ne 0 -o $skip_count -ne 0 -o $fail_count != 0 ] ; then 24 | echo 25 | fi 26 | echo "=== ${t} ===" 27 | ${t}@exe@ @abs_srcroot@ @abs_objroot@ 28 | result_code=$? 29 | case ${result_code} in 30 | ${pass_code}) 31 | pass_count=$((pass_count+1)) 32 | ;; 33 | ${skip_code}) 34 | skip_count=$((skip_count+1)) 35 | ;; 36 | ${fail_code}) 37 | fail_count=$((fail_count+1)) 38 | ;; 39 | *) 40 | echo "Test harness error" 1>&2 41 | exit 1 42 | esac 43 | done 44 | 45 | total_count=`expr ${pass_count} + ${skip_count} + ${fail_count}` 46 | echo 47 | echo "Test suite summary: pass: ${pass_count}/${total_count}, skip: ${skip_count}/${total_count}, fail: ${fail_count}/${total_count}" 48 | 49 | if [ ${fail_count} -eq 0 ] ; then 50 | exit 0 51 | else 52 | exit 1 53 | fi 54 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Define a custom assert() in order to reduce the chances of deadlock during 3 | * assertion failure. 4 | */ 5 | #ifndef assert 6 | #define assert(e) do { \ 7 | if (unlikely(config_debug && !(e))) { \ 8 | malloc_printf( \ 9 | ": %s:%d: Failed assertion: \"%s\"\n", \ 10 | __FILE__, __LINE__, #e); \ 11 | abort(); \ 12 | } \ 13 | } while (0) 14 | #endif 15 | 16 | #ifndef not_reached 17 | #define not_reached() do { \ 18 | if (config_debug) { \ 19 | malloc_printf( \ 20 | ": %s:%d: Unreachable code reached\n", \ 21 | __FILE__, __LINE__); \ 22 | abort(); \ 23 | } \ 24 | unreachable(); \ 25 | } while (0) 26 | #endif 27 | 28 | #ifndef not_implemented 29 | #define not_implemented() do { \ 30 | if (config_debug) { \ 31 | malloc_printf(": %s:%d: Not implemented\n", \ 32 | __FILE__, __LINE__); \ 33 | abort(); \ 34 | } \ 35 | } while (0) 36 | #endif 37 | 38 | #ifndef assert_not_implemented 39 | #define assert_not_implemented(e) do { \ 40 | if (unlikely(config_debug && !(e))) \ 41 | not_implemented(); \ 42 | } while (0) 43 | #endif 44 | 45 | 46 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/large_lock_set.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Used for adaptive locking. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | */ 6 | 7 | #ifndef WLPDSTM_LARGE_LOCK_SET_H_ 8 | #define WLPDSTM_LARGE_LOCK_SET_H_ 9 | 10 | #include 11 | #include 12 | 13 | namespace wlpdstm { 14 | 15 | template 16 | class LargeLockSet { 17 | static const uint32_t MIN_SET_VERSION = 0; 18 | static const uint32_t MAX_SET_VERSION = (uint32_t)-1; 19 | 20 | public: 21 | LargeLockSet() { 22 | Reset(); 23 | } 24 | 25 | bool Set(uint32_t el) { 26 | if(Contains(el)) { 27 | return true; 28 | } 29 | 30 | table[el] = version; 31 | return false; 32 | } 33 | 34 | bool Contains(uint32_t el) const { 35 | return table[el] == version; 36 | } 37 | 38 | void Clear() { 39 | if(version == MAX_SET_VERSION) { 40 | Reset(); 41 | } else { 42 | ++version; 43 | } 44 | } 45 | 46 | private: 47 | void Reset() { 48 | version = MIN_SET_VERSION + 1; 49 | memset(&table, MIN_SET_VERSION, sizeof(uint32_t) * SIZE); 50 | } 51 | 52 | private: 53 | uint32_t version; 54 | uint32_t table[SIZE]; 55 | }; 56 | } 57 | 58 | #endif /* WLPDSTM_LARGE_LOCK_SET_H_ */ 59 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/mtx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define NTHREADS 2 4 | #define NINCRS 2000000 5 | 6 | TEST_BEGIN(test_mtx_basic) 7 | { 8 | mtx_t mtx; 9 | 10 | assert_false(mtx_init(&mtx), "Unexpected mtx_init() failure"); 11 | mtx_lock(&mtx); 12 | mtx_unlock(&mtx); 13 | mtx_fini(&mtx); 14 | } 15 | TEST_END 16 | 17 | typedef struct { 18 | mtx_t mtx; 19 | unsigned x; 20 | } thd_start_arg_t; 21 | 22 | static void * 23 | thd_start(void *varg) 24 | { 25 | thd_start_arg_t *arg = (thd_start_arg_t *)varg; 26 | unsigned i; 27 | 28 | for (i = 0; i < NINCRS; i++) { 29 | mtx_lock(&arg->mtx); 30 | arg->x++; 31 | mtx_unlock(&arg->mtx); 32 | } 33 | return (NULL); 34 | } 35 | 36 | TEST_BEGIN(test_mtx_race) 37 | { 38 | thd_start_arg_t arg; 39 | thd_t thds[NTHREADS]; 40 | unsigned i; 41 | 42 | assert_false(mtx_init(&arg.mtx), "Unexpected mtx_init() failure"); 43 | arg.x = 0; 44 | for (i = 0; i < NTHREADS; i++) 45 | thd_create(&thds[i], thd_start, (void *)&arg); 46 | for (i = 0; i < NTHREADS; i++) 47 | thd_join(thds[i], NULL); 48 | assert_u_eq(arg.x, NTHREADS * NINCRS, 49 | "Race-related counter corruption"); 50 | } 51 | TEST_END 52 | 53 | int 54 | main(void) 55 | { 56 | 57 | return (test( 58 | test_mtx_basic, 59 | test_mtx_race)); 60 | } 61 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/integration/sdallocx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define MAXALIGN (((size_t)1) << 25) 4 | #define NITER 4 5 | 6 | TEST_BEGIN(test_basic) 7 | { 8 | void *ptr = mallocx(64, 0); 9 | sdallocx(ptr, 64, 0); 10 | } 11 | TEST_END 12 | 13 | TEST_BEGIN(test_alignment_and_size) 14 | { 15 | size_t nsz, sz, alignment, total; 16 | unsigned i; 17 | void *ps[NITER]; 18 | 19 | for (i = 0; i < NITER; i++) 20 | ps[i] = NULL; 21 | 22 | for (alignment = 8; 23 | alignment <= MAXALIGN; 24 | alignment <<= 1) { 25 | total = 0; 26 | for (sz = 1; 27 | sz < 3 * alignment && sz < (1U << 31); 28 | sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) { 29 | for (i = 0; i < NITER; i++) { 30 | nsz = nallocx(sz, MALLOCX_ALIGN(alignment) | 31 | MALLOCX_ZERO); 32 | ps[i] = mallocx(sz, MALLOCX_ALIGN(alignment) | 33 | MALLOCX_ZERO); 34 | total += nsz; 35 | if (total >= (MAXALIGN << 1)) 36 | break; 37 | } 38 | for (i = 0; i < NITER; i++) { 39 | if (ps[i] != NULL) { 40 | sdallocx(ps[i], sz, 41 | MALLOCX_ALIGN(alignment)); 42 | ps[i] = NULL; 43 | } 44 | } 45 | } 46 | } 47 | } 48 | TEST_END 49 | 50 | int 51 | main(void) 52 | { 53 | 54 | return (test( 55 | test_basic, 56 | test_alignment_and_size)); 57 | } 58 | -------------------------------------------------------------------------------- /lib/nvm-nv-jemalloc.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifdef TS_NVM_IS_NV_JEMALLOC 5 | #define _GNU_SOURCE 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "util.h" 17 | #include "debug.h" 18 | #include "port.h" 19 | #include "nvm.h" 20 | 21 | ts_nvm_root_obj_t *nvm_load_heap(const char *path, size_t sz, int *is_created) 22 | { 23 | ts_nvm_root_obj_t *root_obj; 24 | 25 | /* Get a root pointer */ 26 | *is_created = 1; 27 | root_obj = nv_calloc(1, sizeof(*root_obj)); 28 | if (unlikely(!root_obj)) { 29 | return NULL; 30 | } 31 | flush_to_nvm(root_obj, sizeof(*root_obj)); 32 | wmb(); 33 | 34 | return root_obj; 35 | } 36 | 37 | void nvm_heap_destroy(void) 38 | { 39 | /* Do nothing! */ 40 | } 41 | 42 | void *nvm_alloc(size_t size) 43 | { 44 | return nv_malloc(size); 45 | } 46 | 47 | void *nvm_aligned_alloc(size_t alignment, size_t size) 48 | { 49 | return nv_aligned_alloc(alignment, size); 50 | } 51 | 52 | void nvm_free(void *ptr) 53 | { 54 | nv_free(ptr); 55 | } 56 | 57 | #endif /* TS_NVM_IS_NV_JEMALLOC */ 58 | -------------------------------------------------------------------------------- /benchmark/rlu/hazard_ptrs.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "hazard_ptrs.h" 5 | 6 | ///////////////////////////////////////////////////////// 7 | // DEFINES 8 | ///////////////////////////////////////////////////////// 9 | #define CPU_RELAX() asm volatile("pause\n": : :"memory"); 10 | #define MEMBARSTLD() __sync_synchronize() 11 | 12 | ///////////////////////////////////////////////////////// 13 | // EXTERNAL FUNCTIONS 14 | ///////////////////////////////////////////////////////// 15 | void HP_reset(hp_thread_t *self) { 16 | self->n_hp_records = 0; 17 | } 18 | 19 | void HP_save(hp_thread_t *self) { 20 | self->saved_n_hp_records = self->n_hp_records; 21 | } 22 | 23 | void HP_restore(hp_thread_t *self) { 24 | self->n_hp_records = self->saved_n_hp_records; 25 | } 26 | 27 | hp_record_t *HP_alloc(hp_thread_t *self) { 28 | hp_record_t *p_hp; 29 | 30 | p_hp = &(self->hp_records[self->n_hp_records]); 31 | self->n_hp_records++; 32 | 33 | if (self->n_hp_records >= HP_MAX_RECORDS) { 34 | abort(); 35 | } 36 | 37 | return p_hp; 38 | 39 | } 40 | 41 | void HP_init(hp_record_t *p_hp, volatile int64_t **ptr_ptr) { 42 | 43 | while (1) { 44 | p_hp->ptr = *ptr_ptr; 45 | MEMBARSTLD(); 46 | 47 | if (p_hp->ptr == *ptr_ptr) { 48 | return; 49 | } 50 | 51 | CPU_RELAX(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /benchmark/rlu/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _TYPES_H_ 2 | #define _TYPES_H_ 3 | #include 4 | ///////////////////////////////////////////////////////// 5 | // DEFINES 6 | ///////////////////////////////////////////////////////// 7 | #define LIST_VAL_MIN (INT_MIN) 8 | #define LIST_VAL_MAX (INT_MAX) 9 | ///////////////////////////////////////////////////////// 10 | // TYPES 11 | ///////////////////////////////////////////////////////// 12 | #define NODE_PADDING (16) 13 | #define MAX_BUCKETS (1000000) 14 | typedef int val_t; 15 | 16 | typedef struct node { 17 | val_t val; 18 | struct node *p_next; 19 | #ifdef IS_VERSION 20 | struct vlist_slot *slots; 21 | #endif 22 | } node_t; 23 | 24 | typedef struct list { 25 | node_t *p_head; 26 | } list_t; 27 | 28 | typedef struct hash_list { 29 | int n_buckets; 30 | list_t *buckets[MAX_BUCKETS]; 31 | } hash_list_t; 32 | 33 | #define VLIST_ENTRIES_PER_TASK 2 34 | 35 | 36 | typedef struct vlist_record { 37 | unsigned long epoch; 38 | struct vlist_record *rec_next; 39 | int count; 40 | struct node *nodes[VLIST_ENTRIES_PER_TASK]; 41 | struct vlist_slot *slots[VLIST_ENTRIES_PER_TASK]; 42 | } vlist_record_t; 43 | 44 | typedef struct vlist_slot { 45 | unsigned long epoch; 46 | struct node *next; 47 | struct vlist_slot *slot_next; 48 | struct vlist_record *rec; 49 | } vlist_slot_t; 50 | #endif 51 | -------------------------------------------------------------------------------- /lib++/Makefile: -------------------------------------------------------------------------------- 1 | CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) 2 | 3 | include $(CUR_DIR)/../Makefile.inc 4 | 5 | # configuration 6 | ifeq ($(strip $(CONF)),gtest) 7 | LIB_SUFFIX = -gtest 8 | CXXFLAGS += -DTS_GTEST 9 | endif 10 | 11 | CXXFLAGS += -std=c++14 -I$(INC_DIR) 12 | CXXFLAGS += -march=native -mtune=native -O3 13 | CXXFLAGS += -g -ggdb3 14 | CXXFLAGS += -Winline -Werror -Wall -Wextra -Wshadow 15 | CXXFLAGS += -Wno-attributes -Wno-unused-parameter -Wno-unused-value 16 | CXXFLAGS += -Wno-unused-function -Wno-packed-not-aligned 17 | LDFLAGS += -lpthread $(MEMMGR) $(PMEM) 18 | 19 | DEPS_DIR := $(CUR_DIR)/.deps$(LIB_SUFFIX) 20 | DEPCFLAGS = -MD -MF $(DEPS_DIR)/$*.d -MP 21 | 22 | SRC_FILES = $(wildcard *.cpp) 23 | OBJS_DIR = $(CUR_DIR)/.objs$(LIB_SUFFIX) 24 | OBJ_FILES = $(addprefix $(OBJS_DIR)/, $(SRC_FILES:.cpp=.o)) 25 | 26 | all: libts++$(LIB_SUFFIX).a 27 | 28 | $(OBJS_DIR)/%.o: %.cpp $(DEPS_DIR) $(OBJS_DIR) 29 | $(Q)$(CXX) $(CXXFLAGS) $(DEPCFLAGS) -c -o $@ $< 30 | 31 | $(OBJS_DIR): 32 | $(Q)mkdir -p $(OBJS_DIR) 33 | 34 | $(DEPS_DIR): 35 | $(Q)mkdir -p $(DEPS_DIR) 36 | 37 | libts++$(LIB_SUFFIX).a: $(OBJ_FILES) 38 | $(Q)/bin/rm -f $@ 39 | $(Q)$(AR) cru $@ $^ 40 | 41 | clean: 42 | $(Q)rm -f libts++*.a 43 | $(Q)rm -rf $(CUR_DIR)/.deps* 44 | $(Q)rm -rf $(CUR_DIR)/.objs* 45 | 46 | .PHONY: all clean 47 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/transaction.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | */ 4 | 5 | #include "transaction.h" 6 | 7 | wlpdstm::VersionLock wlpdstm::TransactionDynamic::version_lock_table[FULL_VERSION_LOCK_TABLE_SIZE]; 8 | 9 | CACHE_LINE_ALIGNED wlpdstm::GlobalTimestamp wlpdstm::TransactionDynamic::commit_ts; 10 | 11 | #ifndef GREEN_CM 12 | CACHE_LINE_ALIGNED wlpdstm::GlobalTimestamp wlpdstm::TransactionDynamic::cm_ts; 13 | #endif /* GREEN_CM */ 14 | 15 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionDynamic::minimum_observed_ts; 16 | 17 | CACHE_LINE_ALIGNED wlpdstm::PaddedSpinTryLock wlpdstm::TransactionDynamic::minimum_observed_ts_lock; 18 | 19 | wlpdstm::TransactionDynamic *wlpdstm::TransactionDynamic::transactions[MAX_THREADS]; 20 | 21 | Word wlpdstm::TransactionDynamic::thread_count; 22 | 23 | CACHE_LINE_ALIGNED wlpdstm::PaddedBool wlpdstm::TransactionDynamic::synchronization_in_progress; 24 | 25 | #ifdef PRIVATIZATION_QUIESCENCE 26 | CACHE_LINE_ALIGNED volatile Word wlpdstm::TransactionDynamic::quiescence_timestamp_array[MAX_THREADS]; 27 | #endif /* PRIVATIZATION_QUIESCENCE */ 28 | 29 | #ifdef DYNAMIC_DYNAMIC 30 | wlpdstm::TransactionDynamic::SetFunPtr wlpdstm::TransactionDynamic::set_fun_ptr_table[TM_IMPLEMENTATION_VARIANT_COUNT]; 31 | #endif /* DYNAMIC_DYNAMIC */ 32 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/msvc_compat/strings.h: -------------------------------------------------------------------------------- 1 | #ifndef strings_h 2 | #define strings_h 3 | 4 | /* MSVC doesn't define ffs/ffsl. This dummy strings.h header is provided 5 | * for both */ 6 | #ifdef _MSC_VER 7 | # include 8 | # pragma intrinsic(_BitScanForward) 9 | static __forceinline int ffsl(long x) 10 | { 11 | unsigned long i; 12 | 13 | if (_BitScanForward(&i, x)) 14 | return (i + 1); 15 | return (0); 16 | } 17 | 18 | static __forceinline int ffs(int x) 19 | { 20 | 21 | return (ffsl(x)); 22 | } 23 | 24 | # ifdef _M_X64 25 | # pragma intrinsic(_BitScanForward64) 26 | # endif 27 | 28 | static __forceinline int ffsll(unsigned __int64 x) 29 | { 30 | unsigned long i; 31 | #ifdef _M_X64 32 | if (_BitScanForward64(&i, x)) 33 | return (i + 1); 34 | return (0); 35 | #else 36 | // Fallback for 32-bit build where 64-bit version not available 37 | // assuming little endian 38 | union { 39 | unsigned __int64 ll; 40 | unsigned long l[2]; 41 | } s; 42 | 43 | s.ll = x; 44 | 45 | if (_BitScanForward(&i, s.l[0])) 46 | return (i + 1); 47 | else if(_BitScanForward(&i, s.l[1])) 48 | return (i + 33); 49 | return (0); 50 | #endif 51 | } 52 | 53 | #else 54 | # define ffsll(x) __builtin_ffsll(x) 55 | # define ffsl(x) __builtin_ffsl(x) 56 | # define ffs(x) __builtin_ffs(x) 57 | #endif 58 | 59 | #endif /* strings_h */ 60 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/fork.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifndef _WIN32 4 | #include 5 | #endif 6 | 7 | TEST_BEGIN(test_fork) 8 | { 9 | #ifndef _WIN32 10 | void *p; 11 | pid_t pid; 12 | 13 | p = malloc(1); 14 | assert_ptr_not_null(p, "Unexpected malloc() failure"); 15 | 16 | pid = fork(); 17 | 18 | free(p); 19 | 20 | p = malloc(64); 21 | assert_ptr_not_null(p, "Unexpected malloc() failure"); 22 | free(p); 23 | 24 | if (pid == -1) { 25 | /* Error. */ 26 | test_fail("Unexpected fork() failure"); 27 | } else if (pid == 0) { 28 | /* Child. */ 29 | exit(0); 30 | } else { 31 | int status; 32 | 33 | /* Parent. */ 34 | while (true) { 35 | if (waitpid(pid, &status, 0) == -1) 36 | test_fail("Unexpected waitpid() failure"); 37 | if (WIFSIGNALED(status)) { 38 | test_fail("Unexpected child termination due to " 39 | "signal %d", WTERMSIG(status)); 40 | break; 41 | } 42 | if (WIFEXITED(status)) { 43 | if (WEXITSTATUS(status) != 0) { 44 | test_fail( 45 | "Unexpected child exit value %d", 46 | WEXITSTATUS(status)); 47 | } 48 | break; 49 | } 50 | } 51 | } 52 | #else 53 | test_skip("fork(2) is irrelevant to Windows"); 54 | #endif 55 | } 56 | TEST_END 57 | 58 | int 59 | main(void) 60 | { 61 | 62 | return (test( 63 | test_fork)); 64 | } 65 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/timer.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void 4 | timer_start(timedelta_t *timer) 5 | { 6 | 7 | nstime_init(&timer->t0, 0); 8 | nstime_update(&timer->t0); 9 | } 10 | 11 | void 12 | timer_stop(timedelta_t *timer) 13 | { 14 | 15 | nstime_copy(&timer->t1, &timer->t0); 16 | nstime_update(&timer->t1); 17 | } 18 | 19 | uint64_t 20 | timer_usec(const timedelta_t *timer) 21 | { 22 | nstime_t delta; 23 | 24 | nstime_copy(&delta, &timer->t1); 25 | nstime_subtract(&delta, &timer->t0); 26 | return (nstime_ns(&delta) / 1000); 27 | } 28 | 29 | void 30 | timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen) 31 | { 32 | uint64_t t0 = timer_usec(a); 33 | uint64_t t1 = timer_usec(b); 34 | uint64_t mult; 35 | size_t i = 0; 36 | size_t j, n; 37 | 38 | /* Whole. */ 39 | n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1); 40 | i += n; 41 | if (i >= buflen) 42 | return; 43 | mult = 1; 44 | for (j = 0; j < n; j++) 45 | mult *= 10; 46 | 47 | /* Decimal. */ 48 | n = malloc_snprintf(&buf[i], buflen-i, "."); 49 | i += n; 50 | 51 | /* Fraction. */ 52 | while (i < buflen-1) { 53 | uint64_t round = (i+1 == buflen-1 && ((t0 * mult * 10 / t1) % 10 54 | >= 5)) ? 1 : 0; 55 | n = malloc_snprintf(&buf[i], buflen-i, 56 | "%"FMTu64, (t0 * mult / t1) % 10 + round); 57 | i += n; 58 | mult *= 10; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/prof_idump.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | const char *malloc_conf = "" 4 | #ifdef JEMALLOC_PROF 5 | "prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0" 6 | ",lg_prof_interval:0" 7 | # ifdef JEMALLOC_TCACHE 8 | "," 9 | # endif 10 | #endif 11 | #ifdef JEMALLOC_TCACHE 12 | "tcache:false" 13 | #endif 14 | ; 15 | 16 | static bool did_prof_dump_open; 17 | 18 | static int 19 | prof_dump_open_intercept(bool propagate_err, const char *filename) 20 | { 21 | int fd; 22 | 23 | did_prof_dump_open = true; 24 | 25 | fd = open("/dev/null", O_WRONLY); 26 | assert_d_ne(fd, -1, "Unexpected open() failure"); 27 | 28 | return (fd); 29 | } 30 | 31 | TEST_BEGIN(test_idump) 32 | { 33 | bool active; 34 | void *p; 35 | 36 | test_skip_if(!config_prof); 37 | 38 | active = true; 39 | assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active, 40 | sizeof(active)), 0, 41 | "Unexpected mallctl failure while activating profiling"); 42 | 43 | prof_dump_open = prof_dump_open_intercept; 44 | 45 | did_prof_dump_open = false; 46 | p = mallocx(1, 0); 47 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); 48 | dallocx(p, 0); 49 | assert_true(did_prof_dump_open, "Expected a profile dump"); 50 | } 51 | TEST_END 52 | 53 | int 54 | main(void) 55 | { 56 | 57 | return (test( 58 | test_idump)); 59 | } 60 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_SWISSTM_CONSTANTS_H_ 2 | #define WLPDSTM_SWISSTM_CONSTANTS_H_ 3 | 4 | #include "../common/constants.h" 5 | 6 | namespace wlpdstm { 7 | 8 | // this constant is useful for defining various data structures, but it should be possible 9 | // to replace it with a higher number with no problems 10 | const unsigned MAX_THREADS = 128; 11 | 12 | // the smallest timestamp used 13 | const unsigned MINIMUM_TS = 0; 14 | 15 | const unsigned WORD_LOG_SIZE = 22; 16 | 17 | const unsigned LOCK_RESERVED_BITS = 2; 18 | 19 | // -1 to get the maximum number 20 | const Word MAXIMUM_TS = (1l << (ADDRESS_SPACE_SIZE - LOCK_RESERVED_BITS)) - 1 - MAX_THREADS; 21 | 22 | // top level transaction 23 | const int TX_TOP_LEVEL = 0; 24 | const int TX_NO_LEVEL = (TX_TOP_LEVEL - 1); 25 | 26 | enum OperationType { 27 | NO_OP = 0, 28 | READ_OP = 1, 29 | WRITE_OP = 2, 30 | DELETE_OP = 3 31 | }; 32 | 33 | inline const char *getOperationName(OperationType optype) { 34 | const char *names[] = { 35 | "noop", 36 | "read", 37 | "write", 38 | "delete" 39 | }; 40 | 41 | return names[optype]; 42 | } 43 | } 44 | 45 | #define LSB 1u 46 | 47 | #define MINIMUM_VERSION ((Word *)0) 48 | 49 | #define WRITE_LOCK_CLEAR ((Word)0) 50 | 51 | #define READ_LOCK_SET ((Word)LSB) 52 | 53 | #endif /* WLPDSTM_SWISSTM_CONSTANTS_H_ */ 54 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/jemalloc_defs.h.in: -------------------------------------------------------------------------------- 1 | /* Defined if __attribute__((...)) syntax is supported. */ 2 | #undef JEMALLOC_HAVE_ATTR 3 | 4 | /* Defined if alloc_size attribute is supported. */ 5 | #undef JEMALLOC_HAVE_ATTR_ALLOC_SIZE 6 | 7 | /* Defined if format(gnu_printf, ...) attribute is supported. */ 8 | #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF 9 | 10 | /* Defined if format(printf, ...) attribute is supported. */ 11 | #undef JEMALLOC_HAVE_ATTR_FORMAT_PRINTF 12 | 13 | /* 14 | * Define overrides for non-standard allocator-related functions if they are 15 | * present on the system. 16 | */ 17 | #undef JEMALLOC_OVERRIDE_MEMALIGN 18 | #undef JEMALLOC_OVERRIDE_VALLOC 19 | 20 | /* 21 | * At least Linux omits the "const" in: 22 | * 23 | * size_t malloc_usable_size(const void *ptr); 24 | * 25 | * Match the operating system's prototype. 26 | */ 27 | #undef JEMALLOC_USABLE_SIZE_CONST 28 | 29 | /* 30 | * If defined, specify throw() for the public function prototypes when compiling 31 | * with C++. The only justification for this is to match the prototypes that 32 | * glibc defines. 33 | */ 34 | #undef JEMALLOC_USE_CXX_THROW 35 | 36 | #ifdef _MSC_VER 37 | # ifdef _WIN64 38 | # define LG_SIZEOF_PTR_WIN 3 39 | # else 40 | # define LG_SIZEOF_PTR_WIN 2 41 | # endif 42 | #endif 43 | 44 | /* sizeof(void *) == 2^LG_SIZEOF_PTR. */ 45 | #undef LG_SIZEOF_PTR 46 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_SWISSTM_CONSTANTS_H_ 2 | #define WLPDSTM_SWISSTM_CONSTANTS_H_ 3 | 4 | #include "../common/constants.h" 5 | 6 | namespace wlpdstm { 7 | 8 | // this constant is useful for defining various data structures, but it should be possible 9 | // to replace it with a higher number with no problems 10 | const unsigned MAX_THREADS = 128; 11 | 12 | // the smallest timestamp used 13 | const unsigned MINIMUM_TS = 0; 14 | 15 | const unsigned WORD_LOG_SIZE = 22; 16 | 17 | const unsigned LOCK_RESERVED_BITS = 2; 18 | 19 | // -1 to get the maximum number 20 | const Word MAXIMUM_TS = (1l << (ADDRESS_SPACE_SIZE - LOCK_RESERVED_BITS)) - 1 - MAX_THREADS; 21 | 22 | // top level transaction 23 | const int TX_TOP_LEVEL = 0; 24 | const int TX_NO_LEVEL = (TX_TOP_LEVEL - 1); 25 | 26 | enum OperationType { 27 | NO_OP = 0, 28 | READ_OP = 1, 29 | WRITE_OP = 2, 30 | DELETE_OP = 3 31 | }; 32 | 33 | inline const char *getOperationName(OperationType optype) { 34 | const char *names[] = { 35 | "noop", 36 | "read", 37 | "write", 38 | "delete" 39 | }; 40 | 41 | return names[optype]; 42 | } 43 | } 44 | 45 | #define LSB 1u 46 | 47 | #define MINIMUM_VERSION ((Word *)0) 48 | 49 | #define WRITE_LOCK_CLEAR ((Word)0) 50 | 51 | #define READ_LOCK_SET ((Word)LSB) 52 | 53 | #endif /* WLPDSTM_SWISSTM_CONSTANTS_H_ */ 54 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/spin.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct spin_s spin_t; 5 | 6 | #endif /* JEMALLOC_H_TYPES */ 7 | /******************************************************************************/ 8 | #ifdef JEMALLOC_H_STRUCTS 9 | 10 | struct spin_s { 11 | unsigned iteration; 12 | }; 13 | 14 | #endif /* JEMALLOC_H_STRUCTS */ 15 | /******************************************************************************/ 16 | #ifdef JEMALLOC_H_EXTERNS 17 | 18 | #endif /* JEMALLOC_H_EXTERNS */ 19 | /******************************************************************************/ 20 | #ifdef JEMALLOC_H_INLINES 21 | 22 | #ifndef JEMALLOC_ENABLE_INLINE 23 | void spin_init(spin_t *spin); 24 | void spin_adaptive(spin_t *spin); 25 | #endif 26 | 27 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_SPIN_C_)) 28 | JEMALLOC_INLINE void 29 | spin_init(spin_t *spin) 30 | { 31 | 32 | spin->iteration = 0; 33 | } 34 | 35 | JEMALLOC_INLINE void 36 | spin_adaptive(spin_t *spin) 37 | { 38 | volatile uint64_t i; 39 | 40 | for (i = 0; i < (KQU(1) << spin->iteration); i++) 41 | CPU_SPINWAIT; 42 | 43 | if (spin->iteration < 63) 44 | spin->iteration++; 45 | } 46 | 47 | #endif 48 | 49 | #endif /* JEMALLOC_H_INLINES */ 50 | /******************************************************************************/ 51 | 52 | -------------------------------------------------------------------------------- /unittest/Makefile: -------------------------------------------------------------------------------- 1 | CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) 2 | 3 | include $(CUR_DIR)/../Makefile.inc 4 | 5 | LIB_SUFFIX = -gtest 6 | CFLAGS += -DTS_GTEST 7 | CFLAGS += -std=c++14 -I$(INC_DIR) -I$(LIB_DIR) 8 | CFLAGS += -march=native -mtune=native -O0 9 | CFLAGS += -g -ggdb3 10 | # CFLAGS += -Werror -Wall 11 | CFLAGS += -Wno-attributes -Wno-unused-parameter -Wno-unused-value 12 | CFLAGS += -Wno-unused-function -Wno-packed-not-aligned 13 | LDFLAGS += -lgtest $(MEMMGR) $(PMEM) -lpthread 14 | 15 | DEPS_DIR := $(CUR_DIR)/.deps 16 | DEPCFLAGS = -MD -MF $(DEPS_DIR)/$*.d -MP 17 | 18 | SRC_FILES = $(wildcard *.cc) 19 | OBJS_DIR = $(CUR_DIR)/.objs 20 | OBJ_FILES = $(addprefix $(OBJS_DIR)/, $(SRC_FILES:.cc=.o)) 21 | BINS = ut-ts 22 | 23 | all: $(BINS) 24 | @for d in $(BINS); \ 25 | do ( cp $$d $(BIN_DIR); \ 26 | ); \ 27 | done 28 | 29 | ut-ts: $(OBJ_FILES) $(LIB_DIR)/libts-gtest.a $(LIB++_DIR)/libts++-gtest.a 30 | $(CXX) -o $@ $^ $(LIB_DIR)/libts-gtest.a $(LIB++_DIR)/libts++-gtest.a $(LDFLAGS) 31 | 32 | $(OBJS_DIR)/%.o: %.cc $(DEPS_DIR) $(OBJS_DIR) 33 | $(Q)$(CXX) $(CFLAGS) $(DEPCFLAGS) -c -o $@ $< 34 | 35 | $(OBJS_DIR): 36 | $(Q)mkdir -p $(OBJS_DIR) 37 | 38 | $(DEPS_DIR): 39 | $(Q)mkdir -p $(DEPS_DIR) 40 | 41 | clean: 42 | $(Q)rm -rf $(CUR_DIR)/.deps* 43 | $(Q)rm -rf $(CUR_DIR)/.objs* 44 | $(Q)rm -rf $(CUR_DIR)/ut-ts 45 | 46 | .PHONY: all clean 47 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/src/mtx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifndef _CRT_SPINCOUNT 4 | #define _CRT_SPINCOUNT 4000 5 | #endif 6 | 7 | bool 8 | mtx_init(mtx_t *mtx) 9 | { 10 | 11 | #ifdef _WIN32 12 | if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, _CRT_SPINCOUNT)) 13 | return (true); 14 | #elif (defined(JEMALLOC_OSSPIN)) 15 | mtx->lock = 0; 16 | #else 17 | pthread_mutexattr_t attr; 18 | 19 | if (pthread_mutexattr_init(&attr) != 0) 20 | return (true); 21 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT); 22 | if (pthread_mutex_init(&mtx->lock, &attr) != 0) { 23 | pthread_mutexattr_destroy(&attr); 24 | return (true); 25 | } 26 | pthread_mutexattr_destroy(&attr); 27 | #endif 28 | return (false); 29 | } 30 | 31 | void 32 | mtx_fini(mtx_t *mtx) 33 | { 34 | 35 | #ifdef _WIN32 36 | #elif (defined(JEMALLOC_OSSPIN)) 37 | #else 38 | pthread_mutex_destroy(&mtx->lock); 39 | #endif 40 | } 41 | 42 | void 43 | mtx_lock(mtx_t *mtx) 44 | { 45 | 46 | #ifdef _WIN32 47 | EnterCriticalSection(&mtx->lock); 48 | #elif (defined(JEMALLOC_OSSPIN)) 49 | OSSpinLockLock(&mtx->lock); 50 | #else 51 | pthread_mutex_lock(&mtx->lock); 52 | #endif 53 | } 54 | 55 | void 56 | mtx_unlock(mtx_t *mtx) 57 | { 58 | 59 | #ifdef _WIN32 60 | LeaveCriticalSection(&mtx->lock); 61 | #elif (defined(JEMALLOC_OSSPIN)) 62 | OSSpinLockUnlock(&mtx->lock); 63 | #else 64 | pthread_mutex_unlock(&mtx->lock); 65 | #endif 66 | } 67 | -------------------------------------------------------------------------------- /include/mvrlu.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _MVRLU_H 5 | #define _MVRLU_H 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef ts_thread_struct_t rlu_thread_data_t; 14 | 15 | #define RLU_INIT(conf) ts_init(conf); 16 | #define RLU_FINISH() ts_finish() 17 | #define RLU_PRINT_STATS() ts_print_stats() 18 | #define RLU_DESTROY_NVM() ts_destroy_nvm() 19 | 20 | #define RLU_THREAD_ALLOC() ts_thread_alloc() 21 | #define RLU_THREAD_FREE(self) ts_thread_free(self) 22 | 23 | #define RLU_THREAD_INIT(self) ts_thread_init(self) 24 | #define RLU_THREAD_FINISH(self) ts_thread_finish(self) 25 | 26 | #define RLU_READER_LOCK(self) ts_begin(self, TS_SNAPSHOT) 27 | #define RLU_READER_UNLOCK(self) ts_end(self) 28 | 29 | #define RLU_ALLOC(size) ts_alloc(size) 30 | #define RLU_FREE(self, p_obj) ts_free(self, p_obj) 31 | 32 | #define RLU_TRY_LOCK(self, p_p_obj) ts_try_lock(self, p_p_obj) 33 | #define RLU_TRY_LOCK_CONST(self, obj) ts_try_lock_const(self, obj) 34 | #define RLU_ABORT(self) ts_abort(self) 35 | 36 | #define RLU_IS_SAME_PTRS(p_obj_1, p_obj_2) ts_cmp_ptrs(p_obj_1, p_obj_2) 37 | #define RLU_ASSIGN_PTR(self, p_ptr, p_obj) ts_assign_ptr(self, p_ptr, p_obj) 38 | 39 | #define RLU_DEREF(self, p_obj) ts_deref(self, p_obj) 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* _MVRLU_H */ 46 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/timestamp.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_TIMESTAMP_H_ 2 | #define WLPDSTM_TIMESTAMP_H_ 3 | 4 | #include "constants.h" 5 | #include "../common/atomic.h" 6 | #include "../common/word.h" 7 | 8 | namespace wlpdstm { 9 | 10 | class GlobalTimestamp { 11 | public: 12 | GlobalTimestamp() : ts(MINIMUM_TS + 1) { } 13 | 14 | Word readCurrentTs() const { 15 | return ts; 16 | } 17 | 18 | Word readCurrentTsAcquire() const { 19 | return atomic_load_acquire(&ts); 20 | } 21 | 22 | Word getNextTsFull() { 23 | return fetch_and_inc_full(&ts); 24 | } 25 | 26 | Word getNextTsAcquire() { 27 | return fetch_and_inc_acquire(&ts); 28 | } 29 | 30 | Word getNextTsRelease() { 31 | return fetch_and_inc_release(&ts); 32 | } 33 | 34 | Word getNextTs() { 35 | return fetch_and_inc_no_barrier(&ts); 36 | } 37 | 38 | Word GenerateTsGV4(); 39 | 40 | void restart() { 41 | ts = MINIMUM_TS + 1; 42 | } 43 | 44 | private: 45 | Word ts; 46 | 47 | char padding[CACHE_LINE_SIZE_BYTES - sizeof(Word)]; 48 | }; 49 | } 50 | 51 | inline Word wlpdstm::GlobalTimestamp::GenerateTsGV4() { 52 | Word old_val = atomic_load_no_barrier(&ts); 53 | Word replaced_val = compare_and_swap_release(&ts, old_val, old_val + 1); 54 | 55 | if(replaced_val != old_val) { 56 | return replaced_val; 57 | } 58 | 59 | return old_val + 1; 60 | } 61 | 62 | #endif // WLPDSTM_TIMESTAMP_H_ 63 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/stm/timestamp.h: -------------------------------------------------------------------------------- 1 | #ifndef WLPDSTM_TIMESTAMP_H_ 2 | #define WLPDSTM_TIMESTAMP_H_ 3 | 4 | #include "constants.h" 5 | #include "../common/atomic.h" 6 | #include "../common/word.h" 7 | 8 | namespace wlpdstm { 9 | 10 | class GlobalTimestamp { 11 | public: 12 | GlobalTimestamp() : ts(MINIMUM_TS + 1) { } 13 | 14 | Word readCurrentTs() const { 15 | return ts; 16 | } 17 | 18 | Word readCurrentTsAcquire() const { 19 | return atomic_load_acquire(&ts); 20 | } 21 | 22 | Word getNextTsFull() { 23 | return fetch_and_inc_full(&ts); 24 | } 25 | 26 | Word getNextTsAcquire() { 27 | return fetch_and_inc_acquire(&ts); 28 | } 29 | 30 | Word getNextTsRelease() { 31 | return fetch_and_inc_release(&ts); 32 | } 33 | 34 | Word getNextTs() { 35 | return fetch_and_inc_no_barrier(&ts); 36 | } 37 | 38 | Word GenerateTsGV4(); 39 | 40 | void restart() { 41 | ts = MINIMUM_TS + 1; 42 | } 43 | 44 | private: 45 | Word ts; 46 | 47 | char padding[CACHE_LINE_SIZE_BYTES - sizeof(Word)]; 48 | }; 49 | } 50 | 51 | inline Word wlpdstm::GlobalTimestamp::GenerateTsGV4() { 52 | Word old_val = atomic_load_no_barrier(&ts); 53 | Word replaced_val = compare_and_swap_release(&ts, old_val, old_val + 1); 54 | 55 | if(replaced_val != old_val) { 56 | return replaced_val; 57 | } 58 | 59 | return old_val + 1; 60 | } 61 | 62 | #endif // WLPDSTM_TIMESTAMP_H_ 63 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/cache_aligned_alloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Allocate memory aligned on a boundary. Boundary is a power of two. 3 | * 4 | * @author Aleksandar Dragojevic 5 | */ 6 | 7 | #ifndef WLPDSTM_CACHE_ALIGNED_ALLOC_H_ 8 | #define WLPDSTM_CACHE_ALIGNED_ALLOC_H_ 9 | 10 | #include 11 | #include 12 | 13 | #include "constants.h" 14 | #include "alloc.h" 15 | 16 | namespace wlpdstm { 17 | 18 | template 19 | void *malloc_aligned(size_t size) { 20 | size_t actual_size = size + BOUNDARY + sizeof(void *); 21 | uintptr_t mem_block = (uintptr_t)MM::Malloc(actual_size); 22 | uintptr_t ret = ((mem_block + sizeof(void *) + BOUNDARY) & ~(BOUNDARY - 1)); 23 | void **back_ptr = (void **)(ret - sizeof(void *)); 24 | *back_ptr = (void *)mem_block; 25 | return (void *)ret; 26 | } 27 | 28 | template 29 | void free_aligned(void *ptr) { 30 | void **back_ptr = (void **)((uintptr_t)ptr - sizeof(void *)); 31 | MM::Free(*back_ptr); 32 | } 33 | 34 | template 35 | class AlignedAlloc { 36 | public: 37 | void *operator new(size_t size) { 38 | return malloc_aligned(size); 39 | } 40 | 41 | void operator delete(void *ptr) { 42 | free_aligned(ptr); 43 | } 44 | }; 45 | 46 | typedef AlignedAlloc CacheAlignedAlloc; 47 | } 48 | 49 | #endif /* WLPDSTM_CACHE_ALIGNED_ALLOC_H_ */ 50 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/extent_dss.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef enum { 5 | dss_prec_disabled = 0, 6 | dss_prec_primary = 1, 7 | dss_prec_secondary = 2, 8 | 9 | dss_prec_limit = 3 10 | } dss_prec_t; 11 | #define DSS_PREC_DEFAULT dss_prec_secondary 12 | #define DSS_DEFAULT "secondary" 13 | 14 | #endif /* JEMALLOC_H_TYPES */ 15 | /******************************************************************************/ 16 | #ifdef JEMALLOC_H_STRUCTS 17 | 18 | extern const char *dss_prec_names[]; 19 | 20 | #endif /* JEMALLOC_H_STRUCTS */ 21 | /******************************************************************************/ 22 | #ifdef JEMALLOC_H_EXTERNS 23 | 24 | extern const char *opt_dss; 25 | 26 | dss_prec_t extent_dss_prec_get(void); 27 | bool extent_dss_prec_set(dss_prec_t dss_prec); 28 | void *extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, 29 | size_t size, size_t alignment, bool *zero, bool *commit); 30 | bool extent_in_dss(void *addr); 31 | bool extent_dss_mergeable(void *addr_a, void *addr_b); 32 | void extent_dss_boot(void); 33 | 34 | #endif /* JEMALLOC_H_EXTERNS */ 35 | /******************************************************************************/ 36 | #ifdef JEMALLOC_H_INLINES 37 | 38 | #endif /* JEMALLOC_H_INLINES */ 39 | /******************************************************************************/ 40 | -------------------------------------------------------------------------------- /tools/ordo/gen_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import os 7 | import subprocess 8 | 9 | from itertools import combinations 10 | 11 | import gen_cpuseq 12 | 13 | iters = 1000000 14 | 15 | 16 | def sh(*args): 17 | out = subprocess.check_output(args) 18 | #return out.decode("utf8").strip() 19 | return out.strip() 20 | 21 | 22 | def get_cores(): 23 | return [int(cpu["processor"]) for cpu in gen_cpuseq.seq(gen_cpuseq.cpuinfo)] 24 | 25 | 26 | def __get_values(a, b): 27 | tok = sh("o/reftable", str(a), str(b), str(iters)).split(" ") 28 | tok = tok[0].split('\n') 29 | tok = map(lambda x: int(x), tok) 30 | f = open('output/%d-%d.txt' % (a, b), 'w') 31 | for i in tok: 32 | f.write("%d\n" % i) 33 | f.close() 34 | return min(tok) 35 | 36 | 37 | def build_table(a, b): 38 | return min(__get_values(a, b), __get_values(b, a)) 39 | 40 | def __ensure_output_dir(): 41 | output_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'output') 42 | if os.path.isdir(output_path): 43 | return 44 | os.makedirs(output_path) 45 | 46 | max_offset = 0 47 | __ensure_output_dir() 48 | for (a, b) in combinations(get_cores(), 2): 49 | key = (min(a, b), max(a, b)) 50 | max_offset = max(build_table(*key), max_offset) 51 | print ("(%d, %d) ... done" % (a, b)) 52 | print (max_offset) 53 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/jemalloc_defs.h: -------------------------------------------------------------------------------- 1 | /* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */ 2 | /* Defined if __attribute__((...)) syntax is supported. */ 3 | #define JEMALLOC_HAVE_ATTR 4 | 5 | /* Defined if alloc_size attribute is supported. */ 6 | #define JEMALLOC_HAVE_ATTR_ALLOC_SIZE 7 | 8 | /* Defined if format(gnu_printf, ...) attribute is supported. */ 9 | #define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF 10 | 11 | /* Defined if format(printf, ...) attribute is supported. */ 12 | #define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF 13 | 14 | /* 15 | * Define overrides for non-standard allocator-related functions if they are 16 | * present on the system. 17 | */ 18 | #define JEMALLOC_OVERRIDE_MEMALIGN 19 | #define JEMALLOC_OVERRIDE_VALLOC 20 | 21 | /* 22 | * At least Linux omits the "const" in: 23 | * 24 | * size_t malloc_usable_size(const void *ptr); 25 | * 26 | * Match the operating system's prototype. 27 | */ 28 | #define JEMALLOC_USABLE_SIZE_CONST 29 | 30 | /* 31 | * If defined, specify throw() for the public function prototypes when compiling 32 | * with C++. The only justification for this is to match the prototypes that 33 | * glibc defines. 34 | */ 35 | #define JEMALLOC_USE_CXX_THROW 36 | 37 | #ifdef _MSC_VER 38 | # ifdef _WIN64 39 | # define LG_SIZEOF_PTR_WIN 3 40 | # else 41 | # define LG_SIZEOF_PTR_WIN 2 42 | # endif 43 | #endif 44 | 45 | /* sizeof(void *) == 2^LG_SIZEOF_PTR. */ 46 | #define LG_SIZEOF_PTR 3 47 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/jemalloc_mangle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | public_symbols_txt=$1 4 | symbol_prefix=$2 5 | 6 | cat < 10 | #include 11 | #include "atomic.h" 12 | 13 | // NOTE: AMD64 does not work with a "=A" (ret) version 14 | // have to check if Intel in 64 bit mode would work 15 | inline uint64_t get_clock_count() { 16 | #ifdef WLPDSTM_X86 17 | # ifdef WLPDSTM_32 18 | uint64_t ret; 19 | __asm__ volatile ("rdtsc" : "=A" (ret)); 20 | return ret; 21 | # elif defined WLPDSTM_64 22 | uint32_t low, high; 23 | __asm__ volatile("rdtsc" : "=a" (low), "=d" (high)); 24 | return (uint64_t)low | (((uint64_t)high) << 32); 25 | # endif /* WLPDSTM_64 */ 26 | #elif defined WLPDSTM_SPARC && defined WLPDSTM_64 27 | uint64_t ret; 28 | __asm__ __volatile__ ("rd %%tick, %0" : "=r" (ret)); 29 | return ret; 30 | #else 31 | // avoid compiler complaints 32 | return 0; 33 | #endif /* arch */ 34 | } 35 | 36 | inline void wait_cycles(uint64_t cycles) { 37 | uint64_t start = get_clock_count(); 38 | uint64_t end; 39 | 40 | while(true) { 41 | end = get_clock_count(); 42 | 43 | if(end - start > cycles) { 44 | break; 45 | } 46 | } 47 | } 48 | 49 | inline void sleep_ns(uint64_t ns) { 50 | #ifdef WLPDSTM_SOLARIS 51 | timespec ts; 52 | ts.tv_sec = 0; 53 | ts.tv_nsec = ns; 54 | nanosleep(&ts, NULL); 55 | #endif /* WLPDSTM_SOLARIS */ 56 | } 57 | 58 | #endif /* WLPDSTM_TIMING_H_ */ 59 | 60 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/dynamic/perf_cnt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * The implementing classes should implement the following interface: 3 | * 4 | * - GlobalInit() 5 | * - ThreadInit() 6 | * - TxStart() 7 | * - TxEnd() 8 | * valid after TxEnd() is called: 9 | * - uint64_t GetElapsedCycles() 10 | * - uint64_t GetRetiredInstructions() 11 | * 12 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 13 | */ 14 | 15 | #ifndef WLPDSTM_PERF_CNT_H_ 16 | #define WLPDSTM_PERF_CNT_H_ 17 | 18 | #include "../common/perfcnt/perf_cnt_impl.h" 19 | 20 | namespace wlpdstm { 21 | 22 | class PerfCnt { 23 | public: 24 | void ThreadInit() { 25 | pcnt.Init(); 26 | } 27 | 28 | void TxStart() { 29 | pcnt.Start(); 30 | } 31 | 32 | void TxEnd() { 33 | pcnt.End(); 34 | } 35 | 36 | static void GlobalInit() { 37 | PerfCntImpl::GlobalInit(); 38 | } 39 | 40 | uint64_t GetElapsedCycles() { 41 | return pcnt.GetElapsedCycles(); 42 | } 43 | 44 | uint64_t GetRetiredInstructions() { 45 | return pcnt.GetRetiredInstructions(); 46 | } 47 | 48 | uint64_t GetCacheMisses() { 49 | return pcnt.GetCacheMisses(); 50 | } 51 | 52 | protected: 53 | PerfCntImpl pcnt; 54 | }; 55 | 56 | } 57 | 58 | #endif /* WLPDSTM_PERF_CNT_H_ */ 59 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.intel: -------------------------------------------------------------------------------- 1 | include Makefile.intel.in 2 | 3 | INTEL_OBJFILES = $(INTEL_OBJ_DIR)/tid.o $(INTEL_OBJ_DIR)/transaction.o $(INTEL_OBJ_DIR)/privatization_tree.o \ 4 | $(INTEL_OBJ_DIR)/jmp.o $(INTEL_OBJ_DIR)/itm.o #$(INTEL_OBJ_DIR)/memory.o 5 | 6 | all: $(INTEL_OBJ_DIR) $(INTEL_LIB_DIR) $(INTEL_LIB).a #$(MUBENCH) 7 | 8 | MUBENCH = $(INTEL_OBJ_DIR)/intset-rbtree-intel 9 | 10 | .PHONY: all clean 11 | 12 | ############### 13 | # create dirs # 14 | ############### 15 | 16 | $(INTEL_OBJ_DIR): 17 | mkdir -p $(INTEL_OBJ_DIR) 18 | 19 | $(INTEL_LIB_DIR): 20 | mkdir -p $(INTEL_LIB_DIR) 21 | 22 | ################## 23 | # create library # 24 | ################## 25 | 26 | $(INTEL_LIB).a: $(INTEL_OBJFILES) 27 | $(AR) cru $@ $^ 28 | 29 | $(INTEL_OBJ_DIR)/tid.o: $(SRC_DIR)/stm/tid.cc 30 | $(CPP) $(CPPFLAGS) -c -o $@ $< 31 | 32 | $(INTEL_OBJ_DIR)/transaction.o: $(SRC_DIR)/stm/transaction.cc 33 | $(CPP) $(CPPFLAGS) -c -o $@ $< 34 | 35 | $(INTEL_OBJ_DIR)/privatization_tree.o: $(SRC_DIR)/stm/privatization_tree.cc 36 | $(CPP) $(CPPFLAGS) -c -o $@ $< 37 | 38 | $(INTEL_OBJ_DIR)/itm.o: $(SRC_DIR)/intel/itm.cc 39 | $(CPP) $(CPPFLAGS) -Qtm_enabled -c -o $@ $< 40 | 41 | #$(INTEL_OBJ_DIR)/memory.o: $(SRC_DIR)/intel/memory.cc 42 | # $(CPP) $(CPPFLAGS) -Qtm_enabled -c -o $@ $< 43 | 44 | $(INTEL_OBJ_DIR)/jmp.o: $(SRC_DIR)/intel/jmp.s 45 | $(AS) -o $@ $< 46 | 47 | 48 | ######### 49 | # clean # 50 | ######### 51 | 52 | clean: 53 | rm -rf $(INTEL_LIB).a 54 | rm -rf $(INTEL_OBJ_DIR) 55 | rm -rf intset-rbtree-intel 56 | 57 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/mubench/time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * All functions related to time are defined in this header file. The 3 | * principle behind is to use as light-weight wrappers as possible. 4 | * 5 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 6 | */ 7 | 8 | #ifndef MUBENCH_TIME_H_ 9 | #define MUBENCH_TIME_H_ 10 | 11 | #include 12 | 13 | 14 | /** 15 | * Get time in ms since epoch. This function might be architecture 16 | * specific. 17 | */ 18 | uint64_t get_time_ms(); 19 | 20 | #define MILLISECONDS_IN_SECOND 1000 21 | #define NANOSECONDS_IN_MILLISECOND 1000000 22 | 23 | #if defined MUBENCH_LINUXOS || defined MUBENCH_SOLARIS 24 | 25 | #define NANOSECONDS_IN_SECOND 1000000000 26 | 27 | #include 28 | #include 29 | 30 | // define functions as inline here 31 | inline uint64_t get_time_ms() { 32 | struct timespec t; 33 | clock_gettime(CLOCK_REALTIME, &t); 34 | return t.tv_sec * MILLISECONDS_IN_SECOND + 35 | t.tv_nsec / NANOSECONDS_IN_MILLISECOND; 36 | } 37 | 38 | #elif defined MUBENCH_MACOS 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | inline uint64_t get_time_ns() { 46 | uint64_t time = mach_absolute_time(); 47 | Nanoseconds nano = AbsoluteToNanoseconds(*(AbsoluteTime *)&time); 48 | return *(uint64_t *)&nano; 49 | } 50 | 51 | inline uint64_t get_time_ms() { 52 | return get_time_ns() / NANOSECONDS_IN_MILLISECOND; 53 | } 54 | 55 | 56 | #endif /* arch */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /benchmark/versioning/benchmark_list.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_LIST_H 2 | #define BENCHMARK_LIST_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | typedef struct barrier { 10 | pthread_cond_t complete; 11 | pthread_mutex_t mutex; 12 | int count; 13 | int crossing; 14 | } barrier_t; 15 | 16 | #define CACHE_ALIGN (192) 17 | 18 | #define CACHE_ALIGN_SIZE(size) ((((size - 1) / CACHE_ALIGN) + 1) * CACHE_ALIGN) 19 | 20 | #define PTHREAD_PADDING (16) 21 | 22 | typedef struct pthread_data { 23 | long pthread_padding[PTHREAD_PADDING]; 24 | long id; 25 | unsigned long nr_ins; 26 | unsigned long nr_del; 27 | unsigned long nr_find; 28 | unsigned long nr_txn; 29 | unsigned long nr_abort; 30 | int range; 31 | int update_ratio; 32 | unsigned int seed; 33 | int zipf; 34 | double zipf_dist_val; 35 | barrier_t *barrier; 36 | void *list; 37 | void *ds_data; // data structure specific data 38 | } pthread_data_t; 39 | 40 | #ifdef MVRLU 41 | void thread_finish(pthread_data_t *d); 42 | void global_finish(); 43 | void destroy_nvm(); 44 | #endif 45 | 46 | pthread_data_t *alloc_pthread_data(void); 47 | void free_pthread_data(pthread_data_t *d); 48 | 49 | void *list_global_init(int init_size, int value_range); 50 | int list_thread_init(pthread_data_t *data, pthread_data_t **sync_data, int nr_threads); 51 | void list_global_exit(void *list); 52 | 53 | int list_ins(int key, pthread_data_t *data); 54 | int list_del(int key, pthread_data_t *data); 55 | int list_find(int key, pthread_data_t *data); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2010 LPD EPFL. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY LPD EPFL ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | SHALL LPD EPFL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 18 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 22 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | The views and conclusions contained in the software and documentation are those 25 | of the authors and should not be interpreted as representing official policies, 26 | either expressed or implied, of LPD EPFL. 27 | 28 | -------------------------------------------------------------------------------- /benchmark/rlu/list_vlist.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIST_VLIST_H_ 2 | #define _LIST_VLIST_H_ 3 | #include 4 | 5 | #include "qsbr.h" 6 | #include "util.h" 7 | #include 8 | #include "types.h" 9 | 10 | #define CACHE_ALIGN (192) 11 | #define CACHE_ALIGN_SIZE(size) ((((size - 1) / CACHE_ALIGN) + 1) * CACHE_ALIGN) 12 | 13 | 14 | 15 | #if 0 16 | typedef struct node { 17 | int value; 18 | vlist_slot_t *slots; 19 | } node_t; 20 | #endif 21 | #if 0 22 | typedef struct vlist_list { 23 | node_t *head; 24 | } vlist_list_t; 25 | #endif 26 | 27 | typedef struct vlist_pthread_data { 28 | vlist_record_t *rec; 29 | unsigned long epoch; 30 | vlist_record_t *new_rec; 31 | unsigned long count; 32 | qsbr_pthread_data_t *qsbr_data; 33 | qsbr_pthread_data_t qsbr_data_inst; 34 | } vlist_pthread_data_t; 35 | #define INDIRECT_EPOCH 0 36 | #define INACTIVE_EPOCH 1 37 | #define STARTING_EPOCH 2 38 | 39 | 40 | #define QSBR_PERIOD 100 41 | void vlist_maybe_quiescent(vlist_pthread_data_t *vlist_data); 42 | node_t *vlist_new_node(); 43 | void add_slot(node_t *node, node_t *next, vlist_pthread_data_t *vlist_data); 44 | void vlist_free_node_later(node_t *node, vlist_pthread_data_t *vlist_data); 45 | void vlist_set_read_epoch(vlist_pthread_data_t *vlist_data); 46 | void vlist_read_cs_enter(vlist_pthread_data_t *vlist_data); 47 | void vlist_read_cs_exit(vlist_pthread_data_t *vlist_data); 48 | void vlist_write_cs_enter(vlist_pthread_data_t *vlist_data); 49 | int vlist_write_cs_exit(vlist_pthread_data_t *vlist_data); 50 | int list_thread_init(vlist_pthread_data_t *data, vlist_pthread_data_t **sync_data, int nr_threads); 51 | #endif 52 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/epochstm/constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #ifndef WLPDSTM_EPOCHSTM_CONSTANTS_H_ 7 | #define WLPDSTM_EPOCHSTM_CONSTANTS_H_ 8 | 9 | #include 10 | 11 | #include "../common/constants.h" 12 | 13 | //#define EPOCH_SIZE_IN_BYTES_1 14 | #define EPOCH_SIZE_IN_BYTES_2 15 | 16 | namespace wlpdstm { 17 | 18 | // this depends on the number of available hw threads 19 | // it can safely be a lower number than the number of 20 | // hw threads, as some background threads need to execute too 21 | // (e.g. 60 or maybe even 56 is enough on Niagara) 22 | const unsigned MAX_THREADS = 64; 23 | 24 | const unsigned MAX_CLEANUP_THREADS = 128; 25 | 26 | const unsigned MIN_EPOCH = 1; 27 | const unsigned NO_EPOCH = MIN_EPOCH - 1; 28 | 29 | #ifdef EPOCH_SIZE_IN_BYTES_1 30 | 31 | typedef uint8_t Epoch; 32 | 33 | const unsigned MAX_EPOCH = 255; 34 | const uint8_t EPOCH_MASK = 0xff; 35 | 36 | #elif defined EPOCH_SIZE_IN_BYTES_2 37 | 38 | typedef uint16_t Epoch; 39 | 40 | const unsigned MAX_EPOCH = (1 << 16) - 1; 41 | const uint16_t EPOCH_MASK = 0xffff; 42 | 43 | #endif /* EPOCH_SIZE_IN_BYTES_1 */ 44 | 45 | const unsigned EPOCHS_IN_WORD = sizeof(Word) / sizeof(Epoch); 46 | const unsigned OREC_EPOCH_SIZE_WORDS = MAX_THREADS / EPOCHS_IN_WORD + (MAX_THREADS % EPOCHS_IN_WORD ? 1 : 0); 47 | 48 | // this should help with speeding up reader checks and cleanups 49 | const uint64_t NO_READERS_64 = (uint64_t)0; 50 | const Word NO_READERS_WORD = (Word)0; 51 | } 52 | 53 | #endif /* WLPDSTM_EPOCHSTM_CONSTANTS_H_ */ 54 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/integration/overflow.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_overflow) 4 | { 5 | unsigned nlextents; 6 | size_t mib[4]; 7 | size_t sz, miblen, max_size_class; 8 | void *p; 9 | 10 | sz = sizeof(unsigned); 11 | assert_d_eq(mallctl("arenas.nlextents", (void *)&nlextents, &sz, NULL, 12 | 0), 0, "Unexpected mallctl() error"); 13 | 14 | miblen = sizeof(mib) / sizeof(size_t); 15 | assert_d_eq(mallctlnametomib("arenas.lextent.0.size", mib, &miblen), 0, 16 | "Unexpected mallctlnametomib() error"); 17 | mib[2] = nlextents - 1; 18 | 19 | sz = sizeof(size_t); 20 | assert_d_eq(mallctlbymib(mib, miblen, (void *)&max_size_class, &sz, 21 | NULL, 0), 0, "Unexpected mallctlbymib() error"); 22 | 23 | assert_ptr_null(malloc(max_size_class + 1), 24 | "Expected OOM due to over-sized allocation request"); 25 | assert_ptr_null(malloc(SIZE_T_MAX), 26 | "Expected OOM due to over-sized allocation request"); 27 | 28 | assert_ptr_null(calloc(1, max_size_class + 1), 29 | "Expected OOM due to over-sized allocation request"); 30 | assert_ptr_null(calloc(1, SIZE_T_MAX), 31 | "Expected OOM due to over-sized allocation request"); 32 | 33 | p = malloc(1); 34 | assert_ptr_not_null(p, "Unexpected malloc() OOM"); 35 | assert_ptr_null(realloc(p, max_size_class + 1), 36 | "Expected OOM due to over-sized allocation request"); 37 | assert_ptr_null(realloc(p, SIZE_T_MAX), 38 | "Expected OOM due to over-sized allocation request"); 39 | free(p); 40 | } 41 | TEST_END 42 | 43 | int 44 | main(void) 45 | { 46 | 47 | return (test( 48 | test_overflow)); 49 | } 50 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/pages.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | /* Page size. LG_PAGE is determined by the configure script. */ 5 | #ifdef PAGE_MASK 6 | # undef PAGE_MASK 7 | #endif 8 | #define PAGE ((size_t)(1U << LG_PAGE)) 9 | #define PAGE_MASK ((size_t)(PAGE - 1)) 10 | 11 | /* Return the page base address for the page containing address a. */ 12 | #define PAGE_ADDR2BASE(a) \ 13 | ((void *)((uintptr_t)(a) & ~PAGE_MASK)) 14 | 15 | /* Return the smallest pagesize multiple that is >= s. */ 16 | #define PAGE_CEILING(s) \ 17 | (((s) + PAGE_MASK) & ~PAGE_MASK) 18 | 19 | #endif /* JEMALLOC_H_TYPES */ 20 | /******************************************************************************/ 21 | #ifdef JEMALLOC_H_STRUCTS 22 | 23 | #endif /* JEMALLOC_H_STRUCTS */ 24 | /******************************************************************************/ 25 | #ifdef JEMALLOC_H_EXTERNS 26 | 27 | void *pages_map(void *addr, size_t size, bool *commit); 28 | void pages_unmap(void *addr, size_t size); 29 | void *pages_trim(void *addr, size_t alloc_size, size_t leadsize, 30 | size_t size, bool *commit); 31 | bool pages_commit(void *addr, size_t size); 32 | bool pages_decommit(void *addr, size_t size); 33 | bool pages_purge(void *addr, size_t size); 34 | void pages_boot(void); 35 | 36 | #endif /* JEMALLOC_H_EXTERNS */ 37 | /******************************************************************************/ 38 | #ifdef JEMALLOC_H_INLINES 39 | 40 | #endif /* JEMALLOC_H_INLINES */ 41 | /******************************************************************************/ 42 | 43 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/membar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * It seems it might be better to have various types of memory barrires explicitly defined 3 | * instead of coupling them with memory accesses like done in atomic_ops library. 4 | * 5 | * The naming scheme for different barriers is: 6 | * 7 | * (membar__)+ 8 | * 9 | * This means that all op1 types have to execute before the next op2. op1 and op2 can 10 | * be either load or store. 11 | * 12 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 13 | */ 14 | 15 | #ifndef WLPDSTM_MEMBAR_H_ 16 | #define WLPDSTM_MEMBAR_H_ 17 | 18 | #ifdef WLPDSTM_X86 19 | 20 | inline void membar_full() { 21 | asm volatile("mfence":::"memory"); 22 | } 23 | 24 | inline void membar_store_load_membar_store_store() { 25 | membar_full(); 26 | } 27 | 28 | inline void membar_load_store_membar_store_store() { 29 | membar_full(); 30 | } 31 | 32 | inline void membar_store_load() { 33 | membar_full(); 34 | } 35 | 36 | inline void membar_store_store() { 37 | membar_full(); 38 | } 39 | 40 | #elif defined WLPDSTM_SPARC 41 | 42 | inline void membar_store_load_membar_store_store() { 43 | asm volatile ("membar #StoreLoad;" 44 | "membar #StoreStore" 45 | :::"memory"); 46 | } 47 | 48 | inline void membar_load_store_membar_store_store() { 49 | asm volatile ("membar #LoadStore;" 50 | "membar #StoreStore" 51 | :::"memory"); 52 | } 53 | 54 | inline void membar_store_load() { 55 | asm volatile ("membar #StoreLoad":::"memory"); 56 | } 57 | 58 | inline void membar_store_store() { 59 | asm volatile ("membar #StoreStore":::"memory"); 60 | } 61 | 62 | #endif /* arch */ 63 | 64 | #endif /* WLPDSTM_MEMBAR_H_ */ 65 | 66 | -------------------------------------------------------------------------------- /tools/ordo/bench.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #if defined (__SVR4) && defined (__sun) 19 | #include 20 | #include 21 | #include 22 | #endif 23 | 24 | #include "bench.h" 25 | #include "cpuseq.h" 26 | 27 | void die(const char* errstr, ...) 28 | { 29 | va_list ap; 30 | 31 | va_start(ap, errstr); 32 | vfprintf(stderr, errstr, ap); 33 | va_end(ap); 34 | fprintf(stderr, "\n"); 35 | exit(EXIT_FAILURE); 36 | } 37 | 38 | void edie(const char* errstr, ...) 39 | { 40 | va_list ap; 41 | 42 | va_start(ap, errstr); 43 | vfprintf(stderr, errstr, ap); 44 | va_end(ap); 45 | fprintf(stderr, ": %s\n", strerror(errno)); 46 | exit(EXIT_FAILURE); 47 | } 48 | 49 | void setaffinity(int c) 50 | { 51 | #if defined (__SVR4) && defined (__sun) 52 | processorid_t obind; 53 | if (processor_bind(P_LWPID, P_MYID, c, &obind) < 0) 54 | edie("setaffinity, processor_bind failed"); 55 | #else 56 | cpu_set_t cpuset; 57 | CPU_ZERO(&cpuset); 58 | CPU_SET(cpuseq[c], &cpuset); 59 | if (sched_setaffinity(0, sizeof(cpuset), &cpuset) < 0) 60 | edie("setaffinity, sched_setaffinity failed"); 61 | #endif 62 | } 63 | 64 | uint64_t usec(void) 65 | { 66 | struct timeval tv; 67 | gettimeofday(&tv, 0); 68 | return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec; 69 | } 70 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/tanger/tanger_string.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include 7 | 8 | #include "tanger-stm-std-string.h" 9 | 10 | #include "../stm/read_write.h" 11 | #include "../stm/transaction.h" 12 | 13 | extern "C" { 14 | 15 | // extern void *tanger_stm_std_memset(void *dest, int c, size_t n) __attribute__((weak)); 16 | extern void *tanger_stm_std_memset(void *dest, int c, size_t n) { 17 | return wlpdstm::memset_tx(wlpdstm::CurrentTransaction::Get(), dest, c, n); 18 | } 19 | 20 | // extern void *tanger_stm_std_memcpy(void *dest, const void *src, size_t n) __attribute__((weak)); 21 | extern void *tanger_stm_std_memcpy(void *dest, const void *src, size_t n) { 22 | return wlpdstm::memcpy_tx(wlpdstm::CurrentTransaction::Get(), dest, src, n); 23 | } 24 | 25 | // extern void *tanger_stm_std_memmove(void *dest, const void *src, size_t n) __attribute__((weak)); 26 | extern void *tanger_stm_std_memmove(void *dest, const void *src, size_t n) { 27 | return wlpdstm::memmove_tx(wlpdstm::CurrentTransaction::Get(), dest, src, n); 28 | } 29 | 30 | extern int tanger_stm_std_strcmp(const char *str1, const char *str2) __attribute__((weak)); 31 | extern int tanger_stm_std_strcmp(const char *str1, const char *str2) { 32 | return wlpdstm::strcmp_tx(wlpdstm::CurrentTransaction::Get(), str1, str2); 33 | } 34 | 35 | extern int tanger_stm_std_strncmp(const char *str1, const char *str2, size_t num) __attribute__((weak)); 36 | extern int tanger_stm_std_strncmp(const char *str1, const char *str2, size_t num) { 37 | return wlpdstm::strncmp_tx(wlpdstm::CurrentTransaction::Get(), str1, str2, num); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/zero.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifdef JEMALLOC_FILL 4 | const char *malloc_conf = 5 | "abort:false,junk:false,zero:true"; 6 | #endif 7 | 8 | static void 9 | test_zero(size_t sz_min, size_t sz_max) 10 | { 11 | uint8_t *s; 12 | size_t sz_prev, sz, i; 13 | #define MAGIC ((uint8_t)0x61) 14 | 15 | sz_prev = 0; 16 | s = (uint8_t *)mallocx(sz_min, 0); 17 | assert_ptr_not_null((void *)s, "Unexpected mallocx() failure"); 18 | 19 | for (sz = sallocx(s, 0); sz <= sz_max; 20 | sz_prev = sz, sz = sallocx(s, 0)) { 21 | if (sz_prev > 0) { 22 | assert_u_eq(s[0], MAGIC, 23 | "Previously allocated byte %zu/%zu is corrupted", 24 | ZU(0), sz_prev); 25 | assert_u_eq(s[sz_prev-1], MAGIC, 26 | "Previously allocated byte %zu/%zu is corrupted", 27 | sz_prev-1, sz_prev); 28 | } 29 | 30 | for (i = sz_prev; i < sz; i++) { 31 | assert_u_eq(s[i], 0x0, 32 | "Newly allocated byte %zu/%zu isn't zero-filled", 33 | i, sz); 34 | s[i] = MAGIC; 35 | } 36 | 37 | if (xallocx(s, sz+1, 0, 0) == sz) { 38 | s = (uint8_t *)rallocx(s, sz+1, 0); 39 | assert_ptr_not_null((void *)s, 40 | "Unexpected rallocx() failure"); 41 | } 42 | } 43 | 44 | dallocx(s, 0); 45 | #undef MAGIC 46 | } 47 | 48 | TEST_BEGIN(test_zero_small) 49 | { 50 | 51 | test_skip_if(!config_fill); 52 | test_zero(1, SMALL_MAXCLASS-1); 53 | } 54 | TEST_END 55 | 56 | TEST_BEGIN(test_zero_large) 57 | { 58 | 59 | test_skip_if(!config_fill); 60 | test_zero(SMALL_MAXCLASS+1, (1U << (LG_LARGE_MINCLASS+1))); 61 | } 62 | TEST_END 63 | 64 | int 65 | main(void) 66 | { 67 | 68 | return (test( 69 | test_zero_small, 70 | test_zero_large)); 71 | } 72 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * These are the general constants used in all STM implementations. 3 | * 4 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 5 | */ 6 | 7 | #ifndef WLPDSTM_CONSTANTS_H_ 8 | #define WLPDSTM_CONSTANTS_H_ 9 | 10 | #ifdef WLPDSTM_X86 11 | #define CACHE_LINE_SIZE_BYTES 64 12 | #define LOG_CACHE_LINE_SIZE_BYTES 6 13 | #elif defined WLPDSTM_SPARC 14 | #define CACHE_LINE_SIZE_BYTES 64 15 | #define LOG_CACHE_LINE_SIZE_BYTES 6 16 | #endif /* arch */ 17 | 18 | #define CACHE_LINE_ALIGNED __attribute__((aligned(CACHE_LINE_SIZE_BYTES))) 19 | 20 | #include "word.h" 21 | 22 | namespace wlpdstm { 23 | 24 | #ifdef WLPDSTM_32 25 | const unsigned ADDRESS_SPACE_SIZE = 32; 26 | const unsigned LOG_BYTES_IN_WORD = 2; 27 | #elif defined WLPDSTM_64 28 | const unsigned ADDRESS_SPACE_SIZE = 64; 29 | const unsigned LOG_BYTES_IN_WORD = 3; 30 | #endif /* X86_64 */ 31 | 32 | static const Word LOG_ENTRY_UNMASKED = ~0x0; 33 | 34 | const uintptr_t BYTES_IN_WORD = 1 << LOG_BYTES_IN_WORD; 35 | const uintptr_t WORD_ADDRESS_MASK = BYTES_IN_WORD - 1; 36 | 37 | inline Word *get_word_address(void *address) { 38 | return (Word *)((uintptr_t)address & ~WORD_ADDRESS_MASK); 39 | } 40 | 41 | inline unsigned get_byte_in_word_index(void *address) { 42 | return (uintptr_t)address & (uintptr_t)WORD_ADDRESS_MASK; 43 | } 44 | 45 | union word_to_bytes { 46 | uint8_t bytes[BYTES_IN_WORD]; 47 | Word word; 48 | }; 49 | 50 | const int MAX_LEXICAL_TX = 64; 51 | } 52 | 53 | #define NO_LEXICAL_TX -1 54 | 55 | // The size of start_buf paddig in cache lines. 56 | // This should be bigger than the biggest start_buf, or will cause cache misses. 57 | #define START_BUF_PADDING_SIZE 10 58 | 59 | #endif /* WLPDSTM_CONSTANTS_H_ */ 60 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/integration/MALLOCX_ARENA.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define NTHREADS 10 4 | 5 | static bool have_dss = 6 | #ifdef JEMALLOC_DSS 7 | true 8 | #else 9 | false 10 | #endif 11 | ; 12 | 13 | void * 14 | thd_start(void *arg) 15 | { 16 | unsigned thread_ind = (unsigned)(uintptr_t)arg; 17 | unsigned arena_ind; 18 | void *p; 19 | size_t sz; 20 | 21 | sz = sizeof(arena_ind); 22 | assert_d_eq(mallctl("arenas.extend", (void *)&arena_ind, &sz, NULL, 0), 23 | 0, "Error in arenas.extend"); 24 | 25 | if (thread_ind % 4 != 3) { 26 | size_t mib[3]; 27 | size_t miblen = sizeof(mib) / sizeof(size_t); 28 | const char *dss_precs[] = {"disabled", "primary", "secondary"}; 29 | unsigned prec_ind = thread_ind % 30 | (sizeof(dss_precs)/sizeof(char*)); 31 | const char *dss = dss_precs[prec_ind]; 32 | int expected_err = (have_dss || prec_ind == 0) ? 0 : EFAULT; 33 | assert_d_eq(mallctlnametomib("arena.0.dss", mib, &miblen), 0, 34 | "Error in mallctlnametomib()"); 35 | mib[1] = arena_ind; 36 | assert_d_eq(mallctlbymib(mib, miblen, NULL, NULL, (void *)&dss, 37 | sizeof(const char *)), expected_err, 38 | "Error in mallctlbymib()"); 39 | } 40 | 41 | p = mallocx(1, MALLOCX_ARENA(arena_ind)); 42 | assert_ptr_not_null(p, "Unexpected mallocx() error"); 43 | dallocx(p, 0); 44 | 45 | return (NULL); 46 | } 47 | 48 | TEST_BEGIN(test_MALLOCX_ARENA) 49 | { 50 | thd_t thds[NTHREADS]; 51 | unsigned i; 52 | 53 | for (i = 0; i < NTHREADS; i++) { 54 | thd_create(&thds[i], thd_start, 55 | (void *)(uintptr_t)i); 56 | } 57 | 58 | for (i = 0; i < NTHREADS; i++) 59 | thd_join(thds[i], NULL); 60 | } 61 | TEST_END 62 | 63 | int 64 | main(void) 65 | { 66 | 67 | return (test( 68 | test_MALLOCX_ARENA)); 69 | } 70 | -------------------------------------------------------------------------------- /benchmark/rlu/hazard_ptrs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HAZARD_PTRS_H 3 | #define HAZARD_PTRS 1 4 | 5 | ///////////////////////////////////////////////////////// 6 | // INCLUDES 7 | ///////////////////////////////////////////////////////// 8 | #ifdef __x86_64 9 | #include 10 | #endif 11 | 12 | ///////////////////////////////////////////////////////// 13 | // DEFINES 14 | ///////////////////////////////////////////////////////// 15 | #define IS_HP_ENABLED 16 | 17 | #define HP_MAX_RECORDS (100) 18 | 19 | ///////////////////////////////////////////////////////// 20 | // TYPES 21 | ///////////////////////////////////////////////////////// 22 | typedef struct _hp_record_t { 23 | volatile int64_t *ptr; 24 | } hp_record_t; 25 | 26 | typedef struct _hp_thread_t { 27 | long saved_n_hp_records; 28 | long n_hp_records; 29 | hp_record_t hp_records[HP_MAX_RECORDS]; 30 | 31 | } hp_thread_t ; 32 | 33 | 34 | ///////////////////////////////////////////////////////// 35 | // EXTERNAL FUNCTIONS 36 | ///////////////////////////////////////////////////////// 37 | void HP_reset(hp_thread_t *self); 38 | void HP_save(hp_thread_t *p_hp); 39 | void HP_restore(hp_thread_t *p_hp); 40 | 41 | hp_record_t *HP_alloc(hp_thread_t *self); 42 | void HP_init(hp_record_t *p_hp, volatile int64_t **ptr_ptr); 43 | 44 | #ifdef IS_HP_ENABLED 45 | 46 | #define HP_RESET(self) HP_reset(self) 47 | #define HP_SAVE(self) HP_save(self) 48 | #define HP_RESTORE(self) HP_restore(self) 49 | 50 | #define HP_ALLOC(self) HP_alloc(self) 51 | #define HP_INIT(self, p_hp, ptr_ptr) HP_init(p_hp, (volatile int64_t **)ptr_ptr) 52 | 53 | #else 54 | 55 | #define HP_RESET(self) 56 | #define HP_SAVE(self) 57 | #define HP_RESTORE(self) 58 | 59 | #define HP_ALLOC(self) 60 | #define HP_INIT(self, p_hp, ptr_ptr) 61 | 62 | #endif 63 | 64 | #endif // HAZARD_PTRS 65 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/COPYING: -------------------------------------------------------------------------------- 1 | Unless otherwise specified, files in the jemalloc source distribution are 2 | subject to the following license: 3 | -------------------------------------------------------------------------------- 4 | Copyright (C) 2002-2016 Jason Evans . 5 | All rights reserved. 6 | Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved. 7 | Copyright (C) 2009-2016 Facebook, Inc. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 1. Redistributions of source code must retain the above copyright notice(s), 12 | this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice(s), 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS 18 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /lib/tvlog.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _TVLOG_H 5 | #define _TVLOG_H 6 | 7 | #include "timestone_i.h" 8 | #include "util.h" 9 | #include "debug.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | int tvlog_create(ts_thread_struct_t *self, ts_tvlog_t *tvlog); 16 | void tvtlog_destroy(ts_tvlog_t *tvlog); 17 | 18 | static inline unsigned long tvlog_used(ts_tvlog_t *log) 19 | { 20 | unsigned long used = log->tail_cnt - log->head_cnt; 21 | return used; 22 | } 23 | 24 | ts_cpy_hdr_struct_t *tvlog_append_begin(ts_tvlog_t *, volatile ts_act_vhdr_t *, 25 | unsigned int, int *); 26 | 27 | static inline void tvlog_append_abort(ts_tvlog_t *tvlog, 28 | ts_cpy_hdr_struct_t *chs) 29 | { 30 | /* Do nothing since tail_cnt and num_objs are not updated yet. 31 | * Let's keep this for readability of the code. */ 32 | } 33 | 34 | static inline void tvlog_append_end(ts_tvlog_t *tvlog, ts_cpy_hdr_struct_t *chs, 35 | int bogus_allocated) 36 | { 37 | tvlog->tail_cnt += get_entry_size(chs); 38 | tvlog->cur_wrt_set->num_objs++; 39 | if (bogus_allocated) { 40 | tvlog->cur_wrt_set->num_objs++; 41 | } 42 | 43 | #ifdef TS_ENABLE_STATS 44 | stat_thread_asgn(tvlog_to_thread(tvlog), n_tvlog_written_bytes, 45 | tvlog->tail_cnt); 46 | #endif 47 | } 48 | 49 | void tvlog_commit(ts_tvlog_t *tvlog, ts_oplog_t *oplog, ts_ptr_set_t *free_set, 50 | unsigned long local_clk, ts_op_info_t *op_info); 51 | void tvlog_abort(ts_tvlog_t *tvlog, ts_ptr_set_t *free_ptrs); 52 | void tvlog_reclaim(ts_tvlog_t *, ts_ckptlog_t *); 53 | void tvlog_reclaim_below_high_watermark(ts_tvlog_t *, ts_ckptlog_t *); 54 | void tvlog_flush(ts_tvlog_t *, ts_ckptlog_t *); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #endif 60 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.tanger.in: -------------------------------------------------------------------------------- 1 | ifeq ($(STACK_PROTECT), ) 2 | STACK_PROTECT = on_read_write 3 | endif 4 | 5 | ifeq ($(STACK_PROTECT_BOUND), ) 6 | STACK_PROTECT_BOUND = tanger 7 | endif 8 | 9 | include Makefile.in 10 | 11 | # dirs 12 | WLPDSTM_LIB_DIR = /home/dragojev/work/wlpdstm/lib 13 | TANGER_OBJ_DIR = $(TARGET_DIR)/tanger_obj 14 | TANGER_LIB = $(WLPDSTM_LIB_DIR)/libtanger-stm 15 | 16 | #LLVM_INCLUDE_DIR = /Users/aleksandar/work/llvm/install/include 17 | 18 | TANGER_HOME = /home/dragojev/work/tanger/tanger 19 | 20 | # LLVM 21 | LLVMCPP = /home/dragojev/work/llvm/install/bin/llvm-g++ 22 | LLVMLD = llvm-ld 23 | 24 | # path to tanger 25 | CPPFLAGS += -I$(TANGER_HOME)/include 26 | 27 | # use explicit parameters for Tanger 28 | CPPFLAGS += -DEXPLICIT_TX_PARAMETER 29 | 30 | # do not use regular iostream 31 | CPPFLAGS += -DUSE_LLVM_IOSTREAM 32 | 33 | # mubench compile parameters 34 | TANGER_INCLUDE_DIR = $(TANGER_HOME)/include 35 | TANGER_LIB_DIR = $(TANGER_HOME)/lib 36 | TANGERINCLUDE ?= $(TANGER_INCLUDE_DIR) 37 | INCLUDE += -I $(TANGERINCLUDE) 38 | STMLIBDIR ?= /home/dragojev/work/wlpdstm/lib 39 | STMSUPPORTDIR = $(TANGER_LIB_DIR)/stmsupport 40 | LLVMBUILD = $(shell llvm-config --build-mode) 41 | TANGERPASS = $(TANGER_HOME)/$(LLVMBUILD)/lib/libtanger.so 42 | EXTRAPASSES ?= 43 | PASSESTORUN ?= -tanger 44 | PASSESTORUNPOST ?= 45 | NATIVELIBSPRE ?= 46 | #HEADERS ?= $(wildcard $(INCLUDE)/*.h) 47 | 48 | CFLAGS += -Wall -DSTM -DTANGER 49 | CXXFLAGS += $(CFLAGS) 50 | CXXFLAGS_MUBENCH = $(CXXFLAGS) -DMUBENCH_TANGER 51 | NATIVELIBS += -lpthread 52 | BASELINKOPTS ?= 53 | NATIVELINKOPTS ?= -g -static 54 | LINKOPTS ?= 55 | #TANGERPASSOPTS ?= -debug -stats 56 | 57 | OPT ?= opt 58 | LLVMLD ?= llvm-ld 59 | LLVMGCC ?= llvm-gcc 60 | LLVMGXX ?= llvm-g++ 61 | LLVMDIS ?= llvm-dis 62 | LLC ?= llc 63 | GCC ?= gcc 64 | GXX ?= g++ 65 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/bin/jemalloc-config.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage() { 4 | cat < 7 | Options: 8 | --help | -h : Print usage. 9 | --version : Print jemalloc version. 10 | --revision : Print shared library revision number. 11 | --config : Print configure options used to build jemalloc. 12 | --prefix : Print installation directory prefix. 13 | --bindir : Print binary installation directory. 14 | --datadir : Print data installation directory. 15 | --includedir : Print include installation directory. 16 | --libdir : Print library installation directory. 17 | --mandir : Print manual page installation directory. 18 | --cc : Print compiler used to build jemalloc. 19 | --cflags : Print compiler flags used to build jemalloc. 20 | --cppflags : Print preprocessor flags used to build jemalloc. 21 | --ldflags : Print library flags used to build jemalloc. 22 | --libs : Print libraries jemalloc was linked against. 23 | EOF 24 | } 25 | 26 | prefix="@prefix@" 27 | exec_prefix="@exec_prefix@" 28 | 29 | case "$1" in 30 | --help | -h) 31 | usage 32 | exit 0 33 | ;; 34 | --version) 35 | echo "@jemalloc_version@" 36 | ;; 37 | --revision) 38 | echo "@rev@" 39 | ;; 40 | --config) 41 | echo "@CONFIG@" 42 | ;; 43 | --prefix) 44 | echo "@PREFIX@" 45 | ;; 46 | --bindir) 47 | echo "@BINDIR@" 48 | ;; 49 | --datadir) 50 | echo "@DATADIR@" 51 | ;; 52 | --includedir) 53 | echo "@INCLUDEDIR@" 54 | ;; 55 | --libdir) 56 | echo "@LIBDIR@" 57 | ;; 58 | --mandir) 59 | echo "@MANDIR@" 60 | ;; 61 | --cc) 62 | echo "@CC@" 63 | ;; 64 | --cflags) 65 | echo "@CFLAGS@" 66 | ;; 67 | --cppflags) 68 | echo "@CPPFLAGS@" 69 | ;; 70 | --ldflags) 71 | echo "@LDFLAGS@ @EXTRA_LDFLAGS@" 72 | ;; 73 | --libs) 74 | echo "@LIBS@" 75 | ;; 76 | *) 77 | usage 78 | exit 1 79 | esac 80 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/intel/jmp.s.backup: -------------------------------------------------------------------------------- 1 | # arch/i386/setjmp.S 2 | # 3 | # setjmp/longjmp for the i386 architecture 4 | # 5 | # 6 | # The jmp_buf is assumed to contain the following, in order: 7 | # %ebx 8 | # %esp 9 | # %ebp 10 | # %esi 11 | # %edi 12 | # 13 | # 14 | .text 15 | .align 4 16 | .globl _ITM_beginTransaction 17 | .type _ITM_beginTransaction, @function 18 | _ITM_beginTransaction: 19 | ##ifdef _REGPARM 20 | movl %eax,%edx 21 | ##else 22 | # movl 4(%esp),%edx 23 | ##endif 24 | popl %ecx # Return address, and adjust the stack 25 | xorl %eax,%eax # Return value 26 | movl %ebx,(%edx) 27 | movl %esp,4(%edx) # Post-return %esp! 28 | pushl %ecx # Make the call/return stack happy 29 | movl %ebp,8(%edx) 30 | movl %esi,12(%edx) 31 | movl %edi,16(%edx) 32 | movl %ecx,20(%edx) # Return address 33 | call _inner_beginTransaction 34 | addl %esp, 4 # Remove the last argument from stack 35 | ret 36 | 37 | .size _ITM_beginTransaction,.-_ITM_beginTransaction 38 | 39 | 40 | .text 41 | .align 4 42 | .globl jmp_to_begin_transaction 43 | .type jmp_to_begin_transaction, @function 44 | jmp_to_begin_transaction: 45 | call _inner_jmpReturn 46 | ##ifdef _REGPARM 47 | xchgl %eax,%edx 48 | ##else 49 | # movl 4(%esp),%edx # jmp_ptr address 50 | # movl 8(%esp),%eax # Return value 51 | ##endif 52 | movl (%edx),%ebx 53 | movl 4(%edx),%esp 54 | movl 8(%edx),%ebp 55 | movl 12(%edx),%esi 56 | movl 16(%edx),%edi 57 | jmp *20(%edx) 58 | 59 | .size jmp_to_begin_transaction,.-jmp_to_begin_transaction 60 | -------------------------------------------------------------------------------- /lib/Makefile: -------------------------------------------------------------------------------- 1 | CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) 2 | 3 | include $(CUR_DIR)/../Makefile.inc 4 | 5 | # configuration 6 | ifeq ($(strip $(CONF)),gtest) 7 | LIB_SUFFIX = -gtest 8 | CFLAGS += -DTS_GTEST 9 | endif 10 | 11 | # - nvm configuration 12 | #CFLAGS += -DTS_NVM_IS_DRAM 13 | #CFLAGS += -DTS_NVM_IS_PMDK 14 | # CFLAGS += -DTS_NVM_IS_MAKALU 15 | CFLAGS += -DTS_NVM_IS_NV_JEMALLOC 16 | 17 | # - debug configuration 18 | #CFLAGS += -DTS_ENABLE_ASSERT ## XXX enable for debugging only 19 | #CFLAGS += -DTS_ENABLE_FREE_POISIONING ## XXX should be removed 20 | 21 | CFLAGS += -I$(INC_DIR) 22 | CFLAGS += -I$(PROJ_DIR)/lib-makalu/include -I$(PROJ_DIR)/lib-nv-jemalloc/include 23 | CFLAGS += -march=native -mtune=native -O3 24 | CFLAGS += -g -ggdb3 25 | CFLAGS += -Winline -Wall -Wextra -Wshadow -Wdeclaration-after-statement 26 | CFLAGS += -Wno-attributes -Wno-unused-parameter -Wno-unused-value 27 | CFLAGS += -Wno-unused-function -Wno-packed-not-aligned 28 | LDFLAGS += -lpthread $(MEMMGR) $(PMEM) 29 | 30 | DEPS_DIR := $(CUR_DIR)/.deps$(LIB_SUFFIX) 31 | DEPCFLAGS = -MD -MF $(DEPS_DIR)/$*.d -MP 32 | 33 | SRC_FILES = $(wildcard *.c) 34 | OBJS_DIR = $(CUR_DIR)/.objs$(LIB_SUFFIX) 35 | OBJ_FILES = $(addprefix $(OBJS_DIR)/, $(SRC_FILES:.c=.o)) 36 | 37 | all: $(INC_DIR)/numa-config.h libts$(LIB_SUFFIX).a 38 | 39 | $(OBJS_DIR)/%.o: %.c $(DEPS_DIR) $(OBJS_DIR) 40 | $(Q)$(CC) $(CFLAGS) $(DEPCFLAGS) -c -o $@ $< 41 | 42 | $(OBJS_DIR): 43 | $(Q)mkdir -p $(OBJS_DIR) 44 | 45 | $(DEPS_DIR): 46 | $(Q)mkdir -p $(DEPS_DIR) 47 | 48 | $(INC_DIR)/numa-config.h: 49 | $(Q)$(TOOLS_DIR)/cpu-topology.py > $@ 50 | 51 | libts$(LIB_SUFFIX).a: $(OBJ_FILES) 52 | $(Q)/bin/rm -f $@ 53 | $(Q)$(AR) cru $@ $^ 54 | 55 | 56 | clean: 57 | $(Q)rm -f libts*.a 58 | $(Q)rm -rf $(CUR_DIR)/.deps* 59 | $(Q)rm -rf $(CUR_DIR)/.objs* 60 | $(Q)rm -f $(INC_DIR)/numa-config.h 61 | 62 | .PHONY: all clean 63 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/jemalloc_internal_decls.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_DECLS_H 2 | #define JEMALLOC_INTERNAL_DECLS_H 3 | 4 | #include 5 | #ifdef _WIN32 6 | # include 7 | # include "msvc_compat/windows_extra.h" 8 | 9 | #else 10 | # include 11 | # include 12 | # if !defined(__pnacl__) && !defined(__native_client__) 13 | # include 14 | # if !defined(SYS_write) && defined(__NR_write) 15 | # define SYS_write __NR_write 16 | # endif 17 | # include 18 | # endif 19 | # include 20 | # ifdef JEMALLOC_GLIBC_MALLOC_HOOK 21 | # include 22 | # endif 23 | # include 24 | # include 25 | # include 26 | # ifdef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME 27 | # include 28 | # endif 29 | #endif 30 | #include 31 | 32 | #include 33 | #ifndef SIZE_T_MAX 34 | # define SIZE_T_MAX SIZE_MAX 35 | #endif 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #ifndef offsetof 43 | # define offsetof(type, member) ((size_t)&(((type *)NULL)->member)) 44 | #endif 45 | #include 46 | #include 47 | #include 48 | #ifdef _MSC_VER 49 | # include 50 | typedef intptr_t ssize_t; 51 | # define PATH_MAX 1024 52 | # define STDERR_FILENO 2 53 | # define __func__ __FUNCTION__ 54 | # ifdef JEMALLOC_HAS_RESTRICT 55 | # define restrict __restrict 56 | # endif 57 | /* Disable warnings about deprecated system functions. */ 58 | # pragma warning(disable: 4996) 59 | #if _MSC_VER < 1800 60 | static int 61 | isblank(int c) 62 | { 63 | 64 | return (c == '\t' || c == ' '); 65 | } 66 | #endif 67 | #else 68 | # include 69 | #endif 70 | #include 71 | 72 | #endif /* JEMALLOC_INTERNAL_H */ 73 | -------------------------------------------------------------------------------- /benchmark/versioning/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | 5 | timestamp=`date +%Y.%m.%d.%H.%M.%S` 6 | dir=$0.$timestamp 7 | mkdir $dir 8 | 9 | duration=1000 10 | 11 | for i in benchmark_list_harris \ 12 | benchmark_list_rcu \ 13 | benchmark_list_rlu \ 14 | benchmark_list_swisstm \ 15 | benchmark_list_vlist 16 | do 17 | for init_size in 1000 18 | do 19 | range=$(echo $init_size+$init_size | bc) 20 | for u in 100 500 1000 21 | do 22 | for ncpu in 1 4 8 12 16 20 24 28 32 36 40 44 48 23 | do 24 | for j in $(seq 5) 25 | do 26 | ./$i -d $duration -u $u -i $init_size -r $range -n $ncpu 27 | done 28 | done | tee $dir/$i.size${init_size}.u${u} 29 | done 30 | done 31 | 32 | done 33 | 34 | for i in benchmark_list_move_vlist \ 35 | benchmark_list_move_rlu \ 36 | benchmark_list_move_swisstm 37 | do 38 | for init_size in 1000 39 | do 40 | range=$(echo $init_size+$init_size | bc) 41 | for ncpu in 1 4 8 12 16 20 24 28 32 36 40 44 48 42 | do 43 | for j in $(seq 5) 44 | do 45 | ./$i -d $duration -i $init_size -r $range -n $ncpu 46 | done 47 | done | tee $dir/$i.size${init_size} 48 | done 49 | 50 | done 51 | 52 | for i in benchmark_tree_vrbtree \ 53 | benchmark_tree_vtree \ 54 | benchmark_tree_rlu \ 55 | benchmark_tree_rcu \ 56 | benchmark_tree_bonsai \ 57 | benchmark_tree_swisstm 58 | do 59 | for init_size in 100000 60 | do 61 | range=$(echo $init_size+$init_size | bc) 62 | for u in 100 500 1000 63 | do 64 | for ncpu in 1 4 8 12 16 20 24 28 32 36 40 44 48 65 | do 66 | for j in $(seq 5) 67 | do 68 | ./$i -d $duration -u $u -i $init_size -r $range -n $ncpu 69 | done 70 | done | tee $dir/$i.size${init_size}.u${u} 71 | done 72 | done 73 | 74 | done 75 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/epochstm/transaction.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 3 | * 4 | */ 5 | 6 | #include "transaction.h" 7 | 8 | CACHE_LINE_ALIGNED wlpdstm::TransactionEpoch::OwnershipRecord wlpdstm::TransactionEpoch::orec_table[OWNERSHIP_TABLE_SIZE]; 9 | 10 | CACHE_LINE_ALIGNED wlpdstm::TransactionEpoch::PaddedTxCounter wlpdstm::TransactionEpoch::counters[MAX_THREADS]; 11 | 12 | CACHE_LINE_ALIGNED wlpdstm::TransactionEpoch *wlpdstm::TransactionEpoch::transactions[MAX_THREADS]; 13 | 14 | CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionEpoch::thread_count; 15 | 16 | //CACHE_LINE_ALIGNED wlpdstm::TransactionEpoch::CleanupWorkItem wlpdstm::TransactionEpoch::cleanup_queue[CLEANUP_WORK_ITEMS]; 17 | // 18 | //CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionEpoch::cleanup_counter; 19 | // 20 | //CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionEpoch::cleanup_done_counter; 21 | // 22 | //Word wlpdstm::TransactionEpoch::cleanup_snapshot_thread_count; 23 | // 24 | //pthread_t wlpdstm::TransactionEpoch::cleanup_threads[MAX_CLEANUP_THREADS]; 25 | // 26 | //unsigned wlpdstm::TransactionEpoch::cleanup_thread_count; 27 | // 28 | //#ifdef MM_EPOCH 29 | //CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionEpoch::cleanup_memory_counter; 30 | // 31 | //CACHE_LINE_ALIGNED wlpdstm::PaddedWord wlpdstm::TransactionEpoch::cleanup_memory_done_counter; 32 | //#endif /* MM_EPOCH */ 33 | 34 | #ifdef USE_TOUCHED_ORECS 35 | CACHE_LINE_ALIGNED volatile uint8_t wlpdstm::TransactionEpoch::touched_orecs[MAX_THREADS][TOUCHED_ORECS_ARRAY_SIZE]; 36 | 37 | //CACHE_LINE_ALIGNED uint8_t wlpdstm::TransactionEpoch::cleanup_touched_orecs[TOUCHED_ORECS_ARRAY_SIZE]; 38 | #endif /* TOUCHED_ORECS */ 39 | 40 | #ifdef USE_MINIMUM_READER_VERSION 41 | CACHE_LINE_ALIGNED wlpdstm::TransactionEpoch::PaddedTxCounter wlpdstm::TransactionEpoch::min_counter; 42 | #endif /* USE_MINIMUM_READER_VERSION */ 43 | 44 | 45 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/jemalloc_internal_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JEMALLOC_ALWAYS_INLINE and JEMALLOC_INLINE are used within header files for 3 | * functions that are static inline functions if inlining is enabled, and 4 | * single-definition library-private functions if inlining is disabled. 5 | * 6 | * JEMALLOC_ALWAYS_INLINE_C and JEMALLOC_INLINE_C are for use in .c files, in 7 | * which case the denoted functions are always static, regardless of whether 8 | * inlining is enabled. 9 | */ 10 | #if defined(JEMALLOC_DEBUG) || defined(JEMALLOC_CODE_COVERAGE) 11 | /* Disable inlining to make debugging/profiling easier. */ 12 | # define JEMALLOC_ALWAYS_INLINE 13 | # define JEMALLOC_ALWAYS_INLINE_C static 14 | # define JEMALLOC_INLINE 15 | # define JEMALLOC_INLINE_C static 16 | # define inline 17 | #else 18 | # define JEMALLOC_ENABLE_INLINE 19 | # ifdef JEMALLOC_HAVE_ATTR 20 | # define JEMALLOC_ALWAYS_INLINE \ 21 | static inline JEMALLOC_ATTR(unused) JEMALLOC_ATTR(always_inline) 22 | # define JEMALLOC_ALWAYS_INLINE_C \ 23 | static inline JEMALLOC_ATTR(always_inline) 24 | # else 25 | # define JEMALLOC_ALWAYS_INLINE static inline 26 | # define JEMALLOC_ALWAYS_INLINE_C static inline 27 | # endif 28 | # define JEMALLOC_INLINE static inline 29 | # define JEMALLOC_INLINE_C static inline 30 | # ifdef _MSC_VER 31 | # define inline _inline 32 | # endif 33 | #endif 34 | 35 | #ifdef JEMALLOC_CC_SILENCE 36 | # define UNUSED JEMALLOC_ATTR(unused) 37 | #else 38 | # define UNUSED 39 | #endif 40 | 41 | #define ZU(z) ((size_t)z) 42 | #define ZI(z) ((ssize_t)z) 43 | #define QU(q) ((uint64_t)q) 44 | #define QI(q) ((int64_t)q) 45 | 46 | #define KZU(z) ZU(z##ULL) 47 | #define KZI(z) ZI(z##LL) 48 | #define KQU(q) QU(q##ULL) 49 | #define KQI(q) QI(q##LL) 50 | 51 | #ifndef __DECONST 52 | # define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) 53 | #endif 54 | 55 | #ifndef JEMALLOC_HAS_RESTRICT 56 | # define restrict 57 | #endif 58 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/nstime.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct nstime_s nstime_t; 5 | 6 | /* Maximum supported number of seconds (~584 years). */ 7 | #define NSTIME_SEC_MAX KQU(18446744072) 8 | 9 | #endif /* JEMALLOC_H_TYPES */ 10 | /******************************************************************************/ 11 | #ifdef JEMALLOC_H_STRUCTS 12 | 13 | struct nstime_s { 14 | uint64_t ns; 15 | }; 16 | 17 | #endif /* JEMALLOC_H_STRUCTS */ 18 | /******************************************************************************/ 19 | #ifdef JEMALLOC_H_EXTERNS 20 | 21 | void nstime_init(nstime_t *time, uint64_t ns); 22 | void nstime_init2(nstime_t *time, uint64_t sec, uint64_t nsec); 23 | uint64_t nstime_ns(const nstime_t *time); 24 | uint64_t nstime_sec(const nstime_t *time); 25 | uint64_t nstime_nsec(const nstime_t *time); 26 | void nstime_copy(nstime_t *time, const nstime_t *source); 27 | int nstime_compare(const nstime_t *a, const nstime_t *b); 28 | void nstime_add(nstime_t *time, const nstime_t *addend); 29 | void nstime_subtract(nstime_t *time, const nstime_t *subtrahend); 30 | void nstime_imultiply(nstime_t *time, uint64_t multiplier); 31 | void nstime_idivide(nstime_t *time, uint64_t divisor); 32 | uint64_t nstime_divide(const nstime_t *time, const nstime_t *divisor); 33 | #ifdef JEMALLOC_JET 34 | typedef bool (nstime_monotonic_t)(void); 35 | extern nstime_monotonic_t *nstime_monotonic; 36 | typedef bool (nstime_update_t)(nstime_t *); 37 | extern nstime_update_t *nstime_update; 38 | #else 39 | bool nstime_monotonic(void); 40 | bool nstime_update(nstime_t *time); 41 | #endif 42 | 43 | #endif /* JEMALLOC_H_EXTERNS */ 44 | /******************************************************************************/ 45 | #ifdef JEMALLOC_H_INLINES 46 | 47 | #endif /* JEMALLOC_H_INLINES */ 48 | /******************************************************************************/ 49 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/integration/thread_arena.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define NTHREADS 10 4 | 5 | void * 6 | thd_start(void *arg) 7 | { 8 | unsigned main_arena_ind = *(unsigned *)arg; 9 | void *p; 10 | unsigned arena_ind; 11 | size_t size; 12 | int err; 13 | 14 | p = malloc(1); 15 | assert_ptr_not_null(p, "Error in malloc()"); 16 | free(p); 17 | 18 | size = sizeof(arena_ind); 19 | if ((err = mallctl("thread.arena", (void *)&arena_ind, &size, 20 | (void *)&main_arena_ind, sizeof(main_arena_ind)))) { 21 | char buf[BUFERROR_BUF]; 22 | 23 | buferror(err, buf, sizeof(buf)); 24 | test_fail("Error in mallctl(): %s", buf); 25 | } 26 | 27 | size = sizeof(arena_ind); 28 | if ((err = mallctl("thread.arena", (void *)&arena_ind, &size, NULL, 29 | 0))) { 30 | char buf[BUFERROR_BUF]; 31 | 32 | buferror(err, buf, sizeof(buf)); 33 | test_fail("Error in mallctl(): %s", buf); 34 | } 35 | assert_u_eq(arena_ind, main_arena_ind, 36 | "Arena index should be same as for main thread"); 37 | 38 | return (NULL); 39 | } 40 | 41 | TEST_BEGIN(test_thread_arena) 42 | { 43 | void *p; 44 | unsigned arena_ind; 45 | size_t size; 46 | int err; 47 | thd_t thds[NTHREADS]; 48 | unsigned i; 49 | 50 | p = malloc(1); 51 | assert_ptr_not_null(p, "Error in malloc()"); 52 | 53 | size = sizeof(arena_ind); 54 | if ((err = mallctl("thread.arena", (void *)&arena_ind, &size, NULL, 55 | 0))) { 56 | char buf[BUFERROR_BUF]; 57 | 58 | buferror(err, buf, sizeof(buf)); 59 | test_fail("Error in mallctl(): %s", buf); 60 | } 61 | 62 | for (i = 0; i < NTHREADS; i++) { 63 | thd_create(&thds[i], thd_start, 64 | (void *)&arena_ind); 65 | } 66 | 67 | for (i = 0; i < NTHREADS; i++) { 68 | intptr_t join_ret; 69 | thd_join(thds[i], (void *)&join_ret); 70 | assert_zd_eq(join_ret, 0, "Unexpected thread join error"); 71 | } 72 | } 73 | TEST_END 74 | 75 | int 76 | main(void) 77 | { 78 | 79 | return (test( 80 | test_thread_arena)); 81 | } 82 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/large.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | void *large_malloc(tsdn_t *tsdn, arena_t *arena, size_t usize, bool zero); 13 | void *large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, 14 | size_t alignment, bool zero); 15 | bool large_ralloc_no_move(tsdn_t *tsdn, extent_t *extent, size_t usize_min, 16 | size_t usize_max, bool zero); 17 | void *large_ralloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent, 18 | size_t usize, size_t alignment, bool zero, tcache_t *tcache); 19 | #ifdef JEMALLOC_JET 20 | typedef void (large_dalloc_junk_t)(void *, size_t); 21 | extern large_dalloc_junk_t *large_dalloc_junk; 22 | typedef void (large_dalloc_maybe_junk_t)(void *, size_t); 23 | extern large_dalloc_maybe_junk_t *large_dalloc_maybe_junk; 24 | #else 25 | void large_dalloc_junk(void *ptr, size_t usize); 26 | void large_dalloc_maybe_junk(void *ptr, size_t usize); 27 | #endif 28 | void large_dalloc_junked_locked(tsdn_t *tsdn, extent_t *extent); 29 | void large_dalloc(tsdn_t *tsdn, extent_t *extent); 30 | size_t large_salloc(tsdn_t *tsdn, const extent_t *extent); 31 | prof_tctx_t *large_prof_tctx_get(tsdn_t *tsdn, const extent_t *extent); 32 | void large_prof_tctx_set(tsdn_t *tsdn, extent_t *extent, prof_tctx_t *tctx); 33 | void large_prof_tctx_reset(tsdn_t *tsdn, extent_t *extent); 34 | 35 | #endif /* JEMALLOC_H_EXTERNS */ 36 | /******************************************************************************/ 37 | #ifdef JEMALLOC_H_INLINES 38 | 39 | #endif /* JEMALLOC_H_INLINES */ 40 | /******************************************************************************/ 41 | -------------------------------------------------------------------------------- /lib/config.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: Copyright (c) 2019-2021 Virginia Tech 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #ifndef _CONFIG_H 5 | #define _CONFIG_H 6 | #include "arch.h" 7 | 8 | //#define TS_ENABLE_SERIALIZABILITY_LINEARIZABILITY 9 | //#define TS_NESTED_LOCKING 10 | #define TS_ENABLE_HELP_RECLAIM 11 | 12 | #define TS_N_READ_SET_ENTRIES 100 13 | #define TS_N_WRITE_SET_ENTRIES 10 14 | #define TS_ENABLE_STATS 15 | //#define TS_TIME_MEASUREMENT 16 | #define TS_ATTACH_GDB_ASSERT_FAIL 0 /* attach gdb at TS_ASSERT() failure */ 17 | 18 | #define TS_ORDO_TIMESTAMPING /* We should delete non-ordo code. */ 19 | 20 | #define TS_MAX_THREAD_NUM (1ul << 14) /* 16384 (2**18 * 2**14 = 2**32) */ 21 | #define TS_INIT_PTR_SET_SIZE 512 22 | #define TS_QP_INTERVAL_USEC 500 /* 0.5 msec */ 23 | 24 | #define TS_TVLOG_SIZE (1ul << 20) /* 1MB */ 25 | #define TS_TVLOG_MASK (~(TS_TVLOG_SIZE - 1)) 26 | #define TS_TVLOG_HIGH_MARK (TS_TVLOG_SIZE - (TS_TVLOG_SIZE >> 2)) /* 75% */ 27 | #define TS_TVLOG_LOW_MARK (TS_TVLOG_SIZE >> 1) /* 50% */ 28 | 29 | #define TS_OPLOG_SIZE (1ul << 20) /* 1MB */ 30 | #define TS_OPLOG_HIGH_MARK (TS_OPLOG_SIZE - (TS_OPLOG_SIZE >> 2)) /* 75% */ 31 | 32 | #define TS_CKPTLOG_SIZE \ 33 | (1ul << 22) /* 4MB */ /* TODO: should be 10x TVLOG_SIZE */ 34 | #define TS_CKPTLOG_HIGH_MARK \ 35 | (TS_CKPTLOG_SIZE - (TS_CKPTLOG_SIZE >> 2)) /* 75% */ 36 | #define TS_CKPTLOG_LOW_MARK \ 37 | (TS_CKPTLOG_HIGH_MARK - (TS_CKPTLOG_SIZE >> 3)) /* 62.5% */ 38 | 39 | #define TS_PTR_SIZE 8 40 | #define TS_PTR_MASK (~(TS_PTR_SIZE - 1)) 41 | #define TS_CACHE_LINE_SIZE L1_CACHE_BYTES 42 | #define TS_CACHE_LINE_MASK (~(TS_CACHE_LINE_SIZE - 1)) 43 | #define TS_PMEM_PAGE_SIZE (2 * 1024 * 1024) /* 2MB */ 44 | #define TS_PMEM_PAGE_MASK (~(TS_PMEM_PAGE_SIZE - 1)) 45 | #define TS_DEFAULT_PADDING CACHE_DEFAULT_PADDING 46 | 47 | #endif /* _CONFIG_H */ 48 | -------------------------------------------------------------------------------- /benchmark/versioning/config-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "list1k": [ 3 | { 4 | "data_structure": "list", 5 | "runs_per_test": 1, 6 | "rlu_max_ws" : 1, 7 | "buckets" : 1, 8 | "duration" : 10000, 9 | "alg_type" : ["timestone"], 10 | "update_rate" : [20, 200, 800], 11 | "initial_size" : 1000, 12 | "range_size" : 2000, 13 | "zipf_dist_val" : 0, 14 | "threads" : [448, 336, 224, 168, 112, 56, 28, 14, 8, 1] 15 | } 16 | ], 17 | "list10k": [ 18 | { 19 | "data_structure": "list", 20 | "runs_per_test": 1, 21 | "rlu_max_ws" : 1, 22 | "buckets" : 1, 23 | "duration" : 10000, 24 | "alg_type" : ["timestone"], 25 | "update_rate" : [20, 200, 800], 26 | "initial_size" : 10000, 27 | "range_size" : 20000, 28 | "zipf_dist_val" : 0, 29 | "threads" : [448, 336, 224, 168, 112, 56, 28, 14, 8, 1] 30 | } 31 | ], 32 | "list50k": [ 33 | { 34 | "data_structure": "list", 35 | "runs_per_test": 1, 36 | "rlu_max_ws" : 1, 37 | "buckets" : 1, 38 | "duration" : 10000, 39 | "alg_type" : ["timestone"], 40 | "update_rate" : [20, 200, 800], 41 | "initial_size" : 50000, 42 | "range_size" : 100000, 43 | "zipf_dist_val" : 0, 44 | "threads" : [448, 336, 224, 168, 112, 56, 28, 14, 8, 1] 45 | } 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/include/jemalloc/internal/ticker.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct ticker_s ticker_t; 5 | 6 | #endif /* JEMALLOC_H_TYPES */ 7 | /******************************************************************************/ 8 | #ifdef JEMALLOC_H_STRUCTS 9 | 10 | struct ticker_s { 11 | int32_t tick; 12 | int32_t nticks; 13 | }; 14 | 15 | #endif /* JEMALLOC_H_STRUCTS */ 16 | /******************************************************************************/ 17 | #ifdef JEMALLOC_H_EXTERNS 18 | 19 | #endif /* JEMALLOC_H_EXTERNS */ 20 | /******************************************************************************/ 21 | #ifdef JEMALLOC_H_INLINES 22 | 23 | #ifndef JEMALLOC_ENABLE_INLINE 24 | void ticker_init(ticker_t *ticker, int32_t nticks); 25 | void ticker_copy(ticker_t *ticker, const ticker_t *other); 26 | int32_t ticker_read(const ticker_t *ticker); 27 | bool ticker_ticks(ticker_t *ticker, int32_t nticks); 28 | bool ticker_tick(ticker_t *ticker); 29 | #endif 30 | 31 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_TICKER_C_)) 32 | JEMALLOC_INLINE void 33 | ticker_init(ticker_t *ticker, int32_t nticks) 34 | { 35 | 36 | ticker->tick = nticks; 37 | ticker->nticks = nticks; 38 | } 39 | 40 | JEMALLOC_INLINE void 41 | ticker_copy(ticker_t *ticker, const ticker_t *other) 42 | { 43 | 44 | *ticker = *other; 45 | } 46 | 47 | JEMALLOC_INLINE int32_t 48 | ticker_read(const ticker_t *ticker) 49 | { 50 | 51 | return (ticker->tick); 52 | } 53 | 54 | JEMALLOC_INLINE bool 55 | ticker_ticks(ticker_t *ticker, int32_t nticks) 56 | { 57 | 58 | if (unlikely(ticker->tick < nticks)) { 59 | ticker->tick = ticker->nticks; 60 | return (true); 61 | } 62 | ticker->tick -= nticks; 63 | return(false); 64 | } 65 | 66 | JEMALLOC_INLINE bool 67 | ticker_tick(ticker_t *ticker) 68 | { 69 | 70 | return (ticker_ticks(ticker, 1)); 71 | } 72 | #endif 73 | 74 | #endif /* JEMALLOC_H_INLINES */ 75 | /******************************************************************************/ 76 | -------------------------------------------------------------------------------- /tools/ordo/gen_cpuseq.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # SPDX-FileCopyrightText: Copyright (c) 2018-2021 Virginia Tech 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import errno 7 | 8 | cpuinfo = [dict(map(str.strip, line.split(":", 1)) 9 | for line in block.splitlines()) 10 | for block in file("/proc/cpuinfo", "r").read().split("\n\n") 11 | if len(block.strip())] 12 | 13 | # Keep only primary hyperthreads 14 | primaries = set() 15 | for cpu in cpuinfo: 16 | processor = cpu["processor"] 17 | try: 18 | s = file("/sys/devices/system/cpu/cpu%s/topology/thread_siblings_list" 19 | % processor).read() 20 | except EnvironmentError, e: 21 | if e.errno == errno.ENOENT: 22 | primaries.add(processor) 23 | continue 24 | raise 25 | ss = set(map(int, s.split(","))) # could be "," or "-" depends on Linux dist. 26 | if int(processor) == min(ss): 27 | primaries.add(processor) 28 | cpuinfo = [cpu for cpu in cpuinfo if cpu["processor"] in primaries] 29 | 30 | 31 | def seq(cpuinfo): 32 | packages = {} 33 | package_ids = set() 34 | for cpu in cpuinfo: 35 | if "physical id" in cpu: 36 | package_id = int(cpu["physical id"]) 37 | packages.setdefault(package_id, []).append(cpu) 38 | if cpu["processor"] is "0": 39 | cpu0_package_id = int(package_id) 40 | package_ids.add(int(package_id)) 41 | else: 42 | yield cpu 43 | for cpu in packages[cpu0_package_id]: 44 | yield cpu 45 | package_ids.remove(cpu0_package_id) 46 | 47 | for package_id in package_ids: 48 | for cpu in packages[package_id]: 49 | yield cpu 50 | 51 | 52 | def order(): 53 | for cpu in seq(cpuinfo): 54 | yield cpu["processor"] 55 | 56 | 57 | if __name__ == "__main__": 58 | with open("cpuseq.h", "w") as f: 59 | f.write("int online_cpus = %d;\n" % (sum(1 for x in order()))) 60 | f.write("int cpuseq[] = { %s " % ", ".join(order()) + "};\n") 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Durable Transactional Memory Can Scale with Timestone (ASPLOS-2020, NVMW-2020) 2 | =================================================== 3 | 4 | ## Directory structure 5 | ```{.sh} 6 | timestone 7 | ├── include # public headers of timestone 8 | ├── lib #timestone library 9 | ├── lib++ #timestone C++ APIs 10 | ├── unittest #Unittest with linked list and B+Tree example 11 | ├── benchmark # benchmark 12 | │   ├── rlu # - rlu implementation and benchmark 13 | │   └── versioning # - versioned programming and benchmark 14 | ├── tools # misc build tools 15 | ``` 16 | 17 | ## Compile Timestone 18 | ```{.sh} 19 | cd timestone/ 20 | make 21 | ``` 22 | ## Run Bechamarks 23 | ```{.sh} 24 | cd timestone/benchmark 25 | sudo ./bench-timestone -b 26 | -d -i -u 27 | -n 28 | 29 | ### sample 30 | sudo ./bench-timestone -b 1000 -d 10000 -i 100 -u 200 -n 16 31 | ``` 32 | ## Run Unittest 33 | ```{.sh} 34 | cd timestone/lib/ 35 | CONF=gtest make 36 | cd ../unittest/ 37 | make 38 | sudo ./ut-ts --gtest_filter=cpp.btree_concurrent 39 | ``` 40 | ## Contact 41 | Please contact us at madhavakrishnan@vt.edu and changwoo@vt.edu 42 | 43 | ## Citation 44 | ``` 45 | @inproceedings{krishnan:timestone, 46 | author = {Krishnan, R. Madhava and Kim, Jaeho and Mathew, Ajit and Fu, Xinwei 47 | and Demeri, Anthony and Min, Changwoo and Kannan, Sudarsun}, 48 | title = {Durable Transactional Memory Can Scale with Timestone}, 49 | year = {2020}, 50 | isbn = {9781450371025}, 51 | publisher = {Association for Computing Machinery}, 52 | address = {New York, NY, USA}, 53 | url = {https://doi.org/10.1145/3373376.3378483}, 54 | doi = {10.1145/3373376.3378483}, 55 | booktitle = {Proceedings of the Twenty-Fifth International Conference on 56 | Architectural Support for Programming Languages and Operating Systems}, 57 | pages = {335–349}, 58 | numpages = {15}, 59 | location = {Lausanne, Switzerland}, 60 | series = {ASPLOS '20} 61 | } 62 | ``` 63 | -------------------------------------------------------------------------------- /lib-nv-jemalloc/test/unit/mq.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define NSENDERS 3 4 | #define NMSGS 100000 5 | 6 | typedef struct mq_msg_s mq_msg_t; 7 | struct mq_msg_s { 8 | mq_msg(mq_msg_t) link; 9 | }; 10 | mq_gen(static, mq_, mq_t, mq_msg_t, link) 11 | 12 | TEST_BEGIN(test_mq_basic) 13 | { 14 | mq_t mq; 15 | mq_msg_t msg; 16 | 17 | assert_false(mq_init(&mq), "Unexpected mq_init() failure"); 18 | assert_u_eq(mq_count(&mq), 0, "mq should be empty"); 19 | assert_ptr_null(mq_tryget(&mq), 20 | "mq_tryget() should fail when the queue is empty"); 21 | 22 | mq_put(&mq, &msg); 23 | assert_u_eq(mq_count(&mq), 1, "mq should contain one message"); 24 | assert_ptr_eq(mq_tryget(&mq), &msg, "mq_tryget() should return msg"); 25 | 26 | mq_put(&mq, &msg); 27 | assert_ptr_eq(mq_get(&mq), &msg, "mq_get() should return msg"); 28 | 29 | mq_fini(&mq); 30 | } 31 | TEST_END 32 | 33 | static void * 34 | thd_receiver_start(void *arg) 35 | { 36 | mq_t *mq = (mq_t *)arg; 37 | unsigned i; 38 | 39 | for (i = 0; i < (NSENDERS * NMSGS); i++) { 40 | mq_msg_t *msg = mq_get(mq); 41 | assert_ptr_not_null(msg, "mq_get() should never return NULL"); 42 | dallocx(msg, 0); 43 | } 44 | return (NULL); 45 | } 46 | 47 | static void * 48 | thd_sender_start(void *arg) 49 | { 50 | mq_t *mq = (mq_t *)arg; 51 | unsigned i; 52 | 53 | for (i = 0; i < NMSGS; i++) { 54 | mq_msg_t *msg; 55 | void *p; 56 | p = mallocx(sizeof(mq_msg_t), 0); 57 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); 58 | msg = (mq_msg_t *)p; 59 | mq_put(mq, msg); 60 | } 61 | return (NULL); 62 | } 63 | 64 | TEST_BEGIN(test_mq_threaded) 65 | { 66 | mq_t mq; 67 | thd_t receiver; 68 | thd_t senders[NSENDERS]; 69 | unsigned i; 70 | 71 | assert_false(mq_init(&mq), "Unexpected mq_init() failure"); 72 | 73 | thd_create(&receiver, thd_receiver_start, (void *)&mq); 74 | for (i = 0; i < NSENDERS; i++) 75 | thd_create(&senders[i], thd_sender_start, (void *)&mq); 76 | 77 | thd_join(receiver, NULL); 78 | for (i = 0; i < NSENDERS; i++) 79 | thd_join(senders[i], NULL); 80 | 81 | mq_fini(&mq); 82 | } 83 | TEST_END 84 | 85 | int 86 | main(void) 87 | { 88 | 89 | return (test( 90 | test_mq_basic, 91 | test_mq_threaded)); 92 | } 93 | 94 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/Makefile.epochstm.in: -------------------------------------------------------------------------------- 1 | ######################################## 2 | # choose memory manager 3 | MM_CPPFLAGS_epoch = -D MM_EPOCH 4 | MM_CPPFLAGS_leak = -D MM_LEAK 5 | MM_CPPFLAGS_txend = -D MM_TXEND 6 | 7 | ifeq ($(MM), ) 8 | MM = txend 9 | endif 10 | 11 | CPPFLAGS += $(MM_CPPFLAGS_${MM}) 12 | 13 | ######################################## 14 | # should application threads perform cleanup 15 | APP_CLEANUP_CPPFLAGS_yes = -D APP_THREAD_CLEANUP 16 | APP_CLEANUP_CPPFLAGS_no = 17 | 18 | ifeq ($(APP_CLEANUP), ) 19 | APP_CLEANUP = yes 20 | endif 21 | 22 | CPPFLAGS += $(APP_CLEANUP_CPPFLAGS_${APP_CLEANUP}) 23 | 24 | ######################################## 25 | # should application threads perform abort rollback 26 | # NOTE: the safe option here is yes 27 | ROLLBACK_ON_ABORT_CPPFLAGS_yes = -D ROLLBACK_ON_ABORT 28 | ROLLBACK_ON_ABORT_CPPFLAGS_no = 29 | 30 | ifeq ($(ROLLBACK_ON_ABORT), ) 31 | ROLLBACK_ON_ABORT = yes 32 | endif 33 | 34 | CPPFLAGS += $(ROLLBACK_ON_ABORT_CPPFLAGS_${ROLLBACK_ON_ABORT}) 35 | 36 | 37 | ######################################## 38 | # contention manager 39 | CM_CPPFLAGS_timid = -D CM_TIMID 40 | CM_CPPFLAGS_greedy = -D CM_GREEDY 41 | 42 | ifeq ($(CM), ) 43 | CM = greedy 44 | endif 45 | 46 | CPPFLAGS += $(CM_CPPFLAGS_${CM}) 47 | 48 | ######################################## 49 | # should cleanup use touched orecs tables 50 | TOUCHED_ORECS_CPPFLAGS_yes = -D USE_TOUCHED_ORECS 51 | TOUCHED_ORECS_CPPFLAGS_no = 52 | 53 | ifeq ($(TOUCHED_ORECS), ) 54 | TOUCHED_ORECS = no 55 | endif 56 | 57 | CPPFLAGS += $(TOUCHED_ORECS_CPPFLAGS_${TOUCHED_ORECS}) 58 | 59 | ######################################## 60 | # use minimum reader version shortcut 61 | MINIMUM_READER_VERSION_CPPFLAGS_yes = -D USE_MINIMUM_READER_VERSION 62 | MINIMUM_READER_VERSION_CPPFLAGS_no = 63 | 64 | ifeq ($(MINIMUM_READER_VERSION), ) 65 | MINIMUM_READER_VERSION = no 66 | endif 67 | 68 | CPPFLAGS += $(MINIMUM_READER_VERSION_CPPFLAGS_${MINIMUM_READER_VERSION}) 69 | 70 | ######################################## 71 | # use thread local counter buffer to reduce contention 72 | TLCNT_CPPFLAGS_yes = -D TLCNT 73 | TLCNT_CPPFLAGS_no = 74 | 75 | ifeq ($(TLCNT), ) 76 | TLCNT = no 77 | endif 78 | 79 | CPPFLAGS += $(TLCNT_CPPFLAGS_${TLCNT}) 80 | 81 | -------------------------------------------------------------------------------- /benchmark/versioning/swisstm/src/common/profiling/base.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file contains interface for profiling with no implementation. Useful for building 3 | * STM with no profiling overhead. 4 | * 5 | * @author Aleksandar Dragojevic aleksandar.dragojevic@epfl.ch 6 | * 7 | */ 8 | 9 | #ifndef WLPDSTM_PROFILING_BASE_H_ 10 | #define WLPDSTM_PROFILING_BASE_H_ 11 | 12 | namespace wlpdstm { 13 | 14 | template 15 | class BaseProfiling { 16 | public: 17 | static void GlobalInit() { 18 | // empty 19 | } 20 | 21 | void ThreadInit(STATS *stats) { 22 | // empty 23 | } 24 | 25 | void ThreadShutdown() { 26 | // empty 27 | } 28 | 29 | ///////////////////// 30 | // callbacks start // 31 | ///////////////////// 32 | 33 | void ThreadStart() { 34 | // empty 35 | } 36 | 37 | void ThreadEnd() { 38 | // empty 39 | } 40 | 41 | void TxStartStart(int lex_tx_id) { 42 | // empty 43 | } 44 | 45 | void TxStartEnd() { 46 | // empty 47 | } 48 | 49 | void TxCommitStart() { 50 | // empty 51 | } 52 | 53 | void TxCommitEnd() { 54 | // empty 55 | } 56 | 57 | void ReadWordStart(Word *addr) { 58 | // empty 59 | } 60 | 61 | void ReadWordEnd(Word res) { 62 | // empty 63 | } 64 | 65 | void WriteWordStart(Word *addr, Word val, Word mask = LOG_ENTRY_UNMASKED) { 66 | // empty 67 | } 68 | 69 | void WriteWordEnd() { 70 | // empty 71 | } 72 | 73 | void TxMallocStart(size_t size) { 74 | // empty 75 | } 76 | 77 | void TxMallocEnd(void *ptr) { 78 | // empty 79 | } 80 | 81 | void TxFreeStart(void *ptr, size_t size) { 82 | // empty 83 | } 84 | 85 | void TxFreeEnd() { 86 | // empty 87 | } 88 | 89 | void TxRestartStart() { 90 | // empty 91 | } 92 | 93 | void TxRestartEnd() { 94 | // empty 95 | } 96 | 97 | void TxAbortStart() { 98 | // empty 99 | } 100 | 101 | void TxAbortEnd() { 102 | // empty 103 | } 104 | 105 | /////////////////// 106 | // callbacks end // 107 | /////////////////// 108 | }; 109 | }; 110 | 111 | #endif /* WLPDSTM_PROFILING_BASE_H_ */ 112 | --------------------------------------------------------------------------------