├── .cproject ├── .gitignore ├── .gitmodules ├── .project ├── COMPILING.rst ├── Dockerfile ├── LICENSE ├── Makefile ├── README.rst ├── common.mk ├── config.mk ├── doc ├── internals │ ├── algorithms │ │ ├── Makefile │ │ ├── cleveref.sty │ │ ├── defs.tex │ │ ├── figlatex.sty │ │ ├── llncs.cls │ │ ├── main.tex │ │ ├── refs.bib │ │ ├── splncs.bst │ │ ├── tree.png │ │ ├── tree1.png │ │ └── tree2.png │ ├── description │ │ ├── cleveref.sty │ │ ├── defs.tex │ │ ├── description.tex │ │ ├── figlatex.sty │ │ └── llncs.cls │ ├── front-end │ │ ├── 3addr-ir.rst │ │ └── llvm-frontend.rst │ └── overview.rst └── notes.rst ├── experiments ├── cav18 │ ├── Makefile │ ├── README.CAV18.rst │ ├── README.rst │ ├── bench │ │ ├── debian │ │ │ ├── blktrace-1.0.5 │ │ │ │ ├── README.rst │ │ │ │ ├── blkiomon │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── blkiomon.c │ │ │ │ │ ├── blkiomon.h │ │ │ │ │ ├── blktrace.h │ │ │ │ │ ├── blktrace_api.h │ │ │ │ │ ├── full.c │ │ │ │ │ ├── jhash.h │ │ │ │ │ ├── rbtree.c │ │ │ │ │ ├── rbtree.h │ │ │ │ │ └── stats.h │ │ │ │ └── test-data │ │ │ │ │ ├── input1.dat │ │ │ │ │ └── input2.dat │ │ │ └── mafft-7.123 │ │ │ │ ├── README.rst │ │ │ │ ├── core │ │ │ │ ├── DNA.h │ │ │ │ ├── Falign.c │ │ │ │ ├── Falign_localhom.c │ │ │ │ ├── Galign11.c │ │ │ │ ├── Halignmm.c │ │ │ │ ├── JTT.c │ │ │ │ ├── Lalign11.c │ │ │ │ ├── Lalignmm.c │ │ │ │ ├── MSalign11.c │ │ │ │ ├── MSalignmm.c │ │ │ │ ├── Makefile │ │ │ │ ├── Qalignmm.c │ │ │ │ ├── Ralignmm.c │ │ │ │ ├── SAalignmm.c │ │ │ │ ├── Salignmm.c │ │ │ │ ├── addfunctions.c │ │ │ │ ├── addsingle.c │ │ │ │ ├── blosum.c │ │ │ │ ├── blosum.h │ │ │ │ ├── constants.c │ │ │ │ ├── contrafoldwrap.c │ │ │ │ ├── countlen.c │ │ │ │ ├── defs.c │ │ │ │ ├── disttbfast.c │ │ │ │ ├── dndblast.c │ │ │ │ ├── dndfast4.c │ │ │ │ ├── dndfast7.c │ │ │ │ ├── dndpre.c │ │ │ │ ├── dndpre_score.c │ │ │ │ ├── dp.h │ │ │ │ ├── dvtditr.c │ │ │ │ ├── f2cl.c │ │ │ │ ├── fft.c │ │ │ │ ├── fft.h │ │ │ │ ├── fftFunctions.c │ │ │ │ ├── functions.h │ │ │ │ ├── genGalign11.c │ │ │ │ ├── genalign11.c │ │ │ │ ├── getlag.c │ │ │ │ ├── io.c │ │ │ │ ├── iteration.c │ │ │ │ ├── mafft-distance.c │ │ │ │ ├── mafft-profile.c │ │ │ │ ├── mafft.tmpl │ │ │ │ ├── makedirectionlist.c │ │ │ │ ├── makemergetable.rb │ │ │ │ ├── mccaskillwrap.c │ │ │ │ ├── miyata.h │ │ │ │ ├── miyata5.h │ │ │ │ ├── mltaln.h │ │ │ │ ├── mltaln9.c │ │ │ │ ├── mtxutl.c │ │ │ │ ├── mtxutl.h │ │ │ │ ├── multi2hat3s.c │ │ │ │ ├── newick2mafft.rb │ │ │ │ ├── nj.c │ │ │ │ ├── pair2hat3s.c │ │ │ │ ├── pairash.c │ │ │ │ ├── pairlara.c │ │ │ │ ├── pairlocalalign.c │ │ │ │ ├── partQalignmm.c │ │ │ │ ├── partSalignmm.c │ │ │ │ ├── regionalrealignment.rb │ │ │ │ ├── regtable2seq.c │ │ │ │ ├── replaceu.c │ │ │ │ ├── restoreu.c │ │ │ │ ├── rna.c │ │ │ │ ├── rnatest.c │ │ │ │ ├── score.c │ │ │ │ ├── seq2regtable.c │ │ │ │ ├── setcore.c │ │ │ │ ├── setdirection.c │ │ │ │ ├── sextet5.c │ │ │ │ ├── share.h │ │ │ │ ├── splittbfast.c │ │ │ │ ├── suboptalign11.c │ │ │ │ ├── tbfast.c │ │ │ │ ├── tddis.c │ │ │ │ ├── tditeration.c │ │ │ │ ├── treeOperation.c │ │ │ │ └── version.c │ │ │ │ └── test-data │ │ │ │ ├── 1ped.fasta │ │ │ │ ├── 2seq.aln.fasta │ │ │ │ ├── 2seq.fasta │ │ │ │ ├── 3seq.aln.fasta │ │ │ │ ├── 3seq.fasta │ │ │ │ ├── 4seq.aln.fasta │ │ │ │ ├── 4seq.fasta │ │ │ │ ├── 5seq.aln.fasta │ │ │ │ ├── 5seq.fasta │ │ │ │ ├── 6seq.aln.fasta │ │ │ │ ├── 6seq.fasta │ │ │ │ ├── 7seq.aln.fasta │ │ │ │ ├── 7seq.fasta │ │ │ │ ├── hat2.2seq │ │ │ │ ├── hat2.3seq │ │ │ │ ├── hat2.4seq │ │ │ │ ├── hat2.5seq │ │ │ │ ├── hat2.6seq │ │ │ │ ├── hat2.7seq │ │ │ │ ├── hat2.sample36 │ │ │ │ ├── hat3.2seq │ │ │ │ ├── hat3.3seq │ │ │ │ ├── hat3.4seq │ │ │ │ ├── hat3.5seq │ │ │ │ ├── hat3.6seq │ │ │ │ ├── hat3.7seq │ │ │ │ ├── hat3.sample36 │ │ │ │ ├── mxscarnamod │ │ │ │ ├── sample.fasta │ │ │ │ ├── sample36.aln.fasta │ │ │ │ └── sample36.fasta │ │ ├── dispatcher.c │ │ ├── mpat.c │ │ ├── multiprodcon.c │ │ ├── pi │ │ │ ├── Makefile │ │ │ ├── manips.sh │ │ │ ├── nidhugg.sh │ │ │ ├── pth_pi_mutex.c │ │ │ ├── pth_pi_mutex_generic.c │ │ │ └── timer.h │ │ ├── poke.c │ │ ├── spat.c │ │ ├── ssb3.c │ │ ├── ssbexp.c │ │ └── ssbsimple.c │ ├── maple-exp.tar.gz │ ├── runlib.sh │ ├── runtable1.sh │ ├── runtable2.sh │ ├── runtable3.sh │ ├── table1 │ │ ├── OUTPUT.rst │ │ ├── TABLE.tex │ │ └── table1.png │ └── table3 │ │ └── table3.png ├── stuff │ ├── Makefile.dgemm │ ├── apr_1.c │ ├── dgemm_driver.c │ ├── manip_dispatcher.sh │ ├── manip_mpat.sh │ ├── manip_poke.sh │ ├── manip_spat.sh │ ├── manip_ssb3.sh │ ├── manip_ssbexp.sh │ ├── manip_ssbsimple.sh │ ├── nidhugg.sh │ ├── posixtestsuite-philo │ │ ├── Makefile │ │ ├── posixtest.h │ │ └── sem_philosopher.c │ ├── posixtestsuite-unlock │ │ ├── 2-1.c │ │ ├── 2-1_generic.c │ │ ├── Makefile │ │ ├── manips.sh │ │ ├── nidhugg.sh │ │ ├── posixtest.h │ │ ├── testfrmw.c │ │ └── testfrmw.h │ ├── ring │ │ ├── Makefile │ │ └── c-ring.c │ ├── ssbexp-nidhugg-explanation.rst │ └── top25-debian-concurrency.txt └── svcomp17 │ ├── README.rst │ ├── URLs │ ├── pthread-ext │ ├── 01_inc_true-unreach-call.c │ ├── 02_inc_cas_true-unreach-call.c │ ├── 03_incdec_true-unreach-call.c │ ├── 04_incdec_cas_true-unreach-call.c │ ├── 05_tas_true-unreach-call.c │ ├── 06_ticket_true-unreach-call.c │ ├── 07_rand_true-unreach-call.c │ ├── 08_rand_cas_true-unreach-call.c │ ├── 09_fmaxsym_true-unreach-call.c │ ├── 10_fmaxsym_cas_true-unreach-call.c │ ├── 11_fmaxsymopt_true-unreach-call.c │ ├── 12_fmaxsymopt_cas_true-unreach-call.c │ ├── 13_unverif_true-unreach-call.c │ ├── 14_spin2003_true-unreach-call.c │ ├── 15_dekker_true-unreach-call.c │ ├── 16_peterson_true-unreach-call.c │ ├── 17_szymanski_true-unreach-call.c │ ├── 18_read_write_lock_true-unreach-call.c │ ├── 19_time_var_mutex_true-unreach-call.c │ ├── 20_lamport_true-unreach-call.c │ ├── 23_lu-fig2.fixed_true-unreach-call.c │ ├── 25_stack_longer_false-unreach-call.c │ ├── 25_stack_longer_true-unreach-call.c │ ├── 25_stack_longest_false-unreach-call.c │ ├── 25_stack_longest_true-unreach-call.c │ ├── 25_stack_true-unreach-call.c │ ├── 26_stack_cas_longer_false-unreach-call.c │ ├── 26_stack_cas_longer_true-unreach-call.c │ ├── 26_stack_cas_longest_false-unreach-call.c │ ├── 26_stack_cas_longest_true-unreach-call.c │ ├── 26_stack_cas_true-unreach-call.c │ ├── 27_Boop_simple_vf_false-unreach-call.c │ ├── 28_buggy_simple_loop1_vf_false-unreach-call.c │ ├── 29_conditionals_vs_true-unreach-call.c │ ├── 30_Function_Pointer3_vs_true-unreach-call.c │ ├── 31_simple_loop5_vs_true-unreach-call.c │ ├── 32_pthread5_vs_false-unreach-call.c │ ├── 33_double_lock_p1_vs_true-unreach-call.c │ ├── 34_double_lock_p2_vs_true-unreach-call.c │ ├── 35_double_lock_p3_vs_true-unreach-call.c │ ├── 36_stack_cas_p0_vs_concur_true-unreach-call.c │ ├── 37_stack_lock_p0_vs_concur_true-unreach-call.c │ ├── 38_rand_cas_vs_concur_true-unreach-call.c │ ├── 39_rand_lock_p0_vs_true-unreach-call.c │ ├── 40_barrier_vf_false-unreach-call.c │ ├── 41_FreeBSD__abd_kbd__sliced_true-unreach-call.c │ ├── 42_FreeBSD__rdma_addr__sliced_true-unreach-call.c │ ├── 43_NetBSD__sysmon_power__sliced_true-unreach-call.c │ ├── 44_Solaris__space_map__sliced_true-unreach-call.c │ ├── 45_monabsex1_vs_true-unreach-call.c │ ├── 46_monabsex2_vs_true-unreach-call.c │ ├── 47_ticket_lock_hc_backoff_vs_true-unreach-call.c │ └── 48_ticket_lock_low_contention_vs_true-unreach-call.c │ └── pthread │ ├── README.rst │ ├── bigshot_p_false-unreach-call.c │ ├── bigshot_s2_true-unreach-call.c │ ├── bigshot_s_true-unreach-call.c │ ├── fib_bench_false-unreach-call.c │ ├── fib_bench_longer_false-unreach-call.c │ ├── fib_bench_longer_true-unreach-call.c │ ├── fib_bench_longest_false-unreach-call.c │ ├── fib_bench_longest_true-unreach-call.c │ ├── fib_bench_true-unreach-call.c │ ├── indexer_true-unreach-call.c │ ├── lazy01_false-unreach-call.c │ ├── queue_false-unreach-call.c │ ├── queue_longer_false-unreach-call.c │ ├── queue_longest_false-unreach-call.c │ ├── queue_ok_longer_true-unreach-call.c │ ├── queue_ok_longest_true-unreach-call.c │ ├── queue_ok_true-unreach-call.c │ ├── reorder_2_false-unreach-call.c │ ├── reorder_5_false-unreach-call.c │ ├── sigma_false-unreach-call.c │ ├── singleton_false-unreach-call.c │ ├── singleton_with-uninit-problems_true-unreach-call.c │ ├── stack_false-unreach-call.c │ ├── stack_longer_false-unreach-call.c │ ├── stack_longer_true-unreach-call.c │ ├── stack_longest_false-unreach-call.c │ ├── stack_longest_true-unreach-call.c │ ├── stack_true-unreach-call.c │ ├── stateful01_false-unreach-call.c │ ├── stateful01_true-unreach-call.c │ ├── sync01_true-unreach-call.c │ └── twostage_3_false-unreach-call.c ├── rt ├── Makefile ├── verifier.c └── verifier.h ├── scripts ├── addr-cluster.py ├── anonymize.sh ├── as2c.py ├── env2h.py └── mk2h.py ├── src ├── Makefile ├── config.h ├── datarace-analysis.cc ├── datarace-analysis.hh ├── datarace-analysis.hpp ├── datarace.hh ├── defect.hh ├── defectreport.cc ├── defectreport.hh ├── driver.sh ├── main.cc ├── memory-pool.cc ├── memory-pool.hh ├── memory-pool.hpp ├── memory-region.hh ├── misc.cc ├── misc.hh ├── opts.cc ├── opts.hh ├── pes │ ├── action.cc │ ├── action.hh │ ├── action.hpp │ ├── cfltree.hh │ ├── cfltree.hpp │ ├── config.cc │ ├── config.hh │ ├── config.hpp │ ├── cut.cc │ ├── cut.hh │ ├── cut.hpp │ ├── event-payload.hh │ ├── event.cc │ ├── event.hh │ ├── event.hpp │ ├── eventbox.cc │ ├── eventbox.hh │ ├── eventbox.hpp │ ├── pes.cc │ ├── primecon.cc │ ├── primecon.hh │ ├── primecon.hpp │ ├── process.cc │ ├── process.hh │ ├── process.hpp │ ├── unfolding-memory-math.hh │ ├── unfolding.cc │ ├── unfolding.hh │ ├── unfolding.hpp │ ├── vclock.cc_ │ └── vclock.hh ├── probdist.hh ├── probdist.tcc ├── redbox-factory.hh ├── redbox-factory.hpp ├── redbox.cc ├── redbox.hh ├── resources.cc ├── resources.hh ├── unfolder │ ├── alt-algorithm.hh │ ├── c15unfolder.cc │ ├── c15unfolder.hh │ ├── c15unfolder.hpp │ ├── comb.hh │ ├── disset.cc │ ├── disset.hh │ ├── disset.hpp │ ├── pidmap.hh │ ├── pidpool.cc │ ├── pidpool.hh │ ├── pidpool.hpp │ ├── replay.hh │ ├── replay.hpp │ ├── stream-converter.hh │ ├── stream-converter.hpp │ ├── trail.cc │ ├── trail.hh │ ├── unfolder.hh │ └── unfolder.hpp ├── verbosity.c └── verbosity.h └── tests ├── regression ├── Makefile ├── README.rst ├── basic │ ├── 16threads.test.sh │ ├── 20threads.test.sh │ ├── 24threads.test.sh │ ├── 2threads.test.sh │ ├── 4threads.test.sh │ ├── 8threads.test.sh │ ├── Makefile │ ├── ccnf-join.test.sh │ ├── ccnf-nojoin.test.sh │ ├── ccnf.c │ ├── conc-factorial-reuse.c │ ├── conc-factorial-reuse.test.sh │ ├── concurrent-create.c │ ├── concurrent-create.test.sh │ ├── conditional-join.c │ ├── conditional-join.test.sh │ ├── conflict-create.c │ ├── conflict-create.test.sh │ ├── factorial-conflicts.c │ ├── factorial-conflicts.test.sh │ ├── file-system.c │ ├── file-system.test.sh │ ├── hello.c │ ├── hello.test.sh │ ├── nthreads.c │ ├── nthreads.test.sh │ ├── pidpool-seen.c │ ├── pidpool-seen.test.sh │ ├── saw-pattern-replay.c │ ├── saw-pattern-replay.test.sh │ ├── saw-pattern-v.c │ ├── saw-pattern-v.test.sh │ ├── saw-pattern.c │ ├── saw-pattern.test.sh │ ├── thread-creates.c │ ├── thread-creates.test.sh │ ├── two-columns.c │ ├── two-columns.test.sh │ ├── ww.c │ └── ww.test.sh ├── cmdargs │ ├── bad-option.test.sh │ ├── help.test.sh │ └── missing.test.sh ├── data-race-analysis │ ├── races1.c │ ├── races1.test.sh │ ├── races2.c │ ├── races2.test.sh │ └── races3.c ├── defects │ ├── abort1.c │ ├── abort1.test.sh │ ├── abort2.c │ ├── abort2.test.sh │ ├── abort3.c │ ├── abort3.test.sh │ ├── assert1.c │ ├── assert1.test.sh │ ├── assert2.c │ ├── assert2.test.sh │ ├── exit1.c │ └── exit1.test.sh ├── dpu-steroids │ ├── Makefile │ ├── bugpids.c │ ├── bugpids.test.sh │ ├── conc-create-schedule.c │ ├── conc-create-schedule.test.sh │ ├── empty-stream.c │ └── empty-stream.test.sh ├── pi │ ├── Makefile │ ├── pi.test.sh │ └── pth_pi_mutex.c ├── prodcons │ └── prodcons.c ├── regtest.sh ├── ring │ └── c-ring.c ├── spin08 │ └── spin08.c └── ssbs │ ├── Makefile │ ├── dispatcher.c │ ├── dispatcher.test.sh │ ├── mpat.c │ ├── mpat.test.sh │ ├── poke.c │ ├── poke.test.sh │ ├── spat.c │ ├── ssb3.c │ ├── ssb3.test.sh │ ├── ssbexp.c │ └── ssbexp.test.sh └── unit ├── Makefile ├── all.cc ├── googletest ├── .gitignore ├── LICENSE ├── Makefile ├── README.dpu.rst ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── custom │ │ ├── gtest-port.h │ │ ├── gtest-printers.h │ │ └── gtest.h │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-linked_ptr.h │ │ ├── gtest-param-util-generated.h │ │ ├── gtest-param-util.h │ │ ├── gtest-port-arch.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ ├── gtest-tuple.h │ │ └── gtest-type-util.h └── src │ ├── gtest-all.cc │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ ├── gtest.cc │ └── gtest_main.cc ├── pes-unit.cc ├── probdist-unit.cc ├── redbox-unit.cc └── unit-tests.cc /.gitignore: -------------------------------------------------------------------------------- 1 | *.mci 2 | *.pdf 3 | *.dot 4 | dot/*.svg 5 | dot/*.png 6 | *.cuf 7 | *.mp 8 | *.cnf 9 | *.bc 10 | *.tr 11 | *.r 12 | *.d 13 | *.o 14 | *.a 15 | *.log 16 | *.pyc 17 | *.pdftex 18 | *.pdftex_t 19 | tags 20 | benchmarks/basic/*.ll 21 | config.h 22 | *.swp 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/steroids"] 2 | path = lib/steroids 3 | url = git@github.com:cesaro/steroids.git 4 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DPU 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM huyenntt/ubuntu-llvm-3.7 2 | RUN apt-get update 3 | RUN ls 4 | WORKDIR /home/devel/steroids 5 | RUN ls 6 | RUN git pull 7 | RUN make 8 | WORKDIR ../dpu 9 | RUN git pull 10 | RUN make 11 | 12 | 13 | -------------------------------------------------------------------------------- /doc/internals/algorithms/Makefile: -------------------------------------------------------------------------------- 1 | 2 | FIGS:=$(wildcard fig/*.fig fig/*/*.fig) 3 | FIGS:=$(patsubst %.fig,%.pdftex,$(FIGS)) $(patsubst %.fig,%.pdftex_t,$(FIGS)) 4 | TEXC:=pdflatex -interaction=nonstopmode 5 | 6 | #T=m 7 | T=main 8 | 9 | p parse : $(FIGS) 10 | rubber-info $T 11 | rubber-info --refs $T 12 | 13 | s simple : $(FIGS) 14 | $(TEXC) $T 15 | -rubber-info $T 16 | 17 | m multi : $(FIGS) 18 | -$(TEXC) $T 19 | bibtex $T 20 | -$(TEXC) $T 21 | -$(TEXC) $T 22 | 23 | c continuous : 24 | latexmk -pdf -pvc -silent $(shell pwd)/$T > /dev/null 2>&1 & 25 | #latexmk -pdf -pvc -silent $T & 26 | ps ax | grep latexmk | grep -v grep 27 | 28 | k kill : 29 | ps ax | grep latexmk | grep -v grep 30 | kill `ps ax | grep latexmk | grep -v grep | sed 's/^ *//' | tr -s ' ' | cut -d ' ' -f 1` 31 | 32 | ps : 33 | ps ax | grep latexmk | grep -v grep 34 | 35 | x xfig : 36 | cd fig; xfig & 37 | 38 | o open : 39 | gnome-open $T.pdf 2> /dev/null & 40 | 41 | clean : 42 | bash -c 'rm -f $T.{aux,bbl,blg,lof,lol,lot,log,out,toc,snm,nav,pag,bcf,run.xml,vtc,fls}' 43 | bash -c 'rm -f $T-blx.bib' 44 | bash -c 'rm -f *.fdb_latexmk' 45 | bash -c 'rm -f fig/*.pdftex fig/*.pdftex_t' 46 | #bash -c 'rm -f fig/*/*.pdftex fig/*/*.pdftex_t' 47 | 48 | .SUFFIXES: .fig .plt .pdftex .pdftex_t 49 | .plt.fig : 50 | gnuplot < $< > $@ 51 | .fig.pdftex : 52 | fig2dev -L pdftex $< $@ 53 | .fig.pdftex_t : 54 | fig2dev -L pdftex_t -p $(basename $<).pdftex $< $@ 55 | -------------------------------------------------------------------------------- /doc/internals/algorithms/tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/doc/internals/algorithms/tree.png -------------------------------------------------------------------------------- /doc/internals/algorithms/tree1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/doc/internals/algorithms/tree1.png -------------------------------------------------------------------------------- /doc/internals/algorithms/tree2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/doc/internals/algorithms/tree2.png -------------------------------------------------------------------------------- /doc/internals/front-end/llvm-frontend.rst: -------------------------------------------------------------------------------- 1 | 2 | LLVM Frontend + 3A Code transformations 3 | ======================================= 4 | 5 | Passes: 6 | 7 | 1. Sanity Checks 8 | - all allocas in the first basic block, and has no predecessors 9 | - pthread_{create,join,mutex_init,mutex_lock,mutex_unlock} 10 | - pthread_create and pthread_join are not in a loop (or if) 11 | - all allocated variables are integers, or arrays of integers 12 | 13 | 2. Construction of 3A code 14 | 3. Large-Block Encoding 15 | 16 | Pass 1: Sanity Checks 17 | --------------------- 18 | 19 | Pass 2: Construction of 3A code 20 | ------------------------------- 21 | 22 | Pass 3: Large-Block Encoding 23 | ---------------------------- 24 | -------------------------------------------------------------------------------- /doc/internals/overview.rst: -------------------------------------------------------------------------------- 1 | 2 | - Describe the mapping from steroids threads to DPU threads, and the limintation 3 | on the number of threads that that artificially imposes. 4 | 5 | - how to profile with valgrind 6 | 7 | - do a README, and move current contents of the README here ;) 8 | - describe dependencies, how to install, and how to run on a simple program 9 | 10 | 11 | Communication Steroids - DPU 12 | ---------------------------- 13 | 14 | - I suspect that there is a problem due to the manner in which we handle tids in 15 | steroids and pids in DPU. I think each of them should send to the other a tid 16 | naming consistent with its own naming model and the opposite peer should do 17 | the translation when necessary. This would require enriching the data 18 | structure for the replay, to send structures {action, count} where action is 19 | "context switch" or "thread create", and count is an event count or a new tid. 20 | 21 | Invariants expected by DPU on the incoming stream of actions: 22 | 23 | - when the stream contains an action THCREAT(x), the tid x satisfies 24 | 0 <= x <= N, 25 | where N is the number of times that an action THCREAT happened in the stream 26 | before this THCREAT, and x is *not* the the tid of a thread that is currently 27 | alive. 28 | 29 | -------------------------------------------------------------------------------- /experiments/cav18/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY : table1 table2 3 | 4 | all : 5 | @echo 'Error: Read the Makefile and choose a target! :)' 6 | 7 | table1 : 8 | ./runtable1.sh 9 | table2 : 10 | ./runtable2.sh 11 | table3 : 12 | ./runtable3.sh 13 | 14 | nohup1 : 15 | nohup ./runtable1.sh > nohup.out 2>&1 & 16 | nohup2 : 17 | nohup ./runtable2.sh > nohup.out 2>&1 & 18 | nohup12 : 19 | nohup bash -c './runtable1.sh; ./runtable2.sh' > nohup.out 2>&1 & 20 | 21 | clean : 22 | rm -Rf table1/log* 23 | rm -Rf table2/log* 24 | rm -Rf table3/log* 25 | -------------------------------------------------------------------------------- /experiments/cav18/README.CAV18.rst: -------------------------------------------------------------------------------- 1 | 2 | Instructions for CAV'18 Reviewers 3 | ================================= 4 | 5 | This file contains: 6 | 7 | - statically linked binaries of the DPU tool 8 | - the source code of the DPU tool 9 | - scripts to run the tool 10 | 11 | Please refer to the README.rst file for further information about DPU. 12 | 13 | Quickstart 14 | ========== 15 | 16 | The tool binary is located at ``bin/dpu``. You can run the tool from that folder 17 | but you should not move the ``dpu`` binary to another folder (as the binary 18 | finds the ``lib/`` folder using a relative file path). 19 | 20 | Run the tool with ``--version`` and ``-h`` to get information about its 21 | commandline options:: 22 | 23 | $ dpu --version 24 | dpu v0.5.0 (d73ecfa), compiled Wed, 31 Jan 2018 22:36:32 +0100 25 | Build type: release 26 | [...] 27 | 28 | $ ./bin/dpu -h 29 | Usage: dpu FILE.{c,i,bc,ll} ANALYZEROPTS -- PROGRAMOPTS 30 | [...] 31 | 32 | Run Optimal DPOR on the benchmark ``multiprodcon.c``:: 33 | 34 | ./bin/dpu experiments/cav18/bench/multiprodcon.c -k0 35 | 36 | Same as above but use QPOR with 2-partial alternatives:: 37 | 38 | ./bin/dpu experiments/cav18/bench/multiprodcon.c -k2 39 | 40 | Same as above but also check for data races on half of the program schedulings analized:: 41 | 42 | ./bin/dpu experiments/cav18/bench/multiprodcon.c -k2 -a dr --drfreq 50 43 | 44 | 45 | Running the Experiments in the Paper 46 | ==================================== 47 | 48 | All necessary information to reproduce the results of Tables 1, 2, and 3 can be 49 | found within the folder ``experiments/cav18``. Please refer to the README inside 50 | that folder. 51 | -------------------------------------------------------------------------------- /experiments/cav18/README.rst: -------------------------------------------------------------------------------- 1 | 2 | CAV'18 Paper Experiments 3 | ======================== 4 | 5 | This folder contains all the necessary scripts to reproduce the experimental 6 | results of the TACAS'18 paper submission. 7 | 8 | Table 1: Comparison between QDPOR and SDPOR 9 | ------------------------------------------- 10 | 11 | In order to build Table 1 from the paper (shown below), just run:: 12 | 13 | make table1 14 | 15 | This will execute the script ``runtable1.sh``, which in turn will 16 | generate a folder inside of the folder ``table1`` with multiple log files. 17 | 18 | After running the script please refer to the following generated files: 19 | 20 | - ``table1/logs/OUTPUT.rst``: the main log. 21 | - ``table1/logs/TABLE.tex``: a LaTeX table generated out of the log. 22 | 23 | As a sample, we include these two files as generated in the same machine where 24 | we have run the experiments for the paper: 25 | 26 | - ``__ 27 | - ``__ 28 | 29 | Although run times and memory consumption sizes are not identical to those 30 | shown in the paper, observe that the variations are usually quite small. 31 | For the record, the table as presented in the paper looked like this: 32 | 33 | .. image:: table1/table1.png 34 | 35 | 36 | Table 2: Debian Experiments 37 | --------------------------- 38 | 39 | Currently all data is in the file ``maple-exp.tar.gz``. 40 | I will expand this README here in a couple of days. 41 | 42 | Table 3: Experiments with the SVCOMP'17 Benchmarks 43 | -------------------------------------------------- 44 | 45 | In order to build Table 3 from the paper (shown below), just run:: 46 | 47 | make table3 48 | 49 | .. image:: table3/table3.png 50 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/blktrace-1.0.5/README.rst: -------------------------------------------------------------------------------- 1 | 2 | The files and folders in this folder come from the Ubuntu package blkiotrace 3 | v.1.0.5, available here: 4 | 5 | http://packages.ubuntu.com/trusty/blktrace 6 | 7 | The only program in the package that uses POSIX threads is ``blkiomon``. We have 8 | preseved here the sources of only this program. 9 | 10 | You would normally run it like this:: 11 | 12 | blktrace /dev/sdw -a issue -a complete -w 3600 -o - | blkiomon -I 10 -h - 13 | 14 | We added 3 new commandline arguments: 15 | 16 | - -i PATH, where PATH is a file to read disk tracing records, as they would 17 | otherwise be read from the standard input 18 | - -x N, where N will be the maximum number of iterations of the main loop 19 | - -y M, where M will be the maximum number of iterations of the thread loop 20 | 21 | To run the modified copy we first capture a file with data records:: 22 | 23 | sudo blktrace -d /dev/nvme0n1p3 -o - | tee input.dat | hexdump -C 24 | 25 | We then run our modified copy like this:: 26 | 27 | blkiomon -i input.dat -I 1 -y 5 -x 23 -h - 28 | 29 | DPU explores 11K configurations in 5 seconds:: 30 | 31 | dpu blkiomon.full.bc -O3 -- blkiomon -i input1.dat -I 1 -y 5 -x 23 -h - 32 | 33 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/blktrace-1.0.5/blkiomon/full.c: -------------------------------------------------------------------------------- 1 | 2 | #include "blkiomon.c" 3 | #include "rbtree.c" 4 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/blktrace-1.0.5/test-data/input1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/blktrace-1.0.5/test-data/input1.dat -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/blktrace-1.0.5/test-data/input2.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/blktrace-1.0.5/test-data/input2.dat -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/Halignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/Halignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/Lalign11.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/Lalign11.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/Lalignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/Lalignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/MSalignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/MSalignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/Qalignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/Qalignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/Ralignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/Ralignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/Salignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/Salignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/blosum.h: -------------------------------------------------------------------------------- 1 | /* 2 | int locpenaltyd = -2400; 3 | int locoffsetd = -60; 4 | char locaminod[26] = "GASTPLIMVDNEQFYWKRHCXXX.-U"; 5 | char locaminod[] = "ARNDCQEGHILKMFPSTWYVBZX.-U"; 6 | char locgrpd[] = 7 | { 8 | 0, 3, 2, 2, 5, 2, 2, 0, 3, 1, 1, 3, 1, 4, 0, 0, 0, 4, 4, 1, 2, 2, 9 | 6, 6, 6, 6, 10 | }; 11 | */ 12 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/constants.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/constants.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/countlen.c: -------------------------------------------------------------------------------- 1 | #include "mltaln.h" 2 | 3 | #define DEBUG 0 4 | 5 | void arguments( int argc, char *argv[] ) 6 | { 7 | int c; 8 | 9 | while( --argc > 0 && (*++argv)[0] == '-' ) 10 | { 11 | while ( (c = *++argv[0]) ) 12 | { 13 | switch( c ) 14 | { 15 | case 'i': 16 | inputfile = *++argv; 17 | fprintf( stderr, "inputfile = %s\n", inputfile ); 18 | --argc; 19 | goto nextoption; 20 | default: 21 | fprintf( stderr, "illegal option %c\n", c ); 22 | argc = 0; 23 | break; 24 | } 25 | } 26 | nextoption: 27 | ; 28 | } 29 | if( argc != 0 ) 30 | { 31 | fprintf( stderr, "options: Check source file !\n" ); 32 | exit( 1 ); 33 | } 34 | } 35 | 36 | 37 | int main( int argc, char *argv[] ) 38 | { 39 | FILE *infp; 40 | int nlenmin; 41 | 42 | arguments( argc, argv ); 43 | 44 | if( inputfile ) 45 | { 46 | infp = fopen( inputfile, "r" ); 47 | if( !infp ) 48 | { 49 | fprintf( stderr, "Cannot open %s\n", inputfile ); 50 | exit( 1 ); 51 | } 52 | } 53 | else 54 | infp = stdin; 55 | 56 | dorp = NOTSPECIFIED; 57 | getnumlen_nogap( infp, &nlenmin ); 58 | 59 | fprintf( stdout, "%d x %d - %d %c\n", njob, nlenmax, nlenmin, dorp ); 60 | return( 0 ); 61 | } 62 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/dndpre_score.c: -------------------------------------------------------------------------------- 1 | #include "mltaln.h" 2 | 3 | #define TEST 0 4 | 5 | int main() 6 | { 7 | int i, j; 8 | char **seq; 9 | static char name[M][B]; 10 | static int nlen[M]; 11 | double **mtx; 12 | FILE *fp; 13 | int res; 14 | 15 | scoremtx = NOTSPECIFIED; 16 | 17 | #if 0 18 | PreRead( stdin, &njob, &nlenmax ); 19 | #else 20 | getnumlen( stdin ); 21 | #endif 22 | rewind( stdin ); 23 | 24 | seq = AllocateCharMtx( njob, nlenmax+1 ); 25 | mtx = AllocateDoubleMtx( njob, njob ); 26 | 27 | #if 0 28 | FRead( stdin, name, nlen, seq ); 29 | #else 30 | readData( stdin, name, nlen, seq ); 31 | #endif 32 | 33 | for( i=0; i 2 | #include 3 | #include 4 | #include 5 | #include "mtxutl.h" 6 | 7 | #define PI 3.14159265358979323846 8 | #define END_OF_VEC -1 9 | 10 | #define NKOUHO 20 11 | #define NKOUHO_LONG 500 12 | 13 | #define MAX(X,Y) ( ((X)>(Y))?(X):(Y) ) 14 | #define MIN(X,Y) ( ((X)<(Y))?(X):(Y) ) 15 | 16 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/io.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/io.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/makemergetable.rb: -------------------------------------------------------------------------------- 1 | #!/bin/env ruby 2 | require 'getopts' 3 | 4 | seedoffset = 0 5 | 6 | if getopts( "s:" ) == nil || ARGV.length == 0 || $OPT_h then 7 | puts "Usage: #{$0} [-s number_of_seeds] input_files" 8 | exit 9 | end 10 | 11 | if $OPT_s 12 | seedoffset = $OPT_s.to_i 13 | end 14 | 15 | 16 | files = ARGV 17 | 18 | 19 | num = seedoffset + 1 20 | for file in files 21 | output = "" 22 | STDERR.puts file 23 | fp = File.open( file, "r" ) 24 | while line = fp.gets 25 | if line =~ /^>/ then 26 | output += " " + num.to_s 27 | num += 1 28 | end 29 | end 30 | fp.close 31 | puts output + " # " + file 32 | end 33 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/miyata.h: -------------------------------------------------------------------------------- 1 | double polarity_[] = 2 | { 3 | 8.1, /* A */ 4 | 10.5, /* R */ 5 | 11.6, /* N */ 6 | 13.0, /* D */ 7 | 5.5, /* C */ 8 | 10.5, /* Q */ 9 | 12.3, /* E */ 10 | 9.0, /* G */ 11 | 10.4, /* H */ 12 | 5.2, /* I */ 13 | 4.9, /* L */ 14 | 11.3, /* K */ 15 | 5.7, /* M */ 16 | 5.2, /* F */ 17 | 8.0, /* P */ 18 | 9.2, /* S */ 19 | 8.6, /* T */ 20 | 5.4, /* W */ 21 | 6.2, /* Y */ 22 | 5.9, /* V */ 23 | }; 24 | 25 | double volume_[] = 26 | { 27 | 31.0, /* A */ 28 | 124.0, /* R */ 29 | 56.0, /* N */ 30 | 54.0, /* D */ 31 | 55.0, /* C */ 32 | 85.0, /* Q */ 33 | 83.0, /* E */ 34 | 3.0, /* G */ 35 | 96.0, /* H */ 36 | 111.0, /* I */ 37 | 111.0, /* L */ 38 | 119.0, /* K */ 39 | 105.0, /* M */ 40 | 132.0, /* F */ 41 | 32.5, /* P */ 42 | 32.0, /* S */ 43 | 61.0, /* T */ 44 | 170.0, /* W */ 45 | 136.0, /* Y */ 46 | 84.0, /* V */ 47 | }; 48 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/mtxutl.h: -------------------------------------------------------------------------------- 1 | void MtxuntDouble( double **, int ); 2 | void MtxmltDouble( double **, double **, int ); 3 | 4 | char *AllocateCharVec( int ); 5 | void FreeCharVec( char * ); 6 | 7 | char **AllocateCharMtx( int, int); 8 | void ReallocateCharMtx( char **, int, int); 9 | void FreeCharMtx( char ** ); 10 | 11 | float *AllocateFloatVec( int ); 12 | void FreeFloatVec( float * ); 13 | 14 | float **AllocateFloatHalfMtx( int ); 15 | float **AllocateFloatMtx( int, int ); 16 | void FreeFloatHalfMtx( float **, int ); 17 | void FreeFloatMtx( float ** ); 18 | 19 | float **AlocateFloatTri( int ); 20 | void FreeFloatTri( float ** ); 21 | 22 | int *AllocateIntVec( int ); 23 | void FreeIntVec( int * ); 24 | 25 | int **AllocateIntMtx( int, int ); 26 | void FreeIntMtx( int ** ); 27 | 28 | char ***AllocateCharCub( int, int, int ); 29 | void FreeCharCub( char *** ); 30 | 31 | int ***AllocateIntCub( int, int, int ); 32 | void FreeIntCub( int *** ); 33 | 34 | double *AllocateDoubleVec( int ); 35 | void FreeDoubleVec( double * ); 36 | 37 | double **AllocateDoubleMtx( int, int ); 38 | void FreeDoubleMtx( double ** ); 39 | 40 | double ***AllocateDoubleCub( int, int, int ); 41 | void FreeDoubleCub( double *** ); 42 | 43 | float ***AllocateFloatCub( int, int, int ); 44 | void FreeFloatCub( float *** ); 45 | 46 | short *AllocateShortVec( int ); 47 | void FreeShortVec( short * ); 48 | 49 | short **AllocateShortMtx( int, int ); 50 | void FreeShortMtx( short ** ); 51 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/partQalignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/partQalignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/partSalignmm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/core/partSalignmm.c -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/share.h: -------------------------------------------------------------------------------- 1 | #if 0 2 | #include 3 | #include 4 | #include 5 | 6 | #endif 7 | #define IMA_YONDERU 'x' /* iranai */ 8 | #define IMA_KAITERU 0 /* iranai */ 9 | #define KAKIOWATTA 'w' 10 | #define YOMIOWATTA 'r' 11 | #define OSHIMAI 'd' 12 | #define ISRUNNING 0 13 | #define SEMAPHORE 1 14 | #define STATUS 2 15 | 16 | #define IPC_ALLOC 0100000 17 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/core/version.c: -------------------------------------------------------------------------------- 1 | #include "mltaln.h" 2 | 3 | int main() 4 | { 5 | fprintf( stdout, VERSION"\n" ); 6 | return( 0 ); 7 | } 8 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat2.2seq: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 1.550 4 | 1. =Equus_caballus_ADHE 5 | 2. =Homo_sapiens_ADH7 6 | 0.620 7 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat2.3seq: -------------------------------------------------------------------------------- 1 | 1 2 | 3 3 | 1.959 4 | 1. =Equus_caballus_ADHE 5 | 2. =Homo_sapiens_ADH7 6 | 3. =Rattus_norvegicus_ADH5 7 | 0.620 0.784 8 | 0.784 9 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat2.4seq: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 2.075 4 | 1. =Equus_caballus_ADHE 5 | 2. =Homo_sapiens_ADH7 6 | 3. =Rattus_norvegicus_ADH5 7 | 4. =Homo_sapiens_ADH4 8 | 0.620 0.784 0.789 9 | 0.784 0.830 10 | 0.770 11 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat2.5seq: -------------------------------------------------------------------------------- 1 | 1 2 | 5 3 | 2.075 4 | 1. =Equus_caballus_ADHE 5 | 2. =Homo_sapiens_ADH7 6 | 3. =Rattus_norvegicus_ADH5 7 | 4. =Homo_sapiens_ADH4 8 | 5. =Homo_sapiens_ADH6 9 | 0.620 0.784 0.789 0.729 10 | 0.784 0.830 0.734 11 | 0.770 0.811 12 | 0.827 13 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat2.6seq: -------------------------------------------------------------------------------- 1 | 1 2 | 6 3 | 2.647 4 | 1. =Equus_caballus_ADHE 5 | 2. =Homo_sapiens_ADH7 6 | 3. =Rattus_norvegicus_ADH5 7 | 4. =Homo_sapiens_ADH4 8 | 5. =Homo_sapiens_ADH6 9 | 6. =Zea_mays_ADH2 10 | 0.620 0.784 0.789 0.729 0.987 11 | 0.784 0.830 0.734 1.052 12 | 0.770 0.811 0.949 13 | 0.827 1.059 14 | 1.038 15 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat2.7seq: -------------------------------------------------------------------------------- 1 | 1 2 | 7 3 | 3.247 4 | 1. =Equus_caballus_ADHE 5 | 2. =Homo_sapiens_ADH7 6 | 3. =Rattus_norvegicus_ADH5 7 | 4. =Homo_sapiens_ADH4 8 | 5. =Homo_sapiens_ADH6 9 | 6. =Zea_mays_ADH2 10 | 7. =Pseudomonas_putida_TOL 11 | 0.620 0.784 0.789 0.729 0.987 1.284 12 | 0.784 0.830 0.734 1.052 1.274 13 | 0.770 0.811 0.949 1.297 14 | 0.827 1.059 1.278 15 | 1.038 1.285 16 | 1.299 17 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat3.2seq: -------------------------------------------------------------------------------- 1 | 0 1 1119 4.53595 3 344 0 341 h 2 | 0 1 1119 4.53595 348 1124 342 1118 h 3 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat3.3seq: -------------------------------------------------------------------------------- 1 | 0 1 1119 4.53595 3 344 0 341 h 2 | 0 1 1119 4.53595 348 1124 342 1118 h 3 | 0 2 1113 4.08454 6 166 0 160 h 4 | 0 2 1113 4.08454 167 339 164 336 h 5 | 0 2 1113 4.08454 346 363 337 354 h 6 | 0 2 1113 4.08454 364 1124 361 1121 h 7 | 1 2 1111 4.08105 3 163 0 160 h 8 | 1 2 1111 4.08105 164 171 169 176 h 9 | 1 2 1111 4.08105 177 347 177 347 h 10 | 1 2 1111 4.08105 348 1118 351 1121 h 11 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat3.4seq: -------------------------------------------------------------------------------- 1 | 0 1 1119 4.53595 3 344 0 341 h 2 | 0 1 1119 4.53595 348 1124 342 1118 h 3 | 0 2 1113 4.08454 6 166 0 160 h 4 | 0 2 1113 4.08454 167 339 164 336 h 5 | 0 2 1113 4.08454 346 363 337 354 h 6 | 0 2 1113 4.08454 364 1124 361 1121 h 7 | 0 3 1122 4.04513 0 3 0 3 h 8 | 0 3 1122 4.04513 7 170 4 167 h 9 | 0 3 1122 4.04513 171 338 171 338 h 10 | 0 3 1122 4.04513 339 355 342 358 h 11 | 0 3 1122 4.04513 356 1124 368 1136 h 12 | 1 2 1111 4.08105 3 163 0 160 h 13 | 1 2 1111 4.08105 164 171 169 176 h 14 | 1 2 1111 4.08105 177 347 177 347 h 15 | 1 2 1111 4.08105 348 1118 351 1121 h 16 | 1 3 1119 3.87761 0 157 0 157 h 17 | 1 3 1119 3.87761 158 179 160 181 h 18 | 1 3 1119 3.87761 180 330 183 333 h 19 | 1 3 1119 3.87761 331 1118 349 1136 h 20 | 2 3 1119 4.13187 0 1 0 1 h 21 | 2 3 1119 4.13187 2 149 5 152 h 22 | 2 3 1119 4.13187 153 172 153 172 h 23 | 2 3 1119 4.13187 173 337 176 340 h 24 | 2 3 1119 4.13187 338 354 351 367 h 25 | 2 3 1119 4.13187 355 1121 370 1136 h 26 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/hat3.5seq: -------------------------------------------------------------------------------- 1 | 0 1 1119 4.53595 3 344 0 341 h 2 | 0 1 1119 4.53595 348 1124 342 1118 h 3 | 0 2 1113 4.08454 6 166 0 160 h 4 | 0 2 1113 4.08454 167 339 164 336 h 5 | 0 2 1113 4.08454 346 363 337 354 h 6 | 0 2 1113 4.08454 364 1124 361 1121 h 7 | 0 3 1122 4.04513 0 3 0 3 h 8 | 0 3 1122 4.04513 7 170 4 167 h 9 | 0 3 1122 4.04513 171 338 171 338 h 10 | 0 3 1122 4.04513 339 355 342 358 h 11 | 0 3 1122 4.04513 356 1124 368 1136 h 12 | 0 4 1098 4.24198 0 142 0 142 h 13 | 0 4 1098 4.24198 143 181 145 183 h 14 | 0 4 1098 4.24198 182 357 185 360 h 15 | 0 4 1098 4.24198 361 1097 361 1097 h 16 | 0 4 1098 4.24198 1122 1124 1098 1100 h 17 | 1 2 1111 4.08105 3 163 0 160 h 18 | 1 2 1111 4.08105 164 171 169 176 h 19 | 1 2 1111 4.08105 177 347 177 347 h 20 | 1 2 1111 4.08105 348 1118 351 1121 h 21 | 1 3 1119 3.87761 0 157 0 157 h 22 | 1 3 1119 3.87761 158 179 160 181 h 23 | 1 3 1119 3.87761 180 330 183 333 h 24 | 1 3 1119 3.87761 331 1118 349 1136 h 25 | 1 4 1085 4.37490 0 9 0 9 h 26 | 1 4 1085 4.37490 10 139 13 142 h 27 | 1 4 1085 4.37490 140 164 145 169 h 28 | 1 4 1085 4.37490 165 331 171 337 h 29 | 1 4 1085 4.37490 337 352 338 353 h 30 | 1 4 1085 4.37490 353 883 359 889 h 31 | 1 4 1085 4.37490 889 910 890 911 h 32 | 1 4 1085 4.37490 911 1091 917 1097 h 33 | 1 4 1085 4.37490 1116 1118 1098 1100 h 34 | 2 3 1119 4.13187 0 1 0 1 h 35 | 2 3 1119 4.13187 2 149 5 152 h 36 | 2 3 1119 4.13187 153 172 153 172 h 37 | 2 3 1119 4.13187 173 337 176 340 h 38 | 2 3 1119 4.13187 338 354 351 367 h 39 | 2 3 1119 4.13187 355 1121 370 1136 h 40 | 2 4 1092 3.99619 0 329 6 335 h 41 | 2 4 1092 3.99619 336 357 336 357 h 42 | 2 4 1092 3.99619 358 1093 361 1096 h 43 | 2 4 1092 3.99619 1118 1121 1097 1100 h 44 | 3 4 1098 3.89799 0 356 3 359 h 45 | 3 4 1098 3.89799 372 1109 360 1097 h 46 | 3 4 1098 3.89799 1134 1136 1098 1100 h 47 | -------------------------------------------------------------------------------- /experiments/cav18/bench/debian/mafft-7.123/test-data/mxscarnamod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/bench/debian/mafft-7.123/test-data/mxscarnamod -------------------------------------------------------------------------------- /experiments/cav18/bench/pi/Makefile: -------------------------------------------------------------------------------- 1 | NAME = pth_pi_mutex 2 | 3 | EXTRACTBC = extract-bc 4 | STEROID = $(HOME)/steroid/utils/find-and-extract-bcs 5 | DIS = llvm-dis 6 | CC = wllvm 7 | LIBS = -lpthread 8 | DPU = $(shell pwd)/../../../dist/bin/dpu 9 | 10 | all: ll 11 | 12 | bc: $(NAME).bc 13 | ll: $(NAME).ll 14 | 15 | $(NAME): $(NAME).c 16 | $(CC) -O3 -o $@ $^ $(LIBS) 17 | 18 | $(NAME).bc: $(NAME) 19 | $(EXTRACTBC) $^ 20 | 21 | $(NAME).full.bc: $(NAME).c 22 | $(STEROID) 23 | 24 | $(NAME).ll: $(NAME).bc 25 | $(DIS) $^ 26 | 27 | run: $(NAME).ll 28 | $(DPU) $^ -vv -- 1 4 1024 29 | 30 | clean: 31 | rm -f $(NAME).full.bc $(NAME).ll $(NAME).bc $(NAME) 32 | 33 | .PHONY: clean run 34 | -------------------------------------------------------------------------------- /experiments/cav18/bench/pi/manips.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=pth_pi_mutex_generic.c 5 | TERMS=131072 6 | EXTRACTBC=extract-bc 7 | DPU=${HOME}/dpu2/dist/bin/dpu 8 | NIDHUGG=./nidhugg.sh 9 | WLLVM=wllvm 10 | LIBS="-lpthread" 11 | COPTS="-O3" 12 | LLVMDIS=llvm-dis 13 | 14 | round() { 15 | echo "scale=3 ; $1/1000000000" | bc 16 | } 17 | 18 | function runtest { 19 | # generate the .ll file 20 | sed "s/XXXX/$1/" ${FILENAME} | sed "s/YYYY/$2/" > generated.c 21 | $WLLVM $COPTS -o generated generated.c $LIBS 22 | $EXTRACTBC generated 23 | $LLVMDIS generated.bc 24 | # transform it for Nidhugg 25 | # $NIDHUGG --transform=nidhugg.ll generated.ll 2&>1 | grep -v "warning" | grep -v "Warning" 26 | 27 | LINENAME="Pi $2 & $1 & " 28 | 29 | # run DPU experiments 30 | for ALT in 0 1 2 3 ; do 31 | echo -n $LINENAME 32 | BEGIN=`date +%s%N` 33 | $DPU generated.ll -a${ALT} 2&>1 > trace 34 | END=`date +%s%N` 35 | EXECTIME=`round $(($END-$BEGIN))` 36 | echo -n $ALT " & " $EXECTIME " & " 37 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 38 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 39 | echo -n $STAT " " $AVG 40 | 41 | if [ $ALT -eq 0 ] ; then 42 | # run Nihugg experiment 43 | BEGIN=`date +%s%N` 44 | $NIDHUGG -sc generated.ll > trace 2> log 45 | END=`date +%s%N` 46 | EXECTIME=`round $(($END-$BEGIN))` 47 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 48 | echo -n $EXECTIME " & " $STAT 49 | echo "\\\\" 50 | else 51 | echo "&&\\\\" 52 | fi 53 | done 54 | 55 | } 56 | 57 | for NT in 2 3 4 5 6 8 10 ; do 58 | runtest $NT $TERMS 59 | done 60 | -------------------------------------------------------------------------------- /experiments/cav18/bench/pi/nidhugg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/local/bin/nidhuggc \ 4 | --nidhugg=/usr/local/bin/nidhugg \ 5 | -extfun-no-race=printf \ 6 | -extfun-no-race=write \ 7 | -extfun-no-race=exit \ 8 | -extfun-no-race=atoi \ 9 | $* 10 | -------------------------------------------------------------------------------- /experiments/cav18/bench/pi/timer.h: -------------------------------------------------------------------------------- 1 | /* File: timer.h 2 | * 3 | * Purpose: Define a macro that returns the number of seconds that 4 | * have elapsed since some point in the past. The timer 5 | * should return times with microsecond accuracy. 6 | * 7 | * Note: The argument passed to the GET_TIME macro should be 8 | * a double, *not* a pointer to a double. 9 | * 10 | * Example: 11 | * #include "timer.h" 12 | * . . . 13 | * double start, finish, elapsed; 14 | * . . . 15 | * GET_TIME(start); 16 | * . . . 17 | * Code to be timed 18 | * . . . 19 | * GET_TIME(finish); 20 | * elapsed = finish - start; 21 | * printf("The code to be timed took %e seconds\n", elapsed); 22 | */ 23 | #ifndef _TIMER_H_ 24 | #define _TIMER_H_ 25 | 26 | #include 27 | 28 | #define GET_TIME(now) { \ 29 | struct timeval t; \ 30 | gettimeofday(&t, NULL); \ 31 | now = t.tv_sec + t.tv_usec/1000000.0; \ 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /experiments/cav18/bench/spat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef PARAM1 6 | #define PARAM1 9 7 | #endif 8 | 9 | #ifndef PARAM2 10 | #define PARAM2 6 11 | #endif 12 | 13 | #define T PARAM1 // number of threads 14 | #define K PARAM2 // number of mutexes 15 | 16 | pthread_mutex_t m[K]; 17 | 18 | /* 19 | The stair pattern 20 | a 21 | | 22 | b . b 23 | | | 24 | d c . c 25 | | | 26 | e d . d 27 | | | 28 | f e . e 29 | | | 30 | g f . f 31 | */ 32 | 33 | // parametric threads 34 | void *th(void *arg) 35 | { 36 | unsigned id = (unsigned long) arg; 37 | 38 | int i = id; 39 | int j = 1; 40 | 41 | // Locks 42 | while (i < K && j < 4) { 43 | pthread_mutex_lock(&m[i]); 44 | //printf ("t%u: lock %d\n", id, i); 45 | i+=j; 46 | j++; 47 | } 48 | 49 | // Unlocks 50 | while (i > id) { 51 | j--; 52 | i-=j; 53 | //printf ("t%u: unlock %d\n", id, i); 54 | pthread_mutex_unlock(&m[i]); 55 | } 56 | return NULL; 57 | } 58 | 59 | int main() 60 | { 61 | pthread_t ids[T]; 62 | 63 | //printf ("== start ==\n"); 64 | for (int i = 0; i < K; i++) 65 | { 66 | pthread_mutex_init(&m[i], NULL); 67 | } 68 | //for (int i = T-1; i >= 0; i--) 69 | for (int i = 0; i < T; i++) 70 | { 71 | pthread_create(&ids[i], NULL, th, (void*) (long) i); 72 | } 73 | 74 | for (int i = 0; i < T; i++) 75 | { 76 | pthread_join(ids[i],NULL); 77 | } 78 | //printf ("== end ==\n"); 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /experiments/cav18/bench/ssbexp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef PARAM1 6 | #define PARAM1 10 // default value 7 | #endif 8 | 9 | #define K PARAM1 10 | 11 | pthread_mutex_t ma[K]; 12 | pthread_mutex_t mi; 13 | int i = 0; 14 | 15 | void *counter() 16 | { 17 | int x; 18 | for (x = 1; x < K; x++) 19 | { 20 | pthread_mutex_lock(&mi); 21 | i = x; 22 | //printf ("count: i %d\n", i); 23 | pthread_mutex_unlock(&mi); 24 | } 25 | return 0; 26 | } 27 | 28 | void *wa(void *aux) 29 | { 30 | long x = (long) aux; 31 | pthread_mutex_lock(&ma[x]); 32 | //printf ("w%ld: locking\n", x); 33 | pthread_mutex_unlock(&ma[x]); 34 | return 0; 35 | } 36 | 37 | int main() 38 | { 39 | long x; 40 | int idx; 41 | pthread_t idk; 42 | pthread_t idw[K]; 43 | 44 | //printf ("== start ==\n"); 45 | pthread_mutex_init(&mi, NULL); 46 | for (x = 0; x < K; x++) 47 | { 48 | pthread_mutex_init(&ma[x], NULL); 49 | pthread_create(&idw[x], 0, wa, (void*) x); 50 | } 51 | pthread_create(&idk, NULL, counter, NULL); 52 | 53 | pthread_mutex_lock (&mi); 54 | idx = i; 55 | //printf ("m: reading %d\n", idx); 56 | pthread_mutex_unlock (&mi); 57 | 58 | pthread_mutex_lock (&ma[idx]); 59 | //printf ("m: locking %d\n", idx); 60 | pthread_mutex_unlock (&ma[idx]); 61 | 62 | for (x = 0; x < K; x++) 63 | pthread_join(idw[x],NULL); 64 | pthread_join(idk,NULL); 65 | //printf ("== end ==\n"); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /experiments/cav18/bench/ssbsimple.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // This is an example of a program 5 | // with three threads that contains SSBs 6 | 7 | pthread_mutex_t mx; 8 | pthread_mutex_t my; 9 | pthread_mutex_t mz; 10 | int x = 0; 11 | 12 | void *ta(void *arg) 13 | { 14 | pthread_mutex_lock(&mx); 15 | x = 1; 16 | pthread_mutex_unlock(&mx); 17 | 18 | pthread_mutex_lock(&mz); 19 | pthread_mutex_unlock(&mz); 20 | return NULL; 21 | } 22 | 23 | void *tb(void *arg) 24 | { 25 | pthread_mutex_lock (&mx); 26 | if (x) 27 | { 28 | pthread_mutex_lock (&my); 29 | pthread_mutex_unlock (&my); 30 | } 31 | pthread_mutex_unlock (&mx); 32 | return NULL; 33 | } 34 | 35 | void *tc(void *arg) 36 | { 37 | pthread_mutex_lock (&my); 38 | pthread_mutex_lock (&mz); 39 | pthread_mutex_unlock (&mz); 40 | pthread_mutex_unlock (&my); 41 | return NULL; 42 | } 43 | 44 | int main() 45 | { 46 | pthread_t ida; 47 | pthread_t idb; 48 | pthread_t idc; 49 | pthread_mutex_init(&mx, NULL); 50 | pthread_mutex_init(&my, NULL); 51 | pthread_mutex_init(&mz, NULL); 52 | 53 | pthread_create(&idc, NULL, tc, NULL); 54 | pthread_create(&idb, NULL, tb, NULL); 55 | pthread_create(&ida, NULL, ta, NULL); 56 | 57 | //pthread_join(ida,NULL); 58 | //pthread_join(idb,NULL); 59 | //pthread_join(idc,NULL); 60 | 61 | pthread_exit (0); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /experiments/cav18/maple-exp.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/maple-exp.tar.gz -------------------------------------------------------------------------------- /experiments/cav18/table1/table1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/table1/table1.png -------------------------------------------------------------------------------- /experiments/cav18/table3/table3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesaro/dpu/5f7ae663e88a42da76fd27bcab6961500679398c/experiments/cav18/table3/table3.png -------------------------------------------------------------------------------- /experiments/stuff/Makefile.dgemm: -------------------------------------------------------------------------------- 1 | CC = wllvm 2 | EXTRACT = $(HOME)/steroid/utils/find-and-extract-bcs 3 | 4 | OBJECTS = dgemm_driver.o driver/others/memory.o ./interface/dgemm.o driver/others/openblas_get_parallel.o driver/others/openblas_set_num_threads.o driver/level3/dgemm_thread_nn.o driver/level3/dgemm_thread_nt.o driver/level3/dgemm_thread_tn.o driver/level3/dgemm_thread_tt.o driver/others/blas_server.o driver/others/openblas_env.o driver/others/parameter.o driver/others/openblas_error_handle.o ./lapack-netlib/SRC/dlarnv.o ./lapack-netlib/SRC/dlaruv.o ./kernel/dgemm_itcopy.o ./kernel/dgemm_beta.o ./kernel/dgemm_kernel.o ./kernel/dgemm_incopy.o ./kernel/dgemm_oncopy.o ./kernel/dgemm_otcopy.o driver/others/divtable.o driver/level3/dgemm_nn.o driver/level3/dgemm_tt.o driver/level3/dgemm_tn.o driver/level3/dgemm_nt.o ./driver/others/xerbla.o 5 | 6 | LIBBLAS = libopenblas_haswellp-r0.2.20.dev.a 7 | 8 | LIBS = -lm -lpthread 9 | EXEC = dgemm_driver 10 | 11 | all: ll 12 | ll: $(EXEC).full.ll 13 | 14 | $(EXEC).full.ll:$(EXEC).full.bc 15 | llvm-dis $< 16 | 17 | $(EXEC).full.bc: $(EXEC).bc 18 | $(EXTRACT) 19 | 20 | $(EXEC).bc: $(EXEC) 21 | extract-bc $(EXEC) 22 | 23 | $(EXEC): $(OBJECTS) 24 | #@$(CC) -o $(EXEC) $(OBJECTS) $(LIBS) 25 | @$(CC) -o $(EXEC) dgemm_driver.o $(LIBBLAS) $(LIBS) 26 | @echo "Linking complete!" 27 | 28 | $(OBJECTS): dgemm_driver.c 29 | export LLVM_COMPILER=clang ; make CC=wllvm 30 | wllvm -c dgemm_driver.c 31 | 32 | -------------------------------------------------------------------------------- /experiments/stuff/dgemm_driver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define dgemm dgemm_ 5 | #define dlarnv dlarnv_ 6 | 7 | #define DEFAULTSIZE 128 8 | #define NBREP 10 9 | 10 | /* constants */ 11 | static int NEXEC=1; 12 | static int IONE=1; 13 | static double c__1=1.0; 14 | char Lower='L', Transpose='T', NoTranspose='N', Forward='F', 15 | Rowwise='R',Columnwise='C', Left='L', NonUnit='N', Right='R', Up='U', NormM='M'; 16 | 17 | /* Lapack/Blas interface */ 18 | void dgemm(char *transa, char *transb, int *m, int *n, int *k, 19 | double *alpha, double *a, int *lda, double *b, int *ldb, 20 | double *beta, double *c, int *ldc); 21 | void dlarnv(int *idist, int *iseed, int *n, double *x); 22 | 23 | /* Internal interfaces */ 24 | int i, N, INFO, NN, THREADS; 25 | double *A, *B, *C, time1, time2, sum, GFlops; 26 | int ISEED[4] = {0,0,0,1}; /* initial seed for dlarnv() */ 27 | 28 | int main (int argc, char **argv){ 29 | int N, NN, i; 30 | 31 | if( argc < 2 ) { 32 | N = DEFAULTSIZE; 33 | } else { 34 | N = atoi( argv[1] ); 35 | } 36 | NN = N*N; 37 | 38 | /* Allocate data */ 39 | A = (double *)malloc(N*N*sizeof(double)); 40 | B = (double *)malloc(N*N*sizeof(double)); 41 | C = (double *)malloc(N*N*sizeof(double)); 42 | 43 | /* Fill the matrix with random values */ 44 | dlarnv(&IONE, ISEED, &NN, A); 45 | dlarnv(&IONE, ISEED, &NN, B); 46 | dlarnv(&IONE, ISEED, &NN, C); 47 | 48 | /* Call the kernel */ 49 | for( i = 0 ; i < NBREP ; i++ ) { 50 | dgemm(&NoTranspose,&NoTranspose,&N,&N,&N,&c__1,A,&N,B,&N,&c__1,C,&N); 51 | } 52 | 53 | /* Done */ 54 | free(A); 55 | free(B); 56 | free(C); 57 | 58 | return EXIT_SUCCESS; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /experiments/stuff/manip_dispatcher.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=dispatcher.c 5 | TERMS=131072 6 | EXTRACTBC=extract-bc 7 | DPU=${HOME}/dpu2/dist/bin/dpu 8 | NIDHUGG=./nidhugg.sh 9 | WLLVM=wllvm 10 | LIBS="-lpthread" 11 | COPTS="-O3" 12 | LLVMDIS=llvm-dis 13 | 14 | round() { 15 | echo "scale=3 ; $1/1000000000" | bc 16 | } 17 | 18 | function runtest { 19 | # generate the .ll file 20 | sed "s/XXXX/$1/" ${FILENAME} | sed "s/YYYY/$2/" > generated.c 21 | $WLLVM $COPTS -o generated generated.c $LIBS 22 | $EXTRACTBC generated 23 | $LLVMDIS generated.bc 24 | 25 | LINENAME="Disp. & $1 & $2 & " 26 | 27 | # run DPU experiments 28 | for ALT in 0 1 2 3 ; do 29 | echo -n $LINENAME 30 | BEGIN=`date +%s%N` 31 | $DPU generated.ll -a${ALT} 2&>1 > trace 32 | END=`date +%s%N` 33 | EXECTIME=`round $(($END-$BEGIN))` 34 | echo -n $ALT " & " $EXECTIME " & " 35 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 36 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 37 | echo -n $STAT " " $AVG 38 | 39 | if [ $ALT -eq 0 ] ; then 40 | # run Nihugg experiment 41 | BEGIN=`date +%s%N` 42 | # $NIDHUGG -sc generated.ll > trace 2> log 43 | END=`date +%s%N` 44 | EXECTIME=`round $(($END-$BEGIN))` 45 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 46 | # echo -n $EXECTIME " & " $STAT 47 | # echo "\\\\" 48 | # else 49 | fi 50 | echo "&&\\\\" 51 | done 52 | 53 | } 54 | 55 | for SNUM in 1 2 3 4 5 ; do 56 | for RNUM in 2 3 4 5 ; do 57 | if [ $RNUM -ge $SNUM ] ; then 58 | runtest $SNUM $RNUM 59 | fi 60 | done 61 | done 62 | -------------------------------------------------------------------------------- /experiments/stuff/manip_mpat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=mpat.c 5 | EXTRACTBC=extract-bc 6 | DPU=${HOME}/dpu2/dist/bin/dpu 7 | NIDHUGG=./nidhugg.sh 8 | WLLVM=wllvm 9 | LIBS="-lpthread" 10 | COPTS="-O3" 11 | LLVMDIS=llvm-dis 12 | 13 | round() { 14 | echo "scale=3 ; $1/1000000000" | bc 15 | } 16 | 17 | function runtest { 18 | # generate the .ll file 19 | sed "s/XXXX/$1/" ${FILENAME} > generated.c 20 | $WLLVM $COPTS -o generated generated.c $LIBS 21 | $EXTRACTBC generated 22 | $LLVMDIS generated.bc 23 | 24 | LINENAME="MPAT & $1 & " 25 | 26 | # run DPU experiments 27 | for ALT in 0 1 2 3 ; do 28 | echo -n $LINENAME 29 | BEGIN=`date +%s%N` 30 | $DPU generated.ll -a${ALT} 2&>1 > trace 31 | END=`date +%s%N` 32 | EXECTIME=`round $(($END-$BEGIN))` 33 | echo -n $ALT " & " $EXECTIME " & " 34 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 35 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 36 | echo -n $STAT " " $AVG 37 | 38 | if [ $ALT -eq 0 ] ; then 39 | # run Nihugg experiment 40 | BEGIN=`date +%s%N` 41 | $NIDHUGG -sc generated.ll > trace 2> log 42 | END=`date +%s%N` 43 | EXECTIME=`round $(($END-$BEGIN))` 44 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 45 | echo -n $EXECTIME " & " $STAT 46 | echo "\\\\" 47 | else 48 | echo "&&\\\\" 49 | fi 50 | done 51 | 52 | } 53 | 54 | for K in 1 2 3 4 5 ; do 55 | runtest $K 56 | done 57 | -------------------------------------------------------------------------------- /experiments/stuff/manip_poke.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=poke.c 5 | EXTRACTBC=extract-bc 6 | DPU=${HOME}/dpu2/dist/bin/dpu 7 | NIDHUGG=./nidhugg.sh 8 | WLLVM=wllvm 9 | LIBS="-lpthread" 10 | COPTS="-O3" 11 | LLVMDIS=llvm-dis 12 | 13 | round() { 14 | echo "scale=3 ; $1/1000000000" | bc 15 | } 16 | 17 | function runtest { 18 | # generate the .ll file 19 | sed "s/XXXX/$1/" ${FILENAME} | sed "s/YYYY/$2/" > generated.c 20 | $WLLVM $COPTS -o generated generated.c $LIBS 21 | $EXTRACTBC generated 22 | $LLVMDIS generated.bc 23 | 24 | LINENAME="Poke $2 & $1 & " 25 | 26 | # run DPU experiments 27 | for ALT in 0 1 2 3 ; do 28 | echo -n $LINENAME 29 | BEGIN=`date +%s%N` 30 | $DPU generated.ll -a${ALT} 2&>1 > trace 31 | END=`date +%s%N` 32 | EXECTIME=`round $(($END-$BEGIN))` 33 | echo -n $ALT " & " $EXECTIME " & " 34 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 35 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 36 | echo -n $STAT " " $AVG 37 | 38 | if [ $ALT -eq 0 ] ; then 39 | # run Nihugg experiment 40 | BEGIN=`date +%s%N` 41 | $NIDHUGG -sc generated.ll > trace 2> log 42 | END=`date +%s%N` 43 | EXECTIME=`round $(($END-$BEGIN))` 44 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 45 | echo -n $EXECTIME " & " $STAT 46 | echo "\\\\" 47 | else 48 | echo "&&\\\\" 49 | fi 50 | done 51 | 52 | } 53 | 54 | for K in 2 3 4 6 8 ; do 55 | for TH in `seq 3 10` ; do 56 | runtest $TH $K 57 | done 58 | done 59 | -------------------------------------------------------------------------------- /experiments/stuff/manip_spat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=spat.c 5 | EXTRACTBC=extract-bc 6 | DPU=${HOME}/dpu2/dist/bin/dpu 7 | NIDHUGG=./nidhugg.sh 8 | WLLVM=wllvm 9 | LIBS="-lpthread" 10 | COPTS="-O3" 11 | LLVMDIS=llvm-dis 12 | 13 | round() { 14 | echo "scale=3 ; $1/1000000000" | bc 15 | } 16 | 17 | function runtest { 18 | # generate the .ll file 19 | sed "s/XXXX/$1/" ${FILENAME} | sed "s/YYYY/$2/" > generated.c 20 | $WLLVM $COPTS -o generated generated.c $LIBS 21 | $EXTRACTBC generated 22 | $LLVMDIS generated.bc 23 | 24 | LINENAME="SPAT $2 & $1 & " 25 | 26 | # run DPU experiments 27 | for ALT in 0 1 2 3 ; do 28 | echo -n $LINENAME 29 | BEGIN=`date +%s%N` 30 | $DPU generated.ll -a${ALT} 2&>1 > trace 31 | END=`date +%s%N` 32 | EXECTIME=`round $(($END-$BEGIN))` 33 | echo -n $ALT " & " $EXECTIME " & " 34 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 35 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 36 | echo -n $STAT " " $AVG 37 | 38 | if [ $ALT -eq 0 ] ; then 39 | # run Nihugg experiment 40 | BEGIN=`date +%s%N` 41 | $NIDHUGG -sc generated.ll > trace 2> log 42 | END=`date +%s%N` 43 | EXECTIME=`round $(($END-$BEGIN))` 44 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 45 | echo -n $EXECTIME " & " $STAT 46 | echo "\\\\" 47 | else 48 | echo "&&\\\\" 49 | fi 50 | done 51 | 52 | } 53 | 54 | for K in 10 20 30 50 100 200 300 500 1000 ; do 55 | for TH in 1 2 3 4 5 6 8; do 56 | runtest $TH $K 57 | done 58 | done 59 | -------------------------------------------------------------------------------- /experiments/stuff/manip_ssb3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=ssb3.c 5 | EXTRACTBC=extract-bc 6 | DPU=${HOME}/dpu2/dist/bin/dpu 7 | NIDHUGG=./nidhugg.sh 8 | WLLVM=wllvm 9 | LIBS="-lpthread" 10 | COPTS="-O3" 11 | LLVMDIS=llvm-dis 12 | 13 | round() { 14 | echo "scale=3 ; $1/1000000000" | bc 15 | } 16 | 17 | function runtest { 18 | # generate the .ll file 19 | sed "s/XXXX/$1/" ${FILENAME} | sed "s/YYYY/$2/" > generated.c 20 | $WLLVM $COPTS -o generated generated.c $LIBS 21 | $EXTRACTBC generated 22 | $LLVMDIS generated.bc 23 | 24 | LINENAME="SSB3 $2 & $(($1+2)) & " 25 | 26 | # run DPU experiments 27 | for ALT in 0 1 2 3 ; do 28 | echo -n $LINENAME 29 | BEGIN=`date +%s%N` 30 | $DPU generated.ll -a${ALT} 2&>1 > trace 31 | END=`date +%s%N` 32 | EXECTIME=`round $(($END-$BEGIN))` 33 | echo -n $ALT " & " $EXECTIME " & " 34 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 35 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 36 | echo -n $STAT " " $AVG 37 | 38 | if [ $ALT -eq 0 ] ; then 39 | # run Nihugg experiment 40 | BEGIN=`date +%s%N` 41 | $NIDHUGG -sc generated.ll > trace 2> log 42 | END=`date +%s%N` 43 | EXECTIME=`round $(($END-$BEGIN))` 44 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 45 | echo -n $EXECTIME " & " $STAT 46 | echo "\\\\" 47 | else 48 | echo "&&\\\\" 49 | fi 50 | done 51 | 52 | } 53 | 54 | for K in 1 2 3 4 5 6 ; do 55 | for TH in 1 2 3 4 5 6 8; do 56 | runtest $TH $K 57 | done 58 | done 59 | -------------------------------------------------------------------------------- /experiments/stuff/manip_ssbexp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=ssbexp.c 5 | EXTRACTBC=extract-bc 6 | DPU=${HOME}/dpu2/dist/bin/dpu 7 | NIDHUGG=./nidhugg.sh 8 | WLLVM=wllvm 9 | LIBS="-lpthread" 10 | COPTS="-O3" 11 | LLVMDIS=llvm-dis 12 | 13 | round() { 14 | echo "scale=3 ; $1/1000000000" | bc 15 | } 16 | 17 | function runtest { 18 | # generate the .ll file 19 | sed "s/XXXX/$1/" ${FILENAME} > generated.c 20 | $WLLVM $COPTS -o generated generated.c $LIBS 21 | $EXTRACTBC generated 22 | $LLVMDIS generated.bc 23 | 24 | LINENAME="SSBexp & $(($1+1)) & " 25 | 26 | # run DPU experiments 27 | for ALT in 0 1 2 3 ; do 28 | echo -n $LINENAME 29 | BEGIN=`date +%s%N` 30 | $DPU generated.ll -a${ALT} 2&>1 > trace 31 | END=`date +%s%N` 32 | EXECTIME=`round $(($END-$BEGIN))` 33 | echo -n $ALT " & " $EXECTIME " & " 34 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 35 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 36 | echo -n $STAT " " $AVG 37 | 38 | if [ $ALT -eq 0 ] ; then 39 | # run Nihugg experiment 40 | BEGIN=`date +%s%N` 41 | $NIDHUGG -sc generated.ll > trace 2> log 42 | END=`date +%s%N` 43 | EXECTIME=`round $(($END-$BEGIN))` 44 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 45 | echo -n $EXECTIME " & " $STAT 46 | echo "\\\\" 47 | else 48 | echo "&&\\\\" 49 | fi 50 | done 51 | 52 | } 53 | 54 | for TH in 1 2 3 4 5 6 8; do 55 | runtest $TH 56 | done 57 | -------------------------------------------------------------------------------- /experiments/stuff/manip_ssbsimple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=ssbsimple.c 5 | EXTRACTBC=extract-bc 6 | DPU=${HOME}/dpu2/dist/bin/dpu 7 | NIDHUGG=./nidhugg.sh 8 | WLLVM=wllvm 9 | LIBS="-lpthread" 10 | COPTS="-O3" 11 | LLVMDIS=llvm-dis 12 | 13 | round() { 14 | echo "scale=3 ; $1/1000000000" | bc 15 | } 16 | 17 | function runtest { 18 | # generate the .ll file 19 | # sed "s/XXXX/$1/" ${FILENAME} > generated.c 20 | cp ${FILENAME} generated.c 21 | $WLLVM $COPTS -o generated generated.c $LIBS 22 | $EXTRACTBC generated 23 | $LLVMDIS generated.bc 24 | 25 | LINENAME="SSBsimple & " 26 | 27 | # run DPU experiments 28 | for ALT in 0 1 2 3 ; do 29 | echo -n $LINENAME 30 | BEGIN=`date +%s%N` 31 | $DPU generated.ll -a${ALT} 2&>1 > trace 32 | END=`date +%s%N` 33 | EXECTIME=`round $(($END-$BEGIN))` 34 | echo -n $ALT " & " $EXECTIME " & " 35 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 36 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 37 | echo -n $STAT " " $AVG 38 | 39 | if [ $ALT -eq 0 ] ; then 40 | # run Nihugg experiment 41 | BEGIN=`date +%s%N` 42 | $NIDHUGG -sc generated.ll > trace 2> log 43 | END=`date +%s%N` 44 | EXECTIME=`round $(($END-$BEGIN))` 45 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 46 | echo -n $EXECTIME " & " $STAT 47 | echo "\\\\" 48 | else 49 | echo "&&\\\\" 50 | fi 51 | done 52 | 53 | } 54 | 55 | runtest 56 | 57 | -------------------------------------------------------------------------------- /experiments/stuff/nidhugg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/local/bin/nidhuggc \ 4 | --nidhugg=/usr/local/bin/nidhugg \ 5 | -extfun-no-race=printf \ 6 | -extfun-no-race=write \ 7 | -extfun-no-race=exit \ 8 | -extfun-no-race=atoi \ 9 | -extfun-no-race=pthread_mutexattr_init \ 10 | -extfun-no-race=pthread_yield \ 11 | -extfun-no-race=pthread_detach \ 12 | -extfun-no-race=pthread_mutexattr_settype \ 13 | -extfun-no-race=pthread_mutexattr_init \ 14 | $* 15 | -------------------------------------------------------------------------------- /experiments/stuff/posixtestsuite-philo/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = sem_philosopher 2 | FULL = $(addsuffix .full.bc, $(EXEC)) 3 | 4 | all: $(FULL) 5 | 6 | EXTRACTBC = extract-bc 7 | STEROID = $(HOME)/steroid/utils/find-and-extract-bcs 8 | DIS = llvm-dis 9 | CC = wllvm 10 | LIBS = -lpthread 11 | DPU = $(HOME)/dpu2/dist/bin/dpu 12 | 13 | BC = $(addsuffix .bc, $(EXEC)) 14 | bc: $(BC) 15 | LL = $(addsuffix .ll, $(EXEC)) 16 | ll: $(LL) 17 | SOURCES = $(addsuffix .c, $(EXEC)) 18 | 19 | sem_conpro: sem_conpro.c 20 | $(CC) -O3 -o $@ $^ $(LIBS) 21 | 22 | sem_philosopher: sem_philosopher.c 23 | $(CC) -O3 -o $@ $^ $(LIBS) 24 | 25 | sem_sleepingbarber: sem_sleepingbarber.c 26 | $(CC) -O3 -o $@ $^ $(LIBS) 27 | 28 | sem_conpro.bc: sem_conpro 29 | $(EXTRACTBC) $^ 30 | 31 | sem_philosopher.bc: sem_philosopher 32 | $(EXTRACTBC) $^ 33 | 34 | sem_sleepingbarber.bc: sem_sleepingbarber 35 | $(EXTRACTBC) $^ 36 | 37 | %.ll: %.bc 38 | $(DIS) $^ 39 | 40 | %.full.bc: $(BC) 41 | $(STEROID) 42 | 43 | run: $(FULL) 44 | $(DPU) $< -vv 45 | $(DPU) $(word 2,$^) -vv 46 | $(DPU) $(word 3,$^) -vv 47 | 48 | clean: 49 | rm -f $(FULL) $(EXEC) $(BC) $(LL) 50 | 51 | .PHONY: clean run 52 | 53 | 54 | -------------------------------------------------------------------------------- /experiments/stuff/posixtestsuite-philo/posixtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 | * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com 4 | * This file is licensed under the GPL license. For the full content 5 | * of this license, see the COPYING file at the top level of this 6 | * source tree. 7 | */ 8 | 9 | /* 10 | * return codes 11 | */ 12 | #define PTS_PASS 0 13 | #define PTS_FAIL 1 14 | #define PTS_UNRESOLVED 2 15 | #define PTS_UNSUPPORTED 4 16 | #define PTS_UNTESTED 5 17 | 18 | -------------------------------------------------------------------------------- /experiments/stuff/posixtestsuite-unlock/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = 2-1 2 | FULL = $(addsuffix .full.bc, $(EXEC)) 3 | 4 | all: $(FULL) 5 | 6 | EXTRACTBC = extract-bc 7 | STEROID = $(HOME)/steroid/utils/find-and-extract-bcs 8 | DIS = llvm-dis 9 | CC = wllvm 10 | LIBS = -lpthread 11 | DPU = $(HOME)/dpu2/dist/bin/dpu 12 | 13 | BC = $(addsuffix .bc, $(EXEC)) 14 | bc: $(BC) 15 | LL = $(addsuffix .ll, $(EXEC)) 16 | ll: $(LL) 17 | SOURCES = $(addsuffix .c, $(EXEC)) 18 | 19 | 1-1: 1-1.c 20 | $(CC) -O3 -o $@ $^ $(LIBS) 21 | 22 | 2-1: 2-1.c 23 | $(CC) -O3 -o $@ $^ $(LIBS) 24 | 25 | 3-1: 3-1.c 26 | $(CC) -O3 -o $@ $^ $(LIBS) 27 | 28 | 5-1: 5-1.c 29 | $(CC) -O3 -o $@ $^ $(LIBS) 30 | 31 | 5-2: 5-2.c 32 | $(CC) -O3 -o $@ $^ $(LIBS) 33 | 34 | 1-1.bc: 1-1 35 | $(EXTRACTBC) $^ 36 | 37 | 2-1.bc: 2-1 38 | $(EXTRACTBC) $^ 39 | 40 | 3-1.bc: 3-1 41 | $(EXTRACTBC) $^ 42 | 43 | 5-1.bc: 5-1 44 | $(EXTRACTBC) $^ 45 | 46 | 5-2.bc: 5-2 47 | $(EXTRACTBC) $^ 48 | 49 | %.ll: %.bc 50 | $(DIS) $^ 51 | 52 | %.full.bc: $(BC) 53 | $(STEROID) 54 | 55 | run: $(FULL) 56 | $(DPU) $< -vv 57 | $(DPU) $(word 2,$^) -vv 58 | $(DPU) $(word 3,$^) -vv 59 | $(DPU) $(word 4,$^) -vv 60 | $(DPU) $(word 5,$^) -vv 61 | 62 | clean: 63 | rm -f $(FULL) $(EXEC) $(BC) $(LL) 64 | 65 | .PHONY: clean run 66 | 67 | 68 | -------------------------------------------------------------------------------- /experiments/stuff/posixtestsuite-unlock/manips.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | FILENAME=2-1_generic.c 5 | LOOPS=2 6 | EXTRACTBC=extract-bc 7 | DPU=${HOME}/dpu2/dist/bin/dpu 8 | NIDHUGG=./nidhugg.sh 9 | WLLVM=wllvm 10 | LIBS="-lpthread" 11 | COPTS="-O3" 12 | LLVMDIS=llvm-dis 13 | 14 | 15 | round() { 16 | echo "scale=3 ; $1/1000000000" | bc 17 | } 18 | 19 | function runtest { 20 | # generate the .ll file 21 | sed "s/XXXX/$1/" ${FILENAME} | sed "s/YYYY/$2/" > generated.c 22 | $WLLVM $COPTS -o generated generated.c $LIBS 23 | $EXTRACTBC generated 24 | $LLVMDIS generated.bc 25 | # transform it for Nidhugg 26 | # $NIDHUGG --transform=nidhugg.ll generated.ll 2&>1 | grep -v "warning" | grep -v "Warning" 27 | 28 | LINENAME="Posix unlock & $1 & $2 & " 29 | 30 | # run DPU experiments 31 | for ALT in 0 1 2 3 ; do 32 | echo -n $LINENAME 33 | BEGIN=`date +%s%N` 34 | $DPU generated.ll -a${ALT} 2&>1 > trace 35 | END=`date +%s%N` 36 | EXECTIME=`round $(($END-$BEGIN))` 37 | echo -n $ALT " & " $EXECTIME " & " 38 | AVG=`grep 'average max trail size' trace | awk '{print $4 " & " }'` 39 | STAT=`grep 'summary' trace | awk '{print $3 " & " $5 " & " $7 " & " }'` 40 | echo -n $STAT " " $AVG 41 | 42 | if [ $ALT -eq 0 ] ; then 43 | # run Nihugg experiment 44 | BEGIN=`date +%s%N` 45 | $NIDHUGG -sc generated.ll > trace 2> log 46 | END=`date +%s%N` 47 | EXECTIME=`round $(($END-$BEGIN))` 48 | STAT=`grep "Trace" trace | awk '{print $3 " & " $5}'` 49 | echo -n $EXECTIME " & " $STAT 50 | echo "\\\\" 51 | else 52 | echo "&&\\\\" 53 | fi 54 | done 55 | 56 | } 57 | 58 | for NT in 2 3 4 5 6 8 10 ; do 59 | runtest $NT $LOOPS 60 | done 61 | -------------------------------------------------------------------------------- /experiments/stuff/posixtestsuite-unlock/nidhugg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/local/bin/nidhuggc \ 4 | --nidhugg=/usr/local/bin/nidhugg \ 5 | -extfun-no-race=printf \ 6 | -extfun-no-race=write \ 7 | -extfun-no-race=exit \ 8 | -extfun-no-race=atoi \ 9 | $* 10 | -------------------------------------------------------------------------------- /experiments/stuff/posixtestsuite-unlock/posixtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 | * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com 4 | * This file is licensed under the GPL license. For the full content 5 | * of this license, see the COPYING file at the top level of this 6 | * source tree. 7 | */ 8 | 9 | /* 10 | * return codes 11 | */ 12 | #define PTS_PASS 0 13 | #define PTS_FAIL 1 14 | #define PTS_UNRESOLVED 2 15 | #define PTS_UNSUPPORTED 4 16 | #define PTS_UNTESTED 5 17 | 18 | -------------------------------------------------------------------------------- /experiments/stuff/ring/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = c-ring 2 | FULL = $(EXEC).bc 3 | 4 | all: $(FULL) 5 | 6 | EXTRACTBC = extract-bc 7 | STEROID = $(HOME)/steroid/utils/find-and-extract-bcs 8 | DIS = llvm-dis 9 | CC = wllvm -Wno-int-to-void-pointer-cast -DSTATIC_TH_STACK 10 | LIBS = -lpthread 11 | DPU = $(HOME)/dpu2/dist/bin/dpu 12 | 13 | BC = $(addsuffix .bc, $(EXEC)) 14 | bc: $(BC) 15 | LL = $(addsuffix .ll, $(EXEC)) 16 | ll: $(LL) 17 | SOURCES = $(addsuffix .c, $(EXEC)) 18 | 19 | c-ring: c-ring.c 20 | $(CC) -O3 -o $@ $^ $(LIBS) 21 | 22 | c-ring.bc: c-ring 23 | $(EXTRACTBC) $^ 24 | 25 | run: $(FULL) 26 | $(DPU) $< -vv -- 1 50 12 27 | 28 | clean: 29 | rm -f $(FULL) $(EXEC) $(BC) $(LL) 30 | 31 | .PHONY: clean run 32 | 33 | 34 | -------------------------------------------------------------------------------- /experiments/svcomp17/README.rst: -------------------------------------------------------------------------------- 1 | 2 | Experiments with the SVCOMP'17 Benchmarks 3 | ========================================= 4 | 5 | ======================== ====================================================== 6 | Folder Status 7 | ======================== ====================================================== 8 | ``pthread`` Almost all benchmarks in this folder run with DPU. 9 | ``pthread-C-DAC`` TBD 10 | ``pthread-atomic`` TBD 11 | ``pthread-complex`` TBD 12 | ``pthread-driver-races`` TBD 13 | ``pthread-ext`` TBD 14 | ``pthread-lit`` TBD 15 | ``pthread-wmm`` DPU does not suppot weak memory, no benchmark in this 16 | folder can be anlayzed with DPU. 17 | ======================== ====================================================== 18 | 19 | How the benchmarks were obtained 20 | ================================ 21 | 22 | On November 2, 2017, we went to 23 | https://github.com/sosy-lab/sv-benchmarks/tree/master/c and listed all the 24 | relevant directories:: 25 | 26 | pthread 27 | pthread-C-DAC 28 | pthread-atomic 29 | pthread-complex 30 | pthread-driver-races 31 | pthread-ext 32 | pthread-lit 33 | pthread-wmm 34 | 35 | We now produced a list of the files in each of the folders: 36 | 37 | .. code:: shell 38 | 39 | for i in pthread pthread-C-DAC pthread-atomic pthread-complex \ 40 | pthread-driver-races pthread-ext pthread-lit 41 | do 42 | svn ls https://github.com/sosy-lab/sv-benchmarks.git/trunk/c/$i > $i; 43 | done 44 | 45 | Files downloaded by running the command: 46 | 47 | .. code:: shell 48 | 49 | wget -x -i URLs 50 | 51 | The files in folder ``c/pthread-driver-races/model`` were downloaded by other 52 | means. 53 | 54 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/01_inc_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | //http://www.ibm.com/developerworks/java/library/j-jtp04186/index.html 5 | //A counter using locks 6 | 7 | #include 8 | 9 | #define assume(e) __VERIFIER_assume(e) 10 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 11 | 12 | volatile unsigned value, m = 0; 13 | 14 | void __VERIFIER_atomic_acquire() 15 | { 16 | assume(m==0); 17 | m = 1; 18 | } 19 | 20 | void __VERIFIER_atomic_release() 21 | { 22 | assume(m==1); 23 | m = 0; 24 | } 25 | 26 | void * thr1(void* arg) { 27 | unsigned v = 0; 28 | 29 | __VERIFIER_atomic_acquire(); 30 | if(value == 0u-1) { 31 | __VERIFIER_atomic_release(); 32 | 33 | return 0; 34 | }else{ 35 | 36 | v = value; 37 | value = v + 1; 38 | __VERIFIER_atomic_release(); 39 | 40 | assert(value > v); 41 | 42 | return 0; 43 | } 44 | } 45 | 46 | int main(){ 47 | pthread_t t; 48 | 49 | while(1) { pthread_create(&t, 0, thr1, 0); } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/02_inc_cas_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | //http://www.ibm.com/developerworks/java/library/j-jtp04186/index.html 4 | //Listing 2. A nonblocking counter using CAS 5 | 6 | #include 7 | 8 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 9 | 10 | void __VERIFIER_atomic_CAS( 11 | volatile unsigned *v, 12 | unsigned e, 13 | unsigned u, 14 | unsigned *r) 15 | { 16 | if(*v == e) 17 | { 18 | *v = u, *r = 1; 19 | } 20 | else 21 | { 22 | *r = 0; 23 | } 24 | } 25 | 26 | volatile unsigned value; 27 | 28 | void* thr1(void* arg) { 29 | unsigned v,vn,casret; 30 | 31 | do { 32 | v = value; 33 | 34 | if(v == 0u-1) { 35 | return 0; 36 | } 37 | 38 | vn = v + 1; 39 | 40 | __VERIFIER_atomic_CAS(&value,v,vn,&casret); 41 | } 42 | while (casret==0); 43 | assert(value > v); 44 | 45 | return 0; 46 | } 47 | 48 | int main(){ 49 | pthread_t t; 50 | 51 | while(1) { pthread_create(&t, 0, thr1, 0); } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/05_tas_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | //Simple test_and_set lock with exponential backoff 4 | // 5 | //From Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors, 1991 (Fig. 1). 6 | //Also available as pseudo-code here: http://www.cs.rochester.edu/research/synchronization/pseudocode/ss.html#tas 7 | 8 | #include 9 | 10 | #define unlocked 0 11 | #define locked 1 12 | volatile int lock = unlocked; 13 | 14 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 15 | 16 | void __VERIFIER_atomic_TAS( 17 | volatile int *v, 18 | volatile int *o) 19 | { 20 | *o = *v; 21 | *v = 1; 22 | } 23 | 24 | inline void acquire_lock(){ 25 | unsigned int delay; 26 | int cond; 27 | 28 | delay = 1; 29 | __VERIFIER_atomic_TAS(&lock,&cond); 30 | while(cond == locked){ 31 | //pause(delay); 32 | if(delay*2 > delay) 33 | delay *= 2; 34 | __VERIFIER_atomic_TAS(&lock,&cond); 35 | } 36 | assert(cond != lock); 37 | } 38 | 39 | inline void release_lock(){ 40 | assert(lock != unlocked); 41 | lock = unlocked; 42 | } 43 | 44 | int c = 0; 45 | void* thr1(void *arg){ 46 | while(1){ 47 | acquire_lock(); 48 | c++; assert(c == 1); c--; 49 | release_lock(); 50 | } 51 | return 0; 52 | } 53 | 54 | int main(){ 55 | pthread_t t; 56 | 57 | while(1) { pthread_create(&t, 0, thr1, 0); } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/09_fmaxsym_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | extern int __VERIFIER_nondet_int(); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 9 | 10 | #define WORKPERTHREAD 2 11 | #define THREADSMAX 3 12 | volatile int max = 0x80000000, m = 0; 13 | 14 | void __VERIFIER_atomic_acquire() 15 | { 16 | assume(m==0); 17 | m = 1; 18 | } 19 | 20 | void __VERIFIER_atomic_release() 21 | { 22 | assume(m==1); 23 | m = 0; 24 | } 25 | 26 | int storage[WORKPERTHREAD*THREADSMAX]; 27 | 28 | inline void findMax(int offset) 29 | { 30 | int i; 31 | int e; 32 | 33 | for(i = offset; i < offset+WORKPERTHREAD; i++) { 34 | e = storage[i]; 35 | 36 | __VERIFIER_atomic_acquire(); 37 | { 38 | if(e > max) { 39 | max = e; 40 | } 41 | } 42 | __VERIFIER_atomic_release(); 43 | assert(e <= max); 44 | } 45 | } 46 | 47 | void* thr1(void* arg) { 48 | int offset=__VERIFIER_nondet_int(); 49 | 50 | assume(offset % WORKPERTHREAD == 0 && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 51 | //assume(offset < WORKPERTHREAD && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 52 | 53 | findMax(offset); 54 | 55 | return 0; 56 | } 57 | 58 | int main(){ 59 | pthread_t t; 60 | 61 | while(1) { pthread_create(&t, 0, thr1, 0); } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/10_fmaxsym_cas_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | extern int __VERIFIER_nondet_int(); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 9 | 10 | #define WORKPERTHREAD 2 11 | #define THREADSMAX 3 12 | volatile int max = 0x80000000; 13 | 14 | int storage[WORKPERTHREAD*THREADSMAX]; 15 | 16 | void __VERIFIER_atomic_CAS( 17 | volatile int *v, 18 | int e, 19 | int u, 20 | int *r) 21 | { 22 | if(*v == e) 23 | { 24 | *v = u, *r = 1; 25 | } 26 | else 27 | { 28 | *r = 0; 29 | } 30 | } 31 | 32 | inline void findMax(int offset){ 33 | int i; 34 | int e; 35 | int c; 36 | int cret; 37 | 38 | for(i = offset; i < offset+WORKPERTHREAD; i++) { 39 | e = storage[i]; 40 | 41 | while(1){ 42 | c = max; 43 | if(e > c){ 44 | __VERIFIER_atomic_CAS(&max,c,e,&cret); 45 | if(cret){ 46 | break; 47 | } 48 | }else{ 49 | break; 50 | } 51 | } 52 | 53 | assert(e <= max); 54 | } 55 | } 56 | 57 | void* thr1(void* arg) { 58 | int offset=__VERIFIER_nondet_int(); 59 | 60 | assume(offset % WORKPERTHREAD == 0 && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 61 | //assume(offset < WORKPERTHREAD && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 62 | 63 | findMax(offset); 64 | 65 | return 0; 66 | } 67 | 68 | int main(){ 69 | pthread_t t; 70 | 71 | while(1) { pthread_create(&t, 0, thr1, 0); } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/11_fmaxsymopt_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | extern int __VERIFIER_nondet_int(); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert_nl(e) { if(!(e)) { goto ERROR; } } 9 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 10 | 11 | #define WORKPERTHREAD 2 12 | #define THREADSMAX 3 13 | volatile int max = 0x80000000, m = 0; 14 | 15 | void __VERIFIER_atomic_acquire() 16 | { 17 | assume(m==0); 18 | m = 1; 19 | } 20 | 21 | void __VERIFIER_atomic_release() 22 | { 23 | assume(m==1); 24 | m = 0; 25 | } 26 | 27 | int storage[WORKPERTHREAD*THREADSMAX]; 28 | 29 | inline void findMax(int offset){ 30 | 31 | int i; 32 | int e; 33 | int my_max = 0x80000000; 34 | 35 | for(i = offset; i < offset+WORKPERTHREAD; i++) { 36 | #ifndef NOBUG 37 | e = storage[i]; 38 | #else 39 | e = rand(); 40 | #endif 41 | 42 | if(e > my_max) { 43 | my_max = e; 44 | } 45 | assert_nl(e <= my_max); 46 | } 47 | 48 | __VERIFIER_atomic_acquire(); 49 | { 50 | if(my_max > max) { 51 | max = my_max; 52 | } 53 | } 54 | __VERIFIER_atomic_release(); 55 | 56 | assert(my_max <= max); 57 | } 58 | 59 | void* thr1(void* arg) { 60 | int offset=__VERIFIER_nondet_int(); 61 | 62 | assume(offset % WORKPERTHREAD == 0 && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 63 | //assume(offset < WORKPERTHREAD && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 64 | 65 | findMax(offset); 66 | 67 | return 0; 68 | } 69 | 70 | int main(){ 71 | pthread_t t; 72 | 73 | while(1) { pthread_create(&t, 0, thr1, 0); } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/12_fmaxsymopt_cas_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | extern int __VERIFIER_nondet_int(); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert_nl(e) { if(!(e)) { goto ERROR; } } 9 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 10 | 11 | void __VERIFIER_atomic_CAS( 12 | volatile int *v, 13 | int e, 14 | int u, 15 | int *r) 16 | { 17 | if(*v == e) 18 | { 19 | *v = u, *r = 1; 20 | } 21 | else 22 | { 23 | *r = 0; 24 | } 25 | } 26 | 27 | #define WORKPERTHREAD 2 28 | #define THREADSMAX 3 29 | volatile int max = 0x80000000; 30 | 31 | int storage[WORKPERTHREAD*THREADSMAX]; 32 | 33 | inline void findMax(int offset){ 34 | int i; 35 | int e; 36 | int my_max = 0x80000000; 37 | int c; 38 | int cret; 39 | 40 | for(i = offset; i < offset+WORKPERTHREAD; i++) { 41 | e = storage[i]; 42 | if(e > my_max) { 43 | my_max = e; 44 | } 45 | assert_nl(e <= my_max); 46 | } 47 | 48 | while(1){ 49 | c = max; 50 | if(my_max > c){ 51 | __VERIFIER_atomic_CAS(&max,c,my_max,&cret); 52 | if(cret){ 53 | break; 54 | } 55 | }else{ 56 | break; 57 | } 58 | } 59 | 60 | assert(my_max <= max); 61 | } 62 | 63 | void* thr1(void* arg) { 64 | int offset=__VERIFIER_nondet_int(); 65 | 66 | assume(offset % WORKPERTHREAD == 0 && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 67 | //assume(offset < WORKPERTHREAD && offset >= 0 && offset < WORKPERTHREAD*THREADSMAX); 68 | 69 | findMax(offset); 70 | 71 | return 0; 72 | } 73 | 74 | int main(){ 75 | pthread_t t; 76 | 77 | while(1) { pthread_create(&t, 0, thr1, 0); } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/13_unverif_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | //Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs (Extended Technical Report). CoRR abs/1102.2330 (2011) 5 | 6 | #include 7 | 8 | #define assume(e) __VERIFIER_assume(e) 9 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 10 | 11 | unsigned int r = 0; 12 | unsigned int s = 0; 13 | 14 | void __VERIFIER_atomic_inc_r() 15 | { 16 | assume(r!=-1); //to avoid overflows 17 | r = r + 1; 18 | } 19 | 20 | void* thr1(void* arg){ 21 | unsigned int l = 0; 22 | 23 | __VERIFIER_atomic_inc_r(); 24 | if(r == 1){ 25 | L3: s = s + 1; 26 | l = l + 1; 27 | assert(s == l); 28 | goto L3; 29 | } 30 | 31 | return 0; 32 | } 33 | 34 | int main(){ 35 | pthread_t t; 36 | 37 | while(1){ 38 | pthread_create(&t, 0, thr1, 0); 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/14_spin2003_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assume(e) __VERIFIER_assume(e) 7 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 8 | 9 | int x=1, m=0; 10 | 11 | void __VERIFIER_atomic_acquire() 12 | { 13 | assume(m==0); 14 | m = 1; 15 | } 16 | 17 | void __VERIFIER_atomic_release() 18 | { 19 | assume(m==1); 20 | m = 0; 21 | } 22 | 23 | void* thr1(void* arg) { 24 | __VERIFIER_atomic_acquire(); // m=0 /\ m'=1 25 | x = 0; 26 | x = 1; 27 | assert(x>=1); 28 | __VERIFIER_atomic_release(); 29 | 30 | return 0; 31 | } 32 | 33 | int main() 34 | { 35 | pthread_t t; 36 | 37 | while(1) pthread_create(&t, 0, thr1, 0); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/15_dekker_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 6 | 7 | int flag1 = 0, flag2 = 0; // N boolean flags 8 | int turn = 0; // integer variable to hold the ID of the thread whose turn is it 9 | int x; // variable to test mutual exclusion 10 | 11 | void* thr1(void* arg) { 12 | flag1 = 1; 13 | while (flag2 >= 1) { 14 | if (turn != 0) { 15 | flag1 = 0; 16 | while (turn != 0) {}; 17 | flag1 = 1; 18 | } 19 | } 20 | // begin: critical section 21 | x = 0; 22 | assert(x<=0); 23 | // end: critical section 24 | turn = 1; 25 | flag1 = 0; 26 | 27 | return 0; 28 | } 29 | 30 | void* thr2(void* arg) { 31 | flag2 = 1; 32 | while (flag1 >= 1) { 33 | if (turn != 1) { 34 | flag2 = 0; 35 | while (turn != 1) {}; 36 | flag2 = 1; 37 | } 38 | } 39 | // begin: critical section 40 | x = 1; 41 | assert(x>=1); 42 | // end: critical section 43 | turn = 1; 44 | flag2 = 0; 45 | 46 | return 0; 47 | } 48 | 49 | int main() 50 | { 51 | pthread_t t; 52 | 53 | pthread_create(&t, 0, thr1, 0); 54 | thr2(0); 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/16_peterson_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 6 | 7 | int turn; // integer variable to hold the ID of the thread whose turn is it 8 | int x; // variable to test mutual exclusion 9 | int flag1 = 0, flag2 = 0; // boolean flags 10 | 11 | void* thr1(void* arg) { // frontend produces 12 transitions from this thread. It would be better if it would produce only 8! 12 | flag1 = 1; 13 | turn = 1; 14 | do {} while (flag2==1 && turn==1); 15 | // begin: critical section 16 | x = 0; 17 | assert(x<=0); 18 | // end: critical section 19 | flag1 = 0; 20 | 21 | return 0; 22 | } 23 | 24 | void* thr2(void* arg) { 25 | flag2 = 1; 26 | turn = 0; 27 | do {} while (flag1==1 && turn==0); 28 | // begin: critical section 29 | x = 1; 30 | assert (x>=1); 31 | // end: critical section 32 | flag2 = 0; 33 | 34 | return 0; 35 | } 36 | 37 | int main() 38 | { 39 | pthread_t t; 40 | 41 | pthread_create(&t, 0, thr1, 0); 42 | thr2(0); 43 | 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/17_szymanski_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 6 | 7 | int flag1 = 0, flag2 = 0; // N integer flags 8 | int x; // variable to test mutual exclusion 9 | 10 | void* thr1(void* arg) { 11 | while (1) { 12 | flag1 = 1; 13 | while (flag2 >= 3); 14 | flag1 = 3; 15 | if (flag2 == 1) { 16 | flag1 = 2; 17 | while (flag2 != 4); 18 | } 19 | flag1 = 4; 20 | while (flag2 >= 2); 21 | // begin critical section 22 | x = 0; 23 | assert(x<=0); 24 | // end critical section 25 | while (2 <= flag2 && flag2 <= 3); 26 | flag1 = 0; 27 | } 28 | 29 | return 0; 30 | } 31 | 32 | void* thr2(void* arg) { 33 | while (1) { 34 | flag2 = 1; 35 | while (flag1 >= 3); 36 | flag2 = 3; 37 | if (flag1 == 1) { 38 | flag2 = 2; 39 | while (flag1 != 4); 40 | } 41 | flag2 = 4; 42 | while (flag1 >= 2); 43 | // begin critical section 44 | x = 1; 45 | assert(x>=1); 46 | // end critical section 47 | while (2 <= flag1 && flag1 <= 3); 48 | flag2 = 0; 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | int main() 55 | { 56 | pthread_t t; 57 | 58 | pthread_create(&t, 0, thr1, 0); 59 | thr2(0); 60 | 61 | return 0; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/18_read_write_lock_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assume(e) __VERIFIER_assume(e) 7 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 8 | 9 | int w=0, r=0, x, y; 10 | 11 | void __VERIFIER_atomic_w() 12 | { 13 | assume(w==0); 14 | assume(r==0); 15 | w = 1; 16 | } 17 | 18 | void* thr1(void* arg) { //writer 19 | __VERIFIER_atomic_w(); 20 | x = 3; 21 | w = 0; 22 | 23 | return 0; 24 | } 25 | 26 | void __VERIFIER_atomic_r() 27 | { 28 | assume(w==0); 29 | r = r+1; 30 | } 31 | 32 | void* thr2(void* arg) { //reader 33 | __VERIFIER_atomic_r(); 34 | y = x; 35 | assert(y == x); 36 | r = r-1; 37 | 38 | return 0; 39 | } 40 | 41 | int main() 42 | { 43 | pthread_t t; 44 | 45 | pthread_create(&t, 0, thr1, 0); 46 | thr2(0); 47 | 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/19_time_var_mutex_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assume(e) __VERIFIER_assume(e) 7 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 8 | 9 | void __VERIFIER_atomic_acquire(int * m) 10 | { 11 | assume(*m==0); 12 | *m = 1; 13 | } 14 | 15 | void __VERIFIER_atomic_release(int * m) 16 | { 17 | assume(*m==1); 18 | *m = 0; 19 | } 20 | 21 | int block; 22 | int busy; // boolean flag indicating whether the block has be an allocated to an inode 23 | int inode; 24 | int m_inode=0; // protects the inode 25 | int m_busy=0; // protects the busy flag 26 | 27 | void * thr1(void* arg) 28 | { 29 | __VERIFIER_atomic_acquire(&m_inode); 30 | if(inode == 0){ 31 | __VERIFIER_atomic_acquire(&m_busy); 32 | busy = 1; 33 | __VERIFIER_atomic_release(&m_busy); 34 | inode = 1; 35 | } 36 | block = 1; 37 | assert(block == 1); 38 | __VERIFIER_atomic_release(&m_inode); 39 | 40 | return 0; 41 | } 42 | 43 | void * thr2(void* arg) 44 | { 45 | __VERIFIER_atomic_acquire(&m_busy); 46 | if(busy == 0){ 47 | block = 0; 48 | assert(block == 0); 49 | } 50 | __VERIFIER_atomic_release(&m_busy); 51 | 52 | return 0; 53 | } 54 | 55 | int main() 56 | { 57 | pthread_t t; 58 | 59 | pthread_create(&t, 0, thr1, 0); 60 | thr2(0); 61 | 62 | return 0; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/20_lamport_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 6 | 7 | int x; 8 | int y; 9 | int b1, b2; // N boolean flags 10 | int X; //variable to test mutual exclusion 11 | 12 | void* thr1(void* arg) { 13 | while (1) { 14 | b1 = 1; 15 | x = 1; 16 | if (y != 0) { 17 | b1 = 0; 18 | while (y != 0) {}; 19 | continue; 20 | } 21 | y = 1; 22 | if (x != 1) { 23 | b1 = 0; 24 | while (b2 >= 1) {}; 25 | if (y != 1) { 26 | while (y != 0) {}; 27 | continue; 28 | } 29 | } 30 | break; 31 | } 32 | // begin: critical section 33 | X = 0; 34 | assert(X <= 0); 35 | // end: critical section 36 | y = 0; 37 | b1 = 0; 38 | 39 | return 0; 40 | } 41 | 42 | void* thr2(void* arg) { 43 | while (1) { 44 | b2 = 1; 45 | x = 2; 46 | if (y != 0) { 47 | b2 = 0; 48 | while (y != 0) {}; 49 | continue; 50 | } 51 | y = 2; 52 | if (x != 2) { 53 | b2 = 0; 54 | while (b1 >= 1) {}; 55 | if (y != 2) { 56 | while (y != 0) {}; 57 | continue; 58 | } 59 | } 60 | break; 61 | } 62 | // begin: critical section 63 | X = 1; 64 | assert(X >= 1); 65 | // end: critical section 66 | y = 0; 67 | b2 = 0; 68 | 69 | return 0; 70 | } 71 | 72 | int main() 73 | { 74 | pthread_t t; 75 | 76 | pthread_create(&t, 0, thr1, 0); 77 | thr2(0); 78 | 79 | return 0; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/27_Boop_simple_vf_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern int __VERIFIER_nondet_int(void); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 7 | 8 | int usecount; 9 | int locked; 10 | int flag1 = 0; 11 | int flag2 = 0; 12 | int release_thr1 = 0; 13 | 14 | void* thr2 (void* arg) //dummy_open 15 | { 16 | while(!release_thr1); 17 | 18 | usecount = usecount + 1; 19 | 20 | if (locked) 21 | return 0; 22 | locked = 1; 23 | flag1 = 1; 24 | return 0; 25 | } 26 | 27 | inline void dummy_release () 28 | { 29 | usecount = usecount - 1; 30 | locked = 0; 31 | return; 32 | } 33 | 34 | inline void unregister_chrdev () 35 | { 36 | if (usecount != 0) 37 | { 38 | // this should fail 39 | assert (0); 40 | } 41 | else 42 | return; 43 | } 44 | 45 | void* thr1 (void* arg) 46 | { 47 | void* rval; 48 | int count; 49 | 50 | usecount = 0; 51 | locked = 0; 52 | 53 | release_thr1 = 1; 54 | while(1) 55 | { 56 | if(flag1) 57 | break; 58 | } 59 | 60 | do 61 | { 62 | rval = (void*)__VERIFIER_nondet_int(); 63 | if (rval == 0) 64 | { 65 | count = 1; 66 | dummy_release (); 67 | } 68 | else 69 | count = 0; 70 | } 71 | while (count != 0); 72 | 73 | dummy_release (); 74 | 75 | unregister_chrdev (); 76 | 77 | return 0; 78 | } 79 | 80 | int main(){ 81 | pthread_t t; 82 | 83 | pthread_create(&t, 0, thr1, 0); 84 | while(1) { pthread_create(&t, 0, thr2, 0); } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/28_buggy_simple_loop1_vf_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | extern unsigned int __VERIFIER_nondet_uint(); 3 | 4 | #include 5 | 6 | #define assert_nl(e) { if(!(e)) { goto ERROR; } } 7 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 8 | 9 | void* thr1(void* arg){ 10 | unsigned int x=__VERIFIER_nondet_uint(), y=__VERIFIER_nondet_uint(), z=__VERIFIER_nondet_uint(); 11 | int i, j=1, k=1; 12 | for(i=0; i i); 16 | } 17 | } 18 | } 19 | 20 | assert(i == x && (/* uncomment to make error go away: x == 0 ||*/ j == y || y <= x+1) && (x == 0 || y <= x+1 || k == z || z < y)) ; 21 | 22 | return 0; 23 | } 24 | 25 | int main() 26 | { 27 | pthread_t t; 28 | 29 | while(1) 30 | { 31 | pthread_create(&t, 0, thr1, 0); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/29_conditionals_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern int __VERIFIER_nondet_int(void); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert_nl(e) { if(!(e)) { goto ERROR; } } 9 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 10 | 11 | int m = 0; 12 | 13 | void __VERIFIER_atomic_acquire() 14 | { 15 | assume(m==0); 16 | m = 1; 17 | } 18 | 19 | void __VERIFIER_atomic_release() 20 | { 21 | assume(m==1); 22 | m = 0; 23 | } 24 | 25 | void* thr1(void* arg) 26 | { 27 | int x; 28 | int y; 29 | 30 | x = __VERIFIER_nondet_int(); 31 | y = __VERIFIER_nondet_int(); 32 | 33 | int z; 34 | __VERIFIER_atomic_acquire(); 35 | if(x == y) 36 | { 37 | z = 0; 38 | } else { 39 | z = 1; 40 | } 41 | 42 | if(z == 0) 43 | { 44 | assert_nl(x == y); 45 | } else { 46 | assert(x != y); 47 | } 48 | __VERIFIER_atomic_release(); 49 | 50 | return 0; 51 | 52 | } 53 | 54 | int main() 55 | { 56 | pthread_t t; 57 | 58 | while(1) 59 | { 60 | pthread_create(&t, 0, thr1, 0); 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/30_Function_Pointer3_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern int __VERIFIER_nondet_int(void); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 9 | 10 | int mutex; 11 | int res; 12 | 13 | void __VERIFIER_atomic_acquire() 14 | { 15 | assume(mutex==0); 16 | mutex = 1; 17 | } 18 | 19 | void __VERIFIER_atomic_release() 20 | { 21 | assume(mutex==1); 22 | mutex = 0; 23 | } 24 | 25 | typedef int (*FuncType)(int, int); 26 | 27 | inline int f1(int a, int b) 28 | { 29 | return a+b+1; 30 | } 31 | 32 | inline int f2(int x, int y) 33 | { 34 | return x-y+2; 35 | } 36 | 37 | void* thr2(void* arg) 38 | { 39 | FuncType pf; 40 | 41 | if( __VERIFIER_nondet_int() ) 42 | pf = f1; 43 | else 44 | pf = f2; 45 | 46 | __VERIFIER_atomic_acquire(); 47 | res = pf(4,3); 48 | __VERIFIER_atomic_release(); 49 | 50 | return 0; 51 | } 52 | 53 | void* thr1(void* arg) 54 | { 55 | while(1) 56 | { 57 | assert(res < 10); 58 | } 59 | 60 | return 0; 61 | } 62 | 63 | 64 | int main() 65 | { 66 | pthread_t t; 67 | 68 | pthread_create(&t, 0, thr1, 0); 69 | while(1) 70 | { 71 | pthread_create(&t, 0, thr2, 0); 72 | } 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/31_simple_loop5_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assume(e) __VERIFIER_assume(e) 7 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 8 | 9 | int a = 1; 10 | int b = 2; 11 | int c = 3; 12 | int temp; 13 | 14 | int mutex; 15 | 16 | void __VERIFIER_atomic_acquire() 17 | { 18 | assume(mutex==0); 19 | mutex = 1; 20 | } 21 | 22 | void __VERIFIER_atomic_release() 23 | { 24 | assume(mutex==1); 25 | mutex = 0; 26 | } 27 | 28 | 29 | void* thr2(void* arg) 30 | { 31 | for(;;){ 32 | __VERIFIER_atomic_acquire(); 33 | temp = a; 34 | a = b; 35 | b = c; 36 | c = temp; 37 | __VERIFIER_atomic_release(); 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | void* thr1(void* arg) 44 | { 45 | while(1) 46 | { 47 | __VERIFIER_atomic_acquire(); 48 | assert(a != b); 49 | __VERIFIER_atomic_release(); 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | int main() { 56 | pthread_t t; 57 | 58 | pthread_create(&t, 0, thr1, 0); 59 | while(1) 60 | { 61 | pthread_create(&t, 0, thr2, 0); 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/32_pthread5_vs_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern int __VERIFIER_nondet_int(void); 2 | extern void __VERIFIER_assume(int); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 9 | 10 | #define MONITOR_EQ(x,y) \ 11 | { \ 12 | while(1) \ 13 | {\ 14 | __VERIFIER_atomic_acquire();\ 15 | assert(g0==g1);\ 16 | __VERIFIER_atomic_release();\ 17 | }\ 18 | } 19 | 20 | int g0 = 0,g1 = 0,x = 0; 21 | _Bool lock = 0; 22 | int mutex = 0; 23 | 24 | void __VERIFIER_atomic_acquire() 25 | { 26 | assume(mutex==0); 27 | mutex = 1; 28 | } 29 | 30 | void __VERIFIER_atomic_release() 31 | { 32 | assume(mutex==1); 33 | mutex = 0; 34 | } 35 | 36 | void* thr3(void* arg) 37 | { 38 | 39 | __VERIFIER_atomic_acquire(); 40 | if(__VERIFIER_nondet_int()) 41 | { 42 | g0=0; 43 | g1=0; 44 | lock=0; 45 | } 46 | __VERIFIER_atomic_release(); 47 | 48 | __VERIFIER_atomic_acquire(); 49 | if(lock) 50 | { 51 | x=1; 52 | assert(g0==1 && g1==1); 53 | } 54 | __VERIFIER_atomic_release(); 55 | 56 | return 0; 57 | } 58 | 59 | void* thr2(void* arg) 60 | { 61 | MONITOR_EQ(g0,g1); 62 | 63 | return 0; 64 | } 65 | 66 | void* thr1(void* arg) 67 | { 68 | __VERIFIER_atomic_acquire(); 69 | g0=1,g1=1; 70 | __VERIFIER_atomic_release(); 71 | lock=1; 72 | 73 | return 0; 74 | } 75 | 76 | int main() { 77 | pthread_t t; 78 | 79 | pthread_create(&t, 0, thr1, 0); 80 | pthread_create(&t, 0, thr2, 0); 81 | while(1) 82 | { 83 | pthread_create(&t, 0, thr3, 0); 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/35_double_lock_p3_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern int __VERIFIER_nondet_int(void); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | #include 6 | 7 | int count = 0; 8 | 9 | #define assume(e) __VERIFIER_assume(e) 10 | #define assert_nl(e) { if(!(e)) { goto ERROR; } } 11 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 12 | 13 | void __VERIFIER_atomic_acquire(int * m) 14 | { 15 | assume(*m==0); 16 | *m = 1; 17 | } 18 | 19 | void __VERIFIER_atomic_release(int * m) 20 | { 21 | assume(*m==1); 22 | *m = 0; 23 | } 24 | 25 | int mutexa = 0; 26 | int mutexb = 0; 27 | inline void my_thread1() 28 | { 29 | __VERIFIER_atomic_acquire(&mutexa); 30 | count++; 31 | count--; 32 | __VERIFIER_atomic_release(&mutexa); 33 | 34 | __VERIFIER_atomic_acquire(&mutexa); 35 | count--; 36 | count++; 37 | __VERIFIER_atomic_release(&mutexa); 38 | 39 | return; 40 | } 41 | 42 | void* thr1(void* arg) 43 | { 44 | while(1) 45 | { 46 | __VERIFIER_atomic_acquire(&mutexa); 47 | assert(count >= -1); 48 | __VERIFIER_atomic_release(&mutexa); 49 | } 50 | return 0; 51 | } 52 | 53 | void* thr2(void* arg) 54 | { 55 | if(__VERIFIER_nondet_int()) 56 | my_thread1(); 57 | //else 58 | //my_thread2(); 59 | return 0; 60 | } 61 | 62 | int main(void) 63 | { 64 | pthread_t t; 65 | 66 | pthread_create(&t, 0, thr1, 0); 67 | while(1) 68 | { 69 | pthread_create(&t, 0, thr2, 0); 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/36_stack_cas_p0_vs_concur_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | //original file: EBStack.java 5 | //amino-cbbs\trunk\amino\java\src\main\java\org\amino\ds\lockfree 6 | //push only 7 | 8 | #include 9 | 10 | #define assume(e) __VERIFIER_assume(e) 11 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 12 | 13 | void __VERIFIER_atomic_CAS( 14 | int *v, 15 | int e, 16 | int u, 17 | int *r) 18 | { 19 | if(*v == e) 20 | { 21 | *v = u, *r = 1; 22 | } 23 | else 24 | { 25 | *r = 0; 26 | } 27 | } 28 | 29 | #define MEMSIZE (2*32+1) //0 for "NULL" 30 | int memory[MEMSIZE]; 31 | #define INDIR(cell,idx) memory[cell+idx] 32 | 33 | int next_alloc_idx = 1; 34 | 35 | int top = 0; 36 | 37 | void __VERIFIER_atomic_index_malloc(int *curr_alloc_idx) 38 | { 39 | if(next_alloc_idx+2-1 > MEMSIZE) *curr_alloc_idx = 0; 40 | else *curr_alloc_idx = next_alloc_idx, next_alloc_idx += 2; 41 | } 42 | 43 | #define isEmpty() (top == 0) 44 | 45 | #define exit(r) assume(0); 46 | 47 | inline void push(int d) { 48 | int oldTop, newTop,ret; 49 | __VERIFIER_atomic_index_malloc(&newTop); 50 | if(newTop == 0) 51 | exit(-1); 52 | INDIR(newTop,0) = d; 53 | while (1) { 54 | oldTop = top; 55 | INDIR(newTop,1) = oldTop; 56 | __VERIFIER_atomic_CAS(&top,oldTop,newTop,&ret); 57 | if(ret) return; 58 | } 59 | } 60 | 61 | void* thr1(void* arg){ 62 | while(1){push(10); assert(top != 0);} 63 | 64 | return 0; 65 | } 66 | 67 | int main() 68 | { 69 | pthread_t t; 70 | 71 | while(1) { pthread_create(&t, 0, thr1, 0); } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/37_stack_lock_p0_vs_concur_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | //original file: EBStack.java 5 | //amino-cbbs\trunk\amino\java\src\main\java\org\amino\ds\lockfree 6 | //push only 7 | 8 | #include 9 | 10 | #define assume(e) __VERIFIER_assume(e) 11 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 12 | 13 | #define MEMSIZE (2*32+1) //0 for "NULL" 14 | int memory[MEMSIZE]; 15 | #define INDIR(cell,idx) memory[cell+idx] 16 | 17 | int next_alloc_idx = 1; 18 | int m = 0; 19 | int top = 0; 20 | 21 | void __VERIFIER_atomic_acquire() 22 | { 23 | assume(m==0); 24 | m = 1; 25 | } 26 | 27 | void __VERIFIER_atomic_release() 28 | { 29 | assume(m==1); 30 | m = 0; 31 | } 32 | 33 | void __VERIFIER_atomic_index_malloc(int *curr_alloc_idx) 34 | { 35 | if(next_alloc_idx+2-1 > MEMSIZE) *curr_alloc_idx = 0; 36 | else *curr_alloc_idx = next_alloc_idx, next_alloc_idx += 2; 37 | } 38 | 39 | #define isEmpty() (top == 0) 40 | 41 | #define exit(r) assume(0) 42 | 43 | inline void push(int d) { 44 | int oldTop = -1, newTop = -1; 45 | 46 | __VERIFIER_atomic_index_malloc(&newTop); 47 | if(newTop == 0) 48 | exit(-1); 49 | else{ 50 | INDIR(newTop,0) = d; 51 | __VERIFIER_atomic_acquire(); 52 | oldTop = top; 53 | INDIR(newTop,1) = oldTop; 54 | top = newTop; 55 | __VERIFIER_atomic_release(); 56 | } 57 | } 58 | 59 | void* thr1(void* arg){ 60 | while(1){push(10); assert(top != 0);} 61 | 62 | return 0; 63 | } 64 | 65 | int main() 66 | { 67 | pthread_t t; 68 | 69 | while(1) { pthread_create(&t, 0, thr1, 0); } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/38_rand_cas_vs_concur_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern int __VERIFIER_nondet_int(void); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | //http://www.ibm.com/developerworks/java/library/j-jtp11234/ 5 | //Listing 5. Implementing a thread-safe PRNG with synchronization and atomic variables 6 | 7 | #include 8 | 9 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 10 | 11 | inline int nC(int s2){ 12 | int nC_return; 13 | do 14 | { 15 | nC_return = __VERIFIER_nondet_int(); 16 | } 17 | while(nC_return == s2 || nC_return == 0); 18 | return nC_return; 19 | } 20 | 21 | int seed = 1; 22 | 23 | void __VERIFIER_atomic_CAS( 24 | int *v, 25 | int e, 26 | int u, 27 | int *r) 28 | { 29 | if(*v == e) 30 | { 31 | *v = u, *r = 1; 32 | } 33 | else 34 | { 35 | *r = 0; 36 | } 37 | } 38 | 39 | #define min(x,y) ((y>=x)?(x):(y)) 40 | 41 | #define NUM 10 42 | 43 | inline int PseudoRandomUsingAtomic_nex() 44 | { 45 | int nex, nexts, casret, nex_return; 46 | while(1) { 47 | nex = seed; 48 | nexts = nC(nex); 49 | __VERIFIER_atomic_CAS(&seed,nex,nexts,&casret); 50 | 51 | if(casret == 1){ 52 | nex_return = min(nexts,NUM); 53 | break; 54 | } 55 | } 56 | return nex_return; 57 | } 58 | 59 | void* thr1(void* arg){ 60 | assert(PseudoRandomUsingAtomic_nex() <= NUM); 61 | 62 | return 0; 63 | } 64 | 65 | int main() 66 | { 67 | pthread_t t; 68 | 69 | while(1) { pthread_create(&t, 0, thr1, 0); } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/39_rand_lock_p0_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern int __VERIFIER_nondet_int(void); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | //http://www.ibm.com/developerworks/java/library/j-jtp11234/ 6 | //Listing 5. Implementing a thread-safe PRNG with synchronization and atomic variables 7 | 8 | #include 9 | 10 | #define assume(e) __VERIFIER_assume(e) 11 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 12 | 13 | int m = 0; 14 | 15 | void __VERIFIER_atomic_acquire() 16 | { 17 | assume(m==0); 18 | m = 1; 19 | } 20 | 21 | void __VERIFIER_atomic_release() 22 | { 23 | assume(m==1); 24 | m = 0; 25 | } 26 | 27 | #define min(x,y) ((y>=x)?(x):(y)) 28 | 29 | inline int calculateNext(int s2){ 30 | int cnex; 31 | do cnex = __VERIFIER_nondet_int(); 32 | while(cnex == s2 || cnex == 0); 33 | return cnex; 34 | } 35 | 36 | int seed = 1; 37 | 38 | #define NUM 10 39 | 40 | inline int PseudoRandomUsingAtomic_nextInt() { 41 | int read, nexts, nextInt_return; 42 | 43 | assert(seed != 0); 44 | 45 | __VERIFIER_atomic_acquire(); 46 | read = seed; 47 | nexts = calculateNext(read); 48 | seed = nexts; 49 | __VERIFIER_atomic_release(); 50 | nextInt_return = min(nexts,NUM); 51 | return nextInt_return; 52 | } 53 | 54 | void* thr1(void* arg){ 55 | PseudoRandomUsingAtomic_nextInt(); 56 | 57 | return 0; 58 | } 59 | 60 | int main() 61 | { 62 | pthread_t t; 63 | 64 | while(1) { pthread_create(&t, 0, thr1, 0); } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/40_barrier_vf_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assume(e) __VERIFIER_assume(e) 7 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 8 | 9 | volatile unsigned int count = 0; //shared 10 | _Bool MTX = 0; //shared mutex 11 | __thread _Bool COND = 0; //condition variables become local flag indicating whether the thread was signaled 12 | 13 | void __VERIFIER_atomic_acquire() 14 | { 15 | assume(MTX==0); 16 | MTX = 1; 17 | } 18 | 19 | void __VERIFIER_atomic_release() 20 | { 21 | assume(MTX==1); 22 | MTX = 0; 23 | } 24 | 25 | #define cnd_wait(c,m){ \ 26 | __VERIFIER_atomic_release(); \ 27 | assume(c); \ 28 | c = 0; \ 29 | __VERIFIER_atomic_acquire(); } 30 | 31 | #define cnd_broadcast(c) (c = 1) //BP must be post-processed manually by changing "b*_COND := 1" to "b*_COND$ := 1" 32 | 33 | void Barrier2() { 34 | __VERIFIER_atomic_acquire(); 35 | count++; 36 | if (count == 3) { 37 | cnd_broadcast(COND); //pthread_cond_broadcast(&cond); 38 | count = 0; } 39 | else 40 | cnd_wait(COND,MTX); //pthread_cond_wait(&cond, &m); 41 | __VERIFIER_atomic_release(); } 42 | 43 | void* thr1(void* arg){ 44 | Barrier2(); 45 | assert(0); 46 | 47 | return 0; 48 | } //should not fail for <3 threads 49 | 50 | int main(){ 51 | pthread_t t; 52 | 53 | while(1) { pthread_create(&t, 0, thr1, 0); } 54 | } 55 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/45_monabsex1_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern int __VERIFIER_nondet_int(void); 2 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 3 | 4 | #include 5 | 6 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 7 | 8 | int s; 9 | 10 | void* thr1(void* arg) 11 | { 12 | int l = __VERIFIER_nondet_int(); 13 | l = 4; 14 | s = l; 15 | assert(s == l); 16 | 17 | return 0; 18 | } 19 | 20 | int main() 21 | { 22 | s = __VERIFIER_nondet_int(); 23 | 24 | pthread_t t; 25 | 26 | while(1) pthread_create(&t, 0, thr1, 0); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/46_monabsex2_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 6 | 7 | _Bool s = 0; 8 | __thread _Bool l = 0; 9 | 10 | void* thr1(void* arg) 11 | { 12 | assert(!l || s); 13 | s = s || 1; 14 | l = 1; //overapproximates 15 | 16 | return 0; 17 | } 18 | 19 | int main() 20 | { 21 | pthread_t t; 22 | 23 | while(1) pthread_create(&t, 0, thr1, 0); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/47_ticket_lock_hc_backoff_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern int __VERIFIER_nondet_int(void); 2 | extern void __VERIFIER_assume(int); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | //Ticket lock with proportional backoff 6 | //Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors 7 | //ACM TOCS 8 | //February 1991 9 | 10 | #include 11 | 12 | #define assume(e) __VERIFIER_assume(e) 13 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 14 | 15 | volatile unsigned s = 0; //served 16 | volatile unsigned t = 0; //next ticket 17 | 18 | void __VERIFIER_atomic_fetch_and_inc(unsigned * l) 19 | { 20 | assume(t != -1); /* pretend "integer-semantics" */ 21 | *l = t; 22 | t = t + 1; 23 | } 24 | 25 | #define pause(e) 26 | 27 | #define spin_lock(l,t,s)\ 28 | {\ 29 | __VERIFIER_atomic_fetch_and_inc(&l); \ 30 | while(1) { \ 31 | pause(l - s); \ 32 | /* consume this many units of time */ \ 33 | /* on most machines, subtraction works correctly despite overflow */ \ 34 | if(s == l) \ 35 | break; \ 36 | }\ 37 | } 38 | 39 | #define spin_unlock(s)\ 40 | {\ 41 | s++;\ 42 | } 43 | 44 | unsigned c = 0; 45 | void* thr1(void* arg) 46 | { 47 | while(1){ 48 | unsigned l; 49 | spin_lock(l,t,s); 50 | c = 1; assert(c == 1); c = 0; 51 | spin_unlock(s); 52 | } 53 | 54 | return 0; 55 | } 56 | 57 | int main() 58 | { 59 | pthread_t t; 60 | 61 | while(__VERIFIER_nondet_int()) pthread_create(&t, 0, thr1, 0); 62 | thr1(0); 63 | 64 | return 0; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread-ext/48_ticket_lock_low_contention_vs_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_assume(int); 2 | extern int __VERIFIER_nondet_int(void); 3 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 4 | 5 | #include 6 | 7 | #define assume(e) __VERIFIER_assume(e) 8 | #define assert(e) { if(!(e)) { ERROR: __VERIFIER_error();(void)0; } } 9 | 10 | volatile unsigned s = 0; //served 11 | volatile unsigned t = 0; //next ticket 12 | 13 | void __VERIFIER_atomic_fetch_and_inc(unsigned * l) 14 | { 15 | assume(t != -1); /* pretend "integer-semantics" */ 16 | *l = t; 17 | t = t + 1; 18 | } 19 | 20 | #define spin_lock(l,t,s)\ 21 | {\ 22 | __VERIFIER_atomic_fetch_and_inc(&l); \ 23 | while (l != s) \ 24 | ; /* spin */ \ 25 | } 26 | 27 | #define spin_unlock(s)\ 28 | {\ 29 | s++;\ 30 | } 31 | 32 | unsigned c = 0; 33 | void* thr1(void* arg) 34 | { 35 | unsigned l; 36 | spin_lock(l,t,s); 37 | c = 1; assert(c == 1); c = 0; 38 | spin_unlock(s); 39 | 40 | return 0; 41 | } 42 | 43 | int main() 44 | { 45 | pthread_t t; 46 | 47 | while(__VERIFIER_nondet_int()) pthread_create(&t, 0, thr1, 0); 48 | thr1(0); 49 | 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/bigshot_p_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 8 | 9 | // DPU: 10 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 11 | 12 | char *v; 13 | 14 | void *thread1(void * arg) 15 | { 16 | // DPU 17 | pthread_mutex_lock (&m); 18 | v = malloc(sizeof(char) * 8); 19 | pthread_mutex_unlock (&m); 20 | return 0; 21 | } 22 | 23 | void *thread2(void *arg) 24 | { 25 | char *vv; 26 | 27 | // DPU 28 | pthread_mutex_lock (&m); 29 | vv = v; 30 | pthread_mutex_unlock (&m); 31 | 32 | if (vv) 33 | { 34 | pthread_mutex_lock (&m); 35 | vv = v; 36 | pthread_mutex_unlock (&m); 37 | strcpy(vv, "Bigshot"); 38 | } 39 | return 0; 40 | } 41 | 42 | 43 | int main() 44 | { 45 | pthread_t t1, t2; 46 | 47 | pthread_create(&t1, 0, thread1, 0); 48 | pthread_create(&t2, 0, thread2, 0); 49 | pthread_join(t1, 0); 50 | pthread_join(t2, 0); 51 | 52 | __VERIFIER_assert(!v || v[0] == 'B'); 53 | 54 | return 0; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/bigshot_s2_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 8 | 9 | char *v; 10 | 11 | void *thread1(void * arg) 12 | { 13 | v = malloc(sizeof(char) * 8); 14 | return 0; 15 | } 16 | 17 | void *thread2(void *arg) 18 | { 19 | if (v) strcpy(v, "Bigshot"); 20 | return 0; 21 | } 22 | 23 | 24 | int main() 25 | { 26 | pthread_t t1, t2; 27 | 28 | pthread_create(&t1, 0, thread1, 0); 29 | pthread_join(t1, 0); 30 | 31 | pthread_create(&t2, 0, thread2, 0); 32 | pthread_join(t2, 0); 33 | 34 | __VERIFIER_assert(v[0] == 'B'); // <---- wrong, malloc() can fail and therefore no strcpy! Competition's rule: malloc() never fails, thus it is safe. 35 | 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/bigshot_s_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 8 | 9 | char *v; 10 | 11 | void *thread1(void * arg) 12 | { 13 | v = malloc(sizeof(char) * 8); 14 | return 0; 15 | } 16 | 17 | void *thread2(void *arg) 18 | { 19 | if (v) strcpy(v, "Bigshot"); 20 | return 0; 21 | } 22 | 23 | 24 | int main() 25 | { 26 | pthread_t t1, t2; 27 | 28 | pthread_create(&t1, 0, thread1, 0); 29 | pthread_join(t1, 0); 30 | 31 | pthread_create(&t2, 0, thread2, 0); 32 | pthread_join(t2, 0); 33 | 34 | __VERIFIER_assert(!v || v[0] == 'B'); 35 | 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/fib_bench_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | int i=1, j=1; 6 | 7 | #define NUM 5 8 | 9 | // DPU 10 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 11 | 12 | void * 13 | t1(void* arg) 14 | { 15 | int k = 0; 16 | 17 | for (k = 0; k < NUM; k++) 18 | { 19 | // DPU 20 | pthread_mutex_lock(&m); 21 | i+=j; 22 | pthread_mutex_unlock(&m); 23 | } 24 | 25 | pthread_exit(NULL); 26 | } 27 | 28 | void * 29 | t2(void* arg) 30 | { 31 | int k = 0; 32 | 33 | for (k = 0; k < NUM; k++) 34 | { 35 | // DPU 36 | pthread_mutex_lock(&m); 37 | j+=i; 38 | pthread_mutex_unlock(&m); 39 | } 40 | 41 | pthread_exit(NULL); 42 | } 43 | 44 | int 45 | main(int argc, char **argv) 46 | { 47 | pthread_t id1, id2; 48 | 49 | pthread_create(&id1, NULL, t1, NULL); 50 | pthread_create(&id2, NULL, t2, NULL); 51 | 52 | // DPU 53 | pthread_mutex_lock(&m); 54 | if (i >= 144 || j >= 144) { 55 | pthread_mutex_unlock(&m); 56 | ERROR: __VERIFIER_error(); 57 | } 58 | pthread_mutex_unlock(&m); 59 | 60 | // DPU 61 | pthread_exit (0); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/fib_bench_longer_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | int i=1, j=1; 6 | 7 | #define NUM 6 8 | 9 | // DPU 10 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 11 | 12 | void * 13 | t1(void* arg) 14 | { 15 | int k = 0; 16 | 17 | for (k = 0; k < NUM; k++) 18 | { 19 | // DPU 20 | pthread_mutex_lock(&m); 21 | i+=j; 22 | pthread_mutex_unlock(&m); 23 | } 24 | 25 | pthread_exit(NULL); 26 | } 27 | 28 | void * 29 | t2(void* arg) 30 | { 31 | int k = 0; 32 | 33 | for (k = 0; k < NUM; k++) 34 | { 35 | // DPU 36 | pthread_mutex_lock(&m); 37 | j+=i; 38 | pthread_mutex_unlock(&m); 39 | } 40 | 41 | pthread_exit(NULL); 42 | } 43 | 44 | int 45 | main(int argc, char **argv) 46 | { 47 | pthread_t id1, id2; 48 | 49 | pthread_create(&id1, NULL, t1, NULL); 50 | pthread_create(&id2, NULL, t2, NULL); 51 | 52 | // DPU 53 | pthread_mutex_lock(&m); 54 | if (i >= 377 || j >= 377) { 55 | pthread_mutex_unlock(&m); 56 | ERROR: __VERIFIER_error(); 57 | } 58 | pthread_mutex_unlock(&m); 59 | 60 | // DPU 61 | pthread_exit (0); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/fib_bench_longer_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | int i=1, j=1; 6 | 7 | #define NUM 6 8 | 9 | // DPU 10 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 11 | 12 | void * 13 | t1(void* arg) 14 | { 15 | int k = 0; 16 | 17 | for (k = 0; k < NUM; k++) 18 | { 19 | // DPU 20 | pthread_mutex_lock(&m); 21 | i+=j; 22 | pthread_mutex_unlock(&m); 23 | } 24 | 25 | pthread_exit(NULL); 26 | } 27 | 28 | void * 29 | t2(void* arg) 30 | { 31 | int k = 0; 32 | 33 | for (k = 0; k < NUM; k++) 34 | { 35 | // DPU 36 | pthread_mutex_lock(&m); 37 | j+=i; 38 | pthread_mutex_unlock(&m); 39 | } 40 | 41 | pthread_exit(NULL); 42 | } 43 | 44 | int 45 | main(int argc, char **argv) 46 | { 47 | pthread_t id1, id2; 48 | 49 | pthread_create(&id1, NULL, t1, NULL); 50 | pthread_create(&id2, NULL, t2, NULL); 51 | 52 | // DPU 53 | pthread_mutex_lock(&m); 54 | if (i > 377 || j > 377) { 55 | pthread_mutex_unlock(&m); 56 | ERROR: __VERIFIER_error(); 57 | } 58 | pthread_mutex_unlock(&m); 59 | 60 | // DPU 61 | pthread_exit (0); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/fib_bench_longest_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 6 | 7 | int i=1, j=1; 8 | 9 | #define NUM 11 10 | 11 | // DPU 12 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 13 | 14 | void * 15 | t1(void* arg) 16 | { 17 | int k = 0; 18 | 19 | for (k = 0; k < NUM; k++) 20 | { 21 | // DPU 22 | pthread_mutex_lock(&m); 23 | i+=j; 24 | pthread_mutex_unlock(&m); 25 | } 26 | 27 | pthread_exit(NULL); 28 | } 29 | 30 | void * 31 | t2(void* arg) 32 | { 33 | int k = 0; 34 | 35 | for (k = 0; k < NUM; k++) 36 | { 37 | // DPU 38 | pthread_mutex_lock(&m); 39 | j+=i; 40 | pthread_mutex_unlock(&m); 41 | } 42 | 43 | pthread_exit(NULL); 44 | } 45 | 46 | int 47 | main(int argc, char **argv) 48 | { 49 | pthread_t id1, id2; 50 | 51 | pthread_create(&id1, NULL, t1, NULL); 52 | pthread_create(&id2, NULL, t2, NULL); 53 | 54 | // DPU 55 | pthread_mutex_lock(&m); 56 | if (i >= 46368 || j >= 46368) { 57 | pthread_mutex_unlock(&m); 58 | ERROR: __VERIFIER_error(); 59 | } 60 | pthread_mutex_unlock(&m); 61 | 62 | // DPU 63 | pthread_exit (0); 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/fib_bench_longest_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 6 | 7 | int i=1, j=1; 8 | 9 | #define NUM 11 10 | 11 | // DPU 12 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 13 | 14 | void * 15 | t1(void* arg) 16 | { 17 | int k = 0; 18 | 19 | for (k = 0; k < NUM; k++) 20 | { 21 | // DPU 22 | pthread_mutex_lock(&m); 23 | i+=j; 24 | pthread_mutex_unlock(&m); 25 | } 26 | 27 | pthread_exit(NULL); 28 | } 29 | 30 | void * 31 | t2(void* arg) 32 | { 33 | int k = 0; 34 | 35 | for (k = 0; k < NUM; k++) 36 | { 37 | // DPU 38 | pthread_mutex_lock(&m); 39 | j+=i; 40 | pthread_mutex_unlock(&m); 41 | } 42 | 43 | pthread_exit(NULL); 44 | } 45 | 46 | int 47 | main(int argc, char **argv) 48 | { 49 | pthread_t id1, id2; 50 | 51 | pthread_create(&id1, NULL, t1, NULL); 52 | pthread_create(&id2, NULL, t2, NULL); 53 | 54 | // DPU 55 | pthread_mutex_lock(&m); 56 | if (i > 46368 || j > 46368) { 57 | pthread_mutex_unlock(&m); 58 | ERROR: __VERIFIER_error(); 59 | } 60 | pthread_mutex_unlock(&m); 61 | 62 | // DPU 63 | pthread_exit (0); 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/fib_bench_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | int i=1, j=1; 6 | 7 | #define NUM 5 8 | 9 | // DPU 10 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 11 | 12 | void * 13 | t1(void* arg) 14 | { 15 | int k = 0; 16 | 17 | for (k = 0; k < NUM; k++) 18 | { 19 | // DPU 20 | pthread_mutex_lock(&m); 21 | i+=j; 22 | pthread_mutex_unlock(&m); 23 | } 24 | 25 | pthread_exit(NULL); 26 | } 27 | 28 | void * 29 | t2(void* arg) 30 | { 31 | int k = 0; 32 | 33 | for (k = 0; k < NUM; k++) 34 | { 35 | // DPU 36 | pthread_mutex_lock(&m); 37 | j+=i; 38 | pthread_mutex_unlock(&m); 39 | } 40 | pthread_exit(NULL); 41 | } 42 | 43 | int 44 | main(int argc, char **argv) 45 | { 46 | pthread_t id1, id2; 47 | 48 | pthread_create(&id1, NULL, t1, NULL); 49 | pthread_create(&id2, NULL, t2, NULL); 50 | 51 | // DPU 52 | pthread_mutex_lock(&m); 53 | if (i > 144 || j > 144) { 54 | ERROR: __VERIFIER_error(); 55 | } 56 | pthread_mutex_unlock(&m); 57 | 58 | // DPU 59 | pthread_exit (0); 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/indexer_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | 6 | #define SIZE 128 7 | #define MAX 4 8 | #define NUM_THREADS 13 9 | 10 | int table[SIZE]; 11 | pthread_mutex_t cas_mutex[SIZE]; 12 | 13 | pthread_t tids[NUM_THREADS]; 14 | 15 | 16 | int cas(int * tab, int h, int val, int new_val) 17 | { 18 | int ret_val = 0; 19 | pthread_mutex_lock(&cas_mutex[h]); 20 | 21 | 22 | if ( tab[h] == val ) { 23 | tab[h] = new_val; 24 | ret_val = 1; 25 | } 26 | 27 | pthread_mutex_unlock(&cas_mutex[h]); 28 | 29 | 30 | return ret_val; 31 | } 32 | 33 | 34 | 35 | void * thread_routine(void * arg) 36 | { 37 | int tid; 38 | int m = 0, w, h; 39 | tid = *((int *)arg); 40 | 41 | while(1){ 42 | if ( m < MAX ){ 43 | w = (++m) * 11 + tid; 44 | } 45 | else{ 46 | pthread_exit(NULL); 47 | } 48 | 49 | h = (w * 7) % SIZE; 50 | 51 | if (h<0) 52 | { 53 | ERROR: __VERIFIER_error(); 54 | ; 55 | } 56 | 57 | while ( cas(table, h, 0, w) == 0){ 58 | h = (h+1) % SIZE; 59 | } 60 | } 61 | 62 | } 63 | 64 | 65 | int main() 66 | { 67 | int i, arg; 68 | 69 | for (i = 0; i < SIZE; i++) 70 | pthread_mutex_init(&cas_mutex[i], NULL); 71 | 72 | for (i = 0; i < NUM_THREADS; i++){ 73 | arg=i; 74 | pthread_create(&tids[i], NULL, thread_routine, &arg); 75 | } 76 | 77 | for (i = 0; i < NUM_THREADS; i++){ 78 | pthread_join(tids[i], NULL); 79 | } 80 | 81 | for (i = 0; i < SIZE; i++){ 82 | pthread_mutex_destroy(&cas_mutex[i]); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/lazy01_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | 6 | pthread_mutex_t mutex; 7 | int data = 0; 8 | 9 | void *thread1(void *arg) 10 | { 11 | pthread_mutex_lock(&mutex); 12 | data++; 13 | pthread_mutex_unlock(&mutex); 14 | } 15 | 16 | 17 | void *thread2(void *arg) 18 | { 19 | pthread_mutex_lock(&mutex); 20 | data+=2; 21 | pthread_mutex_unlock(&mutex); 22 | } 23 | 24 | 25 | void *thread3(void *arg) 26 | { 27 | pthread_mutex_lock(&mutex); 28 | if (data >= 3){ 29 | ERROR: __VERIFIER_error(); 30 | ; 31 | } 32 | pthread_mutex_unlock(&mutex); 33 | } 34 | 35 | 36 | int main() 37 | { 38 | pthread_mutex_init(&mutex, 0); 39 | 40 | pthread_t t1, t2, t3; 41 | 42 | pthread_create(&t1, 0, thread1, 0); 43 | pthread_create(&t2, 0, thread2, 0); 44 | pthread_create(&t3, 0, thread3, 0); 45 | 46 | pthread_join(t1, 0); 47 | pthread_join(t2, 0); 48 | pthread_join(t3, 0); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/singleton_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 8 | 9 | char *v; 10 | // DPU 11 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 12 | 13 | void *thread1(void * arg) 14 | { 15 | v = malloc(sizeof(char)); 16 | return 0; 17 | } 18 | 19 | void *thread2(void *arg) 20 | { 21 | // DPU 22 | pthread_mutex_lock (&m); 23 | v[0] = 'X'; 24 | pthread_mutex_unlock (&m); 25 | return 0; 26 | } 27 | 28 | void *thread3(void *arg) 29 | { 30 | pthread_mutex_lock (&m); 31 | v[0] = 'Y'; 32 | pthread_mutex_unlock (&m); 33 | return 0; 34 | } 35 | 36 | void *thread0(void *arg) 37 | { 38 | pthread_t t1, t2, t3, t4, t5; 39 | 40 | pthread_create(&t1, 0, thread1, 0); 41 | pthread_join(t1, 0); 42 | pthread_create(&t2, 0, thread2, 0); 43 | pthread_create(&t3, 0, thread3, 0); 44 | pthread_create(&t4, 0, thread2, 0); 45 | pthread_create(&t5, 0, thread2, 0); 46 | pthread_join(t2, 0); 47 | pthread_join(t3, 0); 48 | pthread_join(t4, 0); 49 | pthread_join(t5, 0); 50 | 51 | return 0; 52 | } 53 | 54 | int main(void) 55 | { 56 | pthread_t t; 57 | 58 | pthread_create(&t, 0, thread0, 0); 59 | pthread_join(t, 0); 60 | 61 | __VERIFIER_assert(v[0] == 'X'); // <-- wrong, the only thread that writes 'Y' can be the last to write 62 | 63 | return 0; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/singleton_with-uninit-problems_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error();}; return; } 8 | 9 | char *v; 10 | // DPU 11 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 12 | 13 | void *thread1(void * arg) 14 | { 15 | v = malloc(sizeof(char)); 16 | return 0; 17 | } 18 | 19 | void *thread2(void *arg) 20 | { 21 | // DPU 22 | pthread_mutex_lock (&m); 23 | v[0] = 'X'; 24 | pthread_mutex_unlock (&m); 25 | return 0; 26 | } 27 | 28 | void *thread3(void *arg) 29 | { 30 | pthread_mutex_lock (&m); 31 | v[0] = 'Y'; 32 | pthread_mutex_unlock (&m); 33 | return 0; 34 | } 35 | 36 | void *thread0(void *arg) 37 | { 38 | pthread_t t1, t2, t3, t4, t5; 39 | 40 | pthread_create(&t1, 0, thread1, 0); 41 | pthread_join(t1, 0); 42 | pthread_create(&t2, 0, thread2, 0); 43 | pthread_create(&t3, 0, thread3, 0); 44 | pthread_create(&t4, 0, thread2, 0); 45 | pthread_create(&t5, 0, thread2, 0); 46 | pthread_join(t2, 0); 47 | pthread_join(t3, 0); 48 | pthread_join(t4, 0); 49 | pthread_join(t5, 0); 50 | 51 | return 0; 52 | } 53 | 54 | int main(void) 55 | { 56 | pthread_t t; 57 | 58 | pthread_create(&t, 0, thread0, 0); 59 | pthread_join(t, 0); 60 | 61 | __VERIFIER_assert(v[0] == 'X' || v[0] == 'Y'); 62 | 63 | return 0; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/stateful01_false-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | pthread_mutex_t ma, mb; 6 | int data1, data2; 7 | 8 | void * thread1(void * arg) 9 | { 10 | pthread_mutex_lock(&ma); 11 | data1++; 12 | pthread_mutex_unlock(&ma); 13 | 14 | pthread_mutex_lock(&ma); 15 | data2++; 16 | pthread_mutex_unlock(&ma); 17 | return 0; 18 | } 19 | 20 | 21 | void * thread2(void * arg) 22 | { 23 | pthread_mutex_lock(&ma); 24 | data1+=5; 25 | pthread_mutex_unlock(&ma); 26 | 27 | pthread_mutex_lock(&ma); 28 | data2-=6; 29 | pthread_mutex_unlock(&ma); 30 | return 0; 31 | } 32 | 33 | 34 | int main() 35 | { 36 | pthread_t t1, t2; 37 | 38 | pthread_mutex_init(&ma, 0); 39 | pthread_mutex_init(&mb, 0); 40 | 41 | data1 = 10; 42 | data2 = 10; 43 | 44 | pthread_create(&t1, 0, thread1, 0); 45 | pthread_create(&t2, 0, thread2, 0); 46 | 47 | pthread_join(t1, 0); 48 | pthread_join(t2, 0); 49 | 50 | if (data1==16 && data2==5) 51 | { 52 | ERROR: __VERIFIER_error(); 53 | ; 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/stateful01_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | 5 | pthread_mutex_t ma, mb; 6 | int data1, data2; 7 | 8 | void * thread1(void * arg) 9 | { 10 | pthread_mutex_lock(&ma); 11 | data1++; 12 | pthread_mutex_unlock(&ma); 13 | 14 | pthread_mutex_lock(&ma); 15 | data2++; 16 | pthread_mutex_unlock(&ma); 17 | return 0; 18 | } 19 | 20 | 21 | void * thread2(void * arg) 22 | { 23 | pthread_mutex_lock(&ma); 24 | data1+=5; 25 | pthread_mutex_unlock(&ma); 26 | 27 | pthread_mutex_lock(&ma); 28 | data2-=6; 29 | pthread_mutex_unlock(&ma); 30 | return 0; 31 | } 32 | 33 | 34 | int main() 35 | { 36 | pthread_t t1, t2; 37 | 38 | pthread_mutex_init(&ma, 0); 39 | pthread_mutex_init(&mb, 0); 40 | 41 | data1 = 10; 42 | data2 = 10; 43 | 44 | pthread_create(&t1, 0, thread1, 0); 45 | pthread_create(&t2, 0, thread2, 0); 46 | 47 | pthread_join(t1, 0); 48 | pthread_join(t2, 0); 49 | 50 | if (data1!=16 && data2!=5) 51 | { 52 | ERROR: __VERIFIER_error(); 53 | ; 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /experiments/svcomp17/pthread/sync01_true-unreach-call.c: -------------------------------------------------------------------------------- 1 | extern void __VERIFIER_error() __attribute__ ((__noreturn__)); 2 | 3 | #include 4 | #include 5 | 6 | int num; 7 | 8 | pthread_mutex_t m; 9 | pthread_cond_t empty, full; 10 | 11 | void * thread1(void * arg) 12 | { 13 | pthread_mutex_lock(&m); 14 | 15 | while (num > 0) 16 | my_pthread_cond_wait(&empty, &m); 17 | 18 | num++; 19 | 20 | pthread_mutex_unlock(&m); 21 | my_pthread_cond_signal(&full); 22 | return 0; 23 | } 24 | 25 | 26 | void * thread2(void * arg) 27 | { 28 | pthread_mutex_lock(&m); 29 | 30 | while (num == 0) 31 | my_pthread_cond_wait(&full, &m); 32 | 33 | num--; 34 | 35 | pthread_mutex_unlock(&m); 36 | 37 | my_pthread_cond_signal(&empty); 38 | return 0; 39 | } 40 | 41 | 42 | int main() 43 | { 44 | pthread_t t1, t2; 45 | 46 | num = 1; 47 | 48 | pthread_mutex_init(&m, 0); 49 | my_pthread_cond_init(&empty, 0); 50 | my_pthread_cond_init(&full, 0); 51 | 52 | pthread_create(&t1, 0, thread1, 0); 53 | pthread_create(&t2, 0, thread2, 0); 54 | 55 | pthread_join(t1, 0); 56 | pthread_join(t2, 0); 57 | 58 | if (num!=1) 59 | { 60 | ERROR: __VERIFIER_error(); 61 | ; 62 | } 63 | 64 | return 0; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /rt/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY : compile_ 3 | 4 | R ?= .. 5 | D := $R/rt 6 | TARGETS := 7 | 8 | include $R/common.mk 9 | 10 | all : compile 11 | 12 | compile : $D/verifier.bc 13 | 14 | clean : clean_ 15 | 16 | clean_ : 17 | @rm -f $D/verifier.bc 18 | -------------------------------------------------------------------------------- /scripts/addr-cluster.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This scripts expects to read from the standard input a list of \n separated 4 | # integers in base 16 (adresses). It will then print the number of unique 5 | # integers it has read and the number of contiguous intervals (regions) that 6 | # those integers can be grouped into. 7 | 8 | import sys 9 | 10 | ls = [] 11 | uniq = {} 12 | total = 0 13 | 14 | print 'readin stdin ...' 15 | for l in sys.stdin : 16 | total += 1 17 | a = int (l, 16) 18 | 19 | #a = 8 * (a / 8) # sort of equivalent to the job done by variable w below 20 | 21 | if a in uniq : 22 | uniq[a] += 1 23 | else : 24 | uniq[a] = 1 25 | ls.append (a) 26 | if total % 1000 == 0 : 27 | print 'addresses', total 28 | 29 | w = 8 # width of a memory operation (bytes) 30 | 31 | print 'sorting ...' 32 | sor = sorted (ls) 33 | regions = {} 34 | l = sor[0] 35 | h = l 36 | count = 1 37 | 38 | print 'clustering ...' 39 | for a in sor[1:] : 40 | # if the new address is <= than the last byte written by the last write +1, 41 | # then we are still in the same region 42 | if a <= h + w : 43 | count += 1 44 | h = max (a, h) 45 | continue 46 | regions[l,h] = count 47 | l = a 48 | h = a 49 | count = 1 50 | if len (regions) % 1000 == 0 : 51 | print 'regions', len (regions) 52 | 53 | regions[l,h] = count 54 | 55 | last = 0 56 | for l,h in sorted (regions, key =lambda (l,h): l) : 57 | print '+', l - last 58 | last = h 59 | print l, '-', h, ':', regions[l,h], 'addr', h - l, 'b' 60 | 61 | print 'addresses', total 62 | print 'unique addresses', len (uniq) 63 | print 'regions', len (regions) 64 | 65 | -------------------------------------------------------------------------------- /scripts/anonymize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | R="$1" 4 | 5 | sed -i.sed "s/C.sar Rodr.guez/XXXX/" $R/README.rst 6 | sed -i.sed "s/github.com.cesaro.dpu/XXXX/" $R/README.rst 7 | sed -i.sed "s/lipn.univ-paris13.fr..rodriguez/XXXX/" $R/README.rst 8 | sed -i.sed "s/our CONCUR'15 paper/the CONCUR'15 paper/" $R/README.rst 9 | 10 | find $R | grep '\.sed$' | xargs rm 11 | 12 | -------------------------------------------------------------------------------- /scripts/as2c.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | 5 | def main () : 6 | try : 7 | sys.stdout.write ("__asm__ (\n") 8 | for s in sys.stdin : 9 | s = "%s" % s.rstrip() 10 | s = s.replace ("\\", "\\\\") 11 | s = s.replace ("\"", "\\\"") 12 | s = " \"%s\\n\"\n" % s 13 | sys.stdout.write (s) 14 | sys.stdout.write (");\n") 15 | 16 | except IOError : 17 | raise 18 | 19 | if __name__ == '__main__' : 20 | main () 21 | -------------------------------------------------------------------------------- /scripts/env2h.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | import os 5 | 6 | def is_numeric (s) : 7 | for c in s : 8 | if c not in " 0123456789()+-*/%<.>" : 9 | return False 10 | return True 11 | 12 | try : 13 | x = float (s) 14 | return True 15 | except ValueError : 16 | return False 17 | 18 | def is_quoted (s) : 19 | return len (s) and s[0] == '"' and s[-1] == '"' 20 | 21 | def quote (v) : 22 | if is_numeric (v) : 23 | return v 24 | if is_quoted (v) : 25 | return v 26 | return '"%s"' % v 27 | 28 | def main () : 29 | 30 | print '// Automatically generated using env2h.py, do not edit!' 31 | print '#ifndef _CONFIG__' 32 | print '#define _CONFIG__' 33 | print 34 | 35 | varset = set (sys.argv[1:]) 36 | for var in varset : 37 | if var not in os.environ : 38 | print '#undef', var 39 | continue 40 | val = os.environ[var] 41 | val = val.strip() 42 | print '#define', var, quote(val) 43 | 44 | print 45 | print '#endif' 46 | 47 | if __name__ == '__main__' : 48 | main () 49 | -------------------------------------------------------------------------------- /scripts/mk2h.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | 5 | def is_numeric (s) : 6 | for c in s : 7 | if c not in " 0123456789()+-*/%<.>" : 8 | return False 9 | return True 10 | 11 | try : 12 | x = float (s) 13 | return True 14 | except ValueError : 15 | return False 16 | 17 | def is_quoted (s) : 18 | return len (s) and s[0] == '"' and s[-1] == '"' 19 | 20 | def val (v) : 21 | if is_numeric (v) : 22 | return v 23 | if is_quoted (v) : 24 | return v 25 | return '"%s"' % v 26 | 27 | def error (l, m) : 28 | print '// error: "%s": %s' % (l, m) 29 | 30 | def main () : 31 | print '// Automatically generated using mkh.py, do not edit!' 32 | print '#ifndef _CONFIG__' 33 | print '#define _CONFIG__' 34 | 35 | for l in sys.stdin : 36 | l = l.strip() 37 | if len (l) == 0 : 38 | print 39 | continue 40 | if l[0] == "#" : 41 | print '//' + l[1:] 42 | continue 43 | if ':=' in l : 44 | tok = l.split (':=') 45 | elif '?=' in l : 46 | tok = l.split ('?=') 47 | elif '=' in l : 48 | tok = l.split ('=') 49 | else : 50 | error (l, 'unable to parse as a variable declaration') 51 | sys.exit (1) 52 | 53 | print '#define', tok[0].strip(), val(tok[1].strip()) 54 | 55 | print '#endif' 56 | 57 | if __name__ == '__main__' : 58 | main () 59 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | R ?= .. 3 | D := $R/src 4 | LIBS = $(STIDROOT)/src/libsteroids.a 5 | 6 | include $R/common.mk 7 | 8 | .PHONY: $(STIDROOT)/src/libsteroids.a 9 | $(STIDROOT)/src/libsteroids.a : 10 | $(MAKE) -C $(STIDROOT) src/libsteroids.a 11 | 12 | all : compile 13 | 14 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #include "../config.h" 2 | -------------------------------------------------------------------------------- /src/datarace.hh: -------------------------------------------------------------------------------- 1 | #ifndef _DATARACE_HH_ 2 | #define _DATARACE_HH_ 3 | 4 | #include "pes/event.hh" 5 | #include "pes/cut.hh" 6 | #include "unfolder/replay.hh" 7 | #include "defect.hh" 8 | #include "verbosity.h" 9 | 10 | namespace dpu { 11 | 12 | struct DataRace : public Defect 13 | { 14 | const Event *e1; 15 | const Event *e2; 16 | Addr addr; 17 | unsigned size; 18 | Cut trace; 19 | 20 | DataRace (const Event *e1, const Event *e2, Addr a, unsigned size) : 21 | e1 (e1), 22 | e2 (e2), 23 | addr (a), 24 | size (size), 25 | trace (e1->cone, e2->cone) 26 | { 27 | ASSERT (e1); 28 | ASSERT (e2); 29 | 30 | Replay r (*e1->unfolding(), trace); 31 | 32 | description = fmt ("Data race: threads %d and %d can concurrently " 33 | "access and modify variable %p (%d bytes)", 34 | r.pidmap.get (e1->pid()), r.pidmap.get (e2->pid()), (void*) a, size); 35 | replay = r; 36 | } 37 | 38 | void dump () const 39 | { 40 | PRINT ("== begin data race =="); 41 | PRINT (" %s", description.c_str()); 42 | PRINT ("\n Offending execution:"); 43 | trace.dump (); 44 | PRINT ("== end data race =="); 45 | } 46 | }; 47 | 48 | } // namespace 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/defect.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DEFECT_HH_ 3 | #define _DEFECT_HH_ 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "stid/executor.hh" 11 | #include "unfolder/replay.hh" 12 | 13 | namespace dpu 14 | { 15 | 16 | struct Defect 17 | { 18 | Defect () : 19 | description (), 20 | replay () 21 | {} 22 | 23 | Defect (const Unfolding &u) : 24 | description (), 25 | replay (Replay (u)) 26 | {} 27 | 28 | Defect (std::string &des, const Unfolding &u) : 29 | description (des), 30 | replay (Replay (u)) 31 | {} 32 | 33 | Defect (std::string &des, Replay &r) : 34 | description (des), 35 | replay (r) 36 | {} 37 | 38 | Defect (std::string &des, const Event *e) : 39 | description (des), 40 | replay (Replay (*e->unfolding(), e->cone)) 41 | {} 42 | 43 | std::string description; 44 | stid::Replay replay; 45 | }; 46 | 47 | } // namespace 48 | 49 | // yaml trait for a context switch 50 | template<> 51 | struct llvm::yaml::MappingTraits { 52 | static void mapping (llvm::yaml::IO &io, struct replayevent &x) 53 | { 54 | io.mapRequired ("tid", x.tid); 55 | io.mapRequired ("nr", x.count); 56 | } 57 | static const bool flow = true; 58 | }; 59 | 60 | // yaml trait for the replay vector 61 | LLVM_YAML_IS_SEQUENCE_VECTOR(struct replayevent); 62 | 63 | // yaml trait for the defect 64 | template<> 65 | struct llvm::yaml::MappingTraits { 66 | static void mapping (llvm::yaml::IO &io, struct dpu::Defect &d) 67 | { 68 | io.mapRequired ("description", d.description); 69 | io.mapRequired ("replay", static_cast (d.replay)); 70 | } 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/defectreport.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "llvm/Support/raw_ostream.h" 6 | 7 | #include "verbosity.h" 8 | #include "defect.hh" 9 | #include "defectreport.hh" 10 | 11 | namespace dpu 12 | { 13 | 14 | void Defectreport::save (const char *path) 15 | { 16 | std::error_code ec; 17 | llvm::raw_fd_ostream f (path, ec, llvm::sys::fs::OpenFlags::F_None); 18 | if (ec.value() != 0) 19 | throw std::system_error (ec, path); 20 | llvm::yaml::Output out (f); 21 | out << *this; 22 | } 23 | 24 | void Defectreport::add_defect (const Defect &d) 25 | { 26 | //PRINT ("dpu: defect found: %s", d.description.c_str()); 27 | defects.emplace_back (d); 28 | } 29 | 30 | } // namespace 31 | -------------------------------------------------------------------------------- /src/memory-pool.cc: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "memory-pool.hh" 4 | 5 | namespace dpu 6 | { 7 | 8 | void MemoryPool::assertt () const 9 | { 10 | int i; 11 | 12 | if (regions.empty()) return; 13 | 14 | // check that each memory region is non-empty, disjoint with others, and 15 | // sorted by increasing order 16 | ASSERT (! regions[0].empty()); 17 | for (i = 1; i < regions.size(); ++i) 18 | { 19 | ASSERT (! regions[i].empty()); 20 | ASSERT (regions[i-1] < regions[i]); 21 | ASSERT (! regions[i-1].overlaps(regions[i])); 22 | } 23 | } 24 | 25 | } // namespace dpu 26 | -------------------------------------------------------------------------------- /src/misc.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "misc.hh" 9 | 10 | std::string __attribute__((weak)) fmt (const std::string fmt_str, ...) 11 | { 12 | /* reserve 2 times as much as the length of the fmt_str */ 13 | int n = fmt_str.size() * 2; 14 | int final_n; 15 | std::string str; 16 | std::unique_ptr formatted; 17 | 18 | va_list ap; 19 | while(1) 20 | { 21 | formatted.reset (new char[n]); 22 | strcpy (&formatted[0], fmt_str.c_str()); 23 | va_start(ap, fmt_str); 24 | final_n = vsnprintf(&formatted[0], n, fmt_str.c_str(), ap); 25 | va_end(ap); 26 | if (final_n < 0 || final_n >= n) 27 | n += abs(final_n - n + 1); 28 | else 29 | break; 30 | } 31 | return std::string(formatted.get()); 32 | } 33 | 34 | std::string __attribute__((weak)) operator * (std::string lhs, int i) 35 | { 36 | int len; 37 | 38 | len = lhs.size (); 39 | lhs.reserve (len * i); 40 | for (; i >= 2; --i) lhs.append (lhs.data (), len); 41 | return lhs; 42 | } 43 | 44 | std::string __attribute__((weak)) quoted_str (const char * str) 45 | { 46 | std::string s; 47 | 48 | s.reserve (strlen (str)); 49 | for (const char * c = str; *c; ++c) 50 | { 51 | switch (*c) 52 | { 53 | case '\t' : 54 | s.append ("\\t"); 55 | break; 56 | case '\r' : 57 | s.append ("\\r"); 58 | break; 59 | case '\n' : 60 | s.append ("\\n"); 61 | break; 62 | case '\0' : // unreachable 63 | s.append ("\\0"); 64 | break; 65 | default : 66 | s.push_back (*c); 67 | } 68 | } 69 | return s; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/misc.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __MISC_HH_ 3 | #define __MISC_HH_ 4 | 5 | #include 6 | 7 | #define UNITS_UNIT(s) \ 8 | ((s) < 2048 ? "B" : \ 9 | (s) / 1024 < 1024 ? "K" : \ 10 | (s) / (1024 * 1024) < 1024 ? "M" : "G") 11 | 12 | #define UNITS_SIZE(s) \ 13 | ((s) < 2048 ? (s) : \ 14 | (s) / 1024 < 1024 ? (s) / 1024 : \ 15 | (s) / (1024 * 1024) < 1024 ? (s) / (1024 * 1024) : \ 16 | (s) / (size_t) (1024 * 1024 * 1024)) 17 | 18 | std::string fmt (const std::string fmt_str, ...); 19 | std::string operator * (std::string lhs, int i); 20 | 21 | std::string quoted_str (const char * str); 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/opts.hh: -------------------------------------------------------------------------------- 1 | #ifndef _OPTS_HH_ 2 | #define _OPTS_HH_ 3 | 4 | #include 5 | #include 6 | 7 | #include "unfolder/alt-algorithm.hh" 8 | 9 | namespace dpu { 10 | namespace opts { 11 | 12 | typedef enum {POR, DRA} Analysis; 13 | 14 | extern const char *progname; 15 | extern int verbosity; 16 | extern std::string inpath; 17 | extern std::string defectspath; 18 | extern Analysis analysis; 19 | extern std::vector argv; 20 | extern unsigned kbound; 21 | extern Altalgo alt_algo; 22 | extern std::string dotpath; 23 | extern std::string instpath; 24 | extern size_t memsize; 25 | extern size_t stacksize; 26 | extern unsigned optlevel; 27 | extern unsigned maxcts; 28 | extern bool strace; 29 | extern bool dosleep; 30 | extern unsigned timeout; 31 | extern unsigned drfreq; 32 | 33 | 34 | void parse (int argc, char **argv_); 35 | size_t parse_size (const char *str, char default_units); 36 | void dump (); 37 | void usage (int exitcode); 38 | void print_options (); 39 | void help (); 40 | void version (); 41 | 42 | }} // namespace dpu::opts 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/pes/action.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PES_ACTION_HH_ 3 | #define __PES_ACTION_HH_ 4 | 5 | #include 6 | #include 7 | 8 | // necessary for the .hpp 9 | #include "verbosity.h" 10 | 11 | namespace dpu 12 | { 13 | 14 | typedef uint64_t Addr; 15 | 16 | enum class ActionType 17 | { 18 | // loads 19 | RD8, 20 | RD16, 21 | RD32, 22 | RD64, 23 | // stores 24 | WR8, 25 | WR16, 26 | WR32, 27 | WR64, 28 | // memory management 29 | MALLOC, 30 | FREE, 31 | // threads 32 | THCREAT, 33 | THSTART, 34 | THEXIT, 35 | THJOIN, 36 | // locks 37 | //MTXINIT, 38 | MTXLOCK, 39 | MTXUNLK, 40 | }; 41 | 42 | static std::ostream & operator<< (std::ostream &os, const enum ActionType &a); 43 | 44 | const char *action_type_str (ActionType t); 45 | const char *action_type_str (unsigned t); 46 | 47 | /// Action (type, val) 48 | struct Action 49 | { 50 | ActionType type; 51 | Addr addr; 52 | uint64_t val; 53 | 54 | void pretty_print (); 55 | inline bool operator == (const Action &other) const; 56 | }; 57 | 58 | // implementation of inline methods 59 | #include "action.hpp" 60 | 61 | } // namespace dpu 62 | #endif 63 | -------------------------------------------------------------------------------- /src/pes/config.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "pes/config.hh" 3 | 4 | namespace dpu { 5 | 6 | void Config::dump () const 7 | { 8 | PRINT ("== begin config =="); 9 | __dump_cut (); 10 | __dump_mutexes (); 11 | PRINT ("== end config =="); 12 | } 13 | 14 | void Config::__dump_mutexes () const 15 | { 16 | for (auto &pair : mutexmax) 17 | { 18 | PRINT ("Addr %-#16lx e %08x", pair.first, pair.second->uid()); 19 | } 20 | } 21 | 22 | } // namespace 23 | -------------------------------------------------------------------------------- /src/pes/config.hh: -------------------------------------------------------------------------------- 1 | #ifndef __PES_CONFIG_HH_ 2 | #define __PES_CONFIG_HH_ 3 | 4 | #include 5 | 6 | #include "pes/unfolding.hh" 7 | #include "pes/event.hh" 8 | 9 | #include "verbosity.h" 10 | 11 | namespace dpu 12 | { 13 | 14 | class Config : public Cut 15 | { 16 | public: 17 | 18 | /// creates an empty onfiguration for as much as u.num_procs processes 19 | inline Config (const Unfolding &u); 20 | /// creates an empty configuration for as much as n processes 21 | inline Config (unsigned n); 22 | /// copy constructor 23 | inline Config (const Config &other); 24 | 25 | /// assignment operator 26 | inline Config & operator= (const Config & other); 27 | /// move-assignment operator 28 | inline Config & operator= (Config && other); 29 | 30 | /// fires an enabled event 31 | inline void fire (Event *e); 32 | /// removes one of the maximal events of the configuration 33 | inline void unfire (Event *e); 34 | 35 | /// empties the configuration 36 | inline void clear (); 37 | 38 | /// prints the cut in stdout 39 | void dump () const; 40 | 41 | /// maximal event for the given pid, or nullptr 42 | inline Event *proc_max (unsigned pid); 43 | /// maximal event for the given address (or THCREAT/EXIT if pid is given) 44 | inline const Event * mutex_max (Addr a) const; 45 | inline Event *mutex_max (Addr a); 46 | 47 | public: 48 | /// map from lock addresss to events 49 | std::unordered_map mutexmax; 50 | 51 | void __dump_mutexes () const; 52 | }; 53 | 54 | // implementation of inline methods 55 | #include "pes/config.hpp" 56 | 57 | } // namespace dpu 58 | #endif 59 | -------------------------------------------------------------------------------- /src/pes/event-payload.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PES_EVENTPAYLOAD_HH_ 3 | #define __PES_EVENTPAYLOAD_HH_ 4 | 5 | #include 6 | #include 7 | 8 | namespace dpu 9 | { 10 | 11 | class EventPayload 12 | { 13 | public: 14 | 15 | virtual size_t pointed_memory_size () const 16 | { 17 | return 0; 18 | } 19 | 20 | virtual std::string str() const 21 | { 22 | return ""; 23 | } 24 | }; 25 | 26 | } // namespace dpu 27 | #endif 28 | -------------------------------------------------------------------------------- /src/pes/eventbox.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "pes/unfolding.hh" 3 | #include "pes/eventbox.hh" 4 | #include "pes/event.hh" 5 | 6 | namespace dpu { 7 | 8 | Event *Eventbox::event_below () const 9 | { 10 | return ((Event *) this) - 1; 11 | } 12 | 13 | unsigned Eventbox::pid () const 14 | { 15 | return Unfolding::ptr2pid (this); 16 | } 17 | 18 | } // namespace 19 | -------------------------------------------------------------------------------- /src/pes/eventbox.hh: -------------------------------------------------------------------------------- 1 | #ifndef __PES_EVENTBOX_HH_ 2 | #define __PES_EVENTBOX_HH_ 3 | 4 | // needed for the .hpp 5 | #include "verbosity.h" 6 | 7 | namespace dpu 8 | { 9 | 10 | class Event; 11 | 12 | class Eventbox 13 | { 14 | public: 15 | /// constructor 16 | inline Eventbox (Event *pre); 17 | /// first event contained in the box, undefined if the box contains no event 18 | inline Event *event_above () const; 19 | /// the last event of the box below, undefined if this is the first box 20 | inline Event *event_below () const; 21 | /// process causal predecessor of all events in the box 22 | inline Event *pre () const; 23 | /// returns the id of the process containing this event box 24 | unsigned pid () const; 25 | 26 | private: 27 | /// the event that causally precedes all events in this box 28 | Event *_pre; 29 | }; 30 | 31 | // implementation of inline methods 32 | #include "pes/eventbox.hpp" 33 | 34 | } // namespace dpu 35 | #endif 36 | -------------------------------------------------------------------------------- /src/pes/eventbox.hpp: -------------------------------------------------------------------------------- 1 | 2 | Eventbox::Eventbox (Event *pre) : 3 | _pre (pre) 4 | { 5 | //DEBUG ("Eventbox.ctor: this %p pid %u pre %p sizeof %zu", 6 | // this, pid(), _pre, sizeof (Eventbox)); 7 | } 8 | 9 | Event *Eventbox::event_above () const 10 | { 11 | return (Event*) (this + 1); 12 | } 13 | 14 | // Event *Eventbox::event_below () const in pes/eventbox.cc 15 | 16 | Event *Eventbox::pre () const 17 | { 18 | return _pre; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/pes/primecon.hh: -------------------------------------------------------------------------------- 1 | 2 | // class Primecon and inline methods needs to be included exactly in the order 3 | // event.hh includes them to avoid circular inclusions 4 | #include "pes/event.hh" 5 | 6 | #ifndef __PES_PRIMECON_HH_ 7 | #define __PES_PRIMECON_HH_ 8 | 9 | #include 10 | #include "pes/cut.hh" 11 | #include "pes/action.hh" 12 | 13 | namespace dpu 14 | { 15 | 16 | class Config; 17 | 18 | class Primecon : public Cut 19 | { 20 | public: 21 | /// start event in any process 22 | Primecon (unsigned n, Event *e); 23 | /// one predecessor 24 | Primecon (const Primecon &p, Event *e); 25 | /// two predecessors 26 | Primecon (const Primecon &p, const Primecon &m, Event *e); 27 | 28 | /// prints the cut in stdout 29 | void dump () const; 30 | 31 | /// returns a human-readable description 32 | std::string str () const; 33 | 34 | /// returns true iff (this # other) 35 | bool in_cfl_with (const Primecon *other) const; 36 | 37 | /// returns false iff (this \cup c is conflict-free) 38 | bool in_cfl_with (const Config &c) const; 39 | 40 | /// returns the maximal lock/unlock for address a 41 | const Event *mutex_max (Addr a) const; 42 | Event *mutex_max (Addr a); 43 | 44 | /// returns the memory size of the data pointed by fields in this object 45 | inline size_t pointed_memory_size () const; 46 | 47 | protected : 48 | /// the list of maximal lock/unlock events sorted by the increasing value of 49 | /// the address 50 | std::vector lockmax; 51 | 52 | void __dump_lockmax () const; 53 | }; 54 | 55 | } // namespace dpu 56 | #endif 57 | -------------------------------------------------------------------------------- /src/pes/primecon.hpp: -------------------------------------------------------------------------------- 1 | // nothing here so far 2 | 3 | /// returns the memory size of the data pointed by fields in this object 4 | size_t Primecon::pointed_memory_size () const 5 | { 6 | return Cut::pointed_memory_size() + lockmax.capacity() * sizeof(Event*); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/pes/process.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "pes/process.hh" 3 | #include "verbosity.h" 4 | 5 | namespace dpu { 6 | void Process::dump () 7 | { 8 | PRINT (" == process begin =="); 9 | PRINT (" this %p pid %u first-event %08x last-event %08x", 10 | this, pid(), first_event()->uid(), last->uid()); 11 | 12 | ASSERT (first_event() and first_event()->action.type == ActionType::THSTART); 13 | for (Event &e : *this) 14 | { 15 | PRINT (" %s", e.str().c_str()); 16 | } 17 | PRINT (" == process end =="); 18 | } 19 | 20 | } // namespace 21 | -------------------------------------------------------------------------------- /src/pes/unfolding.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Unfolding::Unfolding () in pes/unfolding.cc 3 | 4 | Unfolding::Unfolding (const Unfolding &&other) 5 | { 6 | // FIXME - to be implemented 7 | ASSERT (0); 8 | } 9 | 10 | Unfolding::~Unfolding () 11 | { 12 | DEBUG ("Unfolding.dtor: this %p", this); 13 | free (procs); 14 | } 15 | 16 | Process *Unfolding::proc (unsigned p) const 17 | { 18 | return (Process *) (procs + p * PROC_SIZE); 19 | } 20 | 21 | Event *Unfolding::find1 (Action *ac, Event *p) 22 | { 23 | ASSERT (p); 24 | ASSERT (p->node[0].post.size() <= 1); 25 | 26 | if (p->node[0].post.size() == 0) return nullptr; 27 | ASSERT (ac->type == p->node[0].post[0]->action.type); 28 | return p->node[0].post[0]; 29 | } 30 | 31 | Event *Unfolding::find2 (Action *ac, Event *p, Event *m) 32 | { 33 | #ifdef CONFIG_DEBUG 34 | // exactly one event with preset {p,m} ... 35 | int count = 0; 36 | for (Event *e : p->node[0].post) 37 | { 38 | if (e->pre_other() == m) count++; 39 | } 40 | ASSERT (count <= 1); 41 | #endif 42 | 43 | // FIXME - we could choose here p or m depending on the size of the post 44 | for (Event *e : p->node[0].post) 45 | { 46 | if (e->pre_other() == m) 47 | { 48 | // ... and that event is action *ac 49 | ASSERT (e->action == *ac); 50 | return e; 51 | } 52 | } 53 | return nullptr; 54 | } 55 | 56 | unsigned Unfolding::get_fresh_color () 57 | { 58 | color++; 59 | return color; 60 | } 61 | -------------------------------------------------------------------------------- /src/pes/vclock.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __VCLOCK_HH_ 3 | #define __VCLOCK_HH_ 4 | 5 | #include 6 | 7 | namespace dpu 8 | { 9 | 10 | class Vclock 11 | { 12 | public: 13 | Vclock(); 14 | Vclock(unsigned pid, int count); 15 | Vclock (const Vclock &v); //copy constructor 16 | Vclock (const Vclock &v1, const Vclock &v2); 17 | 18 | bool operator== (const Vclock &other) const; 19 | bool operator< (const Vclock &other) const; 20 | bool operator> (const Vclock &other) const; 21 | void operator= (const Vclock &other); 22 | Vclock operator+ (const Vclock &other); 23 | int operator[] (unsigned tid); 24 | 25 | void add_clock(unsigned pid, int count); 26 | void inc_clock(unsigned pid); 27 | int get_size()const; 28 | void print(); 29 | std::string print_dot(); 30 | 31 | private: 32 | std::vector > tab; 33 | uint64_t mask; 34 | }; 35 | 36 | 37 | } // namespace dpu 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/redbox-factory.hh: -------------------------------------------------------------------------------- 1 | #ifndef __REDBOXFACTORY_HH_ 2 | #define __REDBOXFACTORY_HH_ 3 | 4 | #include 5 | 6 | #include "pes/action.hh" 7 | 8 | #include "redbox.hh" 9 | #include "verbosity.h" 10 | 11 | namespace dpu 12 | { 13 | 14 | class RedboxFactory 15 | { 16 | public: 17 | 18 | const unsigned INITIAL_CAPACITY = 250 * 1000; 19 | 20 | RedboxFactory () : 21 | read_regions (), 22 | write_regions () 23 | { 24 | read_regions.reserve (INITIAL_CAPACITY); 25 | write_regions.reserve (INITIAL_CAPACITY); 26 | } 27 | 28 | ~RedboxFactory () 29 | { 30 | for (auto b : boxes) delete b; 31 | } 32 | 33 | inline void add (Addr addr, ActionType t); 34 | inline void add_read (Addr addr, unsigned size); 35 | inline void add_write (Addr addr, unsigned size); 36 | inline void clear (); 37 | 38 | inline Redbox *create (); 39 | 40 | bool empty () const 41 | { 42 | return read_regions.empty() and write_regions.empty(); 43 | } 44 | 45 | size_t size() const 46 | { 47 | return read_size() + write_size(); 48 | } 49 | 50 | size_t read_size() const 51 | { 52 | return read_regions.size(); 53 | } 54 | 55 | size_t write_size() const 56 | { 57 | return write_regions.size(); 58 | } 59 | 60 | private: 61 | MemoryPool::Container read_regions; 62 | MemoryPool::Container write_regions; 63 | std::vector boxes; 64 | 65 | inline void compress (MemoryPool::Container ®ions); 66 | }; 67 | 68 | // implementation of inline methods 69 | #include "redbox-factory.hpp" 70 | 71 | } // namespace dpu 72 | #endif 73 | -------------------------------------------------------------------------------- /src/redbox.cc: -------------------------------------------------------------------------------- 1 | 2 | // FIXME remove this file 3 | -------------------------------------------------------------------------------- /src/redbox.hh: -------------------------------------------------------------------------------- 1 | #ifndef __REDBOX_HH_ 2 | #define __REDBOX_HH_ 3 | 4 | #include 5 | 6 | #include "pes/event-payload.hh" 7 | #include "memory-pool.hh" 8 | #include "misc.hh" 9 | 10 | namespace dpu 11 | { 12 | 13 | class Redbox : public EventPayload 14 | { 15 | public : 16 | 17 | MemoryPool readpool; 18 | MemoryPool writepool; 19 | 20 | virtual ~Redbox() 21 | {} 22 | 23 | virtual size_t pointed_memory_size () const final 24 | { 25 | return readpool.pointed_memory_size() + writepool.pointed_memory_size(); 26 | } 27 | 28 | virtual std::string str() const final 29 | { 30 | return fmt ("%d+%d", readpool.size(), writepool.size()); 31 | } 32 | 33 | size_t size () const 34 | { 35 | return readpool.size() + writepool.size(); 36 | } 37 | 38 | bool empty () const 39 | { 40 | return readpool.empty() and writepool.empty(); 41 | } 42 | 43 | void dump () const 44 | { 45 | std::cout << "=== begin redbox ===\n"; 46 | std::cout << "Read pool:\n"; 47 | std::cout << readpool.str (); 48 | std::cout << "Write pool:\n"; 49 | std::cout << writepool.str (); 50 | std::cout << "=== end redbox ===\n"; 51 | } 52 | }; 53 | 54 | inline 55 | bool operator== (const Redbox &b1, const Redbox &b2) 56 | { 57 | return b1.readpool == b2.readpool and b1.writepool == b2.writepool; 58 | } 59 | 60 | } // namespace dpu 61 | #endif 62 | -------------------------------------------------------------------------------- /src/resources.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "verbosity.h" 9 | #include "resources.hh" 10 | 11 | #define TIMEVAL_2_US(tv) ((tv).tv_sec * 1000 * 1000 + (tv).tv_usec) 12 | 13 | 14 | Resources::Resources () 15 | { 16 | int ret; 17 | ret = gettimeofday (&start, nullptr); 18 | ASSERT (ret == 0); 19 | } 20 | 21 | void Resources::update () 22 | { 23 | struct timeval end; 24 | struct rusage r; 25 | int ret; 26 | 27 | // get current wall time 28 | ret = gettimeofday (&end, nullptr); 29 | ASSERT (ret == 0); 30 | 31 | // end - start 32 | ASSERT (end.tv_sec >= start.tv_sec); 33 | end.tv_sec -= start.tv_sec; 34 | if (end.tv_usec < start.tv_usec) 35 | { 36 | ASSERT (end.tv_sec >= 1); 37 | end.tv_sec -= 1; 38 | end.tv_usec += (1000 * 1000 - start.tv_usec); 39 | } 40 | else 41 | { 42 | end.tv_usec -= start.tv_usec; 43 | } 44 | walltime = TIMEVAL_2_US(end); 45 | 46 | // get cpu time 47 | ret = getrusage (RUSAGE_SELF, &r); 48 | ASSERT (ret == 0); 49 | cputime = TIMEVAL_2_US (r.ru_utime); 50 | systime = TIMEVAL_2_US (r.ru_stime); 51 | maxrss = 0; 52 | maxrss = r.ru_maxrss; 53 | //SHOW (r.ru_maxrss, "lu"); 54 | } 55 | 56 | // /* this will only work in linux, in macos u.unf.maxrss is set to maxrss 57 | // * in kb */ 58 | // fd = open ("/proc/self/statm", O_RDONLY); 59 | // if (fd < 0) return; 60 | // ret = read (fd, buff, 128); 61 | // close (fd); 62 | // buff[127] = 0; 63 | // u.unf.maxrss = strtoul (buff, 0, 10) * sysconf (_SC_PAGESIZE) >> 10; 64 | -------------------------------------------------------------------------------- /src/resources.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __RESOURCES_HH_ 3 | #define __RESOURCES_HH_ 4 | 5 | class Resources 6 | { 7 | public: 8 | 9 | // wall time, in us (microseconds, 1/1000000 secs) 10 | unsigned long walltime; 11 | // user time, in us 12 | unsigned long cputime; 13 | // kernel time, in us 14 | unsigned long systime; 15 | // maximum resident set, in kb 16 | unsigned long maxrss; 17 | 18 | Resources (); 19 | void update (); 20 | private: 21 | struct timeval start; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/unfolder/alt-algorithm.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _C15U_ALTALGORITHM_HH_ 3 | #define _C15U_ALTALGORITHM_HH_ 4 | 5 | namespace dpu 6 | { 7 | 8 | typedef enum { SDPOR, ONLYLAST, KPARTIAL, OPTIMAL } Altalgo; 9 | 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/unfolder/disset.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "unfolder/disset.hh" 3 | 4 | 5 | namespace dpu 6 | { 7 | 8 | void Disset::dump () const 9 | { 10 | const Elem *e; 11 | 12 | PRINT ("== begin disset =="); 13 | 14 | PRINT ("%zu events, top-idx %d, top-disabler %d, ssb-count %u", 15 | stack.size(), top_idx, top_disabler, ssb_count); 16 | PRINT ("Unjustified:"); 17 | for (e = unjust; e; e = e->next) 18 | { 19 | PRINT (" idx %d %s", e->idx, e->e->str().c_str()); 20 | } 21 | 22 | PRINT ("Justified (top-down):"); 23 | for (e = just; e; e = e->next) 24 | { 25 | PRINT (" idx %d dis %d %s", e->idx, e->disabler, e->e->str().c_str()); 26 | } 27 | 28 | PRINT ("== end disset =="); 29 | } 30 | 31 | } // namespace 32 | -------------------------------------------------------------------------------- /src/unfolder/pidpool.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "unfolder/pidpool.hh" 3 | 4 | namespace dpu 5 | { 6 | 7 | #if 0 8 | 9 | == begin pidpool == 10 | Proc 0 11 | curr-depth: 1 12 | assigned : 2, 8 13 | joined : 14 | d 0 pid 3 15 | >d 1 pid 8 16 | d 2 pid -3 17 | 18 | Proc 1 19 | curr-depth: 1 20 | assigned : 2, 8 21 | joined : 22 | d 0 pid 3 23 | >d 1 pid 8 24 | d 2 pid -3 25 | == end pidpool == 26 | 27 | #endif 28 | 29 | void Pidpool::dump () const 30 | { 31 | unsigned i, j; 32 | 33 | PRINT ("== begin pidpool =="); 34 | for (i = 0; i < procs.size(); i++) 35 | { 36 | PRINT ("Proc %u", i); 37 | PRINT (" curr-depth: %d", procs[i].currdepth); 38 | PRINT_ (" assigned : "); 39 | for (unsigned pid : procs[i].assigned) PRINT_ ("%u ", pid); 40 | PRINT_ ("\n joined : "); 41 | for (unsigned pid : procs[i].joined) PRINT_ ("%u ", pid); 42 | PRINT (""); 43 | for (j = 0; j < procs[i].pids.size(); j++) 44 | PRINT (" %sd %u pid %d", 45 | j == procs[i].currdepth ? ">" : " ", j, procs[i].pids[j]); 46 | } 47 | PRINT ("== end pidpool =="); 48 | } 49 | 50 | } // namespace 51 | -------------------------------------------------------------------------------- /src/unfolder/pidpool.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _C15U_PIDPOOL_HH_ 3 | #define _C15U_PIDPOOL_HH_ 4 | 5 | #include 6 | #include 7 | 8 | #include "pes/unfolding.hh" 9 | #include "pes/event.hh" 10 | 11 | namespace dpu 12 | { 13 | 14 | class Pidpool 15 | { 16 | public: 17 | inline Pidpool (Unfolding &u); 18 | 19 | inline unsigned create (const Event *c); 20 | inline void join (const Event *e); 21 | inline void clear (); 22 | void dump () const; 23 | 24 | protected: 25 | struct Prochist 26 | { 27 | std::vector pids; 28 | unsigned currdepth; 29 | std::unordered_set assigned; 30 | std::unordered_set joined; 31 | }; 32 | 33 | Unfolding &u; 34 | std::vector procs; 35 | 36 | inline Prochist * new_prochist (); 37 | inline void update_hist_create (Prochist *h, unsigned pid); 38 | }; 39 | 40 | // implementation of inline methods 41 | #include "pidpool.hpp" 42 | 43 | } // namespace 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/unfolder/trail.hh: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _C15U_TRAIL_HH_ 3 | #define _C15U_TRAIL_HH_ 4 | 5 | #include 6 | #include "pes/event.hh" 7 | #include "verbosity.h" 8 | 9 | namespace dpu 10 | { 11 | 12 | class Trail : public std::vector 13 | { 14 | public: 15 | 16 | Trail () : 17 | nrctxsw (0), 18 | lastpid (0) 19 | {} 20 | 21 | void push (Event *e) 22 | { 23 | ASSERT (e); 24 | _update_nrctxsw_push (e->pid()); 25 | std::vector::push_back (e); 26 | } 27 | 28 | Event *pop () 29 | { 30 | Event *e = back(); 31 | std::vector::pop_back(); 32 | _update_nrctxsw_pop (); 33 | return e; 34 | } 35 | 36 | Event *peek () 37 | { return back (); } 38 | 39 | void dump () const; 40 | void dump2 (const char *prefix) const; 41 | unsigned nr_context_switches () const 42 | { 43 | return nrctxsw; 44 | } 45 | 46 | private: 47 | unsigned nrctxsw; 48 | unsigned lastpid; 49 | 50 | void _update_nrctxsw_push (unsigned newpid) 51 | { 52 | ASSERT (empty() or back()->pid() == lastpid); 53 | if (lastpid == newpid) return; 54 | nrctxsw++; 55 | lastpid = newpid; 56 | } 57 | 58 | void _update_nrctxsw_pop () 59 | { 60 | unsigned newlastpid; 61 | 62 | newlastpid = size() ? back()->pid() : 0; 63 | if (newlastpid != lastpid) nrctxsw--; 64 | lastpid = newlastpid; 65 | } 66 | }; 67 | 68 | } // namespace 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/verbosity.c: -------------------------------------------------------------------------------- 1 | 2 | #include "verbosity.h" 3 | 4 | unsigned __verb_level = VERB_PRINT; 5 | 6 | unsigned verb_debug = 0; 7 | unsigned verb_trace = 0; 8 | unsigned verb_info = 0; 9 | 10 | void verb_set (int i) 11 | { 12 | __verb_level = i; 13 | 14 | #ifdef VERB_LEVEL_DEBUG 15 | verb_debug = i >= VERB_DEBUG; 16 | #endif 17 | #ifdef VERB_LEVEL_TRACE 18 | verb_trace = i >= VERB_TRACE; 19 | #endif 20 | #ifdef VERB_LEVEL_INFO 21 | verb_info = i >= VERB_INFO; 22 | #endif 23 | } 24 | 25 | int verb_get () 26 | { 27 | return __verb_level; 28 | } 29 | 30 | void breakme (void) 31 | { 32 | } 33 | 34 | -------------------------------------------------------------------------------- /tests/regression/Makefile: -------------------------------------------------------------------------------- 1 | 2 | R ?= ../.. 3 | D := $R/tests/regression 4 | 5 | all : run 6 | 7 | run : 8 | $D/regtest.sh $R/dist/bin/dpu $D 9 | 10 | clean : clean 11 | @rm -f $D/regression.log* 12 | @find $D | grep '.log$$' | xargs rm -f 13 | 14 | realclean : 15 | -------------------------------------------------------------------------------- /tests/regression/README.rst: -------------------------------------------------------------------------------- 1 | Add here the svcomp16 bech, once we make them work with DPU. 2 | -------------------------------------------------------------------------------- /tests/regression/basic/16threads.test.sh: -------------------------------------------------------------------------------- 1 | # Can unfold with 16 threads 2 | 3 | gcc -E nthreads.c -D N=16 -o input.i 4 | 5 | cmd $PROG input.i -vv 6 | 7 | test $EXITCODE = 0 8 | grep -i ": 1 max-configs" 9 | grep -i " unfolding: 17 threads created" 10 | rm input.i 11 | -------------------------------------------------------------------------------- /tests/regression/basic/20threads.test.sh: -------------------------------------------------------------------------------- 1 | # Can unfold with 20 threads 2 | 3 | gcc -E nthreads.c -D N=20 -o input.i 4 | 5 | cmd $PROG input.i -vv 6 | 7 | test $EXITCODE = 0 8 | grep "summary: 0 defects, 1 max-configs" 9 | grep " unfolding: 21 threads created" 10 | rm input.i 11 | -------------------------------------------------------------------------------- /tests/regression/basic/24threads.test.sh: -------------------------------------------------------------------------------- 1 | # Can unfold with 24 threads 2 | 3 | gcc -E nthreads.c -D N=24 -o input.i 4 | 5 | cmd $PROG input.i -vv --mem 64M --stack 1M 6 | 7 | test $EXITCODE = 0 8 | grep -i ": 1 max-configs" 9 | grep -i " unfolding: 25 threads created" 10 | rm input.i 11 | -------------------------------------------------------------------------------- /tests/regression/basic/2threads.test.sh: -------------------------------------------------------------------------------- 1 | # Can unfold with 2 threads 2 | 3 | gcc -E nthreads.c -D N=2 -o input.i 4 | 5 | cmd $PROG input.i -vv 6 | 7 | test $EXITCODE = 0 8 | grep -i ": 1 max-configs" 9 | grep -i " unfolding: 3 threads created" 10 | rm input.i 11 | -------------------------------------------------------------------------------- /tests/regression/basic/4threads.test.sh: -------------------------------------------------------------------------------- 1 | # Can unfold with 4 threads 2 | 3 | gcc -E nthreads.c -D N=4 -o input.i 4 | 5 | cmd $PROG input.i -vv 6 | 7 | test $EXITCODE = 0 8 | grep -i ": 1 max-configs" 9 | grep -i " unfolding: 5 threads created" 10 | rm input.i 11 | -------------------------------------------------------------------------------- /tests/regression/basic/8threads.test.sh: -------------------------------------------------------------------------------- 1 | # Can unfold with 8 threads 2 | 3 | gcc -E nthreads.c -D N=8 -o input.i 4 | 5 | cmd $PROG input.i -vv 6 | 7 | test $EXITCODE = 0 8 | grep -i ": 1 max-configs" 9 | grep -i " unfolding: 9 threads created" 10 | rm input.i 11 | -------------------------------------------------------------------------------- /tests/regression/basic/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -Wall -pthread 2 | CC=gcc 3 | 4 | TARGETS = $(patsubst %.c, %, $(wildcard *.c)) 5 | 6 | all : $(TARGETS) 7 | 8 | clean : 9 | rm -f $(TARGETS) regression.log* *.log 10 | -------------------------------------------------------------------------------- /tests/regression/basic/ccnf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef N 6 | #define N 9 7 | #endif 8 | 9 | #ifndef JOIN 10 | #define JOIN 1 11 | #endif 12 | 13 | pthread_mutex_t m[N]; 14 | 15 | void *thread (void *arg) 16 | { 17 | long i = (long) arg; 18 | int ret; 19 | 20 | // enter cs 21 | ret = pthread_mutex_lock (m + i/2); 22 | assert (ret == 0); 23 | 24 | printf ("t%ld: cs %ld\n", i, i/2); 25 | 26 | // exit cs 27 | ret = pthread_mutex_unlock (m + i/2); 28 | assert (ret == 0); 29 | 30 | return 0; 31 | } 32 | 33 | int main (int argc, char ** argv) 34 | { 35 | int ret; 36 | long i; 37 | pthread_t th[N*2]; 38 | 39 | (void) argc; 40 | (void) argv; 41 | 42 | // if N is even this will initialize one mutex more than necessary ;) 43 | // as (N/2) != (N-1)/2 in general 44 | for (i = 0; i < N; i++) 45 | pthread_mutex_init (m + i, 0); 46 | 47 | for (i = 0; i < N*2; i++) 48 | { 49 | ret = pthread_create (th + i, 0, thread, (void*) i); 50 | assert (ret == 0); 51 | } 52 | 53 | // we conditionally do join 54 | if (JOIN) 55 | { 56 | for (i = 0; i < N*2; i++) 57 | { 58 | ret = pthread_join (th[i], 0); 59 | assert (ret == 0); 60 | } 61 | } 62 | 63 | pthread_exit (0); 64 | } 65 | -------------------------------------------------------------------------------- /tests/regression/basic/conc-factorial-reuse.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef N 7 | #define N 5 8 | #endif 9 | 10 | #ifndef K 11 | #define K 4 12 | #endif 13 | 14 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 15 | 16 | void *thread2 (void *arg); 17 | 18 | void *thread (void *arg) 19 | { 20 | long j = (long) arg; 21 | int i, ret; 22 | pthread_t th[K]; 23 | 24 | pthread_mutex_lock(&m); 25 | pthread_mutex_unlock(&m); 26 | 27 | printf ("t%ld: running!\n", j); 28 | for (i = 0; i < K; i++) 29 | { 30 | ret = pthread_create (th + i, 0, thread2, (void*) j); 31 | assert (ret == 0); 32 | 33 | // we only join for the first two, so the third will consume a new slot 34 | if (i < 2) 35 | { 36 | ret = pthread_join (th[i], 0); 37 | assert (ret == 0); 38 | } 39 | } 40 | return 0; 41 | } 42 | 43 | void *thread2 (void *arg) 44 | { 45 | long i = (long) arg; 46 | 47 | printf ("t%ld': running!\n", i); 48 | return 0; 49 | } 50 | 51 | int main (int argc, char ** argv) 52 | { 53 | int ret; 54 | long i; 55 | pthread_t th; 56 | 57 | (void) argc; 58 | (void) argv; 59 | 60 | ret = pthread_mutex_init (&m, 0); 61 | assert (ret == 0); 62 | 63 | for (i = 0; i < N; i++) 64 | { 65 | ret = pthread_create (&th, 0, thread, (void*) i); 66 | assert (ret == 0); 67 | } 68 | pthread_exit (0); 69 | } 70 | -------------------------------------------------------------------------------- /tests/regression/basic/conc-factorial-reuse.test.sh: -------------------------------------------------------------------------------- 1 | # Testing various capabilities of steroids 2 | 3 | # the command to test 4 | cmd $PROG conc-factorial-reuse.c -v 5 | 6 | # the checks to perform on the output 7 | test $EXITCODE = 0 8 | grep "dpu: por: summary: 0 defects, 120 max-configs" 9 | grep "dpu: por: stats: unfolding: 26 threads created" 10 | 11 | -------------------------------------------------------------------------------- /tests/regression/basic/conditional-join.test.sh: -------------------------------------------------------------------------------- 1 | # A thread joins for another thread on some but not all replays 2 | 3 | # the test 4 | cmd $PROG conditional-join.c -v 5 | 6 | test $EXITCODE = 0 7 | grep "dpu: por: summary: 0 defects, 2 max-configs" 8 | grep "dpu: por: stats: unfolding: 5 threads created" 9 | -------------------------------------------------------------------------------- /tests/regression/basic/conflict-create.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef N 7 | #define N 2 8 | #endif 9 | 10 | pthread_mutex_t m; 11 | 12 | void *thread2 (void *arg) 13 | { 14 | long i = (long) arg; 15 | 16 | printf ("u: running, i %ld!\n", i); 17 | return 0; 18 | } 19 | 20 | void *thread (void *arg) 21 | { 22 | long i = (long) arg; 23 | pthread_t th; 24 | int ret; 25 | 26 | printf ("t%ld: running!\n", i); 27 | 28 | // enter cs 29 | ret = pthread_mutex_lock (&m); 30 | assert (ret == 0); 31 | // create a new thread 32 | ret = pthread_create (&th, 0, thread2, arg); 33 | assert (ret == 0); 34 | // exit cs 35 | ret = pthread_mutex_unlock (&m); 36 | assert (ret == 0); 37 | 38 | return 0; 39 | } 40 | 41 | int main (int argc, char ** argv) 42 | { 43 | int ret; 44 | long i; 45 | pthread_t th[N]; 46 | 47 | (void) argc; 48 | (void) argv; 49 | 50 | ret = pthread_mutex_init (&m, 0); 51 | assert (ret == 0); 52 | 53 | for (i = 0; i < N; i++) 54 | { 55 | ret = pthread_create (th + i, 0, thread, (void*) i); 56 | assert (ret == 0); 57 | } 58 | 59 | // we use this instead of exit because some threads do not join for children 60 | pthread_exit (0); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /tests/regression/basic/conflict-create.test.sh: -------------------------------------------------------------------------------- 1 | # N threads enter CS and then create new threads 2 | 3 | # xxx 1 xxx 4 | # dpu: por: summary: 1 max-configs, 0 SSBs, 10 events, 10.0 ev/trail 5 | # xxx 2 xxx 6 | # dpu: por: summary: 2 max-configs, 0 SSBs, 30 events, 18.0 ev/trail 7 | # xxx 3 xxx 8 | # dpu: por: summary: 6 max-configs, 0 SSBs, 98 events, 26.0 ev/trail 9 | # xxx 4 xxx 10 | # dpu: por: summary: 24 max-configs, 0 SSBs, 394 events, 34.0 ev/trail 11 | # xxx 5 xxx 12 | # dpu: por: summary: 120 max-configs, 0 SSBs, 1962 events, 42.0 ev/trail 13 | # xxx 6 xxx 14 | # dpu: por: summary: 720 max-configs, 0 SSBs, 11750 events, 50.0 ev/trail 15 | # xxx 7 xxx 16 | # dpu: por: summary: 5040 max-configs, 0 SSBs, 82210 events, 58.0 ev/trail 17 | 18 | MAX=7 19 | N=$(seq 1 $MAX) 20 | 21 | conf_ev[1]="1 10" 22 | conf_ev[2]="2 30" 23 | conf_ev[3]="6 98" 24 | conf_ev[4]="24 394" 25 | conf_ev[5]="120 1962" 26 | conf_ev[6]="720 11750" 27 | conf_ev[7]="5040 82210" 28 | export conf_ev 29 | 30 | for i in $N; do 31 | gcc -E conflict-create.c -D N=$i -o input$i.i 32 | done 33 | 34 | # the test 35 | cmd for i in $N; do $PROG input$i.i -s 1M -vv > out$i; cat out$i; done 36 | 37 | # exactly MAX executions terminated 38 | test $EXITCODE = 0 39 | for i in $N; do echo "xxx $i xxx"; grep "dpu: por: summary: " out$i; done 40 | 41 | # exactly the espected number of configurations and events 42 | for i in $N; do test \ 43 | "$(grep "dpu: por: summary: " out$i | awk '{print $6, $10}')" = \ 44 | "${conf_ev[$i]}"; done 45 | 46 | # remove intermediate files 47 | for i in $N; do rm input${i}.i; done 48 | for i in $N; do rm out$i; done 49 | -------------------------------------------------------------------------------- /tests/regression/basic/factorial-conflicts.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef N 6 | #define N 1 7 | #endif 8 | 9 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 10 | unsigned count = 0; 11 | 12 | void *thread (void *arg) 13 | { 14 | long i = (long) arg; 15 | int ret; 16 | 17 | printf ("t%ld: running!\n", i); 18 | 19 | // enter cs 20 | ret = pthread_mutex_lock (&m); 21 | assert (ret == 0); 22 | 23 | // increment the count 24 | count++; 25 | 26 | // exit cs 27 | ret = pthread_mutex_unlock (&m); 28 | assert (ret == 0); 29 | 30 | return 0; 31 | } 32 | 33 | int main (int argc, char ** argv) 34 | { 35 | int ret; 36 | long i; 37 | pthread_t th[N]; 38 | 39 | (void) argc; 40 | (void) argv; 41 | 42 | ret = pthread_mutex_init (&m, 0); 43 | assert (ret == 0); 44 | 45 | for (i = 0; i < N; i++) 46 | { 47 | ret = pthread_create (th + i, 0, thread, (void*) i); 48 | assert (ret == 0); 49 | } 50 | 51 | for (i = 0; i < N; i++) 52 | { 53 | ret = pthread_join (th[i], 0); 54 | assert (ret == 0); 55 | } 56 | 57 | printf ("m: done, count %d N %d\n", count, N); 58 | assert (count == N); 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /tests/regression/basic/factorial-conflicts.test.sh: -------------------------------------------------------------------------------- 1 | # Unfolding with N threads and N! executions 2 | 3 | # dpu: por: summary: 1 max-configs, 0 SSBs, 8 events, 8.0 ev/trail 4 | # dpu: por: summary: 2 max-configs, 0 SSBs, 23 events, 14.0 ev/trail 5 | # dpu: por: summary: 6 max-configs, 0 SSBs, 75 events, 20.0 ev/trail 6 | # dpu: por: summary: 24 max-configs, 0 SSBs, 311 events, 26.0 ev/trail 7 | # dpu: por: summary: 120 max-configs, 0 SSBs, 1623 events, 32.0 ev/trail 8 | # dpu: por: summary: 720 max-configs, 0 SSBs, 10221 events, 38.0 ev/trail 9 | # dpu: por: summary: 5040 max-configs, 0 SSBs, 75113 events, 44.0 ev/trail 10 | 11 | MAX=5 12 | N=$(seq 1 $MAX) 13 | 14 | configs[1]=1 15 | configs[2]=2 16 | configs[3]=6 17 | configs[4]=24 18 | configs[5]=120 19 | configs[6]=720 20 | configs[7]=5040 21 | 22 | events[1]=8 23 | events[2]=23 24 | events[3]=75 25 | events[4]=311 26 | events[5]=1623 27 | events[6]=10221 28 | events[7]=75113 29 | export events configs # arrays need to be exported manually 30 | 31 | # generate 32 | for i in $N; do 33 | gcc -E factorial-conflicts.c -D N=$i -o input$i.i 34 | done 35 | 36 | # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 37 | 38 | cmd for i in $N; do $PROG input$i.i -vv > out$i; cat out$i; done 39 | 40 | # exactly MAX executions terminated 41 | test $EXITCODE = 0 42 | for i in $N; do echo "xxx $i xxx"; grep "dpu: por: stats: " out$i; done 43 | 44 | # exactly the espected number of configurations and events 45 | for i in $N; do test \ 46 | "$(grep "dpu: por: summary: " out$i | awk '{print $6, $10}')" = \ 47 | "${configs[$i]} ${events[$i]}"; done 48 | 49 | # remove intermediate files 50 | for i in $N; do rm input${i}.i; done 51 | for i in $N; do rm out$i; done 52 | -------------------------------------------------------------------------------- /tests/regression/basic/hello.test.sh: -------------------------------------------------------------------------------- 1 | # Testing various capabilities of steroids 2 | 3 | # the command to test 4 | cmd $PROG hello.c -vv 5 | 6 | # the checks to perform on the output 7 | test $EXITCODE = 0 8 | grep "dpu: por: summary: 0 defects, 1 max-configs" 9 | grep "dpu: por: stats: unfolding: 1 threads created" 10 | 11 | -------------------------------------------------------------------------------- /tests/regression/basic/nthreads.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef N 7 | #define N 40 8 | #endif 9 | 10 | int rets[N]; 11 | 12 | void *thread (void *arg) 13 | { 14 | long i = (long) arg; 15 | 16 | printf ("t%ld: running!\n", i); 17 | return rets + i; 18 | } 19 | 20 | int main (int argc, char ** argv) 21 | { 22 | int ret; 23 | long i; 24 | void *retval; 25 | pthread_t th[N]; 26 | 27 | (void) argc; 28 | (void) argv; 29 | 30 | for (i = 0; i < N; i++) 31 | { 32 | ret = pthread_create (th + i, 0, thread, (void*) i); 33 | assert (ret == 0); 34 | } 35 | 36 | for (i = 0; i < N; i++) 37 | { 38 | ret = pthread_join (th[i], &retval); 39 | assert (ret == 0); 40 | printf ("m: retval %p\n", retval); 41 | printf ("m: rets + i %p i %ld\n", rets + i, i); 42 | assert (retval == rets + i); 43 | } 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /tests/regression/basic/nthreads.test.sh: -------------------------------------------------------------------------------- 1 | # Can create up to 32 threads 2 | 3 | # initialization 4 | N=$(seq 7 4 31) 5 | for i in $N; do 6 | gcc -E nthreads.c -D N=$i -o input$i.i 7 | done 8 | 9 | # the command to test 10 | cmd for i in $N; do \ 11 | $PROG input$i.i -vv > out$i; done 12 | 13 | # the checks to perform on the output 14 | echo $N 15 | test $EXITCODE = 0 16 | for i in $N; do echo xxx $i xxx; grep "dpu: por: stats: " out$i; done 17 | for i in $N; do grep -i ": 1 max-configs" out$i; done 18 | for i in $N; do grep -i " unfolding: $(($i + 1)) threads created" out$i; done 19 | for i in $N; do rm input${i}.i; done 20 | for i in $N; do rm out$i; done 21 | -------------------------------------------------------------------------------- /tests/regression/basic/pidpool-seen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // 3 executions, revealed a bug in the Pidpool::create() method 6 | 7 | void *ta (void *arg); 8 | void *tb (void *arg); 9 | 10 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 11 | 12 | void *ta (void *arg) 13 | { 14 | (void) arg; 15 | printf ("ta: running\n"); 16 | 17 | pthread_mutex_lock (&m); 18 | pthread_mutex_unlock (&m); 19 | 20 | return 0; 21 | } 22 | 23 | void *tb (void *arg) 24 | { 25 | (void) arg; 26 | printf ("tb: running\n"); 27 | return 0; 28 | } 29 | 30 | int main() 31 | { 32 | pthread_t a, b; 33 | 34 | pthread_create (&b, 0, tb, 0); 35 | pthread_join (b, 0); 36 | 37 | pthread_create (&a, 0, ta, 0); 38 | 39 | pthread_mutex_lock (&m); 40 | pthread_mutex_unlock (&m); 41 | pthread_mutex_lock (&m); 42 | pthread_mutex_unlock (&m); 43 | 44 | pthread_exit (0); 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/regression/basic/pidpool-seen.test.sh: -------------------------------------------------------------------------------- 1 | # Reusing pids after join 2 | 3 | # the test 4 | cmd $PROG pidpool-seen.c -v 5 | 6 | test $EXITCODE = 0 7 | grep "dpu: por: summary: 0 defects, 3 max-configs" 8 | grep "dpu: por: stats: unfolding: 3 threads created" 9 | grep "dpu: por: stats: unfolding: 2 process slots" 10 | grep "dpu: por: stats: por: 0 SSBs" 11 | -------------------------------------------------------------------------------- /tests/regression/basic/saw-pattern-replay.test.sh: -------------------------------------------------------------------------------- 1 | # Like the saw-pattern.c but with some conflicts in the end 2 | 3 | cmd $PROG saw-pattern-replay.c -v 4 | 5 | test $EXITCODE = 0 6 | grep "dpu: por: summary: 0 defects, 3 max-config" 7 | grep "dpu: por: stats: unfolding: 18 threads created" 8 | grep "dpu: por: stats: unfolding: 5 process slots" 9 | -------------------------------------------------------------------------------- /tests/regression/basic/saw-pattern-v.test.sh: -------------------------------------------------------------------------------- 1 | # Like the saw-pattern.c but with some conflicts in the beginning 2 | 3 | cmd $PROG saw-pattern-v.c -v 4 | 5 | test $EXITCODE = 0 6 | grep "dpu: por: summary: 0 defects, 3 max-config" 7 | grep "dpu: por: stats: unfolding: 26 threads created" 8 | grep "dpu: por: stats: unfolding: 5 process slots" 9 | -------------------------------------------------------------------------------- /tests/regression/basic/saw-pattern.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // the main thread creates and joins a thread N times in a loop, which creates a 7 | // pattern similar to that of the teeth of a saw. In fact, each teeth creates K 8 | // concurrent threads. 9 | 10 | #ifndef N 11 | #define N 10 12 | #endif 13 | 14 | #ifndef K 15 | #define K 2 16 | #endif 17 | 18 | void *thread2 (void *arg); 19 | 20 | void *thread (void *arg) 21 | { 22 | long j = (long) arg; 23 | int i, ret; 24 | pthread_t th[K]; 25 | 26 | printf ("t%ld: running!\n", j); 27 | for (i = 0; i < K; i++) 28 | { 29 | ret = pthread_create (th + i, 0, thread2, (void*) j); 30 | assert (ret == 0); 31 | } 32 | for (i = 0; i < K; i++) 33 | { 34 | ret = pthread_join (th[i], 0); 35 | assert (ret == 0); 36 | } 37 | return 0; 38 | } 39 | 40 | void *thread2 (void *arg) 41 | { 42 | long i = (long) arg; 43 | 44 | printf ("t%ld': running!\n", i); 45 | return 0; 46 | } 47 | 48 | int main (int argc, char ** argv) 49 | { 50 | int ret; 51 | long i; 52 | pthread_t th; 53 | 54 | (void) argc; 55 | (void) argv; 56 | 57 | for (i = 0; i < N; i++) 58 | { 59 | printf ("m: =======\n"); 60 | ret = pthread_create (&th, 0, thread, (void*) i); 61 | assert (ret == 0); 62 | 63 | ret = pthread_join (th, 0); 64 | assert (ret == 0); 65 | } 66 | 67 | pthread_exit (0); 68 | } 69 | -------------------------------------------------------------------------------- /tests/regression/basic/saw-pattern.test.sh: -------------------------------------------------------------------------------- 1 | # Create and join a thread N times; that thread creates K concurrent threads 2 | 3 | cmd $PROG saw-pattern.c -v 4 | 5 | test $EXITCODE = 0 6 | grep "dpu: por: summary: 0 defects, 1 max-config" 7 | grep "dpu: por: stats: unfolding: 31 threads created" 8 | grep "dpu: por: stats: unfolding: 4 process slots" 9 | -------------------------------------------------------------------------------- /tests/regression/basic/thread-creates.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef N 6 | #define N 8 7 | #endif 8 | 9 | pthread_t th[N]; 10 | 11 | void *thread (void *arg) 12 | { 13 | int ret; 14 | long i = (long) arg; 15 | 16 | printf ("t%ld: alive!\n", i); 17 | 18 | // if we are the last, we do not create new threads 19 | if (i >= N) return 0; 20 | 21 | // otherwise we create the thread i + 1 22 | assert (i < N); 23 | ret = pthread_create (th + i, 0, thread, (void*) (i + 1)); 24 | assert (ret == 0); 25 | return 0; 26 | } 27 | 28 | int main (int argc, char ** argv) 29 | { 30 | int ret; 31 | long i; 32 | 33 | (void) argc; 34 | (void) argv; 35 | 36 | // create only 1 thread if N >= 1 37 | if (N >= 1) 38 | { 39 | ret = pthread_create (th + 0, 0, thread, (void*) 1); 40 | assert (ret == 0); 41 | } 42 | 43 | // we wait for all threads 44 | for (i = 0; i < N; i++) 45 | { 46 | ret = pthread_join (th[i], 0); 47 | assert (ret == 0); 48 | } 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /tests/regression/basic/two-columns.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef N 7 | #define N 5 8 | #endif 9 | 10 | // N max confs (according to nidhugg) 11 | // 1 2 12 | // 2 6 13 | // 3 20 14 | // 4 70 15 | // 5 252 16 | // 6 924 17 | // 7 3432 18 | // 8 12870 19 | 20 | pthread_mutex_t m; 21 | int count = 0; 22 | 23 | void *thread (void *arg) 24 | { 25 | int ret, i; 26 | long j = (long) arg; 27 | int done = 0; 28 | 29 | for (i = 0; i < N; i++) 30 | { 31 | // enter cs 32 | ret = pthread_mutex_lock (&m); 33 | assert (ret == 0); 34 | 35 | count++; 36 | printf ("t%ld: in cs, i %d, count %d\n", j, i, count); 37 | if (count == 2*N) 38 | { 39 | done = 1; 40 | } 41 | 42 | // exit cs 43 | ret = pthread_mutex_unlock (&m); 44 | assert (ret == 0); 45 | } 46 | 47 | if (done) 48 | { 49 | ret = pthread_mutex_destroy (&m); 50 | assert (ret == 0); 51 | } 52 | return 0; 53 | } 54 | 55 | int main (int argc, char ** argv) 56 | { 57 | int ret; 58 | pthread_t th; 59 | 60 | (void) argc; 61 | (void) argv; 62 | 63 | ret = pthread_mutex_init (&m, 0); 64 | assert (ret == 0); 65 | 66 | ret = pthread_create (&th, 0, thread, (void*) 1); 67 | assert (ret == 0); 68 | 69 | // we do the second thread 70 | thread ((void*) 0); 71 | 72 | // we do not wait for our children 73 | pthread_exit (0); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /tests/regression/basic/two-columns.test.sh: -------------------------------------------------------------------------------- 1 | # Two threads sequentially acquire N times one mutex 2 | 3 | # N max confs (according to nidhugg) 4 | # 1 2 5 | # 2 6 6 | # 3 20 7 | # 4 70 8 | # 5 252 9 | # 6 924 10 | # 7 3432 11 | # 8 12870 12 | 13 | configs[1]=2 14 | configs[2]=6 15 | configs[3]=20 16 | configs[4]=70 17 | configs[5]=252 18 | configs[6]=924 19 | configs[7]=3432 20 | configs[8]=12870 21 | export configs 22 | 23 | # initialization 24 | MAX=8 25 | N=$(seq 1 $MAX) 26 | for i in $N; do 27 | gcc -E two-columns.c -D N=$i -o input$i.i 28 | done 29 | 30 | # the command to test 31 | cmd for i in $N; do \ 32 | $PROG input$i.i -vv > out$i; done 33 | 34 | # exactly MAX executions terminated 35 | echo $N 36 | test $EXITCODE = 0 37 | for i in $N; do echo xxx $i xxx; grep "dpu: por: summary: " out$i; done 38 | for i in $N; do echo xxx $i xxx; grep "dpu: por: stats: " out$i; done 39 | 40 | 41 | # exactly the espected number of configurations, events, and threads 42 | for i in $N; do set -x; test \ 43 | "$(grep "dpu: por: summary: " out$i | awk '{print $6}')" = \ 44 | "${configs[$i]}"; done 45 | for i in $N; do grep " unfolding: 2 threads created" out$i; done 46 | 47 | # remove intermediate files 48 | for i in $N; do rm input$i.i; done 49 | for i in $N; do rm out$i; done 50 | -------------------------------------------------------------------------------- /tests/regression/basic/ww.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | int x=0; 7 | pthread_mutex_t l; 8 | 9 | void * p (void * arg){ 10 | int y = 0; 11 | pthread_mutex_lock (&l); 12 | y = x; 13 | x = 1; 14 | printf ("p: y %d\n", y); 15 | pthread_mutex_unlock (&l); 16 | 17 | return 0; 18 | } 19 | 20 | void * q (void * arg){ 21 | pthread_mutex_lock (&l); 22 | x = 2; 23 | printf ("q: x %d\n", x); 24 | pthread_mutex_unlock (&l); 25 | 26 | return 0; 27 | } 28 | 29 | int main () 30 | { 31 | /* references to the threads */ 32 | pthread_t p_t; 33 | pthread_t q_t; 34 | 35 | pthread_mutex_init (&l, 0); 36 | 37 | /* create the threads and execute */ 38 | pthread_create (&p_t, 0, p, 0); 39 | pthread_create (&q_t, 0, q, 0); 40 | 41 | /* wait for the threads to finish */ 42 | pthread_join (p_t, 0); 43 | pthread_join (q_t, 0); 44 | 45 | assert (x != 3); 46 | 47 | /* show the results */ 48 | printf("x: %d\n", x); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /tests/regression/basic/ww.test.sh: -------------------------------------------------------------------------------- 1 | # Simple program with 2 threads and 1 CS 2 | 3 | cmd $PROG ww.c -vv 4 | 5 | test $EXITCODE = 0 6 | grep "dpu: por: summary: 0 defects, 2 max-configs" 7 | grep "dpu: por: stats: unfolding: 3 threads" 8 | -------------------------------------------------------------------------------- /tests/regression/cmdargs/bad-option.test.sh: -------------------------------------------------------------------------------- 1 | # Dpu signals an error on wrong options 2 | 3 | # $PROG program 4 | # $EXITCODE exitcode 5 | # $TEST path to this file 6 | 7 | cmd $PROG --fjsdkl || $PROG --jjqkl || $PROG -4 8 | 9 | test $EXITCODE != 0 10 | #grep -i usage 11 | test $(wc -l) -ge 1 # at least one line of output 12 | -------------------------------------------------------------------------------- /tests/regression/cmdargs/help.test.sh: -------------------------------------------------------------------------------- 1 | # Displays help 2 | 3 | # $PROG program 4 | # $EXITCODE exitcode 5 | # $TEST path to this file 6 | 7 | cmd $PROG --help 8 | 9 | test $EXITCODE = 0 10 | grep -i Usage 11 | grep -i -- --help 12 | grep -i -- --gdb 13 | grep -i default 14 | -------------------------------------------------------------------------------- /tests/regression/cmdargs/missing.test.sh: -------------------------------------------------------------------------------- 1 | # Dpu signals an error on a missing file 2 | 3 | # $PROG program 4 | # $EXITCODE exitcode 5 | # $TEST path to this file 6 | 7 | cmd $PROG -v 8 | 9 | test $EXITCODE != 0 10 | #grep -i usage 11 | test $(wc -l) -ge 1 # at least one line of output 12 | -------------------------------------------------------------------------------- /tests/regression/data-race-analysis/races2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef N 6 | #define N 2 7 | #endif 8 | 9 | pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; 10 | 11 | int shared = 0; 12 | int shared2 = 13; 13 | 14 | void *thread (void *arg) 15 | { 16 | int local; 17 | int good = 1; 18 | 19 | (void) arg; 20 | 21 | pthread_mutex_lock (&m1); 22 | local = shared; 23 | shared++; 24 | pthread_mutex_unlock (&m1); 25 | 26 | pthread_mutex_lock (&m1); 27 | if (shared % N != local) good = 0; 28 | shared++; 29 | pthread_mutex_unlock (&m1); 30 | 31 | pthread_mutex_lock (&m1); 32 | if (shared % N != local) good = 0; 33 | shared++; 34 | pthread_mutex_unlock (&m1); 35 | 36 | // this line will create a data race between threads only if they have 37 | // followed a "zig-zag" interleaving 38 | if (good) shared2 = 123; 39 | 40 | return (void*) (size_t) local; 41 | } 42 | 43 | int main() 44 | { 45 | pthread_t t[N]; 46 | int i; 47 | 48 | for (i = 0; i < N; i++) 49 | pthread_create (t + i, NULL, thread, NULL); 50 | 51 | pthread_exit (NULL); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /tests/regression/data-race-analysis/races2.test.sh: -------------------------------------------------------------------------------- 1 | # Race depends on threads running 1 specific interleaving 2 | 3 | N="2 3" 4 | 5 | cmd for i in $N; do \ 6 | $PROG races2.c -D N=$i -a dr -v --drfreq 100 > out$i; done 7 | 8 | test $EXITCODE = 0 9 | for i in $N; do echo xxx $i xxx; grep "dpu: dr: result: " out$i; done 10 | for i in $N; do grep "dpu: dr: result: .*data race FOUND" out$i; done 11 | 12 | rm defects.dr.yml 13 | for i in $N; do rm out$i; done 14 | -------------------------------------------------------------------------------- /tests/regression/defects/abort1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main (int argc, char ** argv) 4 | { 5 | // should report a defect 6 | abort (); 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/regression/defects/abort1.test.sh: -------------------------------------------------------------------------------- 1 | # Calls to abort are a defect 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG abort1.c -vv 6 | 7 | test $EXITCODE = 0 8 | grep "1 defects, 1 max-configs" 9 | test -f defects.por.yml 10 | grep -A5 'description.*The program called abort' defects.por.yml 11 | test "$(grep 'description' defects.por.yml | wc -l)" == 1 12 | rm -f defects.por.yml 13 | -------------------------------------------------------------------------------- /tests/regression/defects/abort2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #ifndef N 8 | #define N 3 9 | #endif 10 | 11 | void *thread (void *arg) 12 | { 13 | long i = (long) arg; 14 | 15 | printf ("t%ld: running!\n", i); 16 | 17 | // should report a defect 18 | if (i == 0) abort (); 19 | 20 | return 0; 21 | } 22 | 23 | int main (int argc, char ** argv) 24 | { 25 | int ret; 26 | long i; 27 | void *retval; 28 | pthread_t th[N]; 29 | 30 | (void) argc; 31 | (void) argv; 32 | 33 | for (i = 0; i < N; i++) pthread_create (th + i, 0, thread, (void*) i); 34 | for (i = 0; i < N; i++) pthread_join (th[i], 0); 35 | 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /tests/regression/defects/abort2.test.sh: -------------------------------------------------------------------------------- 1 | # Calls to abort are a defect 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG abort2.c -vv 6 | 7 | test $EXITCODE = 0 8 | grep "1 defects, 1 max-configs" 9 | test -f defects.por.yml 10 | grep -A5 'description.*The program called abort' defects.por.yml 11 | test "$(grep 'description' defects.por.yml | wc -l)" == 1 12 | rm -f defects.por.yml 13 | -------------------------------------------------------------------------------- /tests/regression/defects/abort3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #ifndef N 8 | #define N 3 9 | #endif 10 | 11 | void *thread (void *arg) 12 | { 13 | long i = (long) arg; 14 | 15 | printf ("t: running!\n"); 16 | 17 | // should report a defect 18 | abort (); 19 | 20 | return 0; 21 | } 22 | 23 | int main (int argc, char ** argv) 24 | { 25 | int ret; 26 | long i; 27 | void *retval; 28 | pthread_t th; 29 | 30 | (void) argc; 31 | (void) argv; 32 | 33 | pthread_create (&th, 0, thread, 0); 34 | pthread_join (th, &retval); 35 | 36 | // should fail and trigger another call to abort 37 | assert (retval == (void*) 0x123); 38 | 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /tests/regression/defects/abort3.test.sh: -------------------------------------------------------------------------------- 1 | # Calls to abort are a defect 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG abort3.c -vv 6 | 7 | test $EXITCODE = 0 8 | grep "2 defects, 1 max-configs" 9 | test -f defects.por.yml 10 | grep -A5 'description.*The program called abort' defects.por.yml 11 | test "$(grep 'description' defects.por.yml | wc -l)" == 2 12 | rm -f defects.por.yml 13 | -------------------------------------------------------------------------------- /tests/regression/defects/assert1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef N 7 | #define N 4 8 | #endif 9 | 10 | int rets[N]; 11 | 12 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; 13 | 14 | void *thread (void *arg) 15 | { 16 | long i = (long) arg; 17 | 18 | pthread_mutex_lock (&m); 19 | pthread_mutex_unlock (&m); 20 | 21 | printf ("t%ld: running!\n", i); 22 | return rets + i; 23 | } 24 | 25 | int main (int argc, char ** argv) 26 | { 27 | int ret; 28 | long i; 29 | void *retval; 30 | pthread_t th[N]; 31 | 32 | (void) argc; 33 | (void) argv; 34 | 35 | for (i = 0; i < N; i++) 36 | { 37 | ret = pthread_create (th + i, 0, thread, (void*) i); 38 | assert (ret == 0); 39 | } 40 | 41 | for (i = 0; i < N; i++) 42 | { 43 | ret = pthread_join (th[i], &retval); 44 | assert (ret == 0); 45 | printf ("m: retval %p\n", retval); 46 | printf ("m: rets + i %p i %ld\n", rets + i, i); 47 | 48 | // should fail 49 | assert (retval == rets + 0); 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tests/regression/defects/assert1.test.sh: -------------------------------------------------------------------------------- 1 | # Assertion violation 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG assert1.c -vv 6 | 7 | test $EXITCODE = 0 8 | grep "5 defects, 24 max-configs" 9 | grep 'Assertion .* failed.' 10 | test -f defects.por.yml 11 | grep -A5 'description.*The program called abort' defects.por.yml 12 | test "$(grep 'description' defects.por.yml | wc -l)" == 5 13 | rm -f defects.por.yml 14 | -------------------------------------------------------------------------------- /tests/regression/defects/assert2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef N 7 | #define N 4 8 | #endif 9 | 10 | int rets[N]; 11 | 12 | void *thread (void *arg) 13 | { 14 | long i = (long) arg; 15 | 16 | assert (i <= 1); 17 | printf ("t%ld: running!\n", i); 18 | return rets + i; 19 | } 20 | 21 | int main (int argc, char ** argv) 22 | { 23 | int ret; 24 | long i; 25 | void *retval; 26 | pthread_t th[N]; 27 | 28 | (void) argc; 29 | (void) argv; 30 | 31 | for (i = 0; i < N; i++) 32 | { 33 | ret = pthread_create (th + i, 0, thread, (void*) i); 34 | assert (ret == 0); 35 | } 36 | 37 | for (i = 0; i < N; i++) 38 | { 39 | ret = pthread_join (th[i], &retval); 40 | assert (ret == 0); 41 | printf ("m: retval %p\n", retval); 42 | printf ("m: rets + i %p i %ld\n", rets + i, i); 43 | } 44 | 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /tests/regression/defects/assert2.test.sh: -------------------------------------------------------------------------------- 1 | # Assertion violation 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG assert2.c -vv 6 | 7 | test $EXITCODE = 0 8 | grep "2 defects, 1 max-configs" 9 | grep 'Assertion .* failed.' 10 | test -f defects.por.yml 11 | grep -A5 'description.*The program called abort' defects.por.yml 12 | test "$(grep 'description' defects.por.yml | wc -l)" == 2 13 | rm -f defects.por.yml 14 | -------------------------------------------------------------------------------- /tests/regression/defects/exit1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main (int argc, char ** argv) 7 | { 8 | (void) argc; 9 | (void) argv; 10 | 11 | exit (17); 12 | 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/regression/defects/exit1.test.sh: -------------------------------------------------------------------------------- 1 | # Non-zero exit state 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG exit1.c -vv 6 | 7 | test $EXITCODE = 0 8 | grep "1 defects, 1 max-configs" 9 | test -f defects.por.yml 10 | grep -A5 'description.*The program exited with errorcode 17' defects.por.yml 11 | test "$(grep 'description' defects.por.yml | wc -l)" == 1 12 | rm -f defects.por.yml 13 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -Wall -pthread 2 | CC=gcc 3 | 4 | TARGETS = $(patsubst %.c, %, $(wildcard *.c)) 5 | 6 | all : $(TARGETS) 7 | 8 | clean : 9 | rm -f $(TARGETS) regression.log* *.log 10 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/bugpids.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | pthread_mutex_t k; 6 | pthread_mutex_t m; 7 | 8 | void *t1(void *arg) 9 | { 10 | pthread_mutex_lock(&k); 11 | printf ("t1: lock k\n"); 12 | pthread_mutex_unlock(&k); 13 | return 0; 14 | } 15 | 16 | void *t2(void *arg) 17 | { 18 | pthread_mutex_lock(&m); 19 | printf ("t2: lock m\n"); 20 | pthread_mutex_unlock(&m); 21 | return 0; 22 | } 23 | 24 | int main() 25 | { 26 | pthread_t s; 27 | pthread_t t; 28 | 29 | pthread_mutex_init(&k, NULL); 30 | pthread_mutex_init(&m, NULL); 31 | 32 | pthread_create(&s, NULL, t1, NULL); 33 | 34 | pthread_mutex_lock (&k); 35 | pthread_mutex_unlock (&k); 36 | pthread_create(&t, NULL, t2, NULL); 37 | 38 | pthread_mutex_lock (&m); 39 | pthread_mutex_unlock (&m); 40 | 41 | pthread_join(t, NULL); 42 | pthread_join(s, NULL); 43 | 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/bugpids.test.sh: -------------------------------------------------------------------------------- 1 | # Bug about the missmatch between steroids TIDs and DPU PIDs 2 | 3 | cmd $PROG bugpids.c -vv 4 | 5 | test $EXITCODE = 0 6 | grep "dpu: por: summary: 0 defects, 4 max-configs" 7 | grep "dpu: por: stats: unfolding: 3 threads created" 8 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/conc-create-schedule.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void *ta (void *arg); 6 | void *tb (void *arg); 7 | void *tc (void *arg); 8 | void *td (void *arg); 9 | 10 | pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; 11 | pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER; 12 | 13 | void *ta (void *arg) 14 | { 15 | pthread_t c; 16 | 17 | (void) arg; 18 | printf ("ta: running\n"); 19 | 20 | // triggers a race between thread a and b 21 | pthread_mutex_lock (&m1); 22 | pthread_mutex_unlock (&m1); 23 | 24 | pthread_create (&c, NULL, tc, NULL); 25 | return 0; 26 | } 27 | 28 | void *tb (void *arg) 29 | { 30 | pthread_t d; 31 | 32 | (void) arg; 33 | printf ("tb: running\n"); 34 | 35 | pthread_create (&d, NULL, td, NULL); 36 | 37 | // triggers a race between thread a and b 38 | pthread_mutex_lock (&m1); 39 | pthread_mutex_unlock (&m1); 40 | 41 | // triggers a race between threads b and d 42 | pthread_mutex_lock (&m2); 43 | pthread_mutex_unlock (&m2); 44 | return 0; 45 | } 46 | 47 | void *tc (void *arg) 48 | { 49 | (void) arg; 50 | printf ("tc: running\n"); 51 | return 0; 52 | } 53 | 54 | void *td (void *arg) 55 | { 56 | (void) arg; 57 | printf ("td: running\n"); 58 | // triggers a race between threads b and d 59 | pthread_mutex_lock (&m2); 60 | pthread_mutex_unlock (&m2); 61 | return 0; 62 | } 63 | 64 | int main() 65 | { 66 | pthread_t a, b; 67 | 68 | pthread_create (&a, NULL, ta, NULL); 69 | pthread_create (&b, NULL, tb, NULL); 70 | pthread_exit (NULL); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/conc-create-schedule.test.sh: -------------------------------------------------------------------------------- 1 | # Concurrent thread creation can trigger a mismatch between pids in DPU and steroids 2 | 3 | cmd $PROG conc-create-schedule.c -vv 4 | 5 | test $EXITCODE = 0 6 | grep "dpu: por: summary: 0 defects, 4 max-configs" 7 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/empty-stream.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main () 6 | { 7 | abort (); 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/regression/dpu-steroids/empty-stream.test.sh: -------------------------------------------------------------------------------- 1 | # Steroids returns an empty stream of actions 2 | 3 | rm -f defects.por.yml 4 | 5 | cmd $PROG empty-stream.c -vv 6 | 7 | test $EXITCODE = 0 8 | # should be 1 event, but ok due to limitations on steroids 9 | grep "dpu: por: summary: 1 defects, 1 max-configs.*2 events" 10 | grep "dpu: por: stats: unfolding: 1 threads created" 11 | rm defects.por.yml 12 | -------------------------------------------------------------------------------- /tests/regression/pi/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -Wall -pthread 2 | CC=gcc 3 | 4 | TARGETS = $(patsubst %.c, %, $(wildcard *.c)) 5 | 6 | all : $(TARGETS) 7 | 8 | clean : 9 | rm -f $(TARGETS) regression.log* *.log 10 | -------------------------------------------------------------------------------- /tests/regression/pi/pi.test.sh: -------------------------------------------------------------------------------- 1 | # Computing pi with N threads that mutex-lock before exiting 2 | 3 | # seting MAX beyond 7 produces too many events in the thread 0 ... 4 | 5 | MAX=7 6 | N=$(seq 3 $MAX) 7 | for i in $N; do 8 | gcc -E pth_pi_mutex.c -D THREADS=$i -D ITERS=2000 -o input$i.i 9 | done 10 | 11 | # the command to test 12 | cmd for i in $N; do \ 13 | $PROG input$i.i -vv > out$i; done 14 | 15 | # the checks to perform on the output 16 | echo $N 17 | test $EXITCODE = 0 18 | for i in $N; do echo xxx $i xxx; grep "dpu: por: stats: " out$i; done 19 | for i in $N; do echo xxx $i xxx; grep "dpu: por: summary: " out$i; done 20 | 21 | for i in $N; do grep -i " unfolding: $(($i + 1)) threads created" out$i; done 22 | for i in $N; do rm input${i}.i; done 23 | for i in $N; do rm out$i; done 24 | -------------------------------------------------------------------------------- /tests/regression/prodcons/prodcons.c: -------------------------------------------------------------------------------- 1 | /* */ 2 | 3 | #include 4 | 5 | #define MAX 6 6 | #define MIN 0 7 | 8 | int buf=0; 9 | pthread_mutex_t l1; 10 | 11 | void *prod1() 12 | { 13 | int aux=0; 14 | while(1){ 15 | pthread_mutex_lock(&l1); 16 | if(buf < MAX){ 17 | aux=buf; 18 | buf=aux+1; 19 | aux=0; 20 | } 21 | pthread_mutex_unlock(&l1); 22 | } 23 | } 24 | 25 | 26 | void *prod2() 27 | { 28 | int aux=0; 29 | while(1){ 30 | pthread_mutex_lock(&l1); 31 | if(buf < MAX){ 32 | aux=buf; 33 | buf=aux+2; 34 | aux=0; 35 | } 36 | pthread_mutex_unlock(&l1); 37 | } 38 | } 39 | 40 | 41 | void *cons() 42 | { 43 | int aux=0; 44 | while(1){ 45 | pthread_mutex_lock(&l1); 46 | if(buf > MIN){ 47 | aux=buf; 48 | buf=aux-1; 49 | // aux=0; 50 | } 51 | pthread_mutex_unlock(&l1); 52 | } 53 | } 54 | 55 | int main() 56 | { 57 | 58 | pthread_t id1; 59 | pthread_t id2; 60 | pthread_t id3; 61 | 62 | pthread_mutex_init(&l1, 0); 63 | 64 | pthread_create(&id1, 0, prod1, 0); 65 | pthread_create(&id2, 0, prod2, 0); 66 | pthread_create(&id3, 0, cons, 0); 67 | 68 | pthread_join(id1, 0); 69 | pthread_join(id2, 0); 70 | pthread_join(id3, 0); 71 | } 72 | -------------------------------------------------------------------------------- /tests/regression/spin08/spin08.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int N = 12; 4 | int d = 0; 5 | 6 | pthread_mutex_t l1; 7 | 8 | void *thr1() 9 | { 10 | int i=0; 11 | int l=0; 12 | while (i < N) { 13 | // lock 14 | pthread_mutex_lock(&l1); 15 | l = d; 16 | d = l + i; 17 | l=0; 18 | //unlock 19 | pthread_mutex_unlock(&l1); 20 | i = i + 5; 21 | } 22 | return 0; 23 | } 24 | 25 | void *thr2() 26 | { 27 | int j =0; 28 | int l=0; 29 | while (j < N) { 30 | 31 | // lock 32 | pthread_mutex_lock(&l1); 33 | l = d; 34 | d = l - j; 35 | l = 0; 36 | //unlock 37 | pthread_mutex_unlock(&l1); 38 | j = j + 2; 39 | } 40 | return 0; 41 | } 42 | 43 | 44 | int main() 45 | { 46 | pthread_t t1, t2; 47 | 48 | pthread_mutex_init(&l1, NULL); 49 | 50 | pthread_create(&t1, NULL, thr1, NULL); 51 | pthread_create(&t2, NULL, thr2, NULL); 52 | 53 | pthread_join(t1, NULL); 54 | pthread_join(t2, NULL); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /tests/regression/ssbs/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -Wall -pthread 2 | CC=gcc 3 | 4 | TARGETS = $(patsubst %.c, %, $(wildcard *.c)) 5 | 6 | all : $(TARGETS) 7 | 8 | clean : 9 | rm -f $(TARGETS) regression.log* *.log 10 | -------------------------------------------------------------------------------- /tests/regression/ssbs/mpat.test.sh: -------------------------------------------------------------------------------- 1 | # m pattern 2 | 3 | # xxx i=1 xxx 4 | # dpu: por: summary: 2 max-configs, 0 SSBs, 21 events, 14.0 ev/trail 5 | # xxx i=2 xxx 6 | # dpu: por: summary: 8 max-configs, 0 SSBs, 88 events, 26.0 ev/trail 7 | # xxx i=3 xxx 8 | # dpu: por: summary: 48 max-configs, 0 SSBs, 491 events, 38.0 ev/trail 9 | # xxx i=4 xxx 10 | # dpu: por: summary: 384 max-configs, 0 SSBs, 3822 events, 50.0 ev/trail 11 | # xxx i=5 xxx 12 | # dpu: por: summary: 3840 max-configs, 0 SSBs, 38017 events, 62.0 ev/trail 13 | 14 | # FIXME fill the conv_ev array 15 | conf_ev[1]="2 21" 16 | conf_ev[2]="8 88" 17 | conf_ev[3]="48 491" 18 | conf_ev[4]="384 3822" 19 | conf_ev[5]="3840 38017" 20 | export conf_ev 21 | 22 | MAX=5 23 | K=$(seq 1 $MAX) 24 | 25 | for i in $K; do 26 | gcc -E mpat.c -D PARAM1=$i -o input.$i.i 27 | done 28 | 29 | # the command to test 30 | cmd for i in $K; do \ 31 | $PROG input.$i.i -k2 -s 1M -vv > out.$i; done; 32 | 33 | # the checks to perform on the output 34 | echo K is -$K- 35 | test $EXITCODE = 0 36 | ls -l out* 37 | 38 | for i in $K; do \ 39 | echo xxx i=$i xxx; grep "dpu: por: stats: " out.$i; done 40 | 41 | for i in $K; do \ 42 | echo xxx i=$i xxx; grep "dpu: por: summary: " out.$i; done 43 | 44 | for i in $K; do \ 45 | grep "0 SSBs" out.$i; done 46 | 47 | for i in $K; do \ 48 | for j in $L; do \ 49 | grep -i " unfolding: $(($i + 4)) threads created" out.$i.$j; done; done 50 | 51 | for i in $K; do \ 52 | test "$(grep "dpu: por: summary: " out.$i | awk '{print $6, $10}')" = "${conf_ev[$i]}"; done 53 | 54 | for i in $K; do \ 55 | rm input.$i.i; rm out.$i; done 56 | -------------------------------------------------------------------------------- /tests/regression/ssbs/spat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef PARAM1 6 | #define PARAM1 1 7 | #endif 8 | 9 | #ifndef PARAM2 10 | #define PARAM2 1 11 | #endif 12 | 13 | #define T PARAM1 // number of threads 14 | #define K PARAM2 // number of mutexes 15 | 16 | pthread_mutex_t m[K]; 17 | 18 | /* 19 | The stair pattern 20 | a 21 | | 22 | b . b 23 | | | 24 | d c . c 25 | | | 26 | e d . d 27 | | | 28 | f e . e 29 | | | 30 | g f . f 31 | */ 32 | 33 | // parametric threads 34 | void *th(void *arg) 35 | { 36 | unsigned id = (unsigned long) arg; 37 | 38 | int i = id; 39 | int j = 1; 40 | 41 | // Locks 42 | while (i < K && j < 4) { 43 | pthread_mutex_lock(&m[i]); 44 | //printf ("t%u: lock %d\n", id, i); 45 | i+=j; 46 | j++; 47 | } 48 | 49 | // Unlocks 50 | while (i > id) { 51 | j--; 52 | i-=j; 53 | //printf ("t%u: unlock %d\n", id, i); 54 | pthread_mutex_unlock(&m[i]); 55 | } 56 | return NULL; 57 | } 58 | 59 | int main() 60 | { 61 | int i; 62 | pthread_t ids[T]; 63 | 64 | //printf ("== start ==\n"); 65 | for (i = 0; i < K; i++) 66 | { 67 | pthread_mutex_init(&m[i], NULL); 68 | } 69 | //for (int i = T-1; i >= 0; i--) 70 | for (i = 0; i < T; i++) 71 | { 72 | pthread_create(&ids[i], NULL, th, (void*) (long) i); 73 | } 74 | 75 | for (i = 0; i < T; i++) 76 | { 77 | pthread_join(ids[i],NULL); 78 | } 79 | //printf ("== end ==\n"); 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /tests/regression/ssbs/ssbexp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef PARAM1 6 | #define PARAM1 10 // default value 7 | #endif 8 | 9 | #define K PARAM1 10 | 11 | pthread_mutex_t ma[K]; 12 | pthread_mutex_t mi; 13 | int i = 0; 14 | 15 | void *counter() 16 | { 17 | int x; 18 | for (x = 1; x < K; x++) 19 | { 20 | pthread_mutex_lock(&mi); 21 | i = x; 22 | //printf ("count: i %d\n", i); 23 | pthread_mutex_unlock(&mi); 24 | } 25 | return 0; 26 | } 27 | 28 | void *wa(void *aux) 29 | { 30 | long x = (long) aux; 31 | pthread_mutex_lock(&ma[x]); 32 | //printf ("w%ld: locking\n", x); 33 | pthread_mutex_unlock(&ma[x]); 34 | return 0; 35 | } 36 | 37 | int main() 38 | { 39 | long x; 40 | int idx; 41 | pthread_t idk; 42 | pthread_t idw[K]; 43 | 44 | //printf ("== start ==\n"); 45 | pthread_mutex_init(&mi, NULL); 46 | for (x = 0; x < K; x++) 47 | { 48 | pthread_mutex_init(&ma[x], NULL); 49 | pthread_create(&idw[x], 0, wa, (void*) x); 50 | } 51 | pthread_create(&idk, NULL, counter, NULL); 52 | 53 | pthread_mutex_lock (&mi); 54 | idx = i; 55 | //printf ("m: reading %d\n", idx); 56 | pthread_mutex_unlock (&mi); 57 | 58 | pthread_mutex_lock (&ma[idx]); 59 | //printf ("m: locking %d\n", idx); 60 | pthread_mutex_unlock (&ma[idx]); 61 | 62 | for (x = 0; x < K; x++) 63 | pthread_join(idw[x],NULL); 64 | pthread_join(idk,NULL); 65 | //printf ("== end ==\n"); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /tests/unit/Makefile: -------------------------------------------------------------------------------- 1 | 2 | R ?= ../.. 3 | D := $R/tests/unit 4 | 5 | INC := -I $D -I $D/googletest/include -I $R/src 6 | SRCS := $(wildcard $D/*.cc $D/*/*.cc) $(wildcard $R/src/*.cc $R/src/*.c $R/src/*/*c $R/src/*/*.cc) 7 | SRCS := $(filter-out %/src/main.cc, $(SRCS)) 8 | MSRCS := $D/unit-tests.cc 9 | LIBS := $D/googletest/gtest_main.a 10 | 11 | include $R/common.mk 12 | 13 | all : run 14 | 15 | run : compile 16 | $D/unit-tests 17 | 18 | $D/googletest/gtest_main.a $D/googletest/gtest.a : 19 | make -C $D/googletest/ 20 | 21 | clean : clean_ 22 | clean_ : 23 | @make -C $D/googletest/ clean 24 | -------------------------------------------------------------------------------- /tests/unit/googletest/.gitignore: -------------------------------------------------------------------------------- 1 | # python 2 | *.pyc 3 | -------------------------------------------------------------------------------- /tests/unit/googletest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /tests/unit/googletest/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CPPFLAGS=-I include -I . 3 | CFLAGS=-Wall -Wextra 4 | CC=clang-6.0 5 | CXX=clang++-6.0 6 | 7 | all : gtest.a gtest_main.a 8 | 9 | gtest.a : src/gtest-all.o 10 | $(AR) $(ARFLAGS) $@ $^ 11 | 12 | gtest_main.a : src/gtest-all.o src/gtest_main.o 13 | $(AR) $(ARFLAGS) $@ $^ 14 | 15 | clean : 16 | rm -f src/*.o gtest.a gtest_main.a 17 | -------------------------------------------------------------------------------- /tests/unit/googletest/README.dpu.rst: -------------------------------------------------------------------------------- 1 | 2 | Based on Google Tests 1.8.0, downloaded from 3 | https://github.com/google/googletest/releases, 4 | and stripped to the current state. 5 | -------------------------------------------------------------------------------- /tests/unit/pes-unit.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "verbosity.h" 11 | #include "misc.hh" 12 | #include "pes/event.hh" 13 | #include "pes/unfolding.hh" 14 | #include "pes/process.hh" 15 | #include "pes/eventbox.hh" 16 | #include "pes/config.hh" 17 | #include "pes/cut.hh" 18 | 19 | #include "gtest/gtest.h" 20 | 21 | TEST (Unfolding, Addressing) 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /tests/unit/probdist-unit.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "gtest/gtest.h" 3 | 4 | #include "probdist.hh" 5 | 6 | TEST (ProbdistTest, Integers) 7 | { 8 | Probdist p; 9 | 10 | ASSERT_EQ (p.size(), 0); 11 | ASSERT_EQ (p.counters.size(), 0); 12 | ASSERT_EQ (p.count (12), 0); 13 | 14 | p.clear (); 15 | p.sample (4); 16 | p.sample (4); 17 | p.sample (5); 18 | 19 | ASSERT_EQ (p.size(), 3); 20 | ASSERT_EQ (p.counters.size(), 2); 21 | ASSERT_EQ (p.count (12), 0); 22 | ASSERT_EQ (p.count (4), 2); 23 | ASSERT_EQ (p.count (5), 1); 24 | ASSERT_EQ (p.mass (12), 0); 25 | ASSERT_EQ (p.mass (5), 1 / (float) 3); 26 | ASSERT_EQ (p.mass (4), 2 / (float) 3); 27 | 28 | p.sample (20); 29 | p.sample (20); 30 | p.sample (2); 31 | ASSERT_EQ (p.size(), 6); 32 | ASSERT_EQ (p.mass (2), 1 / (float) p.size()); 33 | ASSERT_EQ (p.mass (20), 2 / (float) p.size()); 34 | 35 | ASSERT_EQ (p.min (), 2); 36 | ASSERT_EQ (p.max (), 20); 37 | ASSERT_EQ (p.average (), 55 / (float) p.size()); 38 | 39 | Probdist q; 40 | 41 | q.sample (&p); 42 | q.sample (&p); 43 | q.sample (&q); 44 | q.sample (&q); 45 | ASSERT_EQ (q.size(), 4); 46 | ASSERT_EQ (q.mass (&p), 0.5); 47 | ASSERT_EQ (q.mass (&q), 0.5); 48 | 49 | // this could be correct or not depending on where thec compiler places p and 50 | // q in memory; remove it if it fails for you 51 | ASSERT_EQ (q.min (), &q); 52 | ASSERT_NE (q.max (), &q); 53 | ASSERT_EQ (q.max (), &p); 54 | } 55 | -------------------------------------------------------------------------------- /tests/unit/unit-tests.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "verbosity.h" 5 | #include "gtest/gtest.h" 6 | 7 | namespace dpu { 8 | 9 | void test1 (); 10 | void test2 (); 11 | void test3 (); 12 | void test4 (); 13 | void test5 (); 14 | void test6 (); 15 | void test7 (); 16 | void test8 (); 17 | void test9 (); 18 | 19 | void test10 (); 20 | void test11 (); 21 | void test12 (); 22 | void test13 (); 23 | void test14 (); 24 | void test15 (); 25 | void test16 (); 26 | void test17 (); 27 | void test18 (); 28 | void test19 (); 29 | 30 | void test20 (); 31 | void test21 (); 32 | void test22 (); 33 | void test23 (); 34 | void test24 (); 35 | void test25 (); 36 | void test26 (); 37 | void test27 (); 38 | void test28 (); 39 | void test29 (); 40 | 41 | void test30 (); 42 | void test31 (); 43 | void test32 (); 44 | void test33 (); 45 | void test34 (); 46 | void test35 (); 47 | void test36 (); 48 | void test37 (); 49 | void test38 (); 50 | void test39 (); 51 | 52 | void test40 (); 53 | void test41 (); 54 | void test42 (); 55 | void test43 (); 56 | void test44 (); 57 | void test45 (); 58 | void test46 (); 59 | void test47 (); 60 | void test48 (); 61 | void test49 (); 62 | 63 | void test50 (); 64 | void test51 (); 65 | void test52 (); 66 | void test53 (); 67 | void test54 (); 68 | void test55 (); 69 | void test56 (); 70 | void test57 (); 71 | void test58 (); 72 | void test59 (); 73 | 74 | } // namespace 75 | 76 | int main (int argc, char **argv) 77 | { 78 | verb_set (VERB_DEBUG); 79 | #if 0 80 | dpu::test57 (); 81 | return 0; 82 | #else 83 | ::testing::InitGoogleTest(&argc, argv); 84 | return RUN_ALL_TESTS(); 85 | #endif 86 | } 87 | 88 | --------------------------------------------------------------------------------