├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── example ├── Makefile ├── bank_account │ ├── Makefile │ └── main.cc ├── circular_list │ ├── Makefile │ └── main.cc ├── deadlock │ ├── Makefile │ └── main.cc ├── log_proc_sweep │ ├── Makefile │ └── main.cc ├── mysql_169_extract │ ├── Makefile │ └── main.cc ├── shared_counter │ ├── Makefile │ └── main.cc └── string_buffer │ ├── Makefile │ └── main.cc ├── maple ├── maple_script ├── pin.mk ├── protobuf.mk ├── script ├── idiom ├── maple │ ├── __init__.py │ ├── benchmark │ │ ├── __init__.py │ │ ├── aget.py │ │ ├── aget_bug1.py │ │ ├── aget_bug2.py │ │ ├── aget_bug2_training.py │ │ ├── apache.py │ │ ├── apache_bug_25520.py │ │ ├── apache_bug_25520_training.py │ │ ├── bank_account.py │ │ ├── circular_list.py │ │ ├── cnc_bug.py │ │ ├── fft.py │ │ ├── log_proc_sweep.py │ │ ├── memcached.py │ │ ├── memcached_bug_127.py │ │ ├── memcached_bug_127_training.py │ │ ├── mysql.py │ │ ├── mysql_169_extract.py │ │ ├── mysql_bug_791.py │ │ ├── mysql_bug_791_training.py │ │ ├── pbzip2.py │ │ ├── pbzip2_bug.py │ │ ├── pbzip2_bug_unknown.py │ │ ├── pfscan.py │ │ ├── radix.py │ │ ├── shared_counter.py │ │ └── string_buffer.py │ ├── core │ │ ├── __init__.py │ │ ├── analyzer.py │ │ ├── config.py │ │ ├── knob.py │ │ ├── logging.py │ │ ├── offline_tool.py │ │ ├── pintool.py │ │ ├── proto.py │ │ ├── static_info.py │ │ ├── testing.py │ │ └── util.py │ ├── extra │ │ ├── __init__.py │ │ └── memcached │ │ │ ├── __init__.py │ │ │ └── memcache.py │ ├── idiom │ │ ├── __init__.py │ │ ├── history.py │ │ ├── iroot.py │ │ ├── main.py │ │ ├── memo.py │ │ ├── offline_tool.py │ │ ├── pintool.py │ │ └── testing.py │ ├── pct │ │ ├── __init__.py │ │ └── history.py │ ├── race │ │ ├── __init__.py │ │ ├── main.py │ │ ├── pintool.py │ │ ├── race.py │ │ └── testing.py │ ├── regression │ │ ├── __init__.py │ │ ├── common.py │ │ ├── idiom.py │ │ ├── main.py │ │ └── systematic.py │ ├── sinst │ │ ├── __init__.py │ │ ├── main.py │ │ └── sinst.py │ ├── systematic │ │ ├── __init__.py │ │ ├── main.py │ │ ├── pintool.py │ │ ├── program.py │ │ ├── scheduler.py │ │ ├── search.py │ │ └── testing.py │ └── tracer │ │ ├── __init__.py │ │ ├── log.py │ │ ├── main.py │ │ └── pintool.py ├── race ├── regression ├── sinst ├── systematic └── tracer ├── src ├── core │ ├── analyzer.h │ ├── atomic.h │ ├── basictypes.h │ ├── callstack.cc │ ├── callstack.h │ ├── cmdline_knob.cc │ ├── cmdline_knob.h │ ├── debug_analyzer.cc │ ├── debug_analyzer.h │ ├── descriptor.cc │ ├── descriptor.h │ ├── execution_control.cpp │ ├── execution_control.hpp │ ├── filter.cc │ ├── filter.h │ ├── knob.cc │ ├── knob.h │ ├── lock_set.cc │ ├── lock_set.h │ ├── logging.cc │ ├── logging.h │ ├── offline_tool.cc │ ├── offline_tool.h │ ├── package.mk │ ├── pin_knob.cpp │ ├── pin_knob.hpp │ ├── pin_sync.hpp │ ├── pin_util.cpp │ ├── pin_util.hpp │ ├── stat.cc │ ├── stat.h │ ├── static_info.cc │ ├── static_info.h │ ├── static_info.proto │ ├── sync.h │ ├── vector_clock.cc │ ├── vector_clock.h │ ├── wrapper.cpp │ └── wrapper.hpp ├── idiom │ ├── chess_profiler.cpp │ ├── chess_profiler.hpp │ ├── chess_profiler_main.cpp │ ├── history.cc │ ├── history.h │ ├── history.proto │ ├── iroot.cc │ ├── iroot.h │ ├── iroot.proto │ ├── memo.cc │ ├── memo.h │ ├── memo.proto │ ├── memo_tool.cc │ ├── memo_tool.h │ ├── memo_tool_main.cc │ ├── observer.cc │ ├── observer.h │ ├── observer_new.cc │ ├── observer_new.h │ ├── package.mk │ ├── pct_profiler.cpp │ ├── pct_profiler.hpp │ ├── pct_profiler_main.cpp │ ├── predictor.cc │ ├── predictor.h │ ├── predictor_new.cc │ ├── predictor_new.h │ ├── profiler.cpp │ ├── profiler.hpp │ ├── profiler_main.cpp │ ├── randsched_profiler.cpp │ ├── randsched_profiler.hpp │ ├── randsched_profiler_main.cpp │ ├── scheduler.cpp │ ├── scheduler.hpp │ ├── scheduler_common.cpp │ ├── scheduler_common.hpp │ └── scheduler_main.cpp ├── pct │ ├── history.cc │ ├── history.h │ ├── history.proto │ ├── package.mk │ ├── scheduler.cpp │ ├── scheduler.hpp │ └── scheduler_main.cpp ├── race │ ├── detector.cc │ ├── detector.h │ ├── djit.cc │ ├── djit.h │ ├── fasttrack.cc │ ├── fasttrack.h │ ├── package.mk │ ├── pct_profiler.cpp │ ├── pct_profiler.hpp │ ├── pct_profiler_main.cpp │ ├── profiler.cpp │ ├── profiler.hpp │ ├── profiler_main.cpp │ ├── race.cc │ ├── race.h │ └── race.proto ├── randsched │ ├── history.cc │ ├── history.h │ ├── history.proto │ ├── package.mk │ ├── scheduler.cpp │ ├── scheduler.hpp │ └── scheduler_main.cpp ├── sinst │ ├── analyzer.cc │ ├── analyzer.h │ ├── package.mk │ ├── profiler.cpp │ ├── profiler.hpp │ ├── profiler_main.cpp │ ├── sinst.cc │ ├── sinst.h │ └── sinst.proto ├── systematic │ ├── chess.cc │ ├── chess.h │ ├── chess.proto │ ├── controller.cpp │ ├── controller.hpp │ ├── controller_main.cpp │ ├── fair.cc │ ├── fair.h │ ├── package.mk │ ├── program.cc │ ├── program.h │ ├── program.proto │ ├── random.cc │ ├── random.h │ ├── scheduler.cc │ ├── scheduler.h │ ├── search.cc │ ├── search.h │ └── search.proto └── tracer │ ├── loader.cc │ ├── loader.h │ ├── loader_main.cc │ ├── log.cc │ ├── log.h │ ├── log.proto │ ├── package.mk │ ├── profiler.cpp │ ├── profiler.hpp │ ├── profiler_main.cpp │ ├── recorder.cc │ └── recorder.h └── test ├── idiom ├── observer │ ├── mem_idiom1.cc │ ├── mem_idiom1.py │ ├── mem_idiom4.cc │ ├── mem_idiom4.py │ ├── sync_idiom1.cc │ ├── sync_idiom1.py │ ├── sync_idiom4.cc │ └── sync_idiom4.py └── predictor │ ├── atomic_inst.cc │ ├── atomic_inst.py │ ├── cond.cc │ ├── cond.py │ ├── cond2.cc │ ├── cond2.py │ ├── deadlock.cc │ ├── deadlock.py │ ├── hb_filter.cc │ ├── hb_filter.py │ ├── hb_filter2.cc │ ├── hb_filter2.py │ ├── libc_lock.cc │ ├── libc_lock.py │ ├── mem_idiom1.cc │ ├── mem_idiom1.py │ ├── mem_idiom2.cc │ ├── mem_idiom2.py │ ├── mem_idiom4.cc │ ├── mem_idiom4.py │ ├── mem_idiom4_vw.cc │ ├── mem_idiom4_vw.py │ ├── mem_idiom5.cc │ ├── mem_idiom5.py │ ├── mutex_filter.cc │ ├── mutex_filter.py │ ├── mutex_filter2.cc │ ├── mutex_filter2.py │ ├── mutex_filter3.cc │ ├── mutex_filter3.py │ ├── mutex_filter_multivar.cc │ ├── mutex_filter_multivar.py │ ├── sync_idiom1.cc │ ├── sync_idiom1.py │ ├── sync_idiom4.cc │ └── sync_idiom4.py └── systematic └── chess ├── barrier.cc ├── barrier.py ├── cond.cc ├── cond.py ├── cond2.cc ├── cond2.py ├── cond4.cc ├── cond4.py ├── fair.cc ├── fair.py ├── mutex.cc ├── mutex.py ├── mutex2.cc ├── mutex2.py ├── mutex3.cc ├── mutex3.py ├── por_mutex.cc ├── por_mutex.py ├── race.cc ├── race.py ├── timedwait.cc └── timedwait.py /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.gitignore 3 | *.d 4 | *.o 5 | *.so 6 | *.swp 7 | *.pyc 8 | *.pb.h 9 | *.pb.cc 10 | GPATH 11 | GRTAGS 12 | GTAGS 13 | tmp/ 14 | build-debug/ 15 | build-release/ 16 | script/maple/proto/ 17 | -------------------------------------------------------------------------------- /example/Makefile: -------------------------------------------------------------------------------- 1 | # Toplevel makefile for examples 2 | 3 | subdirs := $(wildcard */) 4 | subdirs_clean := $(subdirs:%/=%_clean) 5 | 6 | .PHONY: all clean $(subdirs) $(subdirs_clean) 7 | 8 | all: $(subdirs) 9 | 10 | $(subdirs): 11 | $(MAKE) -C $@ 12 | 13 | clean: $(subdirs_clean) 14 | 15 | $(subdirs_clean): 16 | $(MAKE) -C $(patsubst %_clean,%,$@) clean 17 | 18 | -------------------------------------------------------------------------------- /example/bank_account/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -g -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /example/circular_list/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -g -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /example/deadlock/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /example/deadlock/main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 23 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 24 | 25 | void foo() { 26 | for (int i = 0; i < 200; i++) ; 27 | } 28 | 29 | void *thread(void *arg) { 30 | int res; 31 | printf("thread\n"); 32 | res = pthread_mutex_lock(&mutex); 33 | res = pthread_mutex_lock(&mutex2); 34 | foo(); 35 | res = pthread_mutex_unlock(&mutex2); 36 | res = pthread_mutex_unlock(&mutex); 37 | return NULL; 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | pthread_t tid; 42 | pthread_create(&tid, NULL, thread, NULL); 43 | int res; 44 | res = pthread_mutex_lock(&mutex2); 45 | res = pthread_mutex_lock(&mutex); 46 | foo(); 47 | res = pthread_mutex_unlock(&mutex); 48 | res = pthread_mutex_unlock(&mutex2); 49 | pthread_join(tid, NULL); 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /example/log_proc_sweep/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -g -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /example/mysql_169_extract/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -g -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /example/shared_counter/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -g -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /example/shared_counter/main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | unsigned NUM_THREADS = 1; 23 | unsigned global_count = 0; 24 | void *thread(void *); 25 | 26 | int main(int argc, char *argv[]) { 27 | long i; 28 | pthread_t pthread_id[200]; 29 | NUM_THREADS = atoi(argv[1]); 30 | 31 | for(i = 0; i < NUM_THREADS; i++) 32 | pthread_create(&pthread_id[i], NULL, thread, (void *) i); 33 | for(i = 0; i < NUM_THREADS; i++) 34 | pthread_join(pthread_id[i], NULL); 35 | 36 | assert(global_count==NUM_THREADS); 37 | return 0; 38 | } 39 | 40 | void *thread(void * num) { 41 | unsigned temp = global_count; 42 | temp++; 43 | global_count = temp; 44 | return NULL; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /example/string_buffer/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXXFLAGS := -Werror -g -fno-omit-frame-pointer -pthread 3 | 4 | targets = $(basename $(wildcard *.cc)) 5 | 6 | all: $(targets) 7 | 8 | clean: 9 | rm -rf $(targets) 10 | 11 | -------------------------------------------------------------------------------- /maple: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PKG_HOME=$(dirname $(readlink -f $0)) 4 | $PKG_HOME/script/idiom default $* 5 | 6 | -------------------------------------------------------------------------------- /maple_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PKG_HOME=$(dirname $(readlink -f $0)) 4 | $PKG_HOME/script/idiom default_script $* 5 | 6 | -------------------------------------------------------------------------------- /pin.mk: -------------------------------------------------------------------------------- 1 | # Rules for the PIN binary instrumentation tool. 2 | 3 | ifndef PIN_HOME 4 | $(error Please define PIN_HOME environment.) 5 | endif 6 | 7 | PIN_ROOT := $(PIN_HOME) 8 | 9 | CONFIG_ROOT := $(PIN_ROOT)/source/tools/Config 10 | include $(CONFIG_ROOT)/makefile.config 11 | #include $(TOOLS_ROOT)/Config/makefile.default.rules 12 | 13 | PIN_REVISION := $(shell $(PIN_ROOT)/pin -version | grep Rev | cut -d ' ' -f 3) 14 | CFLAGS += -DCONFIG_PIN_REVISION=$(PIN_REVISION) 15 | CXXFLAGS += -DCONFIG_PIN_REVISION=$(PIN_REVISION) 16 | 17 | # Check if this is a PinPlay kit. 18 | ifneq ($(wildcard $(PIN_HOME)/extras/pinplay),) 19 | $(info *** Building with PinPlay kit ***) 20 | 21 | PINPLAY_HOME := $(PIN_HOME)/extras/pinplay 22 | CFLAGS += -DCONFIG_PINPLAY 23 | CXXFLAGS += -DCONFIG_PINPLAY 24 | INCS += -I$(PINPLAY_HOME)/include 25 | INCS += -I$(PINPLAY_HOME)/include-ext 26 | TOOL_LPATHS += -L$(PINPLAY_HOME)/lib/$(TARGET) 27 | TOOL_LPATHS += -L$(PINPLAY_HOME)/lib-ext/$(TARGET) 28 | 29 | # PinPlay library must be loaded fist. 30 | TOOL_LIBS := -lpinplay -lbz2 -lz $(TOOL_LIBS) 31 | 32 | # Controller library (Pin-2.14). 33 | CONTROLLER_LIB := $(CONTROLLERLIB) 34 | endif 35 | 36 | $(CONTROLLERLIB): 37 | $(MAKE) -C $(TOOLS_ROOT)/InstLib dir $(OBJDIR)controller$(LIB_SUFFIX) 38 | -------------------------------------------------------------------------------- /protobuf.mk: -------------------------------------------------------------------------------- 1 | # Rules for the Google Protobuf tool. 2 | 3 | ifndef PROTOBUF_HOME 4 | $(error Please define PROTOBUF_HOME environment.) 5 | endif 6 | 7 | PROTOC=$(PROTOBUF_HOME)/bin/protoc 8 | -------------------------------------------------------------------------------- /script/idiom: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setup python 4 | PYTHON=python 5 | 6 | # obtain the script home 7 | SCRIPT_HOME=$(dirname $(readlink -f $0)) 8 | 9 | # setup python path for the scripts 10 | export PYTHONPATH=$SCRIPT_HOME:$PYTHONPATH 11 | 12 | # call the python script 13 | $PYTHON $SCRIPT_HOME/maple/idiom/main.py $* 14 | 15 | -------------------------------------------------------------------------------- /script/maple/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/__init__.py -------------------------------------------------------------------------------- /script/maple/benchmark/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/benchmark/__init__.py -------------------------------------------------------------------------------- /script/maple/benchmark/aget.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import config 20 | from maple.core import testing 21 | 22 | _sio = [None, os.devnull, 'stderr'] 23 | 24 | class Test(testing.CmdlineTest): 25 | def __init__(self, input_idx): 26 | testing.CmdlineTest.__init__(self, input_idx) 27 | self.add_input(([self.bin(), '-n2', 'http://zodiac.eecs.umich.edu/testfile', '-l', 'aget.file'], _sio)) 28 | self.add_input(([self.bin(), '-n3', 'http://zodiac.eecs.umich.edu/testfile', '-l', 'aget.file'], _sio)) 29 | self.add_input(([self.bin(), '-n2', 'http://zodiac.eecs.umich.edu/test/46.txt', '-l', 'aget.file'], _sio)) 30 | self.add_input(([self.bin(), '-n3', 'http://zodiac.eecs.umich.edu/test/46.txt', '-l', 'aget.file'], _sio)) 31 | self.add_input(([self.bin(), '-n2', 'http://zodiac.eecs.umich.edu/test/47.txt', '-l', 'aget.file'], _sio)) 32 | self.add_input(([self.bin(), '-n2', 'http://zodiac.eecs.umich.edu/test/48.txt', '-l', 'aget.file'], _sio)) 33 | self.add_input(([self.bin(), '-n2', 'http://zodiac.eecs.umich.edu/test/49.txt', '-l', 'aget.file'], _sio)) 34 | self.add_input(([self.bin(), '-n3', 'http://zodiac.eecs.umich.edu/test/49.txt', '-l', 'aget.file'], _sio)) 35 | def bin(self): 36 | return config.benchmark_home('aget') + '/aget' 37 | def setup(self): 38 | assert not os.path.exists('aget.file') 39 | def tear_down(self): 40 | assert os.path.exists('aget.file') 41 | os.remove('aget.file') 42 | 43 | def get_test(input_idx='default'): 44 | return Test(input_idx) 45 | 46 | -------------------------------------------------------------------------------- /script/maple/benchmark/aget_bug1.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import config 20 | from maple.core import testing 21 | 22 | _sio = [None, os.devnull, 'stderr'] 23 | 24 | class Test(testing.CmdlineTest): 25 | def __init__(self, input_idx): 26 | testing.CmdlineTest.__init__(self, input_idx) 27 | #self.add_input(([self.bin(), '-n1', 'http://apache.cyberuse.com/httpd/httpd-2.2.21.tar.gz', '-l', 'aget.file'], _sio)) 28 | self.add_input(([self.bin(), '-n1', 'http://zodiac.eecs.umich.edu/httpd-2.2.21.tar.gz', '-l', 'aget.file'], _sio)) 29 | def bin(self): 30 | return config.benchmark_home('aget_bug1') + '/aget' 31 | def setup(self): 32 | assert not os.path.exists('aget.file') 33 | def tear_down(self): 34 | assert os.path.exists('aget.file') 35 | os.remove('aget.file') 36 | 37 | def get_test(input_idx='default'): 38 | return Test(input_idx) 39 | 40 | -------------------------------------------------------------------------------- /script/maple/benchmark/aget_bug2_training.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | import subprocess 20 | from maple.core import config 21 | from maple.core import logging 22 | from maple.core import testing 23 | 24 | _sio = [None, os.devnull, 'stderr'] 25 | 26 | class Test(testing.ServerTest): 27 | def __init__(self, input_idx): 28 | testing.ServerTest.__init__(self, input_idx) 29 | self.add_input(([self.bin(), '-n1', 'http://apache.cyberuse.com/httpd/httpd-2.2.21.tar.gz', '-l', 'aget.file'], _sio)) 30 | def setup(self): 31 | if os.path.exists('aget.file'): 32 | os.remove('aget.file') 33 | def tear_down(self): 34 | if os.path.exists('aget.file'): 35 | os.remove('aget.file') 36 | def start(self): 37 | args, sio = self.input() 38 | cmd = [] 39 | if self.prefix != None: 40 | cmd.extend(self.prefix) 41 | cmd.extend(args) 42 | self.proc = subprocess.Popen(cmd) 43 | def stop(self): 44 | self.proc.wait() 45 | def bin(self): 46 | return config.benchmark_home('aget_bug2') + '/aget' 47 | 48 | def get_test(input_idx='default'): 49 | return Test(input_idx) 50 | 51 | -------------------------------------------------------------------------------- /script/maple/benchmark/bank_account.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | class Test(testing.CmdlineTest): 22 | def __init__(self, input_idx): 23 | testing.CmdlineTest.__init__(self, input_idx) 24 | self.add_input(([self.bin(), '2'], [None, None, None])) 25 | def bin(self): 26 | return config.pkg_home() + '/example/bank_account/main' 27 | 28 | def get_test(input_idx='default'): 29 | return Test(input_idx) 30 | 31 | -------------------------------------------------------------------------------- /script/maple/benchmark/circular_list.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | class Test(testing.CmdlineTest): 22 | def __init__(self, input_idx): 23 | testing.CmdlineTest.__init__(self, input_idx) 24 | self.add_input(([self.bin(), '2'], [None, None, None])) 25 | def bin(self): 26 | return config.pkg_home() + '/example/circular_list/main' 27 | 28 | def get_test(input_idx='default'): 29 | return Test(input_idx) 30 | 31 | -------------------------------------------------------------------------------- /script/maple/benchmark/fft.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | _sio = [None, 'stdout', 'stderr'] 22 | 23 | class Test(testing.CmdlineTest): 24 | def __init__(self, input_idx): 25 | testing.CmdlineTest.__init__(self, input_idx) 26 | self.add_input(([self.bin(), '-p2', '-m8'], _sio)) 27 | self.add_input(([self.bin(), '-p4', '-m8'], _sio)) 28 | self.add_input(([self.bin(), '-p4', '-m10'], _sio)) 29 | self.add_input(([self.bin(), '-p2', '-m10'], _sio)) 30 | self.add_input(([self.bin(), '-p2', '-m6'], _sio)) 31 | self.add_input(([self.bin(), '-p4', '-m6'], _sio)) 32 | self.add_input(([self.bin(), '-p2', '-m12'], _sio)) 33 | self.add_input(([self.bin(), '-p4', '-m12'], _sio)) 34 | def bin(self): 35 | return config.benchmark_home('splash2') + '/codes/kernels/fft/FFT' 36 | 37 | def get_test(input_idx='default'): 38 | return Test(input_idx) 39 | 40 | -------------------------------------------------------------------------------- /script/maple/benchmark/log_proc_sweep.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | class Test(testing.CmdlineTest): 22 | def __init__(self, input_idx): 23 | testing.CmdlineTest.__init__(self, input_idx) 24 | self.add_input(([self.bin(), '2'], [None, None, None])) 25 | def bin(self): 26 | return config.pkg_home() + '/example/log_proc_sweep/main' 27 | 28 | def get_test(input_idx='default'): 29 | return Test(input_idx) 30 | 31 | -------------------------------------------------------------------------------- /script/maple/benchmark/mysql_169_extract.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | class Test(testing.CmdlineTest): 22 | def __init__(self, input_idx): 23 | testing.CmdlineTest.__init__(self, input_idx) 24 | self.add_input(([self.bin()], [None, None, None])) 25 | def bin(self): 26 | return config.pkg_home() + '/example/mysql_169_extract/main' 27 | 28 | def get_test(input_idx='default'): 29 | return Test(input_idx) 30 | 31 | -------------------------------------------------------------------------------- /script/maple/benchmark/pbzip2.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import config 20 | from maple.core import testing 21 | 22 | _sio = [None, os.devnull, 'stderr'] 23 | 24 | class Test(testing.CmdlineTest): 25 | def __init__(self, input_idx): 26 | testing.CmdlineTest.__init__(self, input_idx) 27 | self.add_input(([self.bin(), '-p2', '-b1', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile')], _sio)) 28 | self.add_input(([self.bin(), '-p2', '-b2', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile')], _sio)) 29 | self.add_input(([self.bin(), '-p4', '-b1', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile')], _sio)) 30 | self.add_input(([self.bin(), '-p4', '-b2', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile')], _sio)) 31 | self.add_input(([self.bin(), '-p2', '-b1', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile3')], _sio)) 32 | self.add_input(([self.bin(), '-p2', '-b2', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile3')], _sio)) 33 | self.add_input(([self.bin(), '-p4', '-b1', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile3')], _sio)) 34 | self.add_input(([self.bin(), '-p4', '-b2', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile3')], _sio)) 35 | def bin(self): 36 | return config.benchmark_home('pbzip2') + '/pbzip2' 37 | def input_dir(self): 38 | return config.benchmark_home('pbzip2') + '/inputs' 39 | 40 | def get_test(input_idx='default'): 41 | return Test(input_idx) 42 | 43 | -------------------------------------------------------------------------------- /script/maple/benchmark/pbzip2_bug.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import config 20 | from maple.core import testing 21 | 22 | _sio = [None, os.devnull, 'stderr'] 23 | 24 | class Test(testing.CmdlineTest): 25 | def __init__(self, input_idx): 26 | testing.CmdlineTest.__init__(self, input_idx) 27 | self.add_input(([self.bin(), '-p1', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile')], _sio)) 28 | def bin(self): 29 | return config.benchmark_home('pbzip2_bug') + '/pbzip2' 30 | def input_dir(self): 31 | return config.benchmark_home('pbzip2_bug') + '/inputs' 32 | 33 | def get_test(input_idx='default'): 34 | return Test(input_idx) 35 | 36 | -------------------------------------------------------------------------------- /script/maple/benchmark/pbzip2_bug_unknown.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import config 20 | from maple.core import testing 21 | 22 | _sio = [None, os.devnull, 'stderr'] 23 | 24 | class Test(testing.CmdlineTest): 25 | def __init__(self, input_idx): 26 | testing.CmdlineTest.__init__(self, input_idx) 27 | self.add_input(([self.bin(), '-p2', '-b1', '-f', '-k', '-c', '%s/%s' % (self.input_dir(), 'testfile')], _sio)) 28 | def bin(self): 29 | return config.benchmark_home('pbzip2_bug_unknown') + '/pbzip2' 30 | def input_dir(self): 31 | return config.benchmark_home('pbzip2_bug_unknown') + '/inputs' 32 | 33 | def get_test(input_idx='default'): 34 | return Test(input_idx) 35 | 36 | -------------------------------------------------------------------------------- /script/maple/benchmark/radix.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | _sio = [None, 'stdout', 'stderr'] 22 | 23 | class Test(testing.CmdlineTest): 24 | def __init__(self, input_idx): 25 | testing.CmdlineTest.__init__(self, input_idx) 26 | self.add_input(([self.bin(), '-p2', '-n1024', '-r128'], _sio)) 27 | self.add_input(([self.bin(), '-p4', '-n1024', '-r128'], _sio)) 28 | self.add_input(([self.bin(), '-p2', '-n4096', '-r256'], _sio)) 29 | self.add_input(([self.bin(), '-p4', '-n4096', '-r256'], _sio)) 30 | self.add_input(([self.bin(), '-p2', '-n8192', '-r1024'], _sio)) 31 | self.add_input(([self.bin(), '-p4', '-n8192', '-r1024'], _sio)) 32 | self.add_input(([self.bin(), '-p2', '-n8192', '-r2048'], _sio)) 33 | self.add_input(([self.bin(), '-p4', '-n8192', '-r2048'], _sio)) 34 | def bin(self): 35 | return config.benchmark_home('splash2') + '/codes/kernels/radix/RADIX' 36 | 37 | def get_test(input_idx='default'): 38 | return Test(input_idx) 39 | 40 | -------------------------------------------------------------------------------- /script/maple/benchmark/shared_counter.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | class Test(testing.CmdlineTest): 22 | def __init__(self, input_idx): 23 | testing.CmdlineTest.__init__(self, input_idx) 24 | self.add_input(([self.bin(), '2'], [None, None, None])) 25 | def bin(self): 26 | return config.pkg_home() + '/example/shared_counter/main' 27 | 28 | def get_test(input_idx='default'): 29 | return Test(input_idx) 30 | 31 | -------------------------------------------------------------------------------- /script/maple/benchmark/string_buffer.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import config 19 | from maple.core import testing 20 | 21 | class Test(testing.CmdlineTest): 22 | def __init__(self, input_idx): 23 | testing.CmdlineTest.__init__(self, input_idx) 24 | self.add_input(([self.bin(), '2'], [None, None, None])) 25 | def bin(self): 26 | return config.pkg_home() + '/example/string_buffer/main' 27 | 28 | def get_test(input_idx='default'): 29 | return Test(input_idx) 30 | 31 | -------------------------------------------------------------------------------- /script/maple/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/core/__init__.py -------------------------------------------------------------------------------- /script/maple/core/analyzer.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import knob 19 | 20 | class Analyzer(knob.KnobUser): 21 | def __init__(self, name): 22 | knob.KnobUser.__init__(self) 23 | self.name = name 24 | 25 | class DebugAnalyzer(Analyzer): 26 | def __init__(self): 27 | Analyzer.__init__(self, 'debug_analyzer') 28 | self.register_knob('enable_debug', 'bool', False, 'whether enable the debug analyzer') 29 | self.register_knob('debug_mem', 'bool', False, 'whether debug mem accesses') 30 | self.register_knob('debug_atomic', 'bool', False, 'whether debug atomic inst') 31 | self.register_knob('debug_main', 'bool', False, 'whether debug main functions') 32 | self.register_knob('debug_call_return', 'bool', False, 'whether debug calls and returns') 33 | self.register_knob('debug_pthread', 'bool', False, 'whether debug pthread functions') 34 | self.register_knob('debug_malloc', 'bool', False, 'whether debug malloc functions') 35 | self.register_knob('debug_syscall', 'bool', False, 'whether debug system calls') 36 | self.register_knob('debug_track_clk', 'bool', True, 'whether track per thread clock') 37 | self.register_knob('debug_track_callstack', 'bool', False, 'whether track runtime call stack') 38 | 39 | -------------------------------------------------------------------------------- /script/maple/core/logging.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import sys 19 | from maple.core import config 20 | 21 | _message_on = True 22 | _message_level = 1 23 | 24 | def err(msg): 25 | sys.stderr.write('[%s] %s' % (config.tool_name(), msg)) 26 | sys.exit(1) 27 | 28 | def msg(msg, level=1): 29 | if _message_on and level <= _message_level: 30 | sys.stdout.write('[%s] %s' % (config.tool_name(), msg)) 31 | 32 | def set_message_level(level): 33 | global _message_level 34 | _message_level = level 35 | 36 | def message_off(): 37 | global _message_on 38 | _message_on = False 39 | 40 | def message_on(): 41 | global _message_on 42 | _message_on = True 43 | 44 | -------------------------------------------------------------------------------- /script/maple/core/proto.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import sys 19 | from maple.core import config 20 | 21 | proto_script_base = config.pkg_home() + '/script/maple/proto' 22 | sys.path.insert(0, proto_script_base) 23 | 24 | def module(name): 25 | if not name in sys.modules: 26 | __import__(name) 27 | return sys.modules[name] 28 | 29 | -------------------------------------------------------------------------------- /script/maple/extra/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/extra/__init__.py -------------------------------------------------------------------------------- /script/maple/extra/memcached/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/extra/memcached/__init__.py -------------------------------------------------------------------------------- /script/maple/idiom/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/idiom/__init__.py -------------------------------------------------------------------------------- /script/maple/idiom/offline_tool.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import config 20 | from maple.core import offline_tool 21 | 22 | class MemoTool(offline_tool.OfflineTool): 23 | def __init__(self): 24 | offline_tool.OfflineTool.__init__(self, 'idiom_memo_tool') 25 | self.register_knob('debug_out', 'string', 'stdout', 'the output file for the debug messages') 26 | self.register_knob('sinfo_in', 'string', 'sinfo.db', 'the input static info database path', 'PATH') 27 | self.register_knob('sinfo_out', 'string', 'sinfo.db', 'the output static info database path', 'PATH') 28 | self.register_knob('iroot_in', 'string', 'iroot.db', 'the input iroot database path', 'PATH') 29 | self.register_knob('iroot_out', 'string', 'iroot.db', 'the output iroot database path', 'PATH') 30 | self.register_knob('memo_in', 'string', 'memo.db', 'the input memoization database path', 'PATH') 31 | self.register_knob('memo_out', 'string', 'memo.db', 'the output memoization database path', 'PATH') 32 | self.register_knob('operation', 'string', 'list', 'the operation to perform') 33 | self.register_knob('arg', 'string', 'null', 'the argument to the operation') 34 | self.register_knob('path', 'string', 'null', 'the path argument to the operation', 'PATH') 35 | self.register_knob('num', 'int', 0, 'the integer argument to the operation') 36 | def bin_path(self): 37 | return os.path.join(config.build_home(self.debug), 'idiom_memo_tool') 38 | 39 | -------------------------------------------------------------------------------- /script/maple/pct/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/pct/__init__.py -------------------------------------------------------------------------------- /script/maple/race/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/race/__init__.py -------------------------------------------------------------------------------- /script/maple/regression/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/regression/__init__.py -------------------------------------------------------------------------------- /script/maple/sinst/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/sinst/__init__.py -------------------------------------------------------------------------------- /script/maple/sinst/sinst.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import proto 20 | 21 | def sinst_pb2(): 22 | return proto.module('sinst.sinst_pb2') 23 | 24 | class SinstDB(object): 25 | def __init__(self, sinfo): 26 | self.sinfo = sinfo 27 | self.proto = sinst_pb2().SharedInstTableProto() 28 | self.sinst_map = {} 29 | def load(self, db_name): 30 | if not os.path.exists(db_name): 31 | return 32 | f = open(db_name, 'rb') 33 | self.proto.ParseFromString(f.read()) 34 | f.close() 35 | for sinst_proto in self.proto.shared_inst: 36 | sinst = self.sinfo.find_inst(sinst_proto.inst_id) 37 | self.sinst_map[sinst.id()] = sinst 38 | def display(self, f): 39 | for sinst in self.sinst_map.itervalues(): 40 | f.write('%s\n' % str(sinst)) 41 | 42 | -------------------------------------------------------------------------------- /script/maple/systematic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/systematic/__init__.py -------------------------------------------------------------------------------- /script/maple/systematic/scheduler.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import knob 19 | 20 | class Scheduler(knob.KnobUser): 21 | def __init__(self, name): 22 | knob.KnobUser.__init__(self) 23 | self.name = name 24 | 25 | class RandomScheduler(Scheduler): 26 | def __init__(self): 27 | Scheduler.__init__(self, 'random_scheduler') 28 | self.register_knob('enable_random_scheduler', 'bool', False, 'whether use the random scheduler') 29 | 30 | class ChessScheduler(Scheduler): 31 | def __init__(self): 32 | Scheduler.__init__(self, 'chess_scheduler') 33 | self.register_knob('enable_chess_scheduler', 'bool', False, 'whether use the CHESS scheduler') 34 | self.register_knob('fair', 'bool', True, 'whether enable the fair control module') 35 | self.register_knob('pb', 'bool', True, 'whether enable preemption bound search') 36 | self.register_knob('por', 'bool', True, 'whether enable parital order reduction') 37 | self.register_knob('abort_diverge', 'bool', True, 'whether abort when divergence happens') 38 | self.register_knob('pb_limit', 'int', 2, 'the maximum number of preemption an execution can have', 'LIMIT') 39 | self.register_knob('search_in', 'string', 'search.db', 'the input file that contains the search information', 'PATH') 40 | self.register_knob('search_out', 'string', 'search.db', 'the output file that contains the search information', 'PATH') 41 | self.register_knob('por_info_path', 'string', 'por-info', 'the dir path that stores the partial order reduction information', 'PATH') 42 | 43 | -------------------------------------------------------------------------------- /script/maple/tracer/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jieyu/maple/14b2769a07473f9eca6ea1bc7f57bbefe1db46f4/script/maple/tracer/__init__.py -------------------------------------------------------------------------------- /script/race: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setup python 4 | PYTHON=python 5 | 6 | # obtain the script home 7 | SCRIPT_HOME=$(dirname $(readlink -f $0)) 8 | 9 | # setup python path for the scripts 10 | export PYTHONPATH=$SCRIPT_HOME:$PYTHONPATH 11 | 12 | # call the python script 13 | $PYTHON $SCRIPT_HOME/maple/race/main.py $* 14 | 15 | -------------------------------------------------------------------------------- /script/regression: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setup python 4 | PYTHON=python 5 | 6 | # obtain the script home 7 | SCRIPT_HOME=$(dirname $(readlink -f $0)) 8 | 9 | # setup python path for the scripts 10 | export PYTHONPATH=$SCRIPT_HOME:$PYTHONPATH 11 | 12 | # call the python script 13 | $PYTHON $SCRIPT_HOME/maple/regression/main.py $* 14 | 15 | -------------------------------------------------------------------------------- /script/sinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setup python 4 | PYTHON=python 5 | 6 | # obtain the script home 7 | SCRIPT_HOME=$(dirname $(readlink -f $0)) 8 | 9 | # setup python path for the scripts 10 | export PYTHONPATH=$SCRIPT_HOME:$PYTHONPATH 11 | 12 | # call the python script 13 | $PYTHON $SCRIPT_HOME/maple/sinst/main.py $* 14 | 15 | -------------------------------------------------------------------------------- /script/systematic: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setup python 4 | PYTHON=python 5 | 6 | # obtain the script home 7 | SCRIPT_HOME=$(dirname $(readlink -f $0)) 8 | 9 | # setup python path for the scripts 10 | export PYTHONPATH=$SCRIPT_HOME:$PYTHONPATH 11 | 12 | # call the python script 13 | $PYTHON $SCRIPT_HOME/maple/systematic/main.py $* 14 | 15 | -------------------------------------------------------------------------------- /script/tracer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # setup python 4 | PYTHON=python 5 | 6 | # obtain the script home 7 | SCRIPT_HOME=$(dirname $(readlink -f $0)) 8 | 9 | # setup python path for the scripts 10 | export PYTHONPATH=$SCRIPT_HOME:$PYTHONPATH 11 | 12 | # call the python script 13 | $PYTHON $SCRIPT_HOME/maple/tracer/main.py $* 14 | 15 | -------------------------------------------------------------------------------- /src/core/cmdline_knob.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/cmdline_knob.h - Define command line switches. 18 | 19 | #ifndef CORE_CMDLINE_KNOB_H_ 20 | #define CORE_CMDLINE_KNOB_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "core/knob.h" 26 | 27 | // Command line knob. 28 | class CmdlineKnob : public Knob { 29 | public: 30 | CmdlineKnob(); 31 | ~CmdlineKnob(); 32 | 33 | void Parse(int argc, char *argv[]); 34 | void RegisterBool(const std::string &name, const std::string &desc, 35 | const std::string &val); 36 | void RegisterInt(const std::string &name, const std::string &desc, 37 | const std::string &val); 38 | void RegisterStr(const std::string &name, const std::string &desc, 39 | const std::string &val); 40 | bool ValueBool(const std::string &name); 41 | int ValueInt(const std::string &name); 42 | std::string ValueStr(const std::string &name); 43 | 44 | private: 45 | typedef enum { 46 | KNOB_TYPE_INVALID = 0, 47 | KNOB_TYPE_BOOL, 48 | KNOB_TYPE_INT, 49 | KNOB_TYPE_STR, 50 | } KnobType; 51 | typedef std::pair TypedKnob; 52 | typedef std::map KnobNameMap; 53 | 54 | bool Exist(const std::string &name); 55 | 56 | KnobNameMap knob_table_; 57 | 58 | DISALLOW_COPY_CONSTRUCTORS(CmdlineKnob); 59 | }; 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/core/filter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/filter.cc - Define address filters. 18 | 19 | #include "core/filter.h" 20 | 21 | void RegionFilter::AddRegion(address_t addr, size_t size, bool locking) { 22 | ScopedLock locker(internal_lock_, locking); 23 | 24 | addr_region_map_[addr] = size; 25 | } 26 | 27 | size_t RegionFilter::RemoveRegion(address_t addr, bool locking) { 28 | ScopedLock locker(internal_lock_, locking); 29 | 30 | if (!addr) return 0; 31 | size_t size = 0; 32 | std::map::iterator it = addr_region_map_.find(addr); 33 | if (it != addr_region_map_.end()) { 34 | size = it->second; 35 | addr_region_map_.erase(it); 36 | } 37 | return size; 38 | } 39 | 40 | bool RegionFilter::Filter(address_t addr, bool locking) { 41 | ScopedLock locker(internal_lock_, locking); 42 | 43 | if (addr_region_map_.begin() == addr_region_map_.end()) 44 | return true; 45 | 46 | std::map::iterator it = addr_region_map_.upper_bound(addr); 47 | if (it == addr_region_map_.begin()) 48 | return true; 49 | 50 | it--; 51 | address_t region_start = it->first; 52 | size_t region_size = it->second; 53 | if (addr >= region_start && addr < region_start + region_size) 54 | return false; 55 | else 56 | return true; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/core/filter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/filter.h - Define address filters. 18 | 19 | #ifndef CORE_FILTER_H_ 20 | #define CORE_FILTER_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "core/sync.h" 26 | 27 | class RegionFilter { 28 | public: 29 | explicit RegionFilter(Mutex *lock) : internal_lock_(lock) {} 30 | ~RegionFilter() { delete internal_lock_; } 31 | 32 | void AddRegion(address_t addr, size_t size) { AddRegion(addr, size, true); } 33 | size_t RemoveRegion(address_t addr) { return RemoveRegion(addr, true); } 34 | bool Filter(address_t addr) { return Filter(addr, true); } 35 | 36 | void AddRegion(address_t addr, size_t size, bool locking); 37 | size_t RemoveRegion(address_t addr, bool locking); 38 | bool Filter(address_t addr, bool locking); 39 | 40 | private: 41 | Mutex *internal_lock_; 42 | std::map addr_region_map_; 43 | 44 | DISALLOW_COPY_CONSTRUCTORS(RegionFilter); 45 | }; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /src/core/knob.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/knob.cc - Implement the command line switches. 18 | 19 | #include "core/knob.h" 20 | 21 | Knob *Knob::knob_ = NULL; 22 | 23 | -------------------------------------------------------------------------------- /src/core/knob.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/knob.h - Define command line switches. 18 | 19 | #ifndef CORE_KNOB_H_ 20 | #define CORE_KNOB_H_ 21 | 22 | #include "core/basictypes.h" 23 | 24 | // The interface class for the command line switches. 25 | class Knob { 26 | public: 27 | Knob() {} 28 | virtual ~Knob() {} 29 | 30 | virtual void RegisterBool(const std::string &name, const std::string &desc, 31 | const std::string &val) = 0; 32 | virtual void RegisterInt(const std::string &name, const std::string &desc, 33 | const std::string &val) = 0; 34 | virtual void RegisterStr(const std::string &name, const std::string &desc, 35 | const std::string &val) = 0; 36 | virtual bool ValueBool(const std::string &name) = 0; 37 | virtual int ValueInt(const std::string &name) = 0; 38 | virtual std::string ValueStr(const std::string &name) = 0; 39 | 40 | static void Initialize(Knob *knob) { knob_ = knob; } 41 | static Knob *Get() { return knob_; } 42 | 43 | protected: 44 | static Knob *knob_; 45 | 46 | private: 47 | DISALLOW_COPY_CONSTRUCTORS(Knob); 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/core/lock_set.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/lock_set.h - Define lock set. 18 | 19 | #ifndef CORE_LOCK_SET_H_ 20 | #define CORE_LOCK_SET_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "core/atomic.h" 26 | 27 | // Lock set. 28 | class LockSet { 29 | public: 30 | typedef uint64 lock_version_t; 31 | 32 | LockSet() {} 33 | ~LockSet() {} 34 | 35 | bool Empty() { return set_.empty(); } 36 | void Add(address_t addr) { set_[addr] = GetNextLockVersion(); } 37 | void Remove(address_t addr) { set_.erase(addr); } 38 | bool Exist(address_t addr) { return set_.find(addr) != set_.end(); } 39 | bool Exist(address_t addr, lock_version_t version); 40 | void Clear() { set_.clear(); } 41 | bool Match(LockSet *ls); 42 | bool Disjoint(LockSet *ls); 43 | bool Disjoint(LockSet *rmt_ls1, LockSet *rmt_ls2); 44 | std::string ToString(); 45 | void IterBegin() { it_ = set_.begin(); } 46 | bool IterEnd() { return it_ == set_.end(); } 47 | void IterNext() { ++it_; } 48 | address_t IterCurrAddr() { return it_->first; } 49 | lock_version_t IterCurrVersion() { return it_->second; } 50 | 51 | protected: 52 | typedef std::map LockVersionMap; 53 | 54 | static lock_version_t GetNextLockVersion() { 55 | return ATOMIC_ADD_AND_FETCH(&curr_lock_version_, 1); 56 | } 57 | 58 | LockVersionMap set_; 59 | LockVersionMap::iterator it_; 60 | 61 | // static data 62 | static lock_version_t curr_lock_version_; 63 | 64 | // using default copy constructor and assignment operator 65 | }; 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /src/core/offline_tool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/offline_tool.h - The abstract definition of offline tools. 18 | 19 | #ifndef CORE_OFFLINE_TOOL_H_ 20 | #define CORE_OFFLINE_TOOL_H_ 21 | 22 | #include "core/basictypes.h" 23 | #include "core/logging.h" 24 | #include "core/sync.h" 25 | #include "core/cmdline_knob.h" 26 | #include "core/static_info.h" 27 | 28 | class OfflineTool { 29 | public: 30 | OfflineTool(); 31 | virtual ~OfflineTool(); 32 | 33 | void Initialize(); 34 | void PreSetup(); 35 | void PostSetup(); 36 | void Parse(int argc, char *argv[]); 37 | void Start(); 38 | void Exit(); 39 | 40 | protected: 41 | virtual Mutex *CreateMutex() { return new NullMutex; } 42 | virtual void HandlePreSetup(); 43 | virtual void HandlePostSetup(); 44 | virtual void HandleStart(); 45 | virtual void HandleExit(); 46 | 47 | Mutex *kernel_lock_; 48 | Knob *knob_; 49 | LogFile *debug_file_; 50 | StaticInfo *sinfo_; 51 | bool read_only_; // Whether this tool is a read-only tool. 52 | 53 | static OfflineTool *tool_; 54 | 55 | private: 56 | DISALLOW_COPY_CONSTRUCTORS(OfflineTool); 57 | }; 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /src/core/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for core package 2 | 3 | protodefs += \ 4 | core/static_info.proto 5 | 6 | srcs += \ 7 | core/callstack.cc \ 8 | core/cmdline_knob.cc \ 9 | core/debug_analyzer.cc \ 10 | core/descriptor.cc \ 11 | core/execution_control.cpp \ 12 | core/filter.cc \ 13 | core/knob.cc \ 14 | core/lock_set.cc \ 15 | core/logging.cc \ 16 | core/offline_tool.cc \ 17 | core/pin_knob.cpp \ 18 | core/pin_util.cpp \ 19 | core/stat.cc \ 20 | core/static_info.cc \ 21 | core/static_info.pb.cc \ 22 | core/vector_clock.cc \ 23 | core/wrapper.cpp 24 | 25 | core_objs := \ 26 | core/callstack.o \ 27 | core/cmdline_knob.o \ 28 | core/debug_analyzer.o \ 29 | core/descriptor.o \ 30 | core/execution_control.o \ 31 | core/filter.o \ 32 | core/knob.o \ 33 | core/lock_set.o \ 34 | core/logging.o \ 35 | core/offline_tool.o \ 36 | core/pin_knob.o \ 37 | core/pin_util.o \ 38 | core/stat.o \ 39 | core/static_info.o \ 40 | core/static_info.pb.o \ 41 | core/vector_clock.o \ 42 | core/wrapper.o 43 | 44 | core_cmd_objs := \ 45 | core/callstack.o \ 46 | core/cmdline_knob.o \ 47 | core/debug_analyzer.o \ 48 | core/descriptor.o \ 49 | core/filter.o \ 50 | core/knob.o \ 51 | core/lock_set.o \ 52 | core/logging.o \ 53 | core/offline_tool.o \ 54 | core/stat.o \ 55 | core/static_info.o \ 56 | core/static_info.pb.o \ 57 | core/vector_clock.o \ 58 | 59 | -------------------------------------------------------------------------------- /src/core/pin_knob.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/pin_knob.hpp - Define command line switches. 18 | 19 | #ifndef CORE_PIN_KNOB_HPP_ 20 | #define CORE_PIN_KNOB_HPP_ 21 | 22 | #include 23 | 24 | #include "pin.H" 25 | 26 | #include "core/basictypes.h" 27 | #include "core/knob.h" 28 | 29 | class PinKnob : public Knob { 30 | public: 31 | PinKnob() {} 32 | ~PinKnob() {} 33 | 34 | void RegisterBool(const std::string &name, const std::string &desc, 35 | const std::string &val); 36 | void RegisterInt(const std::string &name, const std::string &desc, 37 | const std::string &val); 38 | void RegisterStr(const std::string &name, const std::string &desc, 39 | const std::string &val); 40 | bool ValueBool(const std::string &name); 41 | int ValueInt(const std::string &name); 42 | std::string ValueStr(const std::string &name); 43 | 44 | private: 45 | typedef enum { 46 | KNOB_TYPE_INVALID = 0, 47 | KNOB_TYPE_BOOL, 48 | KNOB_TYPE_INT, 49 | KNOB_TYPE_STR, 50 | } KnobType; 51 | typedef std::pair TypedKnob; 52 | typedef std::map KnobNameMap; 53 | 54 | bool Exist(const std::string &name); 55 | 56 | KnobNameMap knob_table_; 57 | 58 | DISALLOW_COPY_CONSTRUCTORS(PinKnob); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/core/pin_sync.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/pin_sync.hpp - Define synchronizations that can be used in 18 | // PIN tools. 19 | 20 | #ifndef CORE_PIN_SYNC_HPP_ 21 | #define CORE_PIN_SYNC_HPP_ 22 | 23 | #include "pin.H" 24 | 25 | #include "core/basictypes.h" 26 | #include "core/sync.h" 27 | 28 | // Define PIN mutex. 29 | class PinMutex : public Mutex { 30 | public: 31 | PinMutex() { PIN_InitLock(&lock_); } 32 | ~PinMutex() {} 33 | 34 | void Lock() { PIN_GetLock(&lock_, 1); } 35 | void Unlock() { PIN_ReleaseLock(&lock_); } 36 | Mutex *Clone() { return new PinMutex; } 37 | 38 | protected: 39 | PIN_LOCK lock_; 40 | 41 | private: 42 | DISALLOW_COPY_CONSTRUCTORS(PinMutex); 43 | }; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /src/core/pin_util.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/pin_util.hpp - Implementation of PIN utility functions. 18 | 19 | #include "core/pin_util.hpp" 20 | 21 | #include "core/logging.h" 22 | 23 | RTN FindRTN(IMG img, const std::string &func_name) { 24 | RTN rtn = RTN_FindByName(img, func_name.c_str()); 25 | if (RTN_Valid(rtn)) 26 | return rtn; 27 | 28 | // handle those symbols with version numbers. 29 | // e.g. pthread_create has global name: pthread_create@@GLIBC... 30 | std::string func_name_v(func_name); 31 | func_name_v.append("@@"); 32 | for(SYM sym = IMG_RegsymHead(img); SYM_Valid(sym); sym = SYM_Next(sym)) { 33 | if (SYM_Name(sym).find(func_name_v) != std::string::npos) { 34 | RTN rtn = RTN_FindByAddress(SYM_Address(sym)); 35 | DEBUG_ASSERT(RTN_Valid(rtn)); 36 | return rtn; 37 | } 38 | } 39 | 40 | return RTN_Invalid(); 41 | } 42 | 43 | IMG GetImgByTrace(TRACE trace) { 44 | IMG img = IMG_Invalid(); 45 | RTN rtn = TRACE_Rtn(trace); 46 | if (RTN_Valid(rtn)) { 47 | SEC sec = RTN_Sec(rtn); 48 | if (SEC_Valid(sec)) { 49 | img = SEC_Img(sec); 50 | } 51 | } 52 | return img; 53 | } 54 | 55 | bool BBLContainMemOp(BBL bbl) { 56 | for (INS ins = BBL_InsHead(bbl); INS_Valid(ins); ins = INS_Next(ins)) { 57 | if (INS_IsStackRead(ins) || INS_IsStackWrite(ins)) 58 | continue; 59 | if (INS_IsMemoryRead(ins) || INS_IsMemoryWrite(ins)) 60 | return true; 61 | } 62 | return false; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/core/pin_util.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/pin_util.hpp - Define PIN utility functions. 18 | 19 | #ifndef CORE_PIN_UTIL_HPP_ 20 | #define CORE_PIN_UTIL_HPP_ 21 | 22 | #include "pin.H" 23 | 24 | #ifdef CONFIG_PINPLAY 25 | #include "pinplay.H" 26 | #endif 27 | 28 | #include "core/basictypes.h" 29 | 30 | // Setup call orders for PinPlay. 31 | #ifdef CONFIG_PINPLAY 32 | #define CALL_ORDER_BEFORE IARG_CALL_ORDER, (PINPLAY_ENGINE::PinPlayFirstBeforeCallOrder() - 1), 33 | #define CALL_ORDER_AFTER IARG_CALL_ORDER, (PINPLAY_ENGINE::PinPlayLastAfterCallOrder() + 1), 34 | #else 35 | #define CALL_ORDER_BEFORE 36 | #define CALL_ORDER_AFTER 37 | #endif 38 | 39 | // Global definitions 40 | 41 | // Find RTN by function name in an image. 42 | extern RTN FindRTN(IMG img, const std::string &func_name); 43 | 44 | // Get the IMG that contains the TRACE. 45 | extern IMG GetImgByTrace(TRACE trace); 46 | 47 | // Return whether the given bbl contains non-stack memory access. 48 | extern bool BBLContainMemOp(BBL bbl); 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/core/static_info.proto: -------------------------------------------------------------------------------- 1 | message DebugInfoProto { 2 | required string file_name = 1; 3 | required int32 line = 2; 4 | required int32 column = 3; 5 | } 6 | 7 | message ImageProto { 8 | required uint32 id = 1; 9 | required string name = 2; 10 | } 11 | 12 | message InstProto { 13 | required uint32 id = 1; 14 | required uint32 image_id = 2; 15 | required uint64 offset = 3; 16 | optional uint32 opcode = 4; 17 | optional DebugInfoProto debug_info = 5; 18 | } 19 | 20 | message StaticInfoProto { 21 | repeated ImageProto image = 1; 22 | repeated InstProto inst = 2; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/core/vector_clock.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/vector_clock.h - Define vector clock. 18 | 19 | #ifndef CORE_VECTOR_CLOCK_H_ 20 | #define CORE_VECTOR_CLOCK_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | 26 | // Vector clock. 27 | class VectorClock { 28 | public: 29 | VectorClock() {} 30 | ~VectorClock() {} 31 | 32 | bool HappensBefore(VectorClock *vc); 33 | bool HappensAfter(VectorClock *vc); 34 | void Join(VectorClock *vc); 35 | void Increment(thread_id_t thd_id); 36 | timestamp_t GetClock(thread_id_t thd_id); 37 | void SetClock(thread_id_t thd_id, timestamp_t clk); 38 | bool Equal(VectorClock *vc); 39 | std::string ToString(); 40 | void IterBegin() { it_ = map_.begin(); } 41 | bool IterEnd() { return it_ == map_.end(); } 42 | void IterNext() { ++it_; } 43 | thread_id_t IterCurrThd() { return it_->first; } 44 | timestamp_t IterCurrClk() { return it_->second; } 45 | 46 | private: 47 | typedef std::map ThreadClockMap; 48 | 49 | ThreadClockMap map_; 50 | ThreadClockMap::iterator it_; 51 | 52 | // using default copy constructor and assignment operator 53 | }; 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/core/wrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: core/wrapper.cpp - Implementation of function wrappers. 18 | 19 | #include "core/wrapper.hpp" 20 | 21 | // The singleton instance for WrapperFactory. 22 | WrapperFactory *WrapperFactory::instance_ = NULL; 23 | 24 | // Register wrappers. 25 | REGISTER_WRAPPER(Malloc); 26 | REGISTER_WRAPPER(Calloc); 27 | REGISTER_WRAPPER(Realloc); 28 | REGISTER_WRAPPER(Free); 29 | REGISTER_WRAPPER(Valloc); 30 | 31 | REGISTER_WRAPPER(Sleep); 32 | REGISTER_WRAPPER(Usleep); 33 | 34 | REGISTER_WRAPPER(SchedSetScheduler); 35 | REGISTER_WRAPPER(SchedYield); 36 | REGISTER_WRAPPER(SchedSetAffinity); 37 | REGISTER_WRAPPER(SetPriority); 38 | 39 | REGISTER_WRAPPER(PthreadCreate); 40 | REGISTER_WRAPPER(PthreadJoin); 41 | REGISTER_WRAPPER(PthreadMutexTryLock); 42 | REGISTER_WRAPPER(PthreadMutexLock); 43 | REGISTER_WRAPPER(PthreadMutexUnlock); 44 | REGISTER_WRAPPER(PthreadCondSignal); 45 | REGISTER_WRAPPER(PthreadCondBroadcast); 46 | REGISTER_WRAPPER(PthreadCondWait); 47 | REGISTER_WRAPPER(PthreadCondTimedwait); 48 | REGISTER_WRAPPER(PthreadBarrierInit); 49 | REGISTER_WRAPPER(PthreadBarrierWait); 50 | 51 | -------------------------------------------------------------------------------- /src/idiom/chess_profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/chess_profiler.hpp - Define the controller for idiom 18 | // CHESS profiler. 19 | 20 | #ifndef IDIOM_CHESS_PROFILER_HPP_ 21 | #define IDIOM_CHESS_PROFILER_HPP_ 22 | 23 | #include "core/basictypes.h" 24 | #include "systematic/controller.hpp" 25 | #include "sinst/sinst.h" 26 | #include "sinst/analyzer.h" 27 | #include "idiom/iroot.h" 28 | #include "idiom/memo.h" 29 | #include "idiom/observer.h" 30 | #include "idiom/observer_new.h" 31 | #include "idiom/predictor.h" 32 | 33 | namespace idiom { 34 | 35 | class ChessProfiler : public systematic::Controller { 36 | public: 37 | ChessProfiler(); 38 | ~ChessProfiler() {} 39 | 40 | private: 41 | void HandlePreSetup(); 42 | void HandlePostSetup(); 43 | bool HandleIgnoreInstCount(IMG img); 44 | bool HandleIgnoreMemAccess(IMG img); 45 | void HandleProgramExit(); 46 | 47 | iRootDB *iroot_db_; 48 | Memo *memo_; 49 | sinst::SharedInstDB *sinst_db_; 50 | sinst::SharedInstAnalyzer *sinst_analyzer_; 51 | Observer *observer_; 52 | ObserverNew *observer_new_; 53 | 54 | DISALLOW_COPY_CONSTRUCTORS(ChessProfiler); 55 | }; 56 | 57 | } // namespace idiom 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /src/idiom/chess_profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/chess_profiler_main.cpp - The main entrance of the 18 | // idiom profiler using CHESS scheduler. 19 | 20 | #include "idiom/chess_profiler.hpp" 21 | 22 | MAIN_ENTRY(idiom::ChessProfiler); 23 | -------------------------------------------------------------------------------- /src/idiom/history.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/history.cc - Implementation of active testing history. 18 | 19 | #include "idiom/history.h" 20 | 21 | #include 22 | 23 | namespace idiom { 24 | 25 | void TestHistory::CreateEntry(iRoot *iroot) { 26 | curr_proto_ = table_proto_.add_history(); 27 | curr_proto_->set_iroot_id(iroot->id()); 28 | } 29 | 30 | void TestHistory::UpdateSeed(unsigned int seed) { 31 | curr_proto_->set_seed(seed); 32 | } 33 | 34 | void TestHistory::UpdateResult(bool success) { 35 | curr_proto_->set_success(success); 36 | } 37 | 38 | int TestHistory::TotalTestRuns(iRoot *iroot) { 39 | int total_test_runs = 0; 40 | for (int i = 0; i < table_proto_.history_size(); i++) { 41 | HistoryProto *proto = table_proto_.mutable_history(i); 42 | if (proto->iroot_id() == iroot->id()) 43 | total_test_runs++; 44 | } 45 | return total_test_runs; 46 | } 47 | 48 | void TestHistory::Load(const std::string &file_name) { 49 | std::fstream in(file_name.c_str(), std::ios::in | std::ios::binary); 50 | table_proto_.ParseFromIstream(&in); 51 | in.close(); 52 | } 53 | 54 | void TestHistory::Save(const std::string &file_name) { 55 | std::fstream out(file_name.c_str(), 56 | std::ios::out | std::ios::trunc | std::ios::binary); 57 | table_proto_.SerializeToOstream(&out); 58 | out.close(); 59 | } 60 | 61 | } // namespace idiom 62 | 63 | -------------------------------------------------------------------------------- /src/idiom/history.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/history.h - Define active testing history. 18 | 19 | #ifndef IDIOM_HISTORY_H_ 20 | #define IDIOM_HISTORY_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "idiom/iroot.h" 26 | #include "idiom/history.pb.h" 27 | 28 | namespace idiom { 29 | 30 | // Active testing history 31 | class TestHistory { 32 | public: 33 | TestHistory() : curr_proto_(NULL) {} 34 | ~TestHistory() {} 35 | 36 | void CreateEntry(iRoot *iroot); 37 | void UpdateSeed(unsigned int seed); 38 | void UpdateResult(bool success); 39 | int TotalTestRuns(iRoot *iroot); 40 | void Load(const std::string &file_name); 41 | void Save(const std::string &file_name); 42 | 43 | private: 44 | HistoryTableProto table_proto_; 45 | HistoryProto *curr_proto_; 46 | 47 | DISALLOW_COPY_CONSTRUCTORS(TestHistory); 48 | }; 49 | 50 | } // namespace idiom 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/idiom/history.proto: -------------------------------------------------------------------------------- 1 | package idiom; 2 | 3 | message HistoryProto { 4 | required uint32 iroot_id = 1; 5 | required uint32 seed = 2; 6 | optional bool success = 3; 7 | } 8 | 9 | message HistoryTableProto { 10 | repeated HistoryProto history = 1; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/idiom/iroot.proto: -------------------------------------------------------------------------------- 1 | package idiom; 2 | 3 | enum IdiomType { 4 | IDIOM_INVALID = 0; 5 | IDIOM_1 = 1; 6 | IDIOM_2 = 2; 7 | IDIOM_3 = 3; 8 | IDIOM_4 = 4; 9 | IDIOM_5 = 5; 10 | } 11 | 12 | enum iRootEventType { 13 | IROOT_EVENT_INVALID = 0; 14 | IROOT_EVENT_MEM_READ = 1; 15 | IROOT_EVENT_MEM_WRITE = 2; 16 | IROOT_EVENT_MUTEX_LOCK = 3; 17 | IROOT_EVENT_MUTEX_UNLOCK = 4; 18 | } 19 | 20 | message iRootEventProto { 21 | required uint32 id = 1; 22 | required uint32 inst_id = 2; 23 | required iRootEventType type = 3; 24 | } 25 | 26 | message iRootProto { 27 | required uint32 id = 1; 28 | required IdiomType idiom = 2; 29 | repeated uint32 event_id = 3; 30 | } 31 | 32 | message iRootDBProto { 33 | repeated iRootEventProto event = 1; 34 | repeated iRootProto iroot = 2; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/idiom/memo.proto: -------------------------------------------------------------------------------- 1 | package idiom; 2 | 3 | message iRootInfoProto { 4 | required uint32 iroot_id = 1; 5 | required uint32 total_test_runs = 2; 6 | optional bool async = 3; 7 | } 8 | 9 | message CandidateProto { 10 | required uint32 iroot_id = 1; 11 | required uint32 test_runs = 2; 12 | } 13 | 14 | message MemoProto { 15 | repeated iRootInfoProto iroot_info = 1; 16 | repeated uint32 exposed = 2; 17 | repeated uint32 failed = 3; 18 | repeated uint32 predicted = 4; 19 | repeated uint32 shadow_exposed = 5; 20 | repeated CandidateProto candidate = 6; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/idiom/memo_tool_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/memo_tool_main.cc - Tha main entrance of the memoization command 18 | // line tool. 19 | 20 | #include "idiom/memo_tool.h" 21 | 22 | static idiom::MemoTool *tool = new idiom::MemoTool; 23 | 24 | int main(int argc, char *argv[]) { 25 | tool->Initialize(); 26 | tool->PreSetup(); 27 | tool->Parse(argc, argv); 28 | tool->PostSetup(); 29 | tool->Start(); 30 | tool->Exit(); 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/idiom/pct_profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/pct_profiler.hpp - Define the controller for idiom 18 | // PCT profiler. 19 | 20 | #ifndef IDIOM_PCT_PROFILER_HPP_ 21 | #define IDIOM_PCT_PROFILER_HPP_ 22 | 23 | #include "core/basictypes.h" 24 | #include "pct/scheduler.hpp" 25 | #include "sinst/sinst.h" 26 | #include "sinst/analyzer.h" 27 | #include "idiom/iroot.h" 28 | #include "idiom/memo.h" 29 | #include "idiom/observer.h" 30 | #include "idiom/observer_new.h" 31 | #include "idiom/predictor.h" 32 | #include "idiom/predictor_new.h" 33 | 34 | namespace idiom { 35 | 36 | class PCTProfiler : public pct::Scheduler { 37 | public: 38 | PCTProfiler(); 39 | ~PCTProfiler() {} 40 | 41 | private: 42 | void HandlePreSetup(); 43 | void HandlePostSetup(); 44 | bool HandleIgnoreInstCount(IMG img); 45 | bool HandleIgnoreMemAccess(IMG img); 46 | void HandleProgramExit(); 47 | 48 | iRootDB *iroot_db_; 49 | Memo *memo_; 50 | sinst::SharedInstDB *sinst_db_; 51 | sinst::SharedInstAnalyzer *sinst_analyzer_; 52 | Observer *observer_; 53 | ObserverNew *observer_new_; 54 | Predictor *predictor_; 55 | PredictorNew *predictor_new_; 56 | 57 | DISALLOW_COPY_CONSTRUCTORS(PCTProfiler); 58 | }; 59 | 60 | } // namespace idiom 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/idiom/pct_profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/pct_profiler_main.cpp - The main entrance of the idiom 18 | // profiler using PCT scheduler. 19 | 20 | #include "idiom/pct_profiler.hpp" 21 | 22 | MAIN_ENTRY(idiom::PCTProfiler); 23 | -------------------------------------------------------------------------------- /src/idiom/profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/profiler.hpp - Define the controller for idiom profiler. 18 | 19 | #ifndef IDIOM_PROFILER_HPP_ 20 | #define IDIOM_PROFILER_HPP_ 21 | 22 | #include "core/basictypes.h" 23 | #include "core/execution_control.hpp" 24 | #include "sinst/sinst.h" 25 | #include "sinst/analyzer.h" 26 | #include "idiom/iroot.h" 27 | #include "idiom/memo.h" 28 | #include "idiom/observer.h" 29 | #include "idiom/observer_new.h" 30 | #include "idiom/predictor.h" 31 | #include "idiom/predictor_new.h" 32 | 33 | namespace idiom { 34 | 35 | class Profiler : public ExecutionControl { 36 | public: 37 | Profiler(); 38 | ~Profiler() {} 39 | 40 | private: 41 | void HandlePreSetup(); 42 | void HandlePostSetup(); 43 | bool HandleIgnoreInstCount(IMG img); 44 | bool HandleIgnoreMemAccess(IMG img); 45 | void HandleProgramExit(); 46 | 47 | iRootDB *iroot_db_; 48 | Memo *memo_; 49 | sinst::SharedInstDB *sinst_db_; 50 | sinst::SharedInstAnalyzer *sinst_analyzer_; 51 | Observer *observer_; 52 | ObserverNew *observer_new_; 53 | Predictor *predictor_; 54 | PredictorNew *predictor_new_; 55 | 56 | DISALLOW_COPY_CONSTRUCTORS(Profiler); 57 | }; 58 | 59 | } // namespace idiom 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /src/idiom/profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/profiler_main.cpp - The main entrance of the idiom profiler. 18 | 19 | #include "idiom/profiler.hpp" 20 | 21 | MAIN_ENTRY(idiom::Profiler); 22 | -------------------------------------------------------------------------------- /src/idiom/randsched_profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/randsched_profiler.hpp - Define the controller for idiom 18 | // Random profiler. 19 | 20 | #ifndef IDIOM_RANDSCHED_PROFILER_HPP_ 21 | #define IDIOM_RANDSCHED_PROFILER_HPP_ 22 | 23 | #include "core/basictypes.h" 24 | #include "randsched/scheduler.hpp" 25 | #include "sinst/sinst.h" 26 | #include "sinst/analyzer.h" 27 | #include "idiom/iroot.h" 28 | #include "idiom/memo.h" 29 | #include "idiom/observer.h" 30 | #include "idiom/observer_new.h" 31 | #include "idiom/predictor.h" 32 | #include "idiom/predictor_new.h" 33 | 34 | namespace idiom { 35 | 36 | class RandSchedProfiler : public randsched::Scheduler { 37 | public: 38 | RandSchedProfiler(); 39 | ~RandSchedProfiler() {} 40 | 41 | private: 42 | void HandlePreSetup(); 43 | void HandlePostSetup(); 44 | bool HandleIgnoreInstCount(IMG img); 45 | bool HandleIgnoreMemAccess(IMG img); 46 | void HandleProgramExit(); 47 | 48 | iRootDB *iroot_db_; 49 | Memo *memo_; 50 | sinst::SharedInstDB *sinst_db_; 51 | sinst::SharedInstAnalyzer *sinst_analyzer_; 52 | Observer *observer_; 53 | ObserverNew *observer_new_; 54 | Predictor *predictor_; 55 | PredictorNew *predictor_new_; 56 | 57 | DISALLOW_COPY_CONSTRUCTORS(RandSchedProfiler); 58 | }; 59 | 60 | } // namespace idiom 61 | 62 | #endif 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/idiom/randsched_profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/randsched_profiler_main.cpp - The main entrance of the idiom 18 | // profiler using Random scheduler. 19 | 20 | #include "idiom/randsched_profiler.hpp" 21 | 22 | MAIN_ENTRY(idiom::RandSchedProfiler); 23 | -------------------------------------------------------------------------------- /src/idiom/scheduler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/scheduler.hpp - Define the active scheduler controller. 18 | 19 | #ifndef IDIOM_SCHEDULER_HPP_ 20 | #define IDIOM_SCHEDULER_HPP_ 21 | 22 | #ifdef CONFIG_PINPLAY 23 | #include "pinplay.H" 24 | #endif 25 | 26 | #include "sinst/sinst.h" 27 | #include "sinst/analyzer.h" 28 | #include "idiom/memo.h" 29 | #include "idiom/observer.h" 30 | #include "idiom/observer_new.h" 31 | #include "idiom/scheduler_common.hpp" 32 | 33 | namespace idiom { 34 | 35 | // The controller for the idiom driven active scheduler. 36 | class Scheduler : public SchedulerCommon { 37 | public: 38 | Scheduler(); 39 | ~Scheduler() {} 40 | 41 | protected: 42 | void HandlePreSetup(); 43 | void HandlePostSetup(); 44 | bool HandleIgnoreInstCount(IMG img); 45 | bool HandleIgnoreMemAccess(IMG img); 46 | void HandleProgramExit(); 47 | 48 | // functions to override 49 | void Choose(); 50 | void TestSuccess(); 51 | void TestFail(); 52 | bool UseDecreasingPriorities(); 53 | bool YieldWithDelay(); 54 | 55 | Memo *memo_; 56 | sinst::SharedInstDB *sinst_db_; 57 | sinst::SharedInstAnalyzer *sinst_analyzer_; 58 | Observer *observer_; 59 | ObserverNew *observer_new_; 60 | 61 | #ifdef CONFIG_PINPLAY 62 | PINPLAY_ENGINE pinplay_engine_; 63 | #endif 64 | 65 | private: 66 | DISALLOW_COPY_CONSTRUCTORS(Scheduler); 67 | }; 68 | 69 | } // namespace idiom 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /src/idiom/scheduler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: idiom/scheduler_main.cpp - The main entrance of the active scheduler. 18 | 19 | #include "idiom/scheduler.hpp" 20 | 21 | MAIN_ENTRY(idiom::Scheduler); 22 | -------------------------------------------------------------------------------- /src/pct/history.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: pct/history.cc - Implementation of the PCT scheduler history. 18 | 19 | #include "pct/history.h" 20 | 21 | #include 22 | 23 | namespace pct { 24 | 25 | unsigned long History::AvgInstCount() { 26 | double total = 0.0; 27 | int size = table_proto_.history_size(); 28 | for (int i = 0; i < size; i++) { 29 | total += (double)table_proto_.history(i).inst_count(); 30 | } 31 | return (unsigned long)(total / (double)size); 32 | } 33 | 34 | unsigned long History::AvgNumThreads() { 35 | double total = 0.0; 36 | int size = table_proto_.history_size(); 37 | for (int i = 0; i < size; i++) { 38 | total += (double)table_proto_.history(i).num_threads(); 39 | } 40 | return (unsigned long)(total / (double)size); 41 | } 42 | 43 | void History::Update(unsigned long inst_count, unsigned long num_threads) { 44 | HistoryProto *proto = table_proto_.add_history(); 45 | proto->set_inst_count(inst_count); 46 | proto->set_num_threads(num_threads); 47 | } 48 | 49 | void History::Load(const std::string &file_name) { 50 | std::fstream in(file_name.c_str(), std::ios::in | std::ios::binary); 51 | table_proto_.ParseFromIstream(&in); 52 | in.close(); 53 | } 54 | 55 | void History::Save(const std::string &file_name) { 56 | std::fstream out(file_name.c_str(), 57 | std::ios::out | std::ios::trunc | std::ios::binary); 58 | table_proto_.SerializeToOstream(&out); 59 | out.close(); 60 | } 61 | 62 | } // namespace pct 63 | 64 | -------------------------------------------------------------------------------- /src/pct/history.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: pct/history.h - Define the PCT scheduler history. 18 | 19 | #ifndef PCT_HISTORY_H_ 20 | #define PCT_HISTORY_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "pct/history.pb.h" // protobuf head file 26 | 27 | namespace pct { 28 | 29 | // PCT scheduler history. 30 | class History { 31 | public: 32 | History() {} 33 | ~History() {} 34 | 35 | bool Empty() { return table_proto_.history_size() == 0; } 36 | unsigned long AvgInstCount(); 37 | unsigned long AvgNumThreads(); 38 | void Update(unsigned long length, unsigned long num_threads); 39 | void Load(const std::string &file_name); 40 | void Save(const std::string &file_name); 41 | 42 | private: 43 | HistoryTableProto table_proto_; 44 | 45 | DISALLOW_COPY_CONSTRUCTORS(History); 46 | }; 47 | 48 | } // namespace pct 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/pct/history.proto: -------------------------------------------------------------------------------- 1 | package pct; 2 | 3 | message HistoryProto { 4 | required uint64 inst_count = 1; 5 | required uint64 num_threads = 2; 6 | } 7 | 8 | message HistoryTableProto { 9 | repeated HistoryProto history = 1; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/pct/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for the pct package 2 | 3 | protodefs += \ 4 | pct/history.proto 5 | 6 | srcs += \ 7 | pct/history.cc \ 8 | pct/history.pb.cc \ 9 | pct/scheduler.cpp \ 10 | pct/scheduler_main.cpp 11 | 12 | pintools += \ 13 | pct_scheduler.so 14 | 15 | pct_scheduler_objs := \ 16 | pct/history.o \ 17 | pct/history.pb.o \ 18 | pct/scheduler.o \ 19 | pct/scheduler_main.o \ 20 | $(core_objs) 21 | 22 | pct_objs := \ 23 | pct/history.o \ 24 | pct/history.pb.o \ 25 | pct/scheduler.o 26 | 27 | -------------------------------------------------------------------------------- /src/pct/scheduler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: pct/scheduler_main.cpp - The main entrance of the PCT scheduler. 18 | 19 | #include "pct/scheduler.hpp" 20 | 21 | MAIN_ENTRY(pct::Scheduler); 22 | -------------------------------------------------------------------------------- /src/race/djit.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/djit.h - Define the data race detector using the Djit 18 | // algorithm. 19 | 20 | #ifndef RACE_DJIT_H_ 21 | #define RACE_DJIT_H_ 22 | 23 | #include 24 | 25 | #include "core/basictypes.h" 26 | #include "core/vector_clock.h" 27 | #include "core/filter.h" 28 | #include "race/detector.h" 29 | #include "race/race.h" 30 | 31 | namespace race { 32 | 33 | class Djit : public Detector { 34 | public: 35 | Djit(); 36 | ~Djit(); 37 | 38 | void Register(); 39 | bool Enabled(); 40 | void Setup(Mutex *lock, RaceDB *race_db); 41 | 42 | protected: 43 | // the meta data for the memory access 44 | class DjitMeta : public Meta { 45 | public: 46 | typedef std::map InstMap; 47 | typedef std::set InstSet; 48 | 49 | explicit DjitMeta(address_t a) : Meta(a), racy(false) {} 50 | ~DjitMeta() {} 51 | 52 | bool racy; // whether this meta is involved in any race 53 | VectorClock writer_vc; 54 | InstMap writer_inst_table; 55 | VectorClock reader_vc; 56 | InstMap reader_inst_table; 57 | InstSet race_inst_set; 58 | }; 59 | 60 | // overrided virtual functions 61 | Meta *GetMeta(address_t iaddr); 62 | void ProcessRead(thread_id_t curr_thd_id, Meta *meta, Inst *inst); 63 | void ProcessWrite(thread_id_t curr_thd_id, Meta *meta, Inst *inst); 64 | void ProcessFree(Meta *meta); 65 | 66 | // settings and flasg 67 | bool track_racy_inst_; 68 | 69 | private: 70 | DISALLOW_COPY_CONSTRUCTORS(Djit); 71 | }; 72 | 73 | } // namespace race 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /src/race/fasttrack.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/fasttrack.cc - Implementation of the data race detector 18 | // using the FastTrack algorithm. 19 | 20 | -------------------------------------------------------------------------------- /src/race/fasttrack.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/fasttrack.h - Define the data race detector using the 18 | // FastTrack algorithm. 19 | 20 | #ifndef RACE_FASTTRACK_H_ 21 | #define RACE_FASTTRACK_H_ 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/race/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for the race package 2 | 3 | protodefs += \ 4 | race/race.proto 5 | 6 | srcs += \ 7 | race/detector.cc \ 8 | race/djit.cc \ 9 | race/fasttrack.cc \ 10 | race/pct_profiler.cpp \ 11 | race/pct_profiler_main.cpp \ 12 | race/profiler.cpp \ 13 | race/profiler_main.cpp \ 14 | race/race.cc \ 15 | race/race.pb.cc 16 | 17 | pintools += \ 18 | race_pct_profiler.so \ 19 | race_profiler.so 20 | 21 | race_profiler_objs := \ 22 | race/detector.o \ 23 | race/djit.o \ 24 | race/fasttrack.o \ 25 | race/profiler.o \ 26 | race/profiler_main.o \ 27 | race/race.o \ 28 | race/race.pb.o \ 29 | $(core_objs) 30 | 31 | race_pct_profiler_objs := \ 32 | race/detector.o \ 33 | race/djit.o \ 34 | race/fasttrack.o \ 35 | race/pct_profiler.o \ 36 | race/pct_profiler_main.o \ 37 | race/race.o \ 38 | race/race.pb.o \ 39 | $(pct_objs) \ 40 | $(core_objs) 41 | 42 | race_objs := \ 43 | race/detector.o \ 44 | race/djit.o \ 45 | race/fasttrack.o \ 46 | race/race.o \ 47 | race/race.pb.o 48 | 49 | -------------------------------------------------------------------------------- /src/race/pct_profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/pct_profiler.hpp - Define the PCT profiler for data race 18 | // detectors. 19 | 20 | #ifndef RACE_PCT_PROFILER_HPP_ 21 | #define RACE_PCT_PROFILER_HPP_ 22 | 23 | #include "core/basictypes.h" 24 | #include "pct/scheduler.hpp" 25 | #include "race/race.h" 26 | #include "race/djit.h" 27 | 28 | namespace race { 29 | 30 | class PctProfiler : public pct::Scheduler { 31 | public: 32 | PctProfiler() : race_db_(NULL), djit_analyzer_(NULL) {} 33 | ~PctProfiler() {} 34 | 35 | protected: 36 | void HandlePreSetup(); 37 | void HandlePostSetup(); 38 | bool HandleIgnoreMemAccess(IMG img); 39 | void HandleProgramExit(); 40 | 41 | RaceDB *race_db_; 42 | Djit *djit_analyzer_; 43 | 44 | private: 45 | DISALLOW_COPY_CONSTRUCTORS(PctProfiler); 46 | }; 47 | 48 | } // namespace race 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/race/pct_profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/pct_profiler_main.cpp - The main entrance of the PCT 18 | // profiler for data race detectors. 19 | 20 | #include "race/pct_profiler.hpp" 21 | 22 | MAIN_ENTRY(race::PctProfiler); 23 | -------------------------------------------------------------------------------- /src/race/profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/profiler.hpp - Define the profiler for data race detectors. 18 | 19 | #ifndef RACE_PROFILER_HPP_ 20 | #define RACE_PROFILER_HPP_ 21 | 22 | #include "core/basictypes.h" 23 | #include "core/execution_control.hpp" 24 | #include "race/race.h" 25 | #include "race/djit.h" 26 | 27 | namespace race { 28 | 29 | class Profiler : public ExecutionControl { 30 | public: 31 | Profiler() : race_db_(NULL), djit_analyzer_(NULL) {} 32 | ~Profiler() {} 33 | 34 | protected: 35 | void HandlePreSetup(); 36 | void HandlePostSetup(); 37 | bool HandleIgnoreMemAccess(IMG img); 38 | void HandleProgramExit(); 39 | 40 | RaceDB *race_db_; 41 | Djit *djit_analyzer_; 42 | 43 | private: 44 | DISALLOW_COPY_CONSTRUCTORS(Profiler); 45 | }; 46 | 47 | } // namespace race 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/race/profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: race/profiler_main.cpp - The main entrance of the profiler for 18 | // data race detectors. 19 | 20 | #include "race/profiler.hpp" 21 | 22 | MAIN_ENTRY(race::Profiler); 23 | -------------------------------------------------------------------------------- /src/race/race.proto: -------------------------------------------------------------------------------- 1 | package race; 2 | 3 | enum RaceEventType { 4 | RACE_EVENT_INVALID = 0; 5 | RACE_EVENT_READ = 1; 6 | RACE_EVENT_WRITE = 2; 7 | } 8 | 9 | message StaticRaceEventProto { 10 | required uint32 id = 1; 11 | required uint32 inst_id = 2; 12 | required RaceEventType type = 3; 13 | } 14 | 15 | message StaticRaceProto { 16 | required uint32 id = 1; 17 | repeated uint32 event_id = 2; 18 | } 19 | 20 | message RaceEventProto { 21 | required uint64 thd_id = 1; 22 | required uint32 static_id = 2; 23 | } 24 | 25 | message RaceProto { 26 | required uint32 exec_id = 1; 27 | required uint64 addr = 2; 28 | repeated RaceEventProto event = 3; 29 | required uint32 static_id = 4; 30 | } 31 | 32 | message RaceDBProto { 33 | repeated StaticRaceEventProto static_event = 1; 34 | repeated StaticRaceProto static_race = 2; 35 | repeated RaceProto race = 3; 36 | repeated uint32 racy_inst_id = 4; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/randsched/history.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: randsched/history.cc - Implementation of the Random scheduler history. 18 | 19 | #include "randsched/history.h" 20 | 21 | #include 22 | 23 | #include "core/logging.h" 24 | 25 | namespace randsched { 26 | 27 | unsigned long History::AvgInstCount() { 28 | double total = 0.0; 29 | int size = table_proto_.history_size(); 30 | for (int i = 0; i < size; i++) { 31 | total += (double)table_proto_.history(i).inst_count(); 32 | } 33 | return (unsigned long)(total / (double)size); 34 | } 35 | 36 | unsigned long History::AvgNumThreads() { 37 | double total = 0.0; 38 | int size = table_proto_.history_size(); 39 | for (int i = 0; i < size; i++) { 40 | total += (double)table_proto_.history(i).num_threads(); 41 | } 42 | return (unsigned long)(total / (double)size); 43 | } 44 | 45 | void History::Update(unsigned long inst_count, unsigned long num_threads) { 46 | HistoryProto *proto = table_proto_.add_history(); 47 | proto->set_inst_count(inst_count); 48 | proto->set_num_threads(num_threads); 49 | } 50 | 51 | void History::Load(const std::string &file_name) { 52 | std::fstream in(file_name.c_str(), std::ios::in | std::ios::binary); 53 | table_proto_.ParseFromIstream(&in); 54 | in.close(); 55 | } 56 | 57 | void History::Save(const std::string &file_name) { 58 | std::fstream out(file_name.c_str(), 59 | std::ios::out | std::ios::trunc | std::ios::binary); 60 | table_proto_.SerializeToOstream(&out); 61 | out.close(); 62 | } 63 | 64 | } // namespace randsched 65 | 66 | -------------------------------------------------------------------------------- /src/randsched/history.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: randsched/history.h - Define the Random scheduler history. 18 | 19 | #ifndef RANDSCHED_HISTORY_H_ 20 | #define RANDSCHED_HISTORY_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "randsched/history.pb.h" // protobuf head file 26 | 27 | namespace randsched { 28 | 29 | // Random scheduler history. 30 | class History { 31 | public: 32 | History() {} 33 | ~History() {} 34 | 35 | bool Empty() { return table_proto_.history_size() == 0; } 36 | unsigned long AvgInstCount(); 37 | unsigned long AvgNumThreads(); 38 | void Update(unsigned long length, unsigned long num_threads); 39 | void Load(const std::string &file_name); 40 | void Save(const std::string &file_name); 41 | 42 | private: 43 | HistoryTableProto table_proto_; 44 | 45 | DISALLOW_COPY_CONSTRUCTORS(History); 46 | }; 47 | 48 | } // namespace randsched 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /src/randsched/history.proto: -------------------------------------------------------------------------------- 1 | package randsched; 2 | 3 | message HistoryProto { 4 | required uint64 inst_count = 1; 5 | required uint64 num_threads = 2; 6 | } 7 | 8 | message HistoryTableProto { 9 | repeated HistoryProto history = 1; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/randsched/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for the randsched package 2 | 3 | protodefs += \ 4 | randsched/history.proto 5 | 6 | srcs += \ 7 | randsched/history.cc \ 8 | randsched/history.pb.cc \ 9 | randsched/scheduler.cpp \ 10 | randsched/scheduler_main.cpp 11 | 12 | pintools += \ 13 | randsched_scheduler.so 14 | 15 | randsched_scheduler_objs := \ 16 | randsched/history.o \ 17 | randsched/history.pb.o \ 18 | randsched/scheduler.o \ 19 | randsched/scheduler_main.o \ 20 | $(core_objs) 21 | 22 | randsched_objs := \ 23 | randsched/history.o \ 24 | randsched/history.pb.o \ 25 | randsched/scheduler.o 26 | 27 | -------------------------------------------------------------------------------- /src/randsched/scheduler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: randsched/scheduler_main.cpp - The main entrance of the Random scheduler. 18 | 19 | #include "randsched/scheduler.hpp" 20 | 21 | MAIN_ENTRY(randsched::Scheduler); 22 | -------------------------------------------------------------------------------- /src/sinst/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for the sinst package 2 | 3 | protodefs += \ 4 | sinst/sinst.proto 5 | 6 | srcs += \ 7 | sinst/analyzer.cc \ 8 | sinst/profiler.cpp \ 9 | sinst/profiler_main.cpp \ 10 | sinst/sinst.cc \ 11 | sinst/sinst.pb.cc 12 | 13 | pintools += \ 14 | sinst_profiler.so 15 | 16 | sinst_profiler_objs := \ 17 | sinst/analyzer.o \ 18 | sinst/profiler.o \ 19 | sinst/profiler_main.o \ 20 | sinst/sinst.o \ 21 | sinst/sinst.pb.o \ 22 | $(core_objs) 23 | 24 | sinst_objs := \ 25 | sinst/analyzer.o \ 26 | sinst/profiler.o \ 27 | sinst/sinst.o \ 28 | sinst/sinst.pb.o 29 | 30 | sinst_cmd_objs := \ 31 | sinst/analyzer.o \ 32 | sinst/sinst.o \ 33 | sinst/sinst.pb.o 34 | 35 | -------------------------------------------------------------------------------- /src/sinst/profiler.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: sinst/profiler.cpp - Implementation of the controller for 18 | // shared instruction profiler. 19 | 20 | #include "sinst/profiler.hpp" 21 | 22 | namespace sinst { 23 | 24 | void Profiler::HandlePreSetup() { 25 | ExecutionControl::HandlePreSetup(); 26 | 27 | knob_->RegisterStr("sinst_in", "the input shared inst database path", "sinst.db"); 28 | knob_->RegisterStr("sinst_out", "the output shared inst database path", "sinst.db"); 29 | 30 | sinst_analyzer_ = new SharedInstAnalyzer; 31 | sinst_analyzer_->Register(); 32 | } 33 | 34 | void Profiler::HandlePostSetup() { 35 | ExecutionControl::HandlePostSetup(); 36 | 37 | // load shared inst db 38 | sinst_db_ = new SharedInstDB(CreateMutex()); 39 | sinst_db_->Load(knob_->ValueStr("sinst_in"), sinfo_); 40 | // add sinst analyzer 41 | sinst_analyzer_->Setup(CreateMutex(), sinst_db_); 42 | AddAnalyzer(sinst_analyzer_); 43 | } 44 | 45 | void Profiler::HandleProgramExit() { 46 | ExecutionControl::HandleProgramExit(); 47 | 48 | if (sinst_analyzer_->Enabled()) { 49 | // save shared inst db 50 | sinst_db_->Save(knob_->ValueStr("sinst_out"), sinfo_); 51 | } 52 | } 53 | 54 | } // namespace sinst 55 | 56 | -------------------------------------------------------------------------------- /src/sinst/profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: sinst/profiler.hpp - Define the controller for shared instruction 18 | // profiler. A shared instruction is an instruction that might access a 19 | // shared location. 20 | 21 | #ifndef SINST_PROFILER_HPP_ 22 | #define SINST_PROFILER_HPP_ 23 | 24 | #include "core/basictypes.h" 25 | #include "core/execution_control.hpp" 26 | #include "sinst/sinst.h" 27 | #include "sinst/analyzer.h" 28 | 29 | namespace sinst { 30 | 31 | class Profiler : public ExecutionControl { 32 | public: 33 | Profiler() : sinst_db_(NULL), sinst_analyzer_(NULL) {} 34 | ~Profiler() {} 35 | 36 | private: 37 | void HandlePreSetup(); 38 | void HandlePostSetup(); 39 | void HandleProgramExit(); 40 | 41 | SharedInstDB *sinst_db_; 42 | SharedInstAnalyzer *sinst_analyzer_; 43 | 44 | DISALLOW_COPY_CONSTRUCTORS(Profiler); 45 | }; 46 | 47 | } // namespace sinst 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /src/sinst/profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: sinst/profiler_main.cpp - The main entrance of the shared 18 | // instruction profiler. 19 | 20 | #include "sinst/profiler.hpp" 21 | 22 | MAIN_ENTRY(sinst::Profiler); 23 | -------------------------------------------------------------------------------- /src/sinst/sinst.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: sinst/sinst.h - Define the shared instruction database. 18 | 19 | #ifndef SINST_SINST_H_ 20 | #define SINST_SINST_H_ 21 | 22 | #include 23 | 24 | #include "core/basictypes.h" 25 | #include "core/sync.h" 26 | #include "core/static_info.h" 27 | #include "sinst/sinst.pb.h" // protobuf head file 28 | 29 | namespace sinst { 30 | 31 | // Shared instruction database 32 | class SharedInstDB { 33 | public: 34 | SharedInstDB(Mutex *lock) : internal_lock_(lock) {} 35 | ~SharedInstDB() { delete internal_lock_; } 36 | 37 | bool Shared(Inst *inst) { return Shared(inst, true); } 38 | void SetShared(Inst *inst) { SetShared(inst, true); } 39 | bool Shared(Inst *inst, bool locking); 40 | void SetShared(Inst *inst, bool locking); 41 | void Load(const std::string &db_name, StaticInfo *sinfo); 42 | void Save(const std::string &db_name, StaticInfo *sinfo); 43 | 44 | private: 45 | typedef std::tr1::unordered_set SharedInstSet; 46 | 47 | Mutex *internal_lock_; 48 | SharedInstSet shared_inst_set_; 49 | SharedInstTableProto table_proto_; 50 | 51 | DISALLOW_COPY_CONSTRUCTORS(SharedInstDB); 52 | }; 53 | 54 | } // namespace sinst 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/sinst/sinst.proto: -------------------------------------------------------------------------------- 1 | package sinst; 2 | 3 | message SharedInstProto { 4 | required uint32 inst_id = 1; 5 | } 6 | 7 | message SharedInstTableProto { 8 | repeated SharedInstProto shared_inst = 1; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/systematic/chess.proto: -------------------------------------------------------------------------------- 1 | import "systematic/program.proto"; 2 | 3 | package systematic; 4 | 5 | message ChessPorProto { 6 | message VisitedStateProto { 7 | required uint32 hash_val = 1; 8 | required uint32 preemptions = 2; 9 | required uint32 exec_id = 3; 10 | required uint32 state_idx = 4; 11 | } 12 | required uint32 num_execs = 1; 13 | repeated VisitedStateProto visited_state = 2; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/systematic/controller_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: systematic/controller_main.cpp - The main entrance of the 18 | // systematic testing framework. 19 | 20 | #include "systematic/controller.hpp" 21 | 22 | MAIN_ENTRY(systematic::Controller); 23 | -------------------------------------------------------------------------------- /src/systematic/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for the systematic package 2 | 3 | protodefs += \ 4 | systematic/chess.proto \ 5 | systematic/program.proto \ 6 | systematic/search.proto 7 | 8 | srcs += \ 9 | systematic/chess.cc \ 10 | systematic/chess.pb.cc \ 11 | systematic/controller.cpp \ 12 | systematic/controller_main.cpp \ 13 | systematic/fair.cc \ 14 | systematic/program.cc \ 15 | systematic/program.pb.cc \ 16 | systematic/random.cc \ 17 | systematic/scheduler.cc \ 18 | systematic/search.cc \ 19 | systematic/search.pb.cc 20 | 21 | pintools += \ 22 | systematic_controller.so 23 | 24 | systematic_controller_objs := \ 25 | systematic/chess.o \ 26 | systematic/chess.pb.o \ 27 | systematic/controller.o \ 28 | systematic/controller_main.o \ 29 | systematic/fair.o \ 30 | systematic/program.o \ 31 | systematic/program.pb.o \ 32 | systematic/random.o \ 33 | systematic/scheduler.o \ 34 | systematic/search.o \ 35 | systematic/search.pb.o \ 36 | $(race_objs) \ 37 | $(core_objs) 38 | 39 | systematic_objs := \ 40 | systematic/chess.o \ 41 | systematic/chess.pb.o \ 42 | systematic/controller.o \ 43 | systematic/fair.o \ 44 | systematic/program.o \ 45 | systematic/program.pb.o \ 46 | systematic/random.o \ 47 | systematic/scheduler.o \ 48 | systematic/search.o \ 49 | systematic/search.pb.o 50 | 51 | -------------------------------------------------------------------------------- /src/systematic/program.proto: -------------------------------------------------------------------------------- 1 | package systematic; 2 | 3 | message ThreadProto { 4 | required uint32 uid = 1; 5 | optional uint32 creator_uid = 2; 6 | optional uint32 creator_idx = 3; 7 | } 8 | 9 | message SObjectProto { 10 | required uint32 uid = 1; 11 | required uint32 image_id = 2; 12 | required uint64 offset = 3; 13 | } 14 | 15 | message DObjectProto { 16 | required uint32 uid = 1; 17 | required uint32 creator_uid = 2; 18 | required uint32 creator_inst_id = 3; 19 | required uint32 creator_idx = 4; 20 | required uint64 offset = 5; 21 | } 22 | 23 | message ProgramProto { 24 | repeated ThreadProto thread = 1; 25 | repeated SObjectProto sobject = 2; 26 | repeated DObjectProto dobject = 3; 27 | } 28 | 29 | enum Operation { 30 | OP_INVALID = 0; 31 | OP_THREAD_START = 1; 32 | OP_THREAD_END = 2; 33 | OP_THREAD_CREATE = 3; 34 | OP_THREAD_JOIN = 4; 35 | OP_MUTEX_LOCK = 11; 36 | OP_MUTEX_UNLOCK = 12; 37 | OP_MUTEX_TRYLOCK = 13; 38 | OP_COND_WAIT = 21; 39 | OP_COND_SIGNAL = 22; 40 | OP_COND_BROADCAST = 23; 41 | OP_COND_TIMEDWAIT = 24; 42 | OP_BARRIER_INIT = 31; 43 | OP_BARRIER_WAIT = 32; 44 | OP_MEM_READ = 41; 45 | OP_MEM_WRITE = 42; 46 | OP_SLEEP = 51; 47 | OP_USLEEP = 52; 48 | OP_NANOSLEEP = 53; 49 | OP_SCHED_YIELD = 54; 50 | } 51 | 52 | message ActionProto { 53 | required uint32 thd_uid = 1; 54 | optional uint32 obj_uid = 2; 55 | required Operation op = 3; 56 | optional uint32 inst_id = 4; 57 | optional uint64 tc = 5; 58 | optional uint64 oc = 6; 59 | optional bool yield = 7; 60 | } 61 | 62 | message StateProto { 63 | repeated uint32 enabled = 1; 64 | optional uint32 taken = 2; 65 | } 66 | 67 | message ExecutionProto { 68 | repeated ActionProto action = 1; 69 | repeated StateProto state = 2; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/systematic/random.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: systematic/random.h - The definition of the random scheduler 18 | // which picks a random thread to run at each schedule point. 19 | 20 | #ifndef SYSTEMATIC_RANDOM_H_ 21 | #define SYSTEMATIC_RANDOM_H_ 22 | 23 | #include "core/basictypes.h" 24 | #include "systematic/scheduler.h" 25 | 26 | namespace systematic { 27 | 28 | class RandomScheduler : public Scheduler { 29 | public: 30 | explicit RandomScheduler(ControllerInterface *controller); 31 | ~RandomScheduler(); 32 | 33 | // overrided virtual functions 34 | void Register(); 35 | bool Enabled(); 36 | void Setup(); 37 | void ProgramStart(); 38 | void ProgramExit(); 39 | void Explore(State *init_state); 40 | 41 | protected: 42 | // helper functions 43 | bool RandomChoice(double true_rate); 44 | Action *PickNextRandom(State *state); 45 | 46 | private: 47 | DISALLOW_COPY_CONSTRUCTORS(RandomScheduler); 48 | }; 49 | 50 | } // namespace systematic 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /src/systematic/search.proto: -------------------------------------------------------------------------------- 1 | import "systematic/program.proto"; 2 | 3 | package systematic; 4 | 5 | message ActionInfoProto { 6 | required uint32 thd_uid = 1; 7 | optional uint32 obj_uid = 2; 8 | required Operation op = 3; 9 | optional uint32 inst_id = 4; 10 | } 11 | 12 | message SearchNodeProto { 13 | required uint32 sel = 1; 14 | repeated uint32 backtrack = 2; 15 | repeated uint32 done = 3; 16 | repeated ActionInfoProto enabled = 4; 17 | } 18 | 19 | message SearchInfoProto { 20 | required bool done = 1; 21 | required uint32 num_runs = 2; 22 | repeated SearchNodeProto node = 3; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/tracer/loader_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: tracer/loader_main.cc - Tha main entrance of the trace loader. 18 | 19 | #include "tracer/loader.h" 20 | 21 | static tracer::Loader *loader = new tracer::Loader; 22 | 23 | int main(int argc, char *argv[]) { 24 | loader->Initialize(); 25 | loader->PreSetup(); 26 | loader->Parse(argc, argv); 27 | loader->PostSetup(); 28 | loader->Start(); 29 | loader->Exit(); 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/tracer/package.mk: -------------------------------------------------------------------------------- 1 | # Rules for the tracer package 2 | 3 | protodefs += \ 4 | tracer/log.proto 5 | 6 | srcs += \ 7 | tracer/loader.cc \ 8 | tracer/loader_main.cc \ 9 | tracer/log.cc \ 10 | tracer/log.pb.cc \ 11 | tracer/profiler.cpp \ 12 | tracer/profiler_main.cpp \ 13 | tracer/recorder.cc 14 | 15 | pintools += \ 16 | tracer_profiler.so 17 | 18 | cmdtools += \ 19 | tracer_loader 20 | 21 | tracer_profiler_objs := \ 22 | tracer/log.o \ 23 | tracer/log.pb.o \ 24 | tracer/profiler.o \ 25 | tracer/profiler_main.o \ 26 | tracer/recorder.o \ 27 | $(core_objs) 28 | 29 | tracer_loader_objs := \ 30 | tracer/loader.o \ 31 | tracer/loader_main.o \ 32 | tracer/log.o \ 33 | tracer/log.pb.o \ 34 | $(core_cmd_objs) 35 | 36 | tracer_objs := \ 37 | tracer/loader.o \ 38 | tracer/log.o \ 39 | tracer/log.pb.o \ 40 | tracer/profiler.o \ 41 | tracer/recorder.o 42 | 43 | tracer_cmd_objs := \ 44 | tracer/loader.o \ 45 | tracer/log.o \ 46 | tracer/log.pb.o 47 | 48 | -------------------------------------------------------------------------------- /src/tracer/profiler.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: tracer/profiler.cpp - Implementation of the tracer online 18 | // profiler. 19 | 20 | #include "tracer/profiler.hpp" 21 | 22 | #include "tracer/log.h" 23 | #include "tracer/recorder.h" 24 | 25 | namespace tracer { 26 | 27 | void Profiler::HandlePreSetup() { 28 | ExecutionControl::HandlePreSetup(); 29 | 30 | knob_->RegisterBool("ignore_ic_pthread", "do not count instructions in pthread", "1"); 31 | knob_->RegisterBool("ignore_lib", "whether ignore accesses from common libraries", "0"); 32 | 33 | recorder_ = new RecorderAnalyzer; 34 | recorder_->Register(); 35 | } 36 | 37 | void Profiler::HandlePostSetup() { 38 | ExecutionControl::HandlePostSetup(); 39 | 40 | // add record analyzer 41 | recorder_->Setup(CreateMutex()); 42 | AddAnalyzer(recorder_); 43 | } 44 | 45 | bool Profiler::HandleIgnoreInstCount(IMG img) { 46 | if (knob_->ValueBool("ignore_ic_pthread")) { 47 | if (!IMG_Valid(img)) 48 | return false; 49 | Image *image = sinfo_->FindImage(IMG_Name(img)); 50 | DEBUG_ASSERT(image); 51 | if (image->IsPthread()) 52 | return true; 53 | } 54 | return false; 55 | } 56 | 57 | bool Profiler::HandleIgnoreMemAccess(IMG img) { 58 | if (!IMG_Valid(img)) 59 | return true; 60 | Image *image = sinfo_->FindImage(IMG_Name(img)); 61 | DEBUG_ASSERT(image); 62 | if (image->IsPthread()) 63 | return true; 64 | if (knob_->ValueBool("ignore_lib")) { 65 | if (image->IsCommonLib()) 66 | return true; 67 | } 68 | return false; 69 | } 70 | 71 | } // namespace tracer 72 | 73 | -------------------------------------------------------------------------------- /src/tracer/profiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: tracer/profiler.hpp - Define tracer online profiler. 18 | 19 | #ifndef TRACER_PROFILER_HPP_ 20 | #define TRACER_PROFILER_HPP_ 21 | 22 | #include "core/basictypes.h" 23 | #include "core/execution_control.hpp" 24 | #include "tracer/recorder.h" 25 | 26 | namespace tracer { 27 | 28 | class TraceLog; 29 | 30 | class Profiler : public ExecutionControl { 31 | public: 32 | Profiler() : recorder_(NULL) {} 33 | ~Profiler() {} 34 | 35 | private: 36 | void HandlePreSetup(); 37 | void HandlePostSetup(); 38 | bool HandleIgnoreInstCount(IMG img); 39 | bool HandleIgnoreMemAccess(IMG img); 40 | 41 | RecorderAnalyzer *recorder_; 42 | 43 | DISALLOW_COPY_CONSTRUCTORS(Profiler); 44 | }; 45 | 46 | } // namespace tracer 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/tracer/profiler_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | // File: tracer/profiler_main.cpp - The main entrance of the tracer 18 | // profiler. 19 | 20 | #include "tracer/profiler.hpp" 21 | 22 | MAIN_ENTRY(tracer::Profiler); 23 | -------------------------------------------------------------------------------- /test/idiom/observer/mem_idiom1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | pthread_barrier_t barrier; 24 | 25 | void *thread0(void *arg) { 26 | pthread_barrier_wait(&barrier); 27 | printf("counter=%d\n", counter); 28 | printf("counter=%d\n", counter); 29 | pthread_barrier_wait(&barrier); 30 | pthread_barrier_wait(&barrier); 31 | return NULL; 32 | } 33 | 34 | void *thread1(void *arg) { 35 | counter = 10; 36 | pthread_barrier_wait(&barrier); 37 | printf("counter=%d\n", counter); 38 | pthread_barrier_wait(&barrier); 39 | counter = 20; 40 | pthread_barrier_wait(&barrier); 41 | return NULL; 42 | } 43 | 44 | void *thread2(void *arg) { 45 | pthread_barrier_wait(&barrier); 46 | printf("counter=%d\n", counter); 47 | pthread_barrier_wait(&barrier); 48 | pthread_barrier_wait(&barrier); 49 | counter = 300; 50 | return NULL; 51 | } 52 | 53 | int main(int argc, char *argv[]) { 54 | pthread_t tids[3]; 55 | pthread_barrier_init(&barrier, NULL, 3); 56 | pthread_create(&tids[0], NULL, thread0, NULL); 57 | pthread_create(&tids[1], NULL, thread1, NULL); 58 | pthread_create(&tids[2], NULL, thread2, NULL); 59 | pthread_join(tids[0], NULL); 60 | pthread_join(tids[1], NULL); 61 | pthread_join(tids[2], NULL); 62 | return 0; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /test/idiom/observer/mem_idiom4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | int counter2 = 0; 24 | pthread_barrier_t barrier; 25 | 26 | void *thread0(void *arg) { 27 | counter = 1; 28 | pthread_barrier_wait(&barrier); 29 | pthread_barrier_wait(&barrier); 30 | counter2 = 2; 31 | counter = 3; 32 | return NULL; 33 | } 34 | 35 | void *thread1(void *arg) { 36 | pthread_barrier_wait(&barrier); 37 | counter = 10; 38 | counter2 = 20; 39 | counter = 30; 40 | pthread_barrier_wait(&barrier); 41 | return NULL; 42 | } 43 | 44 | int main(int argc, char *argv[]) { 45 | pthread_t tids[2]; 46 | pthread_barrier_init(&barrier, NULL, 2); 47 | pthread_create(&tids[0], NULL, thread0, NULL); 48 | pthread_create(&tids[1], NULL, thread1, NULL); 49 | pthread_join(tids[0], NULL); 50 | pthread_join(tids[1], NULL); 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /test/idiom/observer/sync_idiom1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | pthread_barrier_t barrier; 23 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 24 | 25 | void *thread0(void *arg) { 26 | int res; 27 | res = pthread_mutex_lock(&mutex); 28 | res = pthread_mutex_unlock(&mutex); 29 | pthread_barrier_wait(&barrier); 30 | pthread_barrier_wait(&barrier); 31 | res = pthread_mutex_lock(&mutex); 32 | res = pthread_mutex_unlock(&mutex); 33 | return NULL; 34 | } 35 | 36 | void *thread1(void *arg) { 37 | int res; 38 | pthread_barrier_wait(&barrier); 39 | res = pthread_mutex_lock(&mutex); 40 | res = pthread_mutex_unlock(&mutex); 41 | pthread_barrier_wait(&barrier); 42 | return NULL; 43 | } 44 | 45 | int main(int argc, char *argv[]) { 46 | pthread_t tids[2]; 47 | pthread_barrier_init(&barrier, NULL, 2); 48 | pthread_create(&tids[0], NULL, thread0, NULL); 49 | pthread_create(&tids[1], NULL, thread1, NULL); 50 | pthread_join(tids[0], NULL); 51 | pthread_join(tids[1], NULL); 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /test/idiom/observer/sync_idiom4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | pthread_barrier_t barrier; 23 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 24 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 25 | 26 | void *thread0(void *arg) { 27 | int res; 28 | res = pthread_mutex_lock(&mutex); 29 | res = pthread_mutex_unlock(&mutex); 30 | pthread_barrier_wait(&barrier); 31 | pthread_barrier_wait(&barrier); 32 | res = pthread_mutex_lock(&mutex2); 33 | res = pthread_mutex_unlock(&mutex2); 34 | return NULL; 35 | } 36 | 37 | void *thread1(void *arg) { 38 | int res; 39 | pthread_barrier_wait(&barrier); 40 | res = pthread_mutex_lock(&mutex); 41 | res = pthread_mutex_unlock(&mutex); 42 | res = pthread_mutex_lock(&mutex2); 43 | res = pthread_mutex_unlock(&mutex2); 44 | pthread_barrier_wait(&barrier); 45 | return NULL; 46 | } 47 | 48 | int main(int argc, char *argv[]) { 49 | pthread_t tids[2]; 50 | pthread_barrier_init(&barrier, NULL, 2); 51 | pthread_create(&tids[0], NULL, thread0, NULL); 52 | pthread_create(&tids[1], NULL, thread1, NULL); 53 | pthread_join(tids[0], NULL); 54 | pthread_join(tids[1], NULL); 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /test/idiom/predictor/atomic_inst.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | int counter = 0; 25 | 26 | void *thread(void *arg) { 27 | __sync_fetch_and_add(&counter, 1); 28 | return NULL; 29 | } 30 | 31 | int main(int argc, char *argv[]) { 32 | pthread_t tids[NUM_THREADS]; 33 | __sync_fetch_and_add(&counter, 1); 34 | for (int i = 0; i < NUM_THREADS; i++) { 35 | pthread_create(&tids[i], NULL, thread, NULL); 36 | } 37 | for (int i = 0; i < NUM_THREADS; i++) { 38 | pthread_join(tids[i], NULL); 39 | } 40 | __sync_fetch_and_add(&counter, 1); 41 | return 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /test/idiom/predictor/cond.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | bool signaled = false; 23 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 24 | pthread_cond_t cond = PTHREAD_COND_INITIALIZER; 25 | 26 | void *thread0(void *arg) { 27 | int res; 28 | res = pthread_mutex_lock(&mutex); 29 | if (!signaled) 30 | res = pthread_cond_wait(&cond, &mutex); 31 | res = pthread_mutex_unlock(&mutex); 32 | return NULL; 33 | } 34 | 35 | void *thread1(void *arg) { 36 | int res; 37 | res = pthread_mutex_lock(&mutex); 38 | res = pthread_cond_signal(&cond); 39 | signaled = true; 40 | res = pthread_mutex_unlock(&mutex); 41 | return NULL; 42 | } 43 | 44 | int main(int argc, char *argv[]) { 45 | pthread_t tids[2]; 46 | pthread_create(&tids[0], NULL, thread0, NULL); 47 | pthread_create(&tids[1], NULL, thread1, NULL); 48 | pthread_join(tids[0], NULL); 49 | pthread_join(tids[1], NULL); 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test/idiom/predictor/cond2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | bool signaled = false; 23 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 24 | pthread_cond_t cond = PTHREAD_COND_INITIALIZER; 25 | 26 | void *thread0(void *arg) { 27 | int res; 28 | res = pthread_mutex_lock(&mutex); 29 | if (!signaled) 30 | res = pthread_cond_wait(&cond, &mutex); 31 | res = pthread_mutex_unlock(&mutex); 32 | return NULL; 33 | } 34 | 35 | void *thread1(void *arg) { 36 | int res; 37 | res = pthread_mutex_lock(&mutex); 38 | if (!signaled) 39 | res = pthread_cond_wait(&cond, &mutex); 40 | res = pthread_mutex_unlock(&mutex); 41 | return NULL; 42 | } 43 | 44 | void *thread2(void *arg) { 45 | int res; 46 | res = pthread_mutex_lock(&mutex); 47 | res = pthread_cond_signal(&cond); 48 | res = pthread_cond_broadcast(&cond); 49 | signaled = true; 50 | res = pthread_mutex_unlock(&mutex); 51 | return NULL; 52 | } 53 | 54 | int main(int argc, char *argv[]) { 55 | pthread_t tids[3]; 56 | pthread_create(&tids[0], NULL, thread0, NULL); 57 | pthread_create(&tids[1], NULL, thread1, NULL); 58 | pthread_create(&tids[2], NULL, thread2, NULL); 59 | pthread_join(tids[0], NULL); 60 | pthread_join(tids[1], NULL); 61 | pthread_join(tids[2], NULL); 62 | return 0; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /test/idiom/predictor/deadlock.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 23 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 24 | 25 | void foo() { 26 | for (int i = 0; i < 200; i++) ; 27 | } 28 | 29 | void *thread(void *arg) { 30 | int res; 31 | printf("thread\n"); 32 | res = pthread_mutex_lock(&mutex); 33 | res = pthread_mutex_lock(&mutex2); 34 | foo(); 35 | res = pthread_mutex_unlock(&mutex2); 36 | res = pthread_mutex_unlock(&mutex); 37 | return NULL; 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | pthread_t tid; 42 | pthread_create(&tid, NULL, thread, NULL); 43 | int res; 44 | res = pthread_mutex_lock(&mutex2); 45 | res = pthread_mutex_lock(&mutex); 46 | foo(); 47 | res = pthread_mutex_unlock(&mutex); 48 | res = pthread_mutex_unlock(&mutex2); 49 | pthread_join(tid, NULL); 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test/idiom/predictor/hb_filter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | pthread_barrier_t barrier; 24 | 25 | void *thread0(void *arg) { 26 | counter = 1; 27 | pthread_barrier_wait(&barrier); 28 | pthread_barrier_wait(&barrier); 29 | return NULL; 30 | } 31 | 32 | void *thread1(void *arg) { 33 | pthread_barrier_wait(&barrier); 34 | counter = 20; 35 | pthread_barrier_wait(&barrier); 36 | return NULL; 37 | } 38 | 39 | void *thread2(void *arg) { 40 | pthread_barrier_wait(&barrier); 41 | pthread_barrier_wait(&barrier); 42 | counter = 300; 43 | return NULL; 44 | } 45 | 46 | int main(int argc, char *argv[]) { 47 | pthread_t tids[3]; 48 | pthread_barrier_init(&barrier, NULL, 3); 49 | pthread_create(&tids[0], NULL, thread0, NULL); 50 | pthread_create(&tids[1], NULL, thread1, NULL); 51 | pthread_create(&tids[2], NULL, thread2, NULL); 52 | pthread_join(tids[0], NULL); 53 | pthread_join(tids[1], NULL); 54 | pthread_join(tids[2], NULL); 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /test/idiom/predictor/hb_filter2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | pthread_barrier_t barrier; 24 | 25 | void *thread0(void *arg) { 26 | counter = 1; 27 | pthread_barrier_wait(&barrier); 28 | counter = 2; 29 | counter = 3; 30 | return NULL; 31 | } 32 | 33 | void *thread1(void *arg) { 34 | counter = 10; 35 | pthread_barrier_wait(&barrier); 36 | return NULL; 37 | } 38 | 39 | int main(int argc, char *argv[]) { 40 | pthread_t tids[2]; 41 | pthread_barrier_init(&barrier, NULL, 2); 42 | pthread_create(&tids[0], NULL, thread0, NULL); 43 | pthread_create(&tids[1], NULL, thread1, NULL); 44 | pthread_join(tids[0], NULL); 45 | pthread_join(tids[1], NULL); 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /test/idiom/predictor/libc_lock.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | int counter = 0; 25 | 26 | void *thread(void *arg) { 27 | printf("hello world\n"); 28 | return NULL; 29 | } 30 | 31 | int main(int argc, char *argv[]) { 32 | pthread_t tids[NUM_THREADS]; 33 | for (int i = 0; i < NUM_THREADS; i++) { 34 | pthread_create(&tids[i], NULL, thread, NULL); 35 | } 36 | for (int i = 0; i < NUM_THREADS; i++) { 37 | pthread_join(tids[i], NULL); 38 | } 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /test/idiom/predictor/libc_lock.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.idiom import iroot 21 | from maple.idiom import memo 22 | from maple.regression import common 23 | 24 | """ 25 | Expected Results (predicted iroots): 26 | ------------------------------------ 27 | We should not predict more than 45 iroots. 28 | """ 29 | 30 | def source_name(): 31 | return __name__ + common.cxx_ext() 32 | 33 | def setup_profiler(profiler): 34 | pass 35 | 36 | def setup_testcase(testcase): 37 | testcase.threshold = 2 38 | 39 | def verify(profiler, testcase): 40 | sinfo = static_info.StaticInfo() 41 | sinfo.load(profiler.knobs['sinfo_out']) 42 | iroot_db = iroot.iRootDB(sinfo) 43 | iroot_db.load(profiler.knobs['iroot_out']) 44 | if len(iroot_db.iroot_map) >= 45: 45 | logging.msg('iroot_db size mismatch\n') 46 | return False 47 | return True 48 | 49 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | int counter; 25 | 26 | void *thread(void *arg) { 27 | counter += 10; 28 | return NULL; 29 | } 30 | 31 | int main(int argc, char *argv[]) { 32 | pthread_t tids[NUM_THREADS]; 33 | counter = 0; 34 | for (int i = 0; i < NUM_THREADS; i++) { 35 | pthread_create(&tids[i], NULL, thread, NULL); 36 | } 37 | for (int i = 0; i < NUM_THREADS; i++) { 38 | pthread_join(tids[i], NULL); 39 | } 40 | assert(counter == 10 * NUM_THREADS); 41 | return 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | pthread_barrier_t barrier; 24 | 25 | void *thread0(void *arg) { 26 | counter = 1; 27 | pthread_barrier_wait(&barrier); 28 | pthread_barrier_wait(&barrier); 29 | counter = 3; 30 | return NULL; 31 | } 32 | 33 | void *thread1(void *arg) { 34 | pthread_barrier_wait(&barrier); 35 | counter = 10; 36 | counter = 30; 37 | pthread_barrier_wait(&barrier); 38 | return NULL; 39 | } 40 | 41 | int main(int argc, char *argv[]) { 42 | pthread_t tids[2]; 43 | pthread_barrier_init(&barrier, NULL, 2); 44 | pthread_create(&tids[0], NULL, thread0, NULL); 45 | pthread_create(&tids[1], NULL, thread1, NULL); 46 | pthread_join(tids[0], NULL); 47 | pthread_join(tids[1], NULL); 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | int counter = 0; 25 | int counter2 = 0; 26 | 27 | void *thread(void *arg) { 28 | counter = 10; 29 | counter2 = 20; 30 | return NULL; 31 | } 32 | 33 | int main(int argc, char *argv[]) { 34 | pthread_t tids[NUM_THREADS]; 35 | for (int i = 0; i < NUM_THREADS; i++) { 36 | pthread_create(&tids[i], NULL, thread, NULL); 37 | } 38 | for (int i = 0; i < NUM_THREADS; i++) { 39 | pthread_join(tids[i], NULL); 40 | } 41 | return 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom4_vw.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | int counter = 0; 25 | int counter2 = 0; 26 | 27 | void foo() { 28 | for (int i = 0; i < 100; i++) ; 29 | } 30 | 31 | void *thread(void *arg) { 32 | counter = 10; 33 | foo(); 34 | counter2 = 20; 35 | return NULL; 36 | } 37 | 38 | int main(int argc, char *argv[]) { 39 | pthread_t tids[NUM_THREADS]; 40 | for (int i = 0; i < NUM_THREADS; i++) { 41 | pthread_create(&tids[i], NULL, thread, NULL); 42 | } 43 | for (int i = 0; i < NUM_THREADS; i++) { 44 | pthread_join(tids[i], NULL); 45 | } 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom4_vw.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.idiom import iroot 21 | from maple.idiom import memo 22 | from maple.regression import common 23 | 24 | """ 25 | Expected Results (predicted iroots): 26 | ------------------------------------ 27 | 1 IDIOM_1 28 | e0: WRITE [51 target 0x61e mem_idiom4_vw.cc +32] 29 | e1: WRITE [51 target 0x61e mem_idiom4_vw.cc +32] 30 | 2 IDIOM_1 31 | e0: WRITE [52 target 0x62d mem_idiom4_vw.cc +34] 32 | e1: WRITE [52 target 0x62d mem_idiom4_vw.cc +34] 33 | 34 | (We should not predict any idiom4 iroot because of vw) 35 | """ 36 | 37 | def source_name(): 38 | return __name__ + common.cxx_ext() 39 | 40 | def setup_profiler(profiler): 41 | profiler.knobs['ignore_lib'] = True 42 | profiler.knobs['complex_idioms'] = True 43 | profiler.knobs['vw'] = 50 44 | 45 | def setup_testcase(testcase): 46 | testcase.threshold = 2 47 | 48 | def verify(profiler, testcase): 49 | sinfo = static_info.StaticInfo() 50 | sinfo.load(profiler.knobs['sinfo_out']) 51 | iroot_db = iroot.iRootDB(sinfo) 52 | iroot_db.load(profiler.knobs['iroot_out']) 53 | for r in iroot_db.iroot_map.itervalues(): 54 | if r.idiom() == 4: 55 | logging.msg('idiom4 iroot should not be predicted\n') 56 | return False 57 | return True 58 | 59 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom5.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | int counter2 = 0; 24 | 25 | void foo(int n) { 26 | for (int i = 0; i < n; i++) ; 27 | } 28 | 29 | void *thread0(void *arg) { 30 | counter = 1; 31 | counter2 = 2; 32 | return NULL; 33 | } 34 | 35 | void *thread1(void *arg) { 36 | counter2 = 10; 37 | foo(2000); 38 | counter = 20; 39 | return NULL; 40 | } 41 | 42 | int main(int argc, char *argv[]) { 43 | pthread_t tids[2]; 44 | pthread_create(&tids[0], NULL, thread0, NULL); 45 | pthread_create(&tids[1], NULL, thread1, NULL); 46 | pthread_join(tids[0], NULL); 47 | pthread_join(tids[1], NULL); 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /test/idiom/predictor/mem_idiom5.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.idiom import iroot 21 | from maple.idiom import memo 22 | from maple.regression import common 23 | 24 | """ 25 | Expected Results (predicted iroots): 26 | ------------------------------------ 27 | We should not predict any idiom5 iroot. 28 | """ 29 | 30 | def source_name(): 31 | return __name__ + common.cxx_ext() 32 | 33 | def setup_profiler(profiler): 34 | profiler.knobs['ignore_lib'] = True 35 | profiler.knobs['complex_idioms'] = True 36 | profiler.knobs['vw'] = 1000 37 | 38 | def setup_testcase(testcase): 39 | testcase.threshold = 2 40 | 41 | def verify(profiler, testcase): 42 | sinfo = static_info.StaticInfo() 43 | sinfo.load(profiler.knobs['sinfo_out']) 44 | iroot_db = iroot.iRootDB(sinfo) 45 | iroot_db.load(profiler.knobs['iroot_out']) 46 | for r in iroot_db.iroot_map.itervalues(): 47 | if r.idiom() == 5: 48 | logging.msg('idiom5 iroot should not be predicted\n') 49 | return False 50 | return True 51 | 52 | -------------------------------------------------------------------------------- /test/idiom/predictor/mutex_filter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | int counter = 0; 25 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 26 | 27 | void *thread(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&mutex); 30 | counter += 10; 31 | res = pthread_mutex_unlock(&mutex); 32 | return NULL; 33 | } 34 | 35 | int main(int argc, char *argv[]) { 36 | pthread_t tids[NUM_THREADS]; 37 | for (int i = 0; i < NUM_THREADS; i++) { 38 | pthread_create(&tids[i], NULL, thread, NULL); 39 | } 40 | for (int i = 0; i < NUM_THREADS; i++) { 41 | pthread_join(tids[i], NULL); 42 | } 43 | return 0; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /test/idiom/predictor/mutex_filter2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_mutex_t big_mutex = PTHREAD_MUTEX_INITIALIZER; 26 | 27 | void *thread(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&big_mutex); 30 | res = pthread_mutex_lock(&mutex); 31 | res = pthread_mutex_unlock(&mutex); 32 | res = pthread_mutex_lock(&mutex); 33 | res = pthread_mutex_unlock(&mutex); 34 | res = pthread_mutex_unlock(&big_mutex); 35 | return NULL; 36 | } 37 | 38 | int main(int argc, char *argv[]) { 39 | pthread_t tids[NUM_THREADS]; 40 | for (int i = 0; i < NUM_THREADS; i++) { 41 | pthread_create(&tids[i], NULL, thread, NULL); 42 | } 43 | for (int i = 0; i < NUM_THREADS; i++) { 44 | pthread_join(tids[i], NULL); 45 | } 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /test/idiom/predictor/mutex_filter3.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 25 | 26 | void *thread(void *arg) { 27 | int res; 28 | res = pthread_mutex_lock(&mutex); 29 | printf("hello world\n"); 30 | res = pthread_mutex_unlock(&mutex); 31 | return NULL; 32 | } 33 | 34 | int main(int argc, char *argv[]) { 35 | pthread_t tids[NUM_THREADS]; 36 | for (int i = 0; i < NUM_THREADS; i++) { 37 | pthread_create(&tids[i], NULL, thread, NULL); 38 | } 39 | for (int i = 0; i < NUM_THREADS; i++) { 40 | pthread_join(tids[i], NULL); 41 | } 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /test/idiom/predictor/mutex_filter3.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.idiom import iroot 21 | from maple.idiom import memo 22 | from maple.regression import common 23 | 24 | """ 25 | Expected Results (predicted iroots): 26 | ------------------------------------ 27 | We should not predict more than 40 iroots. 28 | """ 29 | 30 | def source_name(): 31 | return __name__ + common.cxx_ext() 32 | 33 | def setup_profiler(profiler): 34 | pass 35 | 36 | def setup_testcase(testcase): 37 | testcase.threshold = 2 38 | 39 | def verify(profiler, testcase): 40 | sinfo = static_info.StaticInfo() 41 | sinfo.load(profiler.knobs['sinfo_out']) 42 | iroot_db = iroot.iRootDB(sinfo) 43 | iroot_db.load(profiler.knobs['iroot_out']) 44 | if len(iroot_db.iroot_map) >= 40: 45 | logging.msg('iroot_db size mismatch\n') 46 | return False 47 | return True 48 | 49 | -------------------------------------------------------------------------------- /test/idiom/predictor/mutex_filter_multivar.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | int counter = 0; 23 | int counter2 = 0; 24 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 25 | 26 | void *thread0(void *arg) { 27 | int res; 28 | res = pthread_mutex_lock(&mutex); 29 | counter = 1; 30 | counter2 = 2; 31 | res = pthread_mutex_unlock(&mutex); 32 | return NULL; 33 | } 34 | 35 | void *thread1(void *arg) { 36 | int res; 37 | counter = 10; 38 | res = pthread_mutex_lock(&mutex); 39 | counter2 = 20; 40 | res = pthread_mutex_unlock(&mutex); 41 | return NULL; 42 | } 43 | 44 | int main(int argc, char *argv[]) { 45 | pthread_t tids[2]; 46 | pthread_create(&tids[0], NULL, thread0, NULL); 47 | pthread_create(&tids[1], NULL, thread1, NULL); 48 | pthread_join(tids[0], NULL); 49 | pthread_join(tids[1], NULL); 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test/idiom/predictor/sync_idiom1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 26 | 27 | void *thread(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&mutex); 30 | res = pthread_mutex_unlock(&mutex); 31 | res = pthread_mutex_lock(&mutex2); 32 | res = pthread_mutex_unlock(&mutex2); 33 | res = pthread_mutex_lock(&mutex); 34 | res = pthread_mutex_unlock(&mutex); 35 | res = pthread_mutex_lock(&mutex2); 36 | res = pthread_mutex_unlock(&mutex2); 37 | return NULL; 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | pthread_t tids[NUM_THREADS]; 42 | int res; 43 | res = pthread_mutex_lock(&mutex); 44 | res = pthread_mutex_unlock(&mutex); 45 | res = pthread_mutex_lock(&mutex2); 46 | res = pthread_mutex_unlock(&mutex2); 47 | for (int i = 0; i < NUM_THREADS; i++) { 48 | pthread_create(&tids[i], NULL, thread, NULL); 49 | } 50 | for (int i = 0; i < NUM_THREADS; i++) { 51 | pthread_join(tids[i], NULL); 52 | } 53 | res = pthread_mutex_lock(&mutex); 54 | res = pthread_mutex_unlock(&mutex); 55 | res = pthread_mutex_lock(&mutex2); 56 | res = pthread_mutex_unlock(&mutex2); 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /test/idiom/predictor/sync_idiom4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 26 | 27 | void *thread(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&mutex); 30 | res = pthread_mutex_unlock(&mutex); 31 | res = pthread_mutex_lock(&mutex2); 32 | res = pthread_mutex_unlock(&mutex2); 33 | res = pthread_mutex_lock(&mutex); 34 | res = pthread_mutex_unlock(&mutex); 35 | res = pthread_mutex_lock(&mutex2); 36 | res = pthread_mutex_unlock(&mutex2); 37 | return NULL; 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | pthread_t tids[NUM_THREADS]; 42 | for (int i = 0; i < NUM_THREADS; i++) { 43 | pthread_create(&tids[i], NULL, thread, NULL); 44 | } 45 | for (int i = 0; i < NUM_THREADS; i++) { 46 | pthread_join(tids[i], NULL); 47 | } 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /test/systematic/chess/barrier.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_barrier_t barrier; 25 | 26 | void *thread0(void *arg) { 27 | int res; 28 | res = pthread_barrier_wait(&barrier); 29 | res = pthread_barrier_wait(&barrier); 30 | return NULL; 31 | } 32 | 33 | void *thread1(void *arg) { 34 | int res; 35 | res = pthread_barrier_wait(&barrier); 36 | res = pthread_barrier_wait(&barrier); 37 | return NULL; 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | pthread_t tids[NUM_THREADS]; 42 | pthread_barrier_init(&barrier, NULL, 2); 43 | pthread_create(&tids[0], NULL, thread0, NULL); 44 | pthread_create(&tids[1], NULL, thread1, NULL); 45 | pthread_join(tids[0], NULL); 46 | pthread_join(tids[1], NULL); 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /test/systematic/chess/barrier.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 6: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/cond.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | bool signaled = false; 25 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 26 | pthread_cond_t cond0 = PTHREAD_COND_INITIALIZER; 27 | 28 | void *thread0(void *arg) { 29 | int res; 30 | res = pthread_mutex_lock(&mutex0); 31 | if (!signaled) 32 | res = pthread_cond_wait(&cond0, &mutex0); 33 | res = pthread_mutex_unlock(&mutex0); 34 | return NULL; 35 | } 36 | 37 | void *thread1(void *arg) { 38 | int res; 39 | res = pthread_mutex_lock(&mutex0); 40 | res = pthread_cond_signal(&cond0); 41 | signaled = true; 42 | res = pthread_mutex_unlock(&mutex0); 43 | return NULL; 44 | } 45 | 46 | int main(int argc, char *argv[]) { 47 | pthread_t tids[NUM_THREADS]; 48 | pthread_create(&tids[0], NULL, thread0, NULL); 49 | pthread_create(&tids[1], NULL, thread1, NULL); 50 | pthread_join(tids[0], NULL); 51 | pthread_join(tids[1], NULL); 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /test/systematic/chess/cond.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 4: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/cond2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 3 23 | 24 | bool signaled = false; 25 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 26 | pthread_cond_t cond0 = PTHREAD_COND_INITIALIZER; 27 | 28 | void *thread0(void *arg) { 29 | int res; 30 | res = pthread_mutex_lock(&mutex0); 31 | if (!signaled) 32 | res = pthread_cond_wait(&cond0, &mutex0); 33 | res = pthread_mutex_unlock(&mutex0); 34 | return NULL; 35 | } 36 | 37 | void *thread1(void *arg) { 38 | int res; 39 | res = pthread_mutex_lock(&mutex0); 40 | if (!signaled) 41 | res = pthread_cond_wait(&cond0, &mutex0); 42 | res = pthread_mutex_unlock(&mutex0); 43 | return NULL; 44 | } 45 | 46 | void *thread2(void *arg) { 47 | int res; 48 | res = pthread_mutex_lock(&mutex0); 49 | res = pthread_cond_broadcast(&cond0); 50 | signaled = true; 51 | res = pthread_mutex_unlock(&mutex0); 52 | return NULL; 53 | } 54 | 55 | int main(int argc, char *argv[]) { 56 | pthread_t tids[NUM_THREADS]; 57 | pthread_create(&tids[0], NULL, thread0, NULL); 58 | pthread_create(&tids[1], NULL, thread1, NULL); 59 | pthread_create(&tids[2], NULL, thread2, NULL); 60 | pthread_join(tids[0], NULL); 61 | pthread_join(tids[1], NULL); 62 | pthread_join(tids[2], NULL); 63 | return 0; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /test/systematic/chess/cond2.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 95: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/cond4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 3 23 | 24 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_cond_t cond0 = PTHREAD_COND_INITIALIZER; 26 | 27 | void *thread0(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&mutex0); 30 | res = pthread_cond_wait(&cond0, &mutex0); 31 | res = pthread_mutex_unlock(&mutex0); 32 | return NULL; 33 | } 34 | 35 | void *thread1(void *arg) { 36 | int res; 37 | res = pthread_mutex_lock(&mutex0); 38 | res = pthread_cond_wait(&cond0, &mutex0); 39 | res = pthread_mutex_unlock(&mutex0); 40 | return NULL; 41 | } 42 | 43 | void *thread2(void *arg) { 44 | int res; 45 | res = pthread_cond_signal(&cond0); 46 | res = pthread_cond_signal(&cond0); 47 | return NULL; 48 | } 49 | 50 | int main(int argc, char *argv[]) { 51 | pthread_t tids[NUM_THREADS]; 52 | pthread_create(&tids[0], NULL, thread0, NULL); 53 | pthread_create(&tids[1], NULL, thread1, NULL); 54 | pthread_create(&tids[2], NULL, thread2, NULL); 55 | pthread_join(tids[0], NULL); 56 | pthread_join(tids[1], NULL); 57 | pthread_join(tids[2], NULL); 58 | return 0; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /test/systematic/chess/cond4.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'runout' 35 | testcase.threshold = 1 36 | 37 | def verify(controller, testcase): 38 | sinfo = static_info.StaticInfo() 39 | sinfo.load(controller.knobs['sinfo_out']) 40 | prog = program.Program(sinfo) 41 | prog.load(controller.knobs['program_out']) 42 | search_info = search.SearchInfo(sinfo, prog) 43 | search_info.load(controller.knobs['search_out']) 44 | if search_info.num_nodes() != 15: 45 | return False 46 | if search_info.find_node(10).num_enabled() != 2: 47 | return False 48 | return True 49 | 50 | -------------------------------------------------------------------------------- /test/systematic/chess/fair.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define NUM_THREADS 2 24 | 25 | bool x = 0; 26 | 27 | void *thread0(void *arg) { 28 | int res; 29 | while (x != 1) 30 | res = sched_yield(); 31 | return NULL; 32 | } 33 | 34 | void *thread1(void *arg) { 35 | x = 1; 36 | return NULL; 37 | } 38 | 39 | int main(int argc, char *argv[]) { 40 | pthread_t tids[NUM_THREADS]; 41 | pthread_create(&tids[0], NULL, thread0, NULL); 42 | pthread_create(&tids[1], NULL, thread1, NULL); 43 | pthread_join(tids[0], NULL); 44 | pthread_join(tids[1], NULL); 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /test/systematic/chess/fair.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = True 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 2: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/mutex.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 25 | 26 | void *thread0(void *arg) { 27 | int res; 28 | res = pthread_mutex_lock(&mutex0); 29 | res = pthread_mutex_unlock(&mutex0); 30 | return NULL; 31 | } 32 | 33 | void *thread1(void *arg) { 34 | int res; 35 | res = pthread_mutex_lock(&mutex0); 36 | res = pthread_mutex_unlock(&mutex0); 37 | return NULL; 38 | } 39 | 40 | int main(int argc, char *argv[]) { 41 | pthread_t tids[NUM_THREADS]; 42 | pthread_create(&tids[0], NULL, thread0, NULL); 43 | pthread_create(&tids[1], NULL, thread1, NULL); 44 | pthread_join(tids[0], NULL); 45 | pthread_join(tids[1], NULL); 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /test/systematic/chess/mutex.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 5: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/mutex2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; 26 | 27 | void *thread0(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&mutex0); 30 | res = pthread_mutex_unlock(&mutex0); 31 | return NULL; 32 | } 33 | 34 | void *thread1(void *arg) { 35 | int res; 36 | res = pthread_mutex_lock(&mutex1); 37 | res = pthread_mutex_unlock(&mutex1); 38 | return NULL; 39 | } 40 | 41 | int main(int argc, char *argv[]) { 42 | pthread_t tids[NUM_THREADS]; 43 | pthread_create(&tids[0], NULL, thread0, NULL); 44 | pthread_create(&tids[1], NULL, thread1, NULL); 45 | pthread_join(tids[0], NULL); 46 | pthread_join(tids[1], NULL); 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /test/systematic/chess/mutex2.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 8: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/mutex3.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; 26 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 27 | 28 | void *thread0(void *arg) { 29 | int res; 30 | res = pthread_mutex_lock(&mutex0); 31 | res = pthread_mutex_unlock(&mutex0); 32 | res = pthread_mutex_lock(&mutex1); 33 | res = pthread_mutex_unlock(&mutex1); 34 | return NULL; 35 | } 36 | 37 | void *thread1(void *arg) { 38 | int res; 39 | res = pthread_mutex_lock(&mutex0); 40 | res = pthread_mutex_unlock(&mutex0); 41 | res = pthread_mutex_lock(&mutex2); 42 | res = pthread_mutex_unlock(&mutex2); 43 | return NULL; 44 | } 45 | 46 | int main(int argc, char *argv[]) { 47 | pthread_t tids[NUM_THREADS]; 48 | pthread_create(&tids[0], NULL, thread0, NULL); 49 | pthread_create(&tids[1], NULL, thread1, NULL); 50 | pthread_join(tids[0], NULL); 51 | pthread_join(tids[1], NULL); 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /test/systematic/chess/mutex3.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 13: 44 | return False 45 | return True 46 | 47 | -------------------------------------------------------------------------------- /test/systematic/chess/por_mutex.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 25 | pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; 26 | pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; 27 | pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER; 28 | pthread_mutex_t mutex4 = PTHREAD_MUTEX_INITIALIZER; 29 | pthread_mutex_t mutex5 = PTHREAD_MUTEX_INITIALIZER; 30 | pthread_mutex_t mutex6 = PTHREAD_MUTEX_INITIALIZER; 31 | 32 | void *thread0(void *arg) { 33 | int res; 34 | res = pthread_mutex_lock(&mutex0); 35 | res = pthread_mutex_unlock(&mutex0); 36 | res = pthread_mutex_lock(&mutex1); 37 | res = pthread_mutex_unlock(&mutex1); 38 | res = pthread_mutex_lock(&mutex2); 39 | res = pthread_mutex_unlock(&mutex2); 40 | return NULL; 41 | } 42 | 43 | void *thread1(void *arg) { 44 | int res; 45 | res = pthread_mutex_lock(&mutex3); 46 | res = pthread_mutex_unlock(&mutex3); 47 | res = pthread_mutex_lock(&mutex4); 48 | res = pthread_mutex_unlock(&mutex4); 49 | res = pthread_mutex_lock(&mutex5); 50 | res = pthread_mutex_unlock(&mutex5); 51 | return NULL; 52 | } 53 | 54 | int main(int argc, char *argv[]) { 55 | pthread_t tids[NUM_THREADS]; 56 | pthread_create(&tids[0], NULL, thread0, NULL); 57 | pthread_create(&tids[1], NULL, thread1, NULL); 58 | pthread_join(tids[0], NULL); 59 | pthread_join(tids[1], NULL); 60 | return 0; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /test/systematic/chess/por_mutex.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | import os 19 | from maple.core import logging 20 | from maple.core import static_info 21 | from maple.systematic import program 22 | from maple.systematic import search 23 | from maple.regression import common 24 | 25 | def source_name(): 26 | return __name__ + common.cxx_ext() 27 | 28 | def setup_controller(controller): 29 | controller.debug = True 30 | controller.knobs['por'] = True 31 | controller.knobs['fair'] = False 32 | controller.knobs['pb_limit'] = 1 33 | 34 | def setup_testcase(testcase): 35 | testcase.mode = 'finish' 36 | 37 | def verify(controller, testcase): 38 | sinfo = static_info.StaticInfo() 39 | sinfo.load(controller.knobs['sinfo_out']) 40 | prog = program.Program(sinfo) 41 | prog.load(controller.knobs['program_out']) 42 | search_info = search.SearchInfo(sinfo, prog) 43 | search_info.load(controller.knobs['search_out']) 44 | if search_info.num_runs() != 19: 45 | return False 46 | por_files = os.listdir(controller.knobs['por_info_path']) 47 | if len(por_files) != 2: 48 | return False 49 | return True 50 | 51 | -------------------------------------------------------------------------------- /test/systematic/chess/race.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NUM_THREADS 2 23 | 24 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 25 | int shared_count = 0; 26 | 27 | void *thread0(void *arg) { 28 | int res; 29 | res = pthread_mutex_lock(&mutex0); 30 | shared_count++; 31 | shared_count++; 32 | res = pthread_mutex_unlock(&mutex0); 33 | return NULL; 34 | } 35 | 36 | void *thread1(void *arg) { 37 | if (shared_count % 2 != 0) 38 | printf("error\n"); 39 | return NULL; 40 | } 41 | 42 | int main(int argc, char *argv[]) { 43 | pthread_t tids[NUM_THREADS]; 44 | pthread_create(&tids[0], NULL, thread0, NULL); 45 | pthread_create(&tids[1], NULL, thread1, NULL); 46 | pthread_join(tids[0], NULL); 47 | pthread_join(tids[1], NULL); 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /test/systematic/chess/race.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def disabled(): 25 | return True 26 | 27 | def source_name(): 28 | return __name__ + common.cxx_ext() 29 | 30 | def setup_controller(controller): 31 | controller.debug = True 32 | controller.knobs['sched_race'] = True 33 | controller.knobs['por'] = False 34 | controller.knobs['fair'] = False 35 | controller.knobs['pb_limit'] = 1 36 | 37 | def setup_testcase(testcase): 38 | testcase.mode = 'finish' 39 | 40 | def verify(controller, testcase): 41 | sinfo = static_info.StaticInfo() 42 | sinfo.load(controller.knobs['sinfo_out']) 43 | prog = program.Program(sinfo) 44 | prog.load(controller.knobs['program_out']) 45 | search_info = search.SearchInfo(sinfo, prog) 46 | search_info.load(controller.knobs['search_out']) 47 | if search_info.num_runs() != 5: 48 | return False 49 | return True 50 | 51 | -------------------------------------------------------------------------------- /test/systematic/chess/timedwait.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The University of Michigan 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Authors - Jie Yu (jieyu@umich.edu) 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define NUM_THREADS 2 24 | 25 | bool signaled = false; 26 | pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER; 27 | pthread_cond_t cond0 = PTHREAD_COND_INITIALIZER; 28 | 29 | void *thread0(void *arg) { 30 | int res; 31 | res = pthread_mutex_lock(&mutex0); 32 | struct timespec ts; 33 | struct timeval tp; 34 | gettimeofday(&tp, NULL); 35 | ts.tv_sec = tp.tv_sec; 36 | ts.tv_nsec = tp.tv_usec * 1000; 37 | ts.tv_sec += 1; 38 | res = pthread_cond_timedwait(&cond0, &mutex0, &ts); 39 | printf("timedwait res=%d\n", res); 40 | res = pthread_mutex_unlock(&mutex0); 41 | return NULL; 42 | } 43 | 44 | void *thread1(void *arg) { 45 | int res; 46 | res = pthread_mutex_lock(&mutex0); 47 | res = pthread_cond_signal(&cond0); 48 | res = pthread_mutex_unlock(&mutex0); 49 | return NULL; 50 | } 51 | 52 | int main(int argc, char *argv[]) { 53 | pthread_t tids[NUM_THREADS]; 54 | pthread_create(&tids[0], NULL, thread0, NULL); 55 | pthread_create(&tids[1], NULL, thread1, NULL); 56 | pthread_join(tids[0], NULL); 57 | pthread_join(tids[1], NULL); 58 | return 0; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /test/systematic/chess/timedwait.py: -------------------------------------------------------------------------------- 1 | """Copyright 2011 The University of Michigan 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Authors - Jie Yu (jieyu@umich.edu) 16 | """ 17 | 18 | from maple.core import logging 19 | from maple.core import static_info 20 | from maple.systematic import program 21 | from maple.systematic import search 22 | from maple.regression import common 23 | 24 | def source_name(): 25 | return __name__ + common.cxx_ext() 26 | 27 | def setup_controller(controller): 28 | controller.debug = True 29 | controller.knobs['por'] = False 30 | controller.knobs['fair'] = False 31 | controller.knobs['pb_limit'] = 1 32 | 33 | def setup_testcase(testcase): 34 | testcase.mode = 'finish' 35 | 36 | def verify(controller, testcase): 37 | sinfo = static_info.StaticInfo() 38 | sinfo.load(controller.knobs['sinfo_out']) 39 | prog = program.Program(sinfo) 40 | prog.load(controller.knobs['program_out']) 41 | search_info = search.SearchInfo(sinfo, prog) 42 | search_info.load(controller.knobs['search_out']) 43 | if search_info.num_runs() != 8: 44 | return False 45 | return True 46 | 47 | --------------------------------------------------------------------------------