├── .gitignore ├── CMakeLists.txt ├── Dockerfile ├── LICENSE ├── README.md ├── cython_lbpeq ├── setup.py └── src │ ├── cython_lbpeq.c │ └── cython_lbpeq.pyx ├── examples ├── data_processing │ └── clustering.py ├── model │ ├── build_model.py │ └── traverse_model.py ├── others │ ├── best_seqs_cc2021.yaml │ ├── best_seqs_sblp2021.yaml │ ├── call_graph.py │ ├── compile2find_best_sequence.py │ ├── compile_functions.py │ ├── distance.py │ ├── distance_function.py │ ├── find_best_sequence.py │ ├── function_cost.py │ ├── functions.py │ ├── globals.py │ ├── insts_costs_from_ir.py │ ├── llvm_instructions.py │ ├── mcoeff.py │ ├── wlcost+comp+inst_from_ir.py │ └── wlcost+inst_from_ir.py ├── predictive │ ├── cbr.py │ ├── cbr_function_msf.py │ ├── cbr_msf.py │ └── cbr_v2.py ├── representation │ ├── extract_graph_from_ir.py │ ├── extract_graph_from_source.py │ ├── extract_histogram.py │ ├── extract_inst2vec.py │ ├── extract_ir2vec.py │ ├── extract_milepost.py │ ├── extract_opcodes.py │ ├── extract_spektral_data_from_ir.py │ ├── extract_stellar_graph_from_ir.py │ ├── graph_from_ast.py │ ├── graph_from_ir.py │ ├── graphs_from_ast.py │ ├── graphs_from_ir.py │ ├── inst2vec.py │ ├── inst2vec_func.py │ ├── ir2vec_from_ir.py │ ├── milepost_from_ir.py │ ├── sequence.py │ └── sequences.py ├── tasks │ ├── classify_app.py │ ├── classify_app_split.py │ └── classify_seq_split.py └── training │ ├── batch_elimination.py │ ├── benchmark_reduction.py │ ├── best_k.py │ ├── combined_elimination.py │ ├── evaluate_partial_sequences.py │ ├── evaluate_partial_sequences_from_best.py │ ├── evaluate_sequences.py │ ├── improved_batch_elimination.py │ ├── iterative_elimination.py │ ├── levels.py │ ├── pso.py │ ├── random_sequences.py │ ├── sequence_reduction.py │ ├── sequence_reduction_from_best.py │ └── sga.py ├── images ├── download.png └── representations.png ├── install_deps.sh ├── notebooks ├── data │ ├── benchmarks │ │ ├── AnghaBench │ │ │ ├── extr_accept_fd_leak_main │ │ │ │ ├── Makefile.clang │ │ │ │ ├── Makefile.llvm │ │ │ │ ├── Makefile.opt │ │ │ │ ├── compile.sh │ │ │ │ └── extr_accept_fd_leak_main.c │ │ │ ├── extr_adv7180_adv7180_probe │ │ │ │ ├── Makefile.clang │ │ │ │ ├── Makefile.llvm │ │ │ │ ├── Makefile.opt │ │ │ │ ├── compile.sh │ │ │ │ └── extr_adv7180_adv7180_probe.c │ │ │ └── extr_aes_rijndaelDecrypt │ │ │ │ ├── Makefile.clang │ │ │ │ ├── Makefile.llvm │ │ │ │ ├── Makefile.opt │ │ │ │ ├── compile.sh │ │ │ │ └── extr_aes_rijndaelDecrypt.c │ │ ├── MiBench │ │ │ ├── automotive-bitcount │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile.clang │ │ │ │ ├── Makefile.llvm │ │ │ │ ├── Makefile.merge │ │ │ │ ├── Makefile.opt │ │ │ │ ├── bitarray.c │ │ │ │ ├── bitcnt_1.c │ │ │ │ ├── bitcnt_2.c │ │ │ │ ├── bitcnt_3.c │ │ │ │ ├── bitcnt_4.c │ │ │ │ ├── bitcnts.c │ │ │ │ ├── bitfiles.c │ │ │ │ ├── bitops.h │ │ │ │ ├── bitstrng.c │ │ │ │ ├── bstr_i.c │ │ │ │ ├── compile.sh │ │ │ │ ├── config.status │ │ │ │ ├── conio.h │ │ │ │ ├── execute.sh │ │ │ │ ├── extkword.h │ │ │ │ ├── optimize.py │ │ │ │ ├── reference_output │ │ │ │ │ ├── reference_output_0.txt │ │ │ │ │ ├── reference_output_1.txt │ │ │ │ │ ├── reference_output_2.txt │ │ │ │ │ ├── reference_output_3.txt │ │ │ │ │ └── reference_output_4.txt │ │ │ │ ├── sniptype.h │ │ │ │ └── split.py │ │ │ ├── consumer-lame │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile.clang │ │ │ │ ├── Makefile.llvm │ │ │ │ ├── Makefile.merge │ │ │ │ ├── Makefile.opt │ │ │ │ ├── README │ │ │ │ ├── VbrTag.c │ │ │ │ ├── VbrTag.h │ │ │ │ ├── brhist.c │ │ │ │ ├── brhist.h │ │ │ │ ├── common.c │ │ │ │ ├── compile.sh │ │ │ │ ├── dct64_i386.c │ │ │ │ ├── decode_i386.c │ │ │ │ ├── encoder.h │ │ │ │ ├── execute.sh │ │ │ │ ├── fft.c │ │ │ │ ├── fft.h │ │ │ │ ├── formatBitstream.c │ │ │ │ ├── formatBitstream.h │ │ │ │ ├── get_audio.c │ │ │ │ ├── get_audio.h │ │ │ │ ├── gpkplotting.c │ │ │ │ ├── gpkplotting.h │ │ │ │ ├── gtkanal.c │ │ │ │ ├── gtkanal.h │ │ │ │ ├── huffman.h │ │ │ │ ├── id3tag.c │ │ │ │ ├── id3tag.h │ │ │ │ ├── ieeefloat.c │ │ │ │ ├── ieeefloat.h │ │ │ │ ├── interface.c │ │ │ │ ├── l3bitstream-pvt.h │ │ │ │ ├── l3bitstream.c │ │ │ │ ├── l3bitstream.h │ │ │ │ ├── l3side.h │ │ │ │ ├── lame.c │ │ │ │ ├── lame.h │ │ │ │ ├── large.wav │ │ │ │ ├── layer3.c │ │ │ │ ├── machine.h │ │ │ │ ├── main.c │ │ │ │ ├── mpg123.h │ │ │ │ ├── mpglib.h │ │ │ │ ├── mpglib_main.c │ │ │ │ ├── newmdct.c │ │ │ │ ├── newmdct.h │ │ │ │ ├── optimize.py │ │ │ │ ├── output.mp3 │ │ │ │ ├── parse.c │ │ │ │ ├── portableio.c │ │ │ │ ├── portableio.h │ │ │ │ ├── psymodel.c │ │ │ │ ├── psymodel.h │ │ │ │ ├── quantize-pvt.c │ │ │ │ ├── quantize-pvt.h │ │ │ │ ├── quantize.c │ │ │ │ ├── quantize.h │ │ │ │ ├── reference_output │ │ │ │ │ ├── reference_output_0.mp3 │ │ │ │ │ └── reference_output_1.mp3 │ │ │ │ ├── reservoir.c │ │ │ │ ├── reservoir.h │ │ │ │ ├── rtp.c │ │ │ │ ├── rtp.h │ │ │ │ ├── small.wav │ │ │ │ ├── split.py │ │ │ │ ├── tabinit.c │ │ │ │ ├── tables.c │ │ │ │ ├── tables.h │ │ │ │ ├── takehiro.c │ │ │ │ ├── timestatus.c │ │ │ │ ├── timestatus.h │ │ │ │ ├── util.c │ │ │ │ ├── util.h │ │ │ │ ├── vbrquantize.c │ │ │ │ ├── version.c │ │ │ │ └── version.h │ │ │ └── telecomm-FFT │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile.clang │ │ │ │ ├── Makefile.llvm │ │ │ │ ├── Makefile.merge │ │ │ │ ├── Makefile.opt │ │ │ │ ├── README │ │ │ │ ├── compile.sh │ │ │ │ ├── ddc.h │ │ │ │ ├── ddcmath.h │ │ │ │ ├── execute.sh │ │ │ │ ├── fftmisc.c │ │ │ │ ├── fourier.h │ │ │ │ ├── fourierf.c │ │ │ │ ├── main.c │ │ │ │ ├── optimize.py │ │ │ │ ├── reference_output │ │ │ │ ├── reference_output_0.txt │ │ │ │ ├── reference_output_1.txt │ │ │ │ ├── reference_output_2.txt │ │ │ │ ├── reference_output_3.txt │ │ │ │ └── reference_output_4.txt │ │ │ │ └── split.py │ │ └── Others │ │ │ └── Fibonacci │ │ │ ├── Makefile.clang │ │ │ ├── Makefile.llvm │ │ │ ├── Makefile.merge │ │ │ ├── Makefile.opt │ │ │ ├── compile.sh │ │ │ └── fibonacci.c │ ├── sequences │ │ ├── levels.yaml │ │ └── llvm-10-Oz-passes.yaml │ ├── training_data_levels │ │ └── AnghaBench │ │ │ ├── extr_accept_fd_leak_main.yaml │ │ │ ├── extr_adv7180_adv7180_probe.yaml │ │ │ └── extr_aes_rijndaelDecrypt.yaml │ └── training_data_sequences │ │ └── AnghaBench │ │ ├── extr_accept_fd_leak_main.yaml │ │ ├── extr_adv7180_adv7180_probe.yaml │ │ └── extr_aes_rijndaelDecrypt.yaml ├── evaluate_sequences.ipynb ├── generate_random_sequences.ipynb ├── graph_clangdriver.ipynb ├── graph_llvmdriver.ipynb └── mcoeff.ipynb ├── setup.py └── yacos ├── __init__.py ├── algorithm ├── __init__.py ├── batch_elimination.py ├── benchmark_reduction.py ├── best_k.py ├── cbr.py ├── cbr_function.py ├── combined_elimination.py ├── improved_batch_elimination.py ├── iterative_elimination.py ├── metaheuristics.py ├── random_.py └── sequence_reduction.py ├── data_processing ├── __init__.py └── clustering.py ├── essential ├── __init__.py ├── dataset.py ├── engine.py ├── goal.py ├── io.py ├── sequence.py └── similarity.py ├── info ├── __init__.py ├── compy │ ├── LICENSE │ ├── __init__.py │ ├── ast_graphs.py │ ├── ast_graphs_test.py │ ├── common.py │ ├── extractors │ │ ├── CMakeLists.txt │ │ ├── __init__.py │ │ ├── clang_ast │ │ │ ├── CMakeLists.txt │ │ │ ├── clang_extractor.cc │ │ │ ├── clang_extractor.h │ │ │ ├── clang_extractor_test.cc │ │ │ ├── clang_graph_frontendaction.cc │ │ │ ├── clang_graph_frontendaction.h │ │ │ ├── clang_seq_frontendaction.cc │ │ │ └── clang_seq_frontendaction.h │ │ ├── common │ │ │ ├── clang_driver.cc │ │ │ ├── clang_driver.h │ │ │ ├── clang_driver_test.cc │ │ │ ├── llvm_driver.cc │ │ │ ├── llvm_driver.h │ │ │ └── visitor.h │ │ ├── extractors.cc │ │ ├── extractors_test.py │ │ ├── llvm_graphs_test.py │ │ └── llvm_ir │ │ │ ├── CMakeLists.txt │ │ │ ├── classify_seq_split.py │ │ │ ├── llvm_extractor.cc │ │ │ ├── llvm_extractor.h │ │ │ ├── llvm_extractor_test.cc │ │ │ ├── llvm_graph_funcinfo.cc │ │ │ ├── llvm_graph_funcinfo.h │ │ │ ├── llvm_graph_pass.cc │ │ │ ├── llvm_graph_pass.h │ │ │ ├── llvm_histogram_pass.cc │ │ │ ├── llvm_histogram_pass.h │ │ │ ├── llvm_insts_pass.cc │ │ │ ├── llvm_insts_pass.h │ │ │ ├── llvm_ir2vec_pass.cc │ │ │ ├── llvm_ir2vec_pass.h │ │ │ ├── llvm_loop_funcinfo.cc │ │ │ ├── llvm_loop_funcinfo.h │ │ │ ├── llvm_loop_pass.cc │ │ │ ├── llvm_loop_pass.h │ │ │ ├── llvm_msf_pass.cc │ │ │ ├── llvm_msf_pass.h │ │ │ ├── llvm_names_pass.cc │ │ │ ├── llvm_names_pass.h │ │ │ ├── llvm_opcodes_pass.cc │ │ │ ├── llvm_opcodes_pass.h │ │ │ ├── llvm_pass_test.cc │ │ │ ├── llvm_seq_pass.cc │ │ │ ├── llvm_seq_pass.h │ │ │ ├── llvm_wl_cost_funcinfo.cc │ │ │ ├── llvm_wl_cost_funcinfo.h │ │ │ ├── llvm_wl_cost_pass.cc │ │ │ ├── llvm_wl_cost_pass.h │ │ │ └── wl_static_profiler │ │ │ ├── CMakeLists.txt │ │ │ ├── LICENSE │ │ │ ├── block_edge_frequency_pass.cc │ │ │ ├── block_edge_frequency_pass.h │ │ │ ├── branch_heuristics_info.cc │ │ │ ├── branch_heuristics_info.h │ │ │ ├── branch_prediction_info.cc │ │ │ ├── branch_prediction_info.h │ │ │ ├── branch_prediction_pass.cc │ │ │ └── branch_prediction_pass.h │ ├── llvm_graphs.py │ ├── llvm_info.py │ ├── llvm_seq.py │ ├── llvm_seq_test.py │ ├── llvm_vec.py │ ├── syntax_seq.py │ └── syntax_seq_test.py ├── image │ ├── __init__.py │ └── extractor.py └── ncc │ ├── LICENSE │ ├── __init__.py │ ├── extractor.py │ ├── inst2vec │ ├── __init__.py │ ├── inst2vec_preprocess.py │ └── inst2vec_utils.py │ ├── rgx_utils.py │ └── task_utils.py └── model ├── __init__.py ├── graph_from_sequences.py ├── net_model.py └── representation_extractor.py /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(yacos) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | set(Clang_DIR /usr/lib/llvm-10/lib/cmake/clang) 6 | 7 | find_package(LLVM 10.0.0) 8 | find_package(Clang) 9 | 10 | set_target_properties(LLVM PROPERTIES 11 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO "C;CXX" 12 | IMPORTED_LOCATION_RELWITHDEBINFO "-lpthread" 13 | ) 14 | 15 | include(FetchContent) 16 | 17 | FetchContent_Declare( 18 | googletest 19 | GIT_REPOSITORY https://github.com/google/googletest.git 20 | GIT_TAG release-1.10.0 21 | ) 22 | FetchContent_GetProperties(googletest) 23 | if(NOT googletest_POPULATED) 24 | FetchContent_Populate(googletest) 25 | add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) 26 | endif() 27 | 28 | FetchContent_Declare( 29 | pybind11 30 | GIT_REPOSITORY https://github.com/pybind/pybind11 31 | GIT_TAG v2.5.0 32 | ) 33 | FetchContent_GetProperties(pybind11) 34 | if(NOT pybind11_POPULATED) 35 | FetchContent_Populate(pybind11) 36 | add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) 37 | endif() 38 | 39 | add_subdirectory(yacos/info/compy/extractors) 40 | -------------------------------------------------------------------------------- /cython_lbpeq/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from Cython.Build import cythonize 3 | import numpy 4 | setup( 5 | name="cythonlbpeq", 6 | version="1.0.0", 7 | description="RBP/LBPEQ", 8 | ext_modules = cythonize("src/cython_lbpeq.pyx"), 9 | include_dirs=[numpy.get_include()] 10 | ) 11 | -------------------------------------------------------------------------------- /cython_lbpeq/src/cython_lbpeq.pyx: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | cimport numpy as cnp 3 | import time 4 | from libc.math cimport round 5 | 6 | cdef double get_coord(int max_coord, double coord) nogil: 7 | cdef double r 8 | r=round(coord) 9 | if (r>=0) and (r < max_coord): 10 | return r 11 | return -1 12 | 13 | cpdef cnp.ndarray cython_lbpeq(cnp.ndarray arg_img, int P=8, int R=2): 14 | ''' 15 | This function extracts the binary pattern around each "pixel of 16 | the binary image. The strategy is very similar to LBP, but 17 | instead of compare the pixel with their neighbors, it just take 18 | the pattern looking at its neighbors. 19 | Exemple: 20 | Supose this part of an BINARY image and the pixel X. 21 | 0 1 1 22 | 1 X 1 23 | 0 0 1 24 | 25 | Consider P=8 and R=1 26 | 27 | Pattern around X is 11001011. 28 | 29 | >-------V 30 | : : 31 | : pixel : <---pattern start here 32 | : : 33 | ^-------< 34 | 35 | 36 | ''' 37 | cdef double[:,::1] img = np.ascontiguousarray(arg_img,dtype=np.double) 38 | cdef int totlin = arg_img.shape[0] 39 | cdef int totcol = arg_img.shape[1] 40 | cdef int r = 0 41 | cdef int c = 0 42 | cdef int p = 0 43 | cdef double pattern = 0 44 | cdef double m = 0 45 | cdef double pixel 46 | 47 | cdef cnp.ndarray rr = -R*np.sin(2*np.pi*np.arange(P,dtype=np.double)/P) 48 | cdef cnp.ndarray cc = R*np.cos(2*np.pi*np.arange(P,dtype=np.double)/P) 49 | cdef double[:, ::1] rbp_matrix = np.zeros([totlin,totcol],dtype=np.double) 50 | cdef double[::1] rp = np.round(rr, 5) 51 | cdef double[::1] cp = np.round(cc, 5) 52 | cdef int x,y 53 | while r < totlin: 54 | c=0 55 | while c < totcol: 56 | pattern = 0 57 | p=0 58 | m=1 59 | while p < P: 60 | x = get_coord(totlin,r+rp[p]) 61 | y = get_coord(totcol,c+cp[p]) 62 | if x != -1 and y != -1: 63 | pixel = img[x,y] 64 | pattern += pixel * m 65 | m = m*2 66 | p = p+1 67 | rbp_matrix[r,c]=pattern 68 | c+=1 69 | r+=1 70 | 71 | return np.asarray(rbp_matrix) 72 | -------------------------------------------------------------------------------- /examples/others/best_seqs_sblp2021.yaml: -------------------------------------------------------------------------------- 1 | BST: 2 | seq: 3 | - -mem2reg 4 | - -jump-threading 5 | - -instcombine 6 | - -early-cse-memssa 7 | - -jump-threading 8 | - -licm 9 | - -early-cse-memssa 10 | - -sroa 11 | - -simplifycfg 12 | - -reassociate 13 | - -instcombine 14 | - -slp-vectorizer 15 | - -early-cse-memssa 16 | SUM: 17 | seq: 18 | - -mem2reg 19 | - -early-cse-memssa 20 | - -correlated-propagation 21 | - -instcombine 22 | - -reassociate 23 | - -simplifycfg 24 | - -early-cse-memssa 25 | - -instcombine 26 | - -licm 27 | - -jump-threading 28 | - -simplifycfg 29 | - -dse 30 | - -reassociate 31 | - -early-cse-memssa 32 | - -instcombine 33 | LIM: 34 | seq: 35 | - -sroa 36 | - -early-cse-memssa 37 | - -reassociate 38 | - -instcombine 39 | - -simplifycfg 40 | - -licm 41 | - -speculative-execution 42 | - -jump-threading 43 | - -early-cse-memssa 44 | - -simplifycfg 45 | - -instcombine 46 | - -simplifycfg 47 | GEO: 48 | seq: 49 | - -loop-vectorize 50 | - -sroa 51 | - -gvn 52 | - -instcombine 53 | - -simplifycfg 54 | - -instcombine 55 | - -licm 56 | - -gvn 57 | - -correlated-propagation 58 | - -jump-threading 59 | - -mldst-motion 60 | - -early-cse-memssa 61 | - -instcombine 62 | - -simplifycfg 63 | - -instsimplify 64 | CAP: 65 | seq: 66 | - -loop-rotate 67 | - -sroa 68 | - -correlated-propagation 69 | - -indvars 70 | - -gvn 71 | - -tailcallelim 72 | - -instcombine 73 | - -jump-threading 74 | - -reassociate 75 | - -simplifycfg 76 | - -instcombine 77 | - -early-cse-memssa 78 | -------------------------------------------------------------------------------- /examples/representation/extract_ir2vec.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | """ 4 | Copyright 2021 Anderson Faustino da Silva. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | # 20 | # Classify applications into 104 classes given their raw code. 21 | # 22 | # The representation (graph) is created from IR. 23 | # 24 | 25 | import os 26 | import sys 27 | import glob 28 | import numpy as np 29 | 30 | from absl import app, flags, logging 31 | 32 | from yacos.info import compy as R 33 | from yacos.info.compy.extractors import LLVMDriver 34 | 35 | 36 | def execute(argv): 37 | """Extract a graph representation.""" 38 | del argv 39 | 40 | FLAGS = flags.FLAGS 41 | 42 | # Instantiate the LLVM driver. 43 | driver = LLVMDriver([]) 44 | # Instantiate the builder. 45 | builder = R.LLVMIR2VecBuilder(driver) 46 | 47 | # Verify datset directory. 48 | if not os.path.isdir(FLAGS.dataset_directory): 49 | logging.error('Dataset directory {} does not exist.'.format( 50 | FLAGS.dataset_directory) 51 | ) 52 | sys.exit(1) 53 | 54 | folders = [ 55 | os.path.join(FLAGS.dataset_directory, subdir) 56 | for subdir in os.listdir(FLAGS.dataset_directory) 57 | if os.path.isdir(os.path.join(FLAGS.dataset_directory, subdir)) 58 | ] 59 | 60 | idx = FLAGS.dataset_directory.rfind('/') 61 | last_folder = FLAGS.dataset_directory[idx+1:] 62 | 63 | # Load data from all folders 64 | for folder in folders: 65 | # Create the output directory. 66 | outdir = os.path.join(folder.replace(last_folder, 67 | '{}_ir2vec'.format(last_folder))) 68 | 69 | os.makedirs(outdir, exist_ok=True) 70 | 71 | # Extract "ir2vec" from the file 72 | sources = glob.glob('{}/*.ll'.format(folder)) 73 | 74 | for source in sources: 75 | try: 76 | extractionInfo = builder.ir_to_info(source) 77 | except Exception: 78 | logging.error('Error {}.'.format(source)) 79 | continue 80 | 81 | filename = source.replace(folder, outdir) 82 | filename = filename[:-3] 83 | np.savez_compressed(filename, 84 | values=extractionInfo.moduleInfo.ir2vec) 85 | 86 | 87 | # Execute 88 | if __name__ == '__main__': 89 | # app 90 | flags.DEFINE_string('dataset_directory', 91 | None, 92 | 'Dataset directory') 93 | flags.mark_flag_as_required('dataset_directory') 94 | 95 | app.run(execute) 96 | -------------------------------------------------------------------------------- /images/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/images/download.png -------------------------------------------------------------------------------- /images/representations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/images/representations.png -------------------------------------------------------------------------------- /install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function add_llvm_10_apt_source { 4 | curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - 5 | if [[ $1 == "16.04" ]]; then 6 | echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" | sudo tee -a /etc/apt/sources.list 7 | elif [[ $1 == "18.04" ]]; then 8 | echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" | sudo tee -a /etc/apt/sources.list 9 | fi 10 | sudo apt-get -qq update 11 | } 12 | 13 | function install_system_packages { 14 | sudo apt install -y graphviz libgraphviz-dev 15 | sudo apt install -y libllvm10 llvm-10-dev 16 | sudo apt install -y clang-10 libclang1-10 libclang-10-dev libclang-common-10-dev 17 | sudo apt install -y creduce libeigen3-dev 18 | wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb 19 | sudo dpkg -i hyperfine_1.11.0_amd64.deb 20 | rm hyperfine_1.11.0_amd64.deb 21 | sudo apt install -y python3-pip 22 | sudo pip3 install cython 23 | } 24 | 25 | function install_yacos_data { 26 | mkdir $HOME/.local/yacos 27 | wget www.csl.uem.br/repository/yacos/yacos_data.tar.xz 28 | tar xfJ yacos_data.tar.xz -C $HOME/.local/yacos 29 | rm -f yacos_data.tar.xz 30 | wget www.csl.uem.br/repository/yacos/yacos_tests.tar.xz 31 | tar xfJ yacos_tests.tar.xz -C $HOME/.local/yacos 32 | rm -f yacos_tests.tar.xz 33 | } 34 | 35 | function install_ir2vec { 36 | git clone https://github.com/IITH-Compilers/IR2Vec.git 37 | cd IR2Vec 38 | git checkout llvm10 39 | mkdir build && cd build 40 | cmake -DLT_LLVM_INSTALL_DIR=/usr -DEigen3_DIR=/usr -DCMAKE_INSTALL_PREFIX=/usr ../src 41 | sudo make install 42 | cd ../.. 43 | sudo rm /usr/seedEmbeddingVocab-300-llvm10.txt 44 | rm -rf IR2Vec 45 | } 46 | 47 | function install_cython_rbp { 48 | cd cython_lbpeq 49 | sudo python3 setup.py install 50 | sudo rm -rf cythonlbpeq.egg-info 51 | sudo rm -rf build 52 | sudo rm -rf dist 53 | } 54 | 55 | if [[ $(lsb_release -rs) == "16.04" ]] || [[ $(lsb_release -rs) == "18.04" ]]; then 56 | echo "OS supported." 57 | add_llvm_10_apt_source $(lsb_release -rs) 58 | elif [[ $(lsb_release -rs) == "20.04" ]]; then 59 | echo "OS supported." 60 | else 61 | echo "Non-supported OS. You have to install the packages manually." 62 | exit 1 63 | fi 64 | 65 | install_system_packages 66 | install_yacos_data 67 | install_ir2vec 68 | install_cython_rbp 69 | 70 | echo "Please install perf, you may want to define instructions or cycles as the objective." 71 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_accept_fd_leak_main/Makefile.clang: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # Compile-time flags 15 | CFLAGS = -w 16 | 17 | # Includes 18 | INCLUDES = 19 | 20 | # Library paths 21 | LFLAGS = 22 | 23 | # Linker flags 24 | LIBS = -lm 25 | 26 | # Source files 27 | SRCS = $(wildcard *.c) 28 | 29 | # Object file 30 | OBJS = $(SRCS:.c=.o) 31 | 32 | # 33 | # BUILD 34 | # 35 | 36 | .PHONY: depend clean 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | # @$(CC) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS) 42 | @cp *.o a.out.o 43 | 44 | %.o: %.c 45 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 46 | 47 | # 48 | # CLEAN 49 | # 50 | 51 | clean: 52 | @$(RM) -f *.o *~ *.yaml 53 | 54 | cleanup: 55 | @$(RM) -f *.o *~ $(TARGET) *.yaml 56 | 57 | # 58 | # DEPEND 59 | # 60 | depend: $(SRCS) 61 | @makedepend $(INCLUDES) $^ 62 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_accept_fd_leak_main/Makefile.llvm: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | # $(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | 56 | %.bc: %.c 57 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 58 | 59 | $(TARGET).o: $(IRS) 60 | @$(LINK) *.bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml *.ll 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ $(TARGET) *.yaml *.ll 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_accept_fd_leak_main/Makefile.opt: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | # @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: $(IRS) 59 | @$(LINK) *.bc -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml *.ll 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ $(TARGET) *.yaml *.ll 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_accept_fd_leak_main/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # $1 = compiler 5 | # $2 = sequence 6 | # $3 = working set 7 | # 8 | 9 | function seconds() { 10 | t=`date +"%H:%M:%S:%N" | awk -F: '{printf "%f", ($1 * 3600) + ($2 * 60) + $3 + ($4 / 1000000000)}'` ; 11 | echo ${t} 12 | } 13 | 14 | function elapsed() { 15 | seconds=`echo "scale=4; ${2}-${1}" | sed -u 's/,/./g' | bc` ; 16 | echo ${seconds} 17 | } 18 | 19 | # Clean up 20 | make -f Makefile.${1} cleanup &> /dev/null 21 | rm -f compile_time.yaml binary_size.yaml 22 | 23 | # Get the initial time 24 | initial_time=`seconds` 25 | 26 | # Compile the benchmark 27 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 28 | if [[ $? -eq 2 ]]; then 29 | exit 30 | fi 31 | 32 | # Get the final time 33 | final_time=`seconds` 34 | 35 | # Store the elapsed time 36 | value=`elapsed $initial_time $final_time` 37 | printf "compile_time: ${value}" > compile_time.yaml 38 | 39 | # Store the binary size 40 | value=`ls -l a.out.o | awk '{print $5}'` 41 | printf "binary_size: ${value}" > binary_size.yaml 42 | 43 | # Store the code size 44 | size a.out.o | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 45 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_adv7180_adv7180_probe/Makefile.clang: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # Compile-time flags 15 | CFLAGS = -w 16 | 17 | # Includes 18 | INCLUDES = 19 | 20 | # Library paths 21 | LFLAGS = 22 | 23 | # Linker flags 24 | LIBS = -lm 25 | 26 | # Source files 27 | SRCS = $(wildcard *.c) 28 | 29 | # Object file 30 | OBJS = $(SRCS:.c=.o) 31 | 32 | # 33 | # BUILD 34 | # 35 | 36 | .PHONY: depend clean 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | # @$(CC) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS) 42 | @cp *.o a.out.o 43 | 44 | %.o: %.c 45 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 46 | 47 | # 48 | # CLEAN 49 | # 50 | 51 | clean: 52 | @$(RM) -f *.o *~ *.yaml 53 | 54 | cleanup: 55 | @$(RM) -f *.o *~ $(TARGET) *.yaml 56 | 57 | # 58 | # DEPEND 59 | # 60 | depend: $(SRCS) 61 | @makedepend $(INCLUDES) $^ 62 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_adv7180_adv7180_probe/Makefile.llvm: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | # $(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | 56 | %.bc: %.c 57 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 58 | 59 | $(TARGET).o: $(IRS) 60 | @$(LINK) *.bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml *.ll 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ $(TARGET) *.yaml *.ll 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_adv7180_adv7180_probe/Makefile.opt: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | # @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: $(IRS) 59 | @$(LINK) *.bc -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml *.ll 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ $(TARGET) *.yaml *.ll 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_adv7180_adv7180_probe/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # $1 = compiler 5 | # $2 = sequence 6 | # $3 = working set 7 | # 8 | 9 | function seconds() { 10 | t=`date +"%H:%M:%S:%N" | awk -F: '{printf "%f", ($1 * 3600) + ($2 * 60) + $3 + ($4 / 1000000000)}'` ; 11 | echo ${t} 12 | } 13 | 14 | function elapsed() { 15 | seconds=`echo "scale=4; ${2}-${1}" | sed -u 's/,/./g' | bc` ; 16 | echo ${seconds} 17 | } 18 | 19 | # Clean up 20 | make -f Makefile.${1} cleanup &> /dev/null 21 | rm -f compile_time.yaml binary_size.yaml 22 | 23 | # Get the initial time 24 | initial_time=`seconds` 25 | 26 | # Compile the benchmark 27 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 28 | if [[ $? -eq 2 ]]; then 29 | exit 30 | fi 31 | 32 | # Get the final time 33 | final_time=`seconds` 34 | 35 | # Store the elapsed time 36 | value=`elapsed $initial_time $final_time` 37 | printf "compile_time: ${value}" > compile_time.yaml 38 | 39 | # Store the binary size 40 | value=`ls -l a.out.o | awk '{print $5}'` 41 | printf "binary_size: ${value}" > binary_size.yaml 42 | 43 | # Store the code size 44 | size a.out.o | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 45 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_aes_rijndaelDecrypt/Makefile.clang: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # Compile-time flags 15 | CFLAGS = -w 16 | 17 | # Includes 18 | INCLUDES = 19 | 20 | # Library paths 21 | LFLAGS = 22 | 23 | # Linker flags 24 | LIBS = -lm 25 | 26 | # Source files 27 | SRCS = $(wildcard *.c) 28 | 29 | # Object file 30 | OBJS = $(SRCS:.c=.o) 31 | 32 | # 33 | # BUILD 34 | # 35 | 36 | .PHONY: depend clean 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | # @$(CC) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS) 42 | @cp *.o a.out.o 43 | 44 | %.o: %.c 45 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 46 | 47 | # 48 | # CLEAN 49 | # 50 | 51 | clean: 52 | @$(RM) -f *.o *~ *.yaml 53 | 54 | cleanup: 55 | @$(RM) -f *.o *~ $(TARGET) *.yaml 56 | 57 | # 58 | # DEPEND 59 | # 60 | depend: $(SRCS) 61 | @makedepend $(INCLUDES) $^ 62 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_aes_rijndaelDecrypt/Makefile.llvm: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | # $(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | 56 | %.bc: %.c 57 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 58 | 59 | $(TARGET).o: $(IRS) 60 | @$(LINK) *.bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml *.ll 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ $(TARGET) *.yaml *.ll 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_aes_rijndaelDecrypt/Makefile.opt: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | # @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: $(IRS) 59 | @$(LINK) *.bc -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml *.ll 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ $(TARGET) *.yaml *.ll 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_aes_rijndaelDecrypt/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # $1 = compiler 5 | # $2 = sequence 6 | # $3 = working set 7 | # 8 | 9 | function seconds() { 10 | t=`date +"%H:%M:%S:%N" | awk -F: '{printf "%f", ($1 * 3600) + ($2 * 60) + $3 + ($4 / 1000000000)}'` ; 11 | echo ${t} 12 | } 13 | 14 | function elapsed() { 15 | seconds=`echo "scale=4; ${2}-${1}" | sed -u 's/,/./g' | bc` ; 16 | echo ${seconds} 17 | } 18 | 19 | # Clean up 20 | make -f Makefile.${1} cleanup &> /dev/null 21 | rm -f compile_time.yaml binary_size.yaml 22 | 23 | # Get the initial time 24 | initial_time=`seconds` 25 | 26 | # Compile the benchmark 27 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 28 | if [[ $? -eq 2 ]]; then 29 | exit 30 | fi 31 | 32 | # Get the final time 33 | final_time=`seconds` 34 | 35 | # Store the elapsed time 36 | value=`elapsed $initial_time $final_time` 37 | printf "compile_time: ${value}" > compile_time.yaml 38 | 39 | # Store the binary size 40 | value=`ls -l a.out.o | awk '{print $5}'` 41 | printf "binary_size: ${value}" > binary_size.yaml 42 | 43 | # Store the code size 44 | size a.out.o | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 45 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/AnghaBench/extr_aes_rijndaelDecrypt/extr_aes_rijndaelDecrypt.c: -------------------------------------------------------------------------------- 1 | #define NULL ((void*)0) 2 | typedef unsigned long size_t; // Customize by platform. 3 | typedef long intptr_t; typedef unsigned long uintptr_t; 4 | typedef long scalar_t__; // Either arithmetic or pointer type. 5 | /* By default, we understand bool (as a convenience). */ 6 | typedef int bool; 7 | #define false 0 8 | #define true 1 9 | 10 | /* Forward declarations */ 11 | 12 | /* Type definitions */ 13 | typedef int /*<<< orphan*/ u8 ; 14 | typedef int u32 ; 15 | 16 | /* Variables and functions */ 17 | int const GETU32 (int /*<<< orphan*/ const*) ; 18 | int /*<<< orphan*/ PUTU32 (int /*<<< orphan*/ *,int) ; 19 | int /*<<< orphan*/ ROUND (int,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; 20 | int const TD41 (int) ; 21 | int const TD42 (int) ; 22 | int const TD43 (int) ; 23 | int const TD44 (int) ; 24 | int /*<<< orphan*/ s ; 25 | int /*<<< orphan*/ t ; 26 | 27 | __attribute__((used)) static void rijndaelDecrypt(const u32 rk[/*44*/], const u8 ct[16], u8 pt[16]) 28 | { 29 | u32 s0, s1, s2, s3, t0, t1, t2, t3; 30 | const int Nr = 10; 31 | #ifndef FULL_UNROLL 32 | int r; 33 | #endif /* ?FULL_UNROLL */ 34 | 35 | /* 36 | * map byte array block to cipher state 37 | * and add initial round key: 38 | */ 39 | s0 = GETU32(ct ) ^ rk[0]; 40 | s1 = GETU32(ct + 4) ^ rk[1]; 41 | s2 = GETU32(ct + 8) ^ rk[2]; 42 | s3 = GETU32(ct + 12) ^ rk[3]; 43 | 44 | #define ROUND(i,d,s) \ 45 | d##0 = TD0(s##0) ^ TD1(s##3) ^ TD2(s##2) ^ TD3(s##1) ^ rk[4 * i]; \ 46 | d##1 = TD0(s##1) ^ TD1(s##0) ^ TD2(s##3) ^ TD3(s##2) ^ rk[4 * i + 1]; \ 47 | d##2 = TD0(s##2) ^ TD1(s##1) ^ TD2(s##0) ^ TD3(s##3) ^ rk[4 * i + 2]; \ 48 | d##3 = TD0(s##3) ^ TD1(s##2) ^ TD2(s##1) ^ TD3(s##0) ^ rk[4 * i + 3] 49 | 50 | #ifdef FULL_UNROLL 51 | 52 | ROUND(1,t,s); 53 | ROUND(2,s,t); 54 | ROUND(3,t,s); 55 | ROUND(4,s,t); 56 | ROUND(5,t,s); 57 | ROUND(6,s,t); 58 | ROUND(7,t,s); 59 | ROUND(8,s,t); 60 | ROUND(9,t,s); 61 | 62 | rk += Nr << 2; 63 | 64 | #else /* !FULL_UNROLL */ 65 | 66 | /* Nr - 1 full rounds: */ 67 | r = Nr >> 1; 68 | for (;;) { 69 | ROUND(1,t,s); 70 | rk += 8; 71 | if (--r == 0) 72 | break; 73 | ROUND(0,s,t); 74 | } 75 | 76 | #endif /* ?FULL_UNROLL */ 77 | 78 | #undef ROUND 79 | 80 | /* 81 | * apply last round and 82 | * map cipher state to byte array block: 83 | */ 84 | s0 = TD41(t0) ^ TD42(t3) ^ TD43(t2) ^ TD44(t1) ^ rk[0]; 85 | PUTU32(pt , s0); 86 | s1 = TD41(t1) ^ TD42(t0) ^ TD43(t3) ^ TD44(t2) ^ rk[1]; 87 | PUTU32(pt + 4, s1); 88 | s2 = TD41(t2) ^ TD42(t1) ^ TD43(t0) ^ TD44(t3) ^ rk[2]; 89 | PUTU32(pt + 8, s2); 90 | s3 = TD41(t3) ^ TD42(t2) ^ TD43(t1) ^ TD44(t0) ^ rk[3]; 91 | PUTU32(pt + 12, s3); 92 | } -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/LICENSE: -------------------------------------------------------------------------------- 1 | From http://www.snippets.org/. 2 | 3 | This code is FREE with no restrictions. 4 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/Makefile.clang: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # Compile-time flags 15 | CFLAGS = -w 16 | 17 | # Includes 18 | INCLUDES = 19 | 20 | # Library paths 21 | LFLAGS = 22 | 23 | # Linker flags 24 | LIBS = -lm 25 | 26 | # Source files 27 | SRCS = $(wildcard *.c) 28 | 29 | # Object file 30 | OBJS = $(SRCS:.c=.o) 31 | 32 | # 33 | # BUILD 34 | # 35 | 36 | .PHONY: depend clean 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | @$(CC) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS) 42 | 43 | %.o: %.c 44 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 45 | 46 | # 47 | # CLEAN 48 | # 49 | 50 | clean: 51 | @$(RM) -f *.o *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 52 | 53 | cleanup: 54 | @$(RM) -f *.o *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 55 | 56 | # 57 | # DEPEND 58 | # 59 | depend: $(SRCS) 60 | @makedepend $(INCLUDES) $^ 61 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/Makefile.llvm: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | 56 | %.bc: %.c 57 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 58 | 59 | $(TARGET).o: $(IRS) 60 | @$(LINK) *.bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/Makefile.merge: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: 59 | @$(LINK) *.ll -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.ll a.out* *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.ll a.out* *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/Makefile.opt: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: $(IRS) 59 | @$(LINK) *.bc -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitarray.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** Functions to maintain an arbitrary length array of bits 5 | */ 6 | 7 | #include "bitops.h" 8 | 9 | char *alloc_bit_array(size_t bits) 10 | { 11 | char *set = calloc((bits + CHAR_BIT - 1) / CHAR_BIT, sizeof(char)); 12 | 13 | return set; 14 | } 15 | 16 | int getbit(char *set, int number) 17 | { 18 | set += number / CHAR_BIT; 19 | return (*set & (1 << (number % CHAR_BIT))) != 0; /* 0 or 1 */ 20 | } 21 | 22 | void setbit(char *set, int number, int value) 23 | { 24 | set += number / CHAR_BIT; 25 | if (value) 26 | *set |= 1 << (number % CHAR_BIT); /* set bit */ 27 | else *set &= ~(1 << (number % CHAR_BIT)); /* clear bit*/ 28 | } 29 | 30 | void flipbit(char *set, int number) 31 | { 32 | set += number / CHAR_BIT; 33 | *set ^= 1 << (number % CHAR_BIT); /* flip bit */ 34 | } 35 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitcnt_1.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** Bit counter by Ratko Tomic 5 | */ 6 | 7 | #include "bitops.h" 8 | 9 | int CDECL bit_count(long x) 10 | { 11 | int n = 0; 12 | /* 13 | ** The loop will execute once for each bit of x set, this is in average 14 | ** twice as fast as the shift/test method. 15 | */ 16 | if (x) do 17 | n++; 18 | while (0 != (x = x&(x-1))) ; 19 | return(n); 20 | } 21 | 22 | #ifdef TEST 23 | 24 | #include 25 | #include "snip_str.h" /* For plural_text() macro */ 26 | 27 | main(int argc, char *argv[]) 28 | { 29 | long n; 30 | 31 | while(--argc) 32 | { 33 | int i; 34 | 35 | n = atol(*++argv); 36 | i = bit_count(n); 37 | printf("%ld contains %d bit%s set\n", 38 | n, i, plural_text(i)); 39 | } 40 | return 0; 41 | } 42 | 43 | #endif /* TEST */ 44 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitcnt_2.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** Bit counter by Ratko Tomic 5 | */ 6 | 7 | #include "bitops.h" 8 | 9 | int CDECL bitcount(long i) 10 | { 11 | i = ((i & 0xAAAAAAAAL) >> 1) + (i & 0x55555555L); 12 | i = ((i & 0xCCCCCCCCL) >> 2) + (i & 0x33333333L); 13 | i = ((i & 0xF0F0F0F0L) >> 4) + (i & 0x0F0F0F0FL); 14 | i = ((i & 0xFF00FF00L) >> 8) + (i & 0x00FF00FFL); 15 | i = ((i & 0xFFFF0000L) >> 16) + (i & 0x0000FFFFL); 16 | return (int)i; 17 | } 18 | 19 | #ifdef TEST 20 | 21 | #include 22 | #include "snip_str.h" /* For plural_text() macro */ 23 | 24 | main(int argc, char *argv[]) 25 | { 26 | long n; 27 | 28 | while(--argc) 29 | { 30 | int i; 31 | 32 | n = atol(*++argv); 33 | i = bitcount(n); 34 | printf("%ld contains %d bit%s set\n", 35 | n, i, plural_text(i)); 36 | } 37 | return 0; 38 | } 39 | 40 | #endif /* TEST */ 41 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitcnt_4.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** BITCNT_4.C - Recursive bit counting functions using table lookup 5 | ** 6 | ** public domain by Bob Stout 7 | */ 8 | 9 | #include "bitops.h" /* from Snippets */ 10 | 11 | static char bits[256] = 12 | { 13 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, /* 0 - 15 */ 14 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, /* 16 - 31 */ 15 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, /* 32 - 47 */ 16 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, /* 48 - 63 */ 17 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, /* 64 - 79 */ 18 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, /* 80 - 95 */ 19 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, /* 96 - 111 */ 20 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, /* 112 - 127 */ 21 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, /* 128 - 143 */ 22 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, /* 144 - 159 */ 23 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, /* 160 - 175 */ 24 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, /* 176 - 191 */ 25 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, /* 192 - 207 */ 26 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, /* 208 - 223 */ 27 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, /* 224 - 239 */ 28 | 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 /* 240 - 255 */ 29 | }; 30 | 31 | /* 32 | ** Count bits in each nybble 33 | ** 34 | ** Note: Only the first 16 table entries are used, the rest could be 35 | ** omitted. 36 | */ 37 | 38 | int CDECL ntbl_bitcnt(long x) 39 | { 40 | int cnt = bits[(int)(x & 0x0000000FL)]; 41 | 42 | if (0L != (x >>= 4)) 43 | cnt += ntbl_bitcnt(x); 44 | 45 | return cnt; 46 | } 47 | 48 | /* 49 | ** Count bits in each byte 50 | */ 51 | 52 | int CDECL btbl_bitcnt(long x) 53 | { 54 | int cnt = bits[ ((char *)&x)[0] & 0xFF ]; 55 | 56 | if (0L != (x >>= 8)) 57 | cnt += btbl_bitcnt(x); 58 | return cnt; 59 | } 60 | 61 | #ifdef TEST 62 | 63 | #include 64 | #include "snip_str.h" /* For plural_text() macro */ 65 | 66 | main(int argc, char *argv[]) 67 | { 68 | long n; 69 | 70 | while(--argc) 71 | { 72 | int i; 73 | 74 | n = atol(*++argv); 75 | i = btbl_bitcnt(n); 76 | printf("%ld contains %d bit%s set\n", 77 | n, i, plural_text(i)); 78 | } 79 | return 0; 80 | } 81 | 82 | #endif /* TEST */ 83 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitcnts.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** BITCNTS.C - Test program for bit counting functions 5 | ** 6 | ** public domain by Bob Stout & Auke Reitsma 7 | */ 8 | 9 | #include 10 | #include 11 | #include "conio.h" 12 | #include 13 | #include 14 | #include 15 | #include "bitops.h" 16 | 17 | #define FUNCS 7 18 | 19 | // RNG implemented localy to avoid library incongruences 20 | #ifdef RAND_MAX 21 | #undef RAND_MAX 22 | #endif 23 | #define RAND_MAX 32767 24 | static unsigned long long int next = 1; 25 | 26 | int rand( void ) { 27 | next = next * 1103515245 + 12345; 28 | return (unsigned int)(next / 65536) % RAND_MAX+1; 29 | } 30 | 31 | void srand( unsigned int seed ) { 32 | next = seed; 33 | } 34 | // End of RNG implementation 35 | 36 | static int CDECL bit_shifter(long int x); 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | clock_t start, stop; 41 | double ct, cmin = DBL_MAX, cmax = 0; 42 | int i, cminix, cmaxix; 43 | long j, n, seed; 44 | int iterations; 45 | static int (* CDECL pBitCntFunc[FUNCS])(long) = { 46 | bit_count, 47 | bitcount, 48 | ntbl_bitcnt, 49 | ntbl_bitcount, 50 | /* btbl_bitcnt, DOESNT WORK*/ 51 | BW_btbl_bitcount, 52 | AR_btbl_bitcount, 53 | bit_shifter 54 | }; 55 | static char *text[FUNCS] = { 56 | "Optimized 1 bit/loop counter", 57 | "Ratko's mystery algorithm", 58 | "Recursive bit count by nybbles", 59 | "Non-recursive bit count by nybbles", 60 | /* "Recursive bit count by bytes",*/ 61 | "Non-recursive bit count by bytes (BW)", 62 | "Non-recursive bit count by bytes (AR)", 63 | "Shift and count bits" 64 | }; 65 | if (argc<2) { 66 | fprintf(stderr,"Usage: bitcnts \n"); 67 | exit(-1); 68 | } 69 | iterations=atoi(argv[1]); 70 | srand(1); 71 | 72 | puts("Bit counter algorithm benchmark\n"); 73 | 74 | for (i = 0; i < FUNCS; i++) { 75 | #if 0 76 | start = clock(); 77 | #endif 78 | 79 | for (j = n = 0, seed = rand(); j < iterations; j++, seed += 13) 80 | n += pBitCntFunc[i](seed); 81 | 82 | #if 0 83 | stop = clock(); 84 | ct = (stop - start) / (double)CLOCKS_PER_SEC; 85 | if (ct < cmin) { 86 | cmin = ct; 87 | cminix = i; 88 | } 89 | if (ct > cmax) { 90 | cmax = ct; 91 | cmaxix = i; 92 | } 93 | 94 | printf("%-38s> Time: %7.3f sec.; Bits: %ld\n", text[i], ct, n); 95 | #endif 96 | printf("%-38s> Bits: %ld\n", text[i], n); 97 | } 98 | #if 0 99 | printf("\nBest > %s\n", text[cminix]); 100 | printf("Worst > %s\n", text[cmaxix]); 101 | #endif 102 | return 0; 103 | } 104 | 105 | static int CDECL bit_shifter(long int x) 106 | { 107 | int i, n; 108 | 109 | for (i = n = 0; x && (i < (sizeof(long) * CHAR_BIT)); ++i, x >>= 1) 110 | n += (int)(x & 1L); 111 | return n; 112 | } 113 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitops.h: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** Macros and prototypes for bit operations 5 | ** 6 | ** public domain for SNIPPETS by: 7 | ** Scott Dudley 8 | ** Auke Reitsma 9 | ** Ratko Tomic 10 | ** Aare Tali 11 | ** J. Blauth 12 | ** Bruce Wedding 13 | ** Bob Stout 14 | */ 15 | 16 | #ifndef BITOPS__H 17 | #define BITOPS__H 18 | 19 | #include 20 | #include /* For size_t */ 21 | #include /* For CHAR_BIT */ 22 | #include "sniptype.h" /* For TOBOOL() */ 23 | #include "extkword.h" /* For CDECL */ 24 | 25 | /* 26 | ** Macros to manipulate bits in any integral data type. 27 | */ 28 | 29 | #define BitSet(arg,posn) ((arg) | (1L << (posn))) 30 | #define BitClr(arg,posn) ((arg) & ~(1L << (posn))) 31 | #define BitFlp(arg,posn) ((arg) ^ (1L << (posn))) 32 | #define BitTst(arg,posn) TOBOOL((arg) & (1L << (posn))) 33 | 34 | /* 35 | ** Macros to manipulate bits in an array of char. 36 | ** These macros assume CHAR_BIT is one of either 8, 16, or 32. 37 | */ 38 | 39 | #define MASK CHAR_BIT-1 40 | #define SHIFT ((CHAR_BIT==8)?3:(CHAR_BIT==16)?4:8) 41 | 42 | #define BitOff(a,x) ((void)((a)[(x)>>SHIFT] &= ~(1 << ((x)&MASK)))) 43 | #define BitOn(a,x) ((void)((a)[(x)>>SHIFT] |= (1 << ((x)&MASK)))) 44 | #define BitFlip(a,x) ((void)((a)[(x)>>SHIFT] ^= (1 << ((x)&MASK)))) 45 | #define IsBit(a,x) ((a)[(x)>>SHIFT] & (1 << ((x)&MASK))) 46 | 47 | /* 48 | ** BITARRAY.C 49 | */ 50 | 51 | char *alloc_bit_array(size_t bits); 52 | int getbit(char *set, int number); 53 | void setbit(char *set, int number, int value); 54 | void flipbit(char *set, int number); 55 | 56 | /* 57 | ** BITFILES.C 58 | */ 59 | 60 | typedef struct { 61 | FILE * file; /* for stream I/O */ 62 | char rbuf; /* read bit buffer */ 63 | char rcnt; /* read bit count */ 64 | char wbuf; /* write bit buffer */ 65 | char wcnt; /* write bit count */ 66 | } bfile; 67 | 68 | bfile * bfopen(char *name, char *mode); 69 | int bfread(bfile *bf); 70 | void bfwrite(int bit, bfile *bf); 71 | void bfclose(bfile *bf); 72 | 73 | /* 74 | ** BITSTRNG.C 75 | */ 76 | 77 | void bitstring(char *str, long byze, int biz, int strwid); 78 | 79 | /* 80 | ** BSTR_I.C 81 | */ 82 | 83 | unsigned int bstr_i(char *cptr); 84 | 85 | /* 86 | ** BITCNT_1.C 87 | */ 88 | 89 | int CDECL bit_count(long x); 90 | 91 | /* 92 | ** BITCNT_2.C 93 | */ 94 | 95 | int CDECL bitcount(long i); 96 | 97 | /* 98 | ** BITCNT_3.C 99 | */ 100 | 101 | int CDECL ntbl_bitcount(long int x); 102 | int CDECL BW_btbl_bitcount(long int x); 103 | int CDECL AR_btbl_bitcount(long int x); 104 | 105 | /* 106 | ** BITCNT_4.C 107 | */ 108 | 109 | int CDECL ntbl_bitcnt(long x); 110 | int CDECL btbl_bitcnt(long x); 111 | 112 | #endif /* BITOPS__H */ 113 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bitstrng.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** bitstring(): print bit pattern of bytes formatted to string. 5 | ** 6 | ** By J. Blauth, Sept. 1992. Hereby placed into the public domain. 7 | ** 8 | ** byze: value to transform to bitstring. 9 | ** biz: count of bits to be shown (counted from lowest bit, can be any 10 | ** even or odd number). 11 | ** strwid: total width the string shall have. Since between every 4 bits a 12 | ** blank (0x20) is inserted (not added after lowest bit), width of 13 | ** bitformat only is (biz+(biz/4-1)). Bits are printed right aligned, 14 | ** positions from highest bit to start of string filled with blanks. 15 | ** If value of strwid smaller than space needed to print all bits, 16 | ** strwid is ignored (e.g.: 17 | ** bitstr(s,b,16,5) results in 19 chars +'\0'). 18 | ** 19 | ** EXAMPLE: 20 | ** for (j = 1; j <= 16; j++) { bitstring(s, j, j, 16); puts(s); } 21 | ** 1: 1 22 | ** 2: 10 23 | ** 3: 011 24 | ** d: 0 0000 0000 1101 25 | ** e: 00 0000 0000 1110 26 | ** f: 000 0000 0000 1111 27 | */ 28 | 29 | #include "bitops.h" 30 | 31 | void bitstring(char *str, long byze, int biz, int strwid) 32 | { 33 | int i, j; 34 | 35 | j = strwid - (biz + (biz >> 2)- (biz % 4 ? 0 : 1)); 36 | for (i = 0; i < j; i++) 37 | *str++ = ' '; 38 | while (--biz >= 0) 39 | { 40 | *str++ = ((byze >> biz) & 1) + '0'; 41 | if (!(biz % 4) && biz) 42 | *str++ = ' '; 43 | } 44 | *str = '\0'; 45 | } 46 | 47 | #ifdef TEST 48 | 49 | #include 50 | 51 | int main(void) 52 | { 53 | char s[80]; long j; 54 | for (j = 1L; j <= 16L; j++) 55 | { 56 | bitstring(s, (long)j, (int)j, 16); 57 | printf("%2ld: %s\n", j, s); 58 | } 59 | return EXIT_SUCCESS; 60 | } 61 | 62 | #endif /* TEST */ 63 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/bstr_i.c: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** Make an ascii binary string into an integer. 5 | ** 6 | ** Public domain by Bob Stout 7 | */ 8 | 9 | #include 10 | #include "bitops.h" 11 | 12 | unsigned int bstr_i(char *cptr) 13 | { 14 | unsigned int i, j = 0; 15 | 16 | while (cptr && *cptr && strchr("01", *cptr)) 17 | { 18 | i = *cptr++ - '0'; 19 | j <<= 1; 20 | j |= (i & 0x01); 21 | } 22 | return(j); 23 | } 24 | 25 | #ifdef TEST 26 | 27 | #include 28 | 29 | int main(int argc, char *argv[]) 30 | { 31 | char *arg; 32 | unsigned int x; 33 | 34 | while (--argc) 35 | { 36 | x = bstr_i(arg = *++argv); 37 | printf("Binary %s = %d = %04Xh\n", arg, x, x); 38 | } 39 | return EXIT_SUCCESS; 40 | } 41 | 42 | #endif /* TEST */ 43 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # $1 = compiler 5 | # $2 = sequence 6 | # $3 = working set 7 | # $4 = times 8 | # 9 | 10 | function seconds() { 11 | t=`date +"%H:%M:%S:%N" | awk -F: '{printf "%f", ($1 * 3600) + ($2 * 60) + $3 + ($4 / 1000000000)}'` ; 12 | echo ${t} 13 | } 14 | 15 | function elapsed() { 16 | seconds=`echo "scale=4; ${2}-${1}" | sed -u 's/,/./g' | bc` ; 17 | echo ${seconds} 18 | } 19 | 20 | # Clean up 21 | if [[ ! $1 == "merge" ]]; then 22 | make -f Makefile.${1} cleanup &> /dev/null 23 | fi 24 | rm -f compile_time.yaml binary_size.yaml 25 | 26 | for i in `seq 1 $4`; do 27 | # Get the initial time 28 | initial_time=`seconds` 29 | 30 | # Compile the benchmark 31 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 32 | if [[ $? -eq 2 ]]; then 33 | exit 34 | fi 35 | 36 | # Get the final time 37 | final_time=`seconds` 38 | 39 | # Store the elapsed time 40 | value=`elapsed $initial_time $final_time` 41 | echo "- ${value}" >> compile_time.yaml 42 | 43 | done 44 | 45 | # Store the binary size 46 | value=`ls -l a.out | awk '{print $5}'` 47 | echo "${value}" > binary_size.yaml 48 | 49 | # Store the code size 50 | size a.out | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 51 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/config.status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Using /Users/guilhermeleobas/Programs/llvm38 as LLVM source directory" 4 | echo "Using /Users/guilhermeleobas/Programs/llvm38/build as LLVM object directory" 5 | echo "Using /Users/guilhermeleobas/Programs/llvm38/build/Release+Asserts/lib/.. as installation root" 6 | 7 | cat < Makefile 8 | ##======- Makefile --------------------------------------*- Makefile -*-======## 9 | ##===----------------------------------------------------------------------===## 10 | PROJECT_NAME = DCC888 11 | LIBRARYNAME = DCC888 12 | LOADABLE_MODULE = 1 13 | USEDLIBS = 14 | LEVEL = . 15 | LLVM_SRC_ROOT = /Users/guilhermeleobas/Programs/llvm38 16 | LLVM_OBJ_ROOT = /Users/guilhermeleobas/Programs/llvm38/build 17 | PROJ_SRC_ROOT = . 18 | PROJ_OBJ_ROOT = . 19 | PROJ_INSTALL_ROOT = /Users/guilhermeleobas/Programs/llvm38/build/Release+Asserts/lib/.. 20 | include \$(LLVM_OBJ_ROOT)/Makefile.config 21 | CXXFLAGS += -std=c++0x -Wno-deprecated-declarations -fexceptions -Wall -Wextra 22 | include \$(LLVM_SRC_ROOT)/Makefile.rules 23 | EOF 24 | 25 | echo "Generated Makefile" 26 | 27 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/conio.h: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** UNXCONIO.H - Port crucial DOS|Win|OS/2 non-blocking console I/O 5 | ** functions to Unix/Posix. 6 | ** 7 | ** public domain SNIPPETS header for use with Steve Poole's TERM_OPT.C 8 | */ 9 | 10 | #ifndef UNXCONIO__H 11 | #define UNXCONIO__H 12 | 13 | #include 14 | #include 15 | 16 | #define echo_on() term_option(0) 17 | #define echo_off() term_option(1) 18 | 19 | int term_option(); 20 | int getch(); 21 | 22 | #endif /* UNXCONIO__H */ 23 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/optimize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright 2021 Anderson Faustino da Silva 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | import subprocess 20 | import yaml 21 | 22 | from absl import logging 23 | 24 | 25 | def optimize_functions(): 26 | """Optimize each function""" 27 | fin = open('optimize.yaml', 'r') 28 | sequences = yaml.safe_load(fin) 29 | fin.close() 30 | 31 | for function, sequence in sequences.items(): 32 | cmdline = 'opt {0} {1}.bc -o {1}.bc'.format(sequence, function) 33 | try: 34 | subprocess.run(cmdline, 35 | shell=True, 36 | check=True, 37 | capture_output=False) 38 | except subprocess.CalledProcessError: 39 | logging.error('Optimize: {}'.format(function)) 40 | exit(1) 41 | 42 | 43 | # Execute 44 | if __name__ == '__main__': 45 | optimize_functions() 46 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/reference_output/reference_output_0.txt: -------------------------------------------------------------------------------- 1 | Bit counter algorithm benchmark 2 | 3 | Optimized 1 bit/loop counter > Bits: 744153 4 | Ratko's mystery algorithm > Bits: 744826 5 | Recursive bit count by nybbles > Bits: 745606 6 | Non-recursive bit count by nybbles > Bits: 740189 7 | Non-recursive bit count by bytes (BW) > Bits: 742576 8 | Non-recursive bit count by bytes (AR) > Bits: 742221 9 | Shift and count bits > Bits: 745540 10 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/reference_output/reference_output_1.txt: -------------------------------------------------------------------------------- 1 | Bit counter algorithm benchmark 2 | 3 | Optimized 1 bit/loop counter > Bits: 13254056 4 | Ratko's mystery algorithm > Bits: 13255501 5 | Recursive bit count by nybbles > Bits: 13257159 6 | Non-recursive bit count by nybbles > Bits: 13246703 7 | Non-recursive bit count by bytes (BW) > Bits: 13250340 8 | Non-recursive bit count by bytes (AR) > Bits: 13249450 9 | Shift and count bits > Bits: 13257011 10 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/reference_output/reference_output_2.txt: -------------------------------------------------------------------------------- 1 | Bit counter algorithm benchmark 2 | 3 | Optimized 1 bit/loop counter > Bits: 215000264 4 | Ratko's mystery algorithm > Bits: 215001150 5 | Recursive bit count by nybbles > Bits: 215002111 6 | Non-recursive bit count by nybbles > Bits: 214994336 7 | Non-recursive bit count by bytes (BW) > Bits: 214997188 8 | Non-recursive bit count by bytes (AR) > Bits: 214996527 9 | Shift and count bits > Bits: 215002037 10 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/reference_output/reference_output_3.txt: -------------------------------------------------------------------------------- 1 | Bit counter algorithm benchmark 2 | 3 | Optimized 1 bit/loop counter > Bits: 1653894850 4 | Ratko's mystery algorithm > Bits: 1653896794 5 | Recursive bit count by nybbles > Bits: 1653899031 6 | Non-recursive bit count by nybbles > Bits: 1653884516 7 | Non-recursive bit count by bytes (BW) > Bits: 1653889585 8 | Non-recursive bit count by bytes (AR) > Bits: 1653888362 9 | Shift and count bits > Bits: 1653898828 10 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/reference_output/reference_output_4.txt: -------------------------------------------------------------------------------- 1 | Bit counter algorithm benchmark 2 | 3 | Optimized 1 bit/loop counter > Bits: 3418026288 4 | Ratko's mystery algorithm > Bits: 3418028139 5 | Recursive bit count by nybbles > Bits: 3418030167 6 | Non-recursive bit count by nybbles > Bits: 3418015660 7 | Non-recursive bit count by bytes (BW) > Bits: 3418021098 8 | Non-recursive bit count by bytes (AR) > Bits: 3418019760 9 | Shift and count bits > Bits: 3418029993 10 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/automotive-bitcount/sniptype.h: -------------------------------------------------------------------------------- 1 | /* +++Date last modified: 05-Jul-1997 */ 2 | 3 | /* 4 | ** SNIPTYPE.H - Include file for SNIPPETS data types and commonly used macros 5 | */ 6 | 7 | #ifndef SNIPTYPE__H 8 | #define SNIPTYPE__H 9 | 10 | #include /* For free() */ 11 | #include /* For NULL & strlen() */ 12 | 13 | typedef enum {Error_ = -1, Success_, False_ = 0, True_} Boolean_T; 14 | 15 | /*#if !defined(WIN32) && !defined(_WIN32) && !defined(__NT__) \ 16 | && !defined(_WINDOWS) 17 | #if !defined(OS2)*/ 18 | typedef unsigned char BYTE; 19 | typedef unsigned long DWORD; 20 | /* #endif*/ 21 | typedef unsigned short WORD; 22 | /*#else 23 | #define WIN32_LEAN_AND_MEAN 24 | #define NOGDI 25 | #define NOSERVICE 26 | #undef INC_OLE1 27 | #undef INC_OLE2 28 | #include 29 | #define HUGE 30 | #endif*/ 31 | 32 | #define NUL '\0' 33 | #define LAST_CHAR(s) (((char *)s)[strlen(s) - 1]) 34 | #define TOBOOL(x) (!(!(x))) 35 | #define FREE(p) (free(p),(p)=NULL) 36 | 37 | #endif /* SNIPTYPE__H */ 38 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/LICENSE: -------------------------------------------------------------------------------- 1 | Can I use LAME in my commercial program? 2 | 3 | Yes, you can, under the restrictions of the LGPL. In particular, you 4 | can include a compiled version of the LAME library (for example, 5 | lame.dll) with a commercial program. Some notable requirements of 6 | the LGPL: 7 | 8 | 1. In your program, you cannot include any source code from LAME, with 9 | the exception of files whose only purpose is to describe the library 10 | interface (such as lame.h). 11 | 12 | 2. Any modifications of LAME must be released under the LGPL. 13 | The LAME project (www.sulaco.org/mp3) would appreciate being 14 | notified of any modifications. 15 | 16 | 3. You must give prominent notice that your program is: 17 | A. using LAME (including version number) 18 | B. LAME is under the LGPL 19 | C. Provide a copy of the LGPL. (the file COPYING contains the LGPL) 20 | D. Provide a copy of LAME source, or a pointer where the LAME 21 | source can be obtained (such as www.sulaco.org/mp3) 22 | An example of prominent notice would be an "About the LAME encoding engine" 23 | button in some pull down menu within the executable of your program. 24 | 25 | 4. If you determine that distribution of LAME requires a patent license, 26 | you must obtain such license. 27 | 28 | 29 | ***IMPORTANT NOTE*** 30 | 31 | The decoding functions provided in LAME use the mpglib decoding 32 | engine which is under the GPL. They may not be used by any 33 | program not released under the GPL unless you obtain such 34 | permission from the MPG123 project. (www.mpg123.de). 35 | 36 | LAME has built in support to read raw pcm and some wav and aiff files. 37 | More robust file I/O can be handled by compiling in LIBSNDFILE, 38 | but LIBSNDFILE is also under the GPL and my not be used by other 39 | programs not under the GPL. 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/Makefile.clang: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # Compile-time flags 15 | CFLAGS = -w -DHAVEMPGLIB -DLAMEPARSE -DNDEBUG -D__NO_MATH_INLINES -O -DLAMESNDFILE 16 | 17 | # Includes 18 | INCLUDES = 19 | 20 | # Library paths 21 | LFLAGS = 22 | 23 | # Linker flags 24 | LIBS = -lm 25 | 26 | # Source files 27 | SRCS = $(wildcard *.c) 28 | 29 | # Object file 30 | OBJS = $(SRCS:.c=.o) 31 | 32 | # 33 | # BUILD 34 | # 35 | 36 | .PHONY: depend clean 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | @$(CC) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS) 42 | 43 | %.o: %.c 44 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 45 | 46 | # 47 | # CLEAN 48 | # 49 | 50 | clean: 51 | @$(RM) -f *.o *~ *.yaml diff.txt runtime.csv error.log output.pgm 52 | 53 | cleanup: 54 | @$(RM) -f *.o *~ *.yaml $(TARGET) diff.txt runtime.csv error.log output.pgm 55 | 56 | # 57 | # DEPEND 58 | # 59 | depend: $(SRCS) 60 | @makedepend $(INCLUDES) $^ 61 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/Makefile.llvm: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -w -emit-llvm -DHAVEMPGLIB -DLAMEPARSE -DNDEBUG -D__NO_MATH_INLINES -O -DLAMESNDFILE 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | 56 | %.bc: %.c 57 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 58 | 59 | $(TARGET).o: $(IRS) 60 | @$(LINK) *.bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml diff.txt runtime.csv error.log output.pgm 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ *.yaml $(TARGET) diff.txt runtime.csv error.log output.pgm 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/Makefile.merge: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm -DHAVEMPGLIB -DLAMEPARSE -DNDEBUG -D__NO_MATH_INLINES -O -DLAMESNDFILE 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: 59 | @$(LINK) *.ll -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.ll a.out* *~ *.yaml diff.txt globals.yaml optimize.yaml runtime.csv error.log output.pgm 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.ll a.out* *~ *.yaml $(TARGET) diff.txt globals.yaml optimize.yaml runtime.csv error.log output.pgm 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/Makefile.opt: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm -DHAVEMPGLIB -DLAMEPARSE -DNDEBUG -D__NO_MATH_INLINES -O -DLAMESNDFILE 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: $(IRS) 59 | @$(LINK) *.bc -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml diff.txt runtime.csv error.log output.pgm 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ *.yaml $(TARGET) diff.txt runtime.csv error.log output.pgm 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/README: -------------------------------------------------------------------------------- 1 | MP3 library 2 | ----------- 3 | Version 0.2 4 | 5 | This decoder is a 'light' version (thrown out all unnecessay parts) 6 | from the mpg123 package. I made this for a company. 7 | 8 | Currently only Layer3 is enabled to save some space. Layer1,2 isn't 9 | tested at all. The interface will not change significantly. 10 | A backport to the mpg123 package is planed. 11 | 12 | comiled and tested only on Solaris 2.6 13 | main.c contains a simple demo application for library. 14 | 15 | COPYING: you may use this source under GPL terms! 16 | 17 | PLEASE NOTE: This software may contain patented alogrithm (at least 18 | patented in some countries). It may be not allowed to sell/use products 19 | based on this source code in these countries. Check this out first! 20 | 21 | COPYRIGHT of MP3 music: 22 | Please note, that the duplicating of copyrighted music without explicit 23 | permission violates the rights of the owner. 24 | 25 | SENDING PATCHES: 26 | Maybe I change the copyright policy (ie some kind of more free BSD licencse). 27 | Please consider this when sending patches/changes. 28 | 29 | FEEDBACK: 30 | I'm interessted to here from you, when you use this package as part 31 | of another project. 32 | 33 | 34 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/brhist.h: -------------------------------------------------------------------------------- 1 | #ifdef BRHIST 2 | #ifndef BRHIST_H_INCLUDED 3 | #define BRHIST_H_INCLUDED 4 | 5 | extern int disp_brhist; 6 | 7 | #include "lame.h" 8 | void brhist_init(lame_global_flags *gfp,int br_min, int br_max); 9 | void brhist_add_count(void); 10 | void brhist_disp(void); 11 | void brhist_disp_total(lame_global_flags *gfp); 12 | extern long brhist_temp[15]; 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # $1 = compiler 5 | # $2 = sequence 6 | # $3 = working set 7 | # $4 = times 8 | # 9 | 10 | function seconds() { 11 | t=`date +"%H:%M:%S:%N" | awk -F: '{printf "%f", ($1 * 3600) + ($2 * 60) + $3 + ($4 / 1000000000)}'` ; 12 | echo ${t} 13 | } 14 | 15 | function elapsed() { 16 | seconds=`echo "scale=4; ${2}-${1}" | sed -u 's/,/./g' | bc` ; 17 | echo ${seconds} 18 | } 19 | 20 | # Clean up 21 | if [[ ! $1 == "merge" ]]; then 22 | make -f Makefile.${1} cleanup &> /dev/null 23 | fi 24 | rm -f compile_time.yaml binary_size.yaml 25 | 26 | for i in `seq 1 $4`; do 27 | # Get the initial time 28 | initial_time=`seconds` 29 | 30 | # Compile the benchmark 31 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 32 | if [[ $? -eq 2 ]]; then 33 | exit 34 | fi 35 | 36 | # Get the final time 37 | final_time=`seconds` 38 | 39 | # Store the elapsed time 40 | value=`elapsed $initial_time $final_time` 41 | echo "- ${value}" >> compile_time.yaml 42 | 43 | done 44 | 45 | # Store the binary size 46 | value=`ls -l a.out | awk '{print $5}'` 47 | echo "${value}" > binary_size.yaml 48 | 49 | # Store the code size 50 | size a.out | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 51 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_DOT_H 2 | #define ENCODER_DOT_H 3 | /*********************************************************************** 4 | * 5 | * encoder and decoder delays 6 | * 7 | ***********************************************************************/ 8 | /* 9 | layerIII enc->dec delay: 1056 (observed) 10 | layerII enc->dec dealy: 480 (observed) 11 | 12 | 13 | polyphase 256-16 (dec or enc) = 240 14 | mdct 256+32 (9*32) (dec or enc) = 288 15 | total: 512+16 16 | 17 | */ 18 | 19 | 20 | 21 | /* ENCDELAY The encoder delay. 22 | 23 | Minimum allowed is MDCTDELAY (see below) 24 | 25 | The first 96 samples will be attenuated, so using a value 26 | less than 96 will result in lost data in the first 96-ENCDELAY 27 | samples. 28 | 29 | suggested: 800 30 | set to 1160 to sync with FhG. 31 | */ 32 | #define ENCDELAY 800 33 | 34 | 35 | 36 | 37 | /* delay of the MDCT used in mdct.c */ 38 | /* original ISO routiens had a delay of 528! Takehiro's routines: */ 39 | #define MDCTDELAY 48 40 | #define FFTOFFSET (224+MDCTDELAY) 41 | 42 | /* 43 | Most decoders, including the one we use, have a delay of 528 samples. 44 | */ 45 | #define DECDELAY 528 46 | 47 | 48 | /* number of subbands */ 49 | #define SBLIMIT 32 50 | 51 | /* parition bands bands */ 52 | #define CBANDS 63 53 | 54 | /* number of critical bands/scale factor bands where masking is computed*/ 55 | #define SBPSY_l 21 56 | #define SBPSY_s 12 57 | 58 | /* total number of scalefactor bands encoded */ 59 | #define SBMAX_l 22 60 | #define SBMAX_s 13 61 | 62 | 63 | 64 | /* FFT sizes */ 65 | #define BLKSIZE 1024 66 | #define HBLKSIZE 513 67 | #define BLKSIZE_s 256 68 | #define HBLKSIZE_s 129 69 | 70 | 71 | /* #define switch_pe 1800 */ 72 | #define NORM_TYPE 0 73 | #define START_TYPE 1 74 | #define SHORT_TYPE 2 75 | #define STOP_TYPE 3 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/execute.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function execute() { 4 | case $TOOL in 5 | "perf") 6 | PERF_TOOL="cycles instructions" 7 | PERF_TYPE="u" 8 | 9 | events=${PERF_TOOL// /:$PERF_TYPE,} 10 | events=$events:$PERF_TYPE 11 | 12 | if [[ $WARMUP_CACHE -eq 1 ]]; then 13 | timeout --signal=TERM ${RUNTIME} ./a.out $RUN_OPTIONS < $STDIN &> /dev/null 14 | if [[ $? -ne 0 ]]; then 15 | echo "Halting warmup cache due to some error" > error.log 16 | exit 1 17 | fi 18 | fi 19 | 20 | timeout --signal=TERM ${RUNTIME} perf stat -x "," -r \ 21 | $TIMES -o runtime.csv -e $events \ 22 | bash -c "./a.out $RUN_OPTIONS < $STDIN" &> /dev/null 23 | if [[ $? -ne 0 ]]; then 24 | echo "Halting execution (perf) due to some error" > error.log 25 | exit 1 26 | fi 27 | data=`sed '1!d' runtime.csv | awk -F',' '{printf "%s", $1}'` ; echo "- $data" > cycles.yaml 28 | data=`sed '2!d' runtime.csv | awk -F',' '{printf "%s", $1}'` ; echo "- $data" > instructions.yaml 29 | ;; 30 | "hyperfine") 31 | hyperfine -w $WARMUP_CACHE -r $TIMES --show-output \ 32 | --export-csv runtime.csv \ 33 | -u second "./a.out $RUN_OPTIONS < $STDIN" &> /dev/null 34 | if [[ $? -ne 0 ]]; then 35 | echo "Halting execution (hyperfine) due to some error" > error.log 36 | exit 1 37 | fi 38 | data=`sed '2!d' runtime.csv | awk -F',' '{printf "%s", $2}'` ; echo "- $data" > runtime.yaml 39 | ;; 40 | *) 41 | echo "Error: this tool is not implemented yet" > error.log 42 | exit 1 43 | ;; 44 | esac 45 | } 46 | 47 | function verify_output() { 48 | # Diff the two files. 49 | diff reference_output/reference_output_$WORKING_SET.mp3 output.mp3 > diff.txt 2>&1 50 | if [[ $? -eq 0 ]]; then 51 | # They are igual 52 | echo "succeed" > verify_output.yaml 53 | else 54 | # They are different 55 | echo "failed" > verify_output.yaml 56 | fi 57 | 58 | } 59 | 60 | # Command line parameters 61 | WORKING_SET=$1 62 | TIMES=$2 63 | TOOL=$3 64 | VERIFY_OUTPUT=$4 65 | WARMUP_CACHE=$5 66 | RUNTIME=$6 67 | STDIN=/dev/null 68 | 69 | case $WORKING_SET in 70 | 0) 71 | RUN_OPTIONS="small.wav output.mp3" 72 | ;; 73 | 1) 74 | RUN_OPTIONS="large.wav output.mp3" 75 | ;; 76 | *) 77 | echo "Error: dataset" 78 | exit 1 79 | ;; 80 | esac 81 | 82 | execute 83 | 84 | if [[ $VERIFY_OUTPUT -eq 1 ]]; then 85 | verify_output 86 | fi 87 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/fft.h: -------------------------------------------------------------------------------- 1 | #ifndef FFT_H 2 | #define FFT_H 3 | 4 | #include "encoder.h" 5 | 6 | void fft_long(FLOAT x_real[BLKSIZE], int, short **); 7 | void fft_short(FLOAT x_real[3][BLKSIZE_s], int, short **); 8 | void init_fft(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/get_audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 1999 Albert Faber 3 | ** 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | 21 | #ifndef GET_AUDIO_H_INCLUDED 22 | #define GET_AUDIO_H_INCLUDED 23 | 24 | #if (defined LIBSNDFILE || defined LAMESNDFILE) 25 | 26 | 27 | /* AIFF Definitions */ 28 | 29 | #define IFF_ID_FORM 0x464f524d /* "FORM" */ 30 | #define IFF_ID_AIFF 0x41494646 /* "AIFF" */ 31 | #define IFF_ID_COMM 0x434f4d4d /* "COMM" */ 32 | #define IFF_ID_SSND 0x53534e44 /* "SSND" */ 33 | #define IFF_ID_MPEG 0x4d504547 /* "MPEG" */ 34 | 35 | 36 | 37 | void CloseSndFile(lame_global_flags *gfp); 38 | FILE * OpenSndFile(lame_global_flags *gfp,const char* lpszFileName,int default_samp, int 39 | default_chan); 40 | unsigned long GetSndSamples(void); 41 | int GetSndSampleRate(void); 42 | int GetSndChannels(void); 43 | int GetSndBitrate(void); 44 | 45 | 46 | int get_audio(lame_global_flags *gfp,short buffer[2][1152],int stereo); 47 | 48 | 49 | 50 | #ifdef LIBSNDFILE 51 | /* INCLUDE the sound library header file */ 52 | #ifdef _MSC_VER 53 | /* one byte alignment for WIN32 platforms */ 54 | #pragma pack(push,1) 55 | #include "./libsndfile/src/sndfile.h" 56 | #pragma pack(pop,1) 57 | #else 58 | #include "sndfile.h" 59 | #endif 60 | 61 | 62 | #else 63 | /***************************************************************** 64 | * LAME/ISO built in audio file I/O routines 65 | *******************************************************************/ 66 | #include "portableio.h" 67 | #include "ieeefloat.h" 68 | 69 | 70 | typedef struct blockAlign_struct { 71 | unsigned long offset; 72 | unsigned long blockSize; 73 | } blockAlign; 74 | 75 | typedef struct IFF_AIFF_struct { 76 | short numChannels; 77 | unsigned long numSampleFrames; 78 | short sampleSize; 79 | FLOAT sampleRate; 80 | unsigned long sampleType; 81 | blockAlign blkAlgn; 82 | } IFF_AIFF; 83 | 84 | extern int aiff_read_headers(FILE*, IFF_AIFF*); 85 | extern int aiff_seek_to_sound_data(FILE*); 86 | extern int aiff_write_headers(FILE*, IFF_AIFF*); 87 | extern int parse_wavheader(void); 88 | extern int parse_aiff(const char fn[]); 89 | extern void aiff_check(const char*, IFF_AIFF*, int*); 90 | 91 | 92 | #endif /* ifndef _LIBSNDDLL */ 93 | #endif /* ifdef LAMESNDFILE or LIBSNDFILE */ 94 | #endif /* ifndef GET_AUDIO_H_INCLUDED*/ 95 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/gpkplotting.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* allocate a graphing widget */ 4 | GtkWidget *gpk_plot_new(int width,int height); 5 | 6 | /* graph a function in the graphing widged */ 7 | void gpk_graph_draw(GtkWidget *widget, 8 | int n, gdouble *xcord, gdouble *ycord, 9 | gdouble xmn, gdouble ymn,gdouble xmx,gdouble ymx, 10 | int clear, char * title,GdkColor *color); 11 | 12 | /* draw a rectangle in the graphing widget */ 13 | void gpk_rectangle_draw(GtkWidget *widget, /* plot on this widged */ 14 | gdouble xcord[2], gdouble ycord[2], /* corners */ 15 | gdouble xmn,gdouble ymn, /* coordinates of corners */ 16 | gdouble xmx,gdouble ymx, 17 | GdkColor *color); /* color to use */ 18 | 19 | /* make a bar graph in the graphing widged */ 20 | void gpk_bargraph_draw(GtkWidget *widget, 21 | int n, gdouble *xcord, gdouble *ycord, 22 | gdouble xmn, gdouble ymn,gdouble xmx,gdouble ymx, 23 | int clear, char * title, int bwidth,GdkColor *color); 24 | 25 | /* set forground color */ 26 | void setcolor(GtkWidget *widget, GdkColor *color,int red,int green,int blue); 27 | 28 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/gtkanal.h: -------------------------------------------------------------------------------- 1 | #ifndef GTKANAL_DOT_H 2 | #define GTKANAL_DOT_H 3 | #include "lame.h" 4 | #include "encoder.h" 5 | 6 | #define READ_AHEAD 10 /* number of frames to read ahead */ 7 | #define MAXMPGLAG READ_AHEAD /* if the mpg123 lag becomes bigger than this we have to stop */ 8 | #define NUMBACK 6 /* number of frames we can back up */ 9 | #define NUMPINFO (NUMBACK+READ_AHEAD+1) 10 | 11 | 12 | 13 | typedef struct { 14 | int frameNum; /* current frame number */ 15 | int frameNum123; 16 | int num_samples; /* number of pcm samples read for this frame */ 17 | double frametime; /* starting time of frame, in seconds */ 18 | double pcmdata[2][1600]; 19 | double pcmdata2[2][1152+1152-DECDELAY]; 20 | double xr[2][2][576]; 21 | double mpg123xr[2][2][576]; 22 | double ms_ratio[2]; 23 | double ms_ener_ratio[2]; 24 | 25 | /* L,R, M and S values */ 26 | double energy[2][4][BLKSIZE]; 27 | double pe[2][4]; 28 | double thr[2][4][SBMAX_l]; 29 | double en[2][4][SBMAX_l]; 30 | double thr_s[2][4][3*SBMAX_s]; 31 | double en_s[2][4][3*SBMAX_s]; 32 | double ers[2][4]; 33 | 34 | double sfb[2][2][SBMAX_l]; 35 | double sfb_s[2][2][3*SBMAX_s]; 36 | double LAMEsfb[2][2][SBMAX_l]; 37 | double LAMEsfb_s[2][2][3*SBMAX_s]; 38 | 39 | int LAMEqss[2][2]; 40 | int qss[2][2]; 41 | int big_values[2][2]; 42 | int sub_gain[2][2][3]; 43 | 44 | double xfsf[2][2][SBMAX_l]; 45 | double xfsf_s[2][2][3*SBMAX_s]; 46 | 47 | int over[2][2]; 48 | double tot_noise[2][2]; 49 | double max_noise[2][2]; 50 | double over_noise[2][2]; 51 | int blocktype[2][2]; 52 | int scalefac_scale[2][2]; 53 | int mpg123blocktype[2][2]; 54 | int mixed[2][2]; 55 | int mainbits[2][2]; 56 | int LAMEmainbits[2][2]; 57 | int framesize,stereo,js,ms_stereo,i_stereo,emph,bitrate,sampfreq,maindata; 58 | int crc,padding; 59 | int scfsi[2],mean_bits,resvsize; 60 | int totbits; 61 | } plotting_data; 62 | 63 | 64 | int gtkcontrol(lame_global_flags *gfp); 65 | extern plotting_data *pinfo; 66 | extern int gtkflag; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/id3tag.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/notebooks/data/benchmarks/MiBench/consumer-lame/id3tag.c -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/id3tag.h: -------------------------------------------------------------------------------- 1 | #ifndef ID3TAG_H_INCLUDED 2 | #define ID3TAG_H_INCLUDED 3 | typedef struct 4 | { 5 | int used; 6 | int valid; 7 | char title[31]; 8 | char artist[31]; 9 | char album[31]; 10 | char year[5]; 11 | char comment[31]; 12 | char tagtext[128]; 13 | char genre[1]; 14 | unsigned char track; 15 | 16 | } ID3TAGDATA; 17 | 18 | void id3_inittag(ID3TAGDATA *tag); 19 | void id3_buildtag(ID3TAGDATA *tag); 20 | int id3_writetag(char* filename, ID3TAGDATA *tag); 21 | 22 | 23 | /* 24 | * Array of all possible music genre. Grabbed from id3ed 25 | */ 26 | extern ID3TAGDATA id3tag; /* id3tag info */ 27 | extern int genre_last; 28 | extern char *genre_list[]; 29 | #endif 30 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/l3bitstream-pvt.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * ISO MPEG Audio Subgroup Software Simulation Group (1996) 3 | * ISO 13818-3 MPEG-2 Audio Encoder - Lower Sampling Frequency Extension 4 | * 5 | * $Id: l3bitstream-pvt.h 33045 2007-01-09 23:44:35Z lattner $ 6 | * 7 | * $Log$ 8 | * Revision 1.1 2007/01/09 23:44:35 lattner 9 | * Readd mibench 10 | * 11 | * Revision 1.1.1.1 2007/01/09 02:54:36 evancheng 12 | * Add selected tests from MiBench 1.0 to LLVM test suite. 13 | * 14 | * Revision 1.4 2000/03/21 23:02:17 markt 15 | * replaced all "gf." by gfp-> 16 | * 17 | * Revision 1.3 2000/02/01 11:26:32 takehiro 18 | * scalefactor's structure changed 19 | * 20 | * Revision 1.2 1999/12/09 00:44:34 cisc 21 | * Removed write_ancillary_data() prototype. (No longer used) 22 | * 23 | * Revision 1.1.1.1 1999/11/24 08:42:59 markt 24 | * initial checkin of LAME 25 | * Starting with LAME 3.57beta with some modifications 26 | * 27 | * Revision 1.1 1996/02/14 04:04:23 rowlands 28 | * Initial revision 29 | * 30 | * Received from Mike Coleman 31 | **********************************************************************/ 32 | 33 | #ifndef L3BITSTREAM_PVT_H 34 | #define L3BITSTREAM_PVT_H 35 | 36 | static int encodeSideInfo( lame_global_flags *gfp,III_side_info_t *si ); 37 | 38 | static void encodeMainData( lame_global_flags *gfp, 39 | int l3_enc[2][2][576], 40 | III_side_info_t *si, 41 | III_scalefac_t scalefac[2][2] ); 42 | 43 | static void drain_into_ancillary_data( int lengthInBits ); 44 | 45 | static void Huffmancodebits( BF_PartHolder **pph, int *ix, gr_info *gi ); 46 | 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/l3bitstream.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * ISO MPEG Audio Subgroup Software Simulation Group (1996) 3 | * ISO 13818-3 MPEG-2 Audio Encoder - Lower Sampling Frequency Extension 4 | * 5 | * $Id: l3bitstream.h 33045 2007-01-09 23:44:35Z lattner $ 6 | * 7 | * $Log$ 8 | * Revision 1.1 2007/01/09 23:44:35 lattner 9 | * Readd mibench 10 | * 11 | * Revision 1.1.1.1 2007/01/09 02:54:36 evancheng 12 | * Add selected tests from MiBench 1.0 to LLVM test suite. 13 | * 14 | * Revision 1.5 2000/03/21 23:02:17 markt 15 | * replaced all "gf." by gfp-> 16 | * 17 | * Revision 1.4 2000/03/14 20:45:04 markt 18 | * removed "info" sturct. Removing fr_ps struct 19 | * 20 | * Revision 1.3 2000/02/01 11:26:32 takehiro 21 | * scalefactor's structure changed 22 | * 23 | * Revision 1.2 1999/12/03 09:45:30 takehiro 24 | * little bit cleanup 25 | * 26 | * Revision 1.1.1.1 1999/11/24 08:43:09 markt 27 | * initial checkin of LAME 28 | * Starting with LAME 3.57beta with some modifications 29 | * 30 | * Revision 1.1 1996/02/14 04:04:23 rowlands 31 | * Initial revision 32 | * 33 | * Received from Mike Coleman 34 | **********************************************************************/ 35 | 36 | #ifndef L3_BITSTREAM_H 37 | #define L3_BITSTREAM_H 38 | 39 | #include "util.h" 40 | 41 | void III_format_bitstream( lame_global_flags *gfp, 42 | int bitsPerFrame, 43 | int l3_enc[2][2][576], 44 | III_side_info_t *l3_side, 45 | III_scalefac_t scalefac[2][2], 46 | Bit_stream_struc *in_bs); 47 | 48 | int HuffmanCode( int table_select, int x, int y, unsigned *code, unsigned int *extword, int *codebits, int *extbits ); 49 | void III_FlushBitstream(void); 50 | 51 | int abs_and_sign( int *x ); /* returns signx and changes *x to abs(*x) */ 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/l3side.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * date programmers comment * 3 | * 25. 6.92 Toshiyuki Ishino Ver 1.0 * 4 | * 29.10.92 Masahiro Iwadare Ver 2.0 * 5 | * 17. 4.93 Masahiro Iwadare Updated for IS Modification * 6 | * * 7 | *********************************************************************/ 8 | 9 | #ifndef L3_SIDE_H 10 | #define L3_SIDE_H 11 | #include "encoder.h" 12 | #include "machine.h" 13 | 14 | /* Layer III side information. */ 15 | 16 | typedef FLOAT8 D576[576]; 17 | typedef int I576[576]; 18 | typedef FLOAT8 D192_3[192][3]; 19 | typedef int I192_3[192][3]; 20 | 21 | 22 | typedef struct { 23 | FLOAT8 l[SBPSY_l + 1]; 24 | FLOAT8 s[SBPSY_s + 1][3]; 25 | } III_psy_xmin; 26 | 27 | typedef struct { 28 | III_psy_xmin thm; 29 | III_psy_xmin en; 30 | } III_psy_ratio; 31 | 32 | typedef struct { 33 | unsigned part2_3_length; 34 | unsigned big_values; 35 | unsigned count1; 36 | unsigned global_gain; 37 | unsigned scalefac_compress; 38 | unsigned window_switching_flag; 39 | unsigned block_type; 40 | unsigned mixed_block_flag; 41 | unsigned table_select[3]; 42 | int /* unsigned */ subblock_gain[3]; 43 | unsigned region0_count; 44 | unsigned region1_count; 45 | unsigned preflag; 46 | unsigned scalefac_scale; 47 | unsigned count1table_select; 48 | 49 | unsigned part2_length; 50 | unsigned sfb_lmax; 51 | unsigned sfb_smax; 52 | unsigned count1bits; 53 | /* added for LSF */ 54 | unsigned *sfb_partition_table; 55 | unsigned slen[4]; 56 | } gr_info; 57 | 58 | typedef struct { 59 | int main_data_begin; /* unsigned -> int */ 60 | unsigned private_bits; 61 | int resvDrain; 62 | unsigned scfsi[2][4]; 63 | struct { 64 | struct gr_info_ss { 65 | gr_info tt; 66 | } ch[2]; 67 | } gr[2]; 68 | } III_side_info_t; 69 | 70 | /* Layer III scale factors. */ 71 | /* note: there are only SBPSY_l=(SBMAX_l-1) and SBPSY_s=(SBMAX_s-1) scalefactors. 72 | * Dont know why these would be dimensioned SBMAX_l and SBMAX-s */ 73 | typedef struct { 74 | int l[SBMAX_l]; /* [cb] */ 75 | int s[SBMAX_s][3]; /* [window][cb] */ 76 | } III_scalefac_t; /* [gr][ch] */ 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/large.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/notebooks/data/benchmarks/MiBench/consumer-lame/large.wav -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/mpglib.h: -------------------------------------------------------------------------------- 1 | 2 | struct buf { 3 | unsigned char *pnt; 4 | long size; 5 | long pos; 6 | struct buf *next; 7 | struct buf *prev; 8 | }; 9 | 10 | struct framebuf { 11 | struct buf *buf; 12 | long pos; 13 | struct frame *next; 14 | struct frame *prev; 15 | }; 16 | 17 | struct mpstr { 18 | struct buf *head,*tail; 19 | int bsize; 20 | int framesize; 21 | int fsizeold; 22 | struct frame fr; 23 | unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */ 24 | real hybrid_block[2][2][SBLIMIT*SSLIMIT]; 25 | int hybrid_blc[2]; 26 | unsigned long header; 27 | int bsnum; 28 | real synth_buffs[2][2][0x110]; 29 | int synth_bo; 30 | 31 | }; 32 | 33 | 34 | #if ( defined(_MSC_VER) || defined(__BORLANDC__) ) 35 | typedef int BOOL; /* windef.h contains the same definition */ 36 | #else 37 | #define BOOL int 38 | #endif 39 | 40 | #define MP3_ERR -1 41 | #define MP3_OK 0 42 | #define MP3_NEED_MORE 1 43 | 44 | 45 | BOOL InitMP3(struct mpstr *mp); 46 | int decodeMP3(struct mpstr *mp,char *inmemory,int inmemsize, 47 | char *outmemory,int outmemsize,int *done); 48 | void ExitMP3(struct mpstr *mp); 49 | 50 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/newmdct.h: -------------------------------------------------------------------------------- 1 | #ifndef MDCT_DOT_H 2 | #define MDCT_DOT_H 3 | void mdct_sub48(lame_global_flags *gfp,short *w0, short *w1, 4 | FLOAT8 mdct_freq[2][2][576], 5 | III_side_info_t *l3_side); 6 | #endif 7 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/optimize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright 2021 Anderson Faustino da Silva 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | import subprocess 20 | import yaml 21 | 22 | from absl import logging 23 | 24 | 25 | def optimize_functions(): 26 | """Optimize each function""" 27 | fin = open('optimize.yaml', 'r') 28 | sequences = yaml.safe_load(fin) 29 | fin.close() 30 | 31 | for function, sequence in sequences.items(): 32 | cmdline = 'opt {0} {1}.bc -o {1}.bc'.format(sequence, function) 33 | try: 34 | subprocess.run(cmdline, 35 | shell=True, 36 | check=True, 37 | capture_output=False) 38 | except subprocess.CalledProcessError: 39 | logging.error('Optimize: {}'.format(function)) 40 | exit(1) 41 | 42 | 43 | # Execute 44 | if __name__ == '__main__': 45 | optimize_functions() 46 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/output.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/notebooks/data/benchmarks/MiBench/consumer-lame/output.mp3 -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/psymodel.h: -------------------------------------------------------------------------------- 1 | #ifndef L3PSY_DOT_H_ 2 | #define L3PSY_DOT_H_ 3 | 4 | /* l3psy.c */ 5 | #include "l3side.h" 6 | void L3psycho_anal( lame_global_flags *gfp, 7 | short int *buffer[2], int gr , 8 | FLOAT8 *ms_ratio, 9 | FLOAT8 *ms_ratio_next, 10 | FLOAT8 *ms_ener_ratio, 11 | III_psy_ratio ratio[2][2], 12 | III_psy_ratio MS_ratio[2][2], 13 | FLOAT8 pe[2], FLOAT8 pe_MS[2], 14 | int blocktype_d[2]); 15 | #endif 16 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/quantize.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * ISO MPEG Audio Subgroup Software Simulation Group (1996) 3 | * ISO 13818-3 MPEG-2 Audio Encoder - Lower Sampling Frequency Extension 4 | * 5 | * $Id: quantize.h 33045 2007-01-09 23:44:35Z lattner $ 6 | * 7 | * $Log$ 8 | * Revision 1.1 2007/01/09 23:44:35 lattner 9 | * Readd mibench 10 | * 11 | * Revision 1.1.1.1 2007/01/09 02:55:54 evancheng 12 | * Add selected tests from MiBench 1.0 to LLVM test suite. 13 | * 14 | * Revision 1.5 2000/03/21 23:02:17 markt 15 | * replaced all "gf." by gfp-> 16 | * 17 | * Revision 1.4 2000/03/14 21:01:47 markt 18 | * removed fr_ps struct 19 | * 20 | * Revision 1.3 2000/02/01 14:09:14 takehiro 21 | * code clean up. changed definition of structure to optimize array index calculation 22 | * 23 | * Revision 1.2 2000/02/01 11:26:32 takehiro 24 | * scalefactor's structure changed 25 | * 26 | * Revision 1.1.1.1 1999/11/24 08:43:45 markt 27 | * initial checkin of LAME 28 | * Starting with LAME 3.57beta with some modifications 29 | * 30 | * Revision 1.1 1996/02/14 04:04:23 rowlands 31 | * Initial revision 32 | * 33 | * Received from Mike Coleman 34 | **********************************************************************/ 35 | 36 | #ifndef LOOP_DOT_H 37 | #define LOOP_DOT_H 38 | #include "util.h" 39 | #include "l3side.h" 40 | 41 | /********************************************************************** 42 | * date programmers comment * 43 | * 25. 6.92 Toshiyuki Ishino Ver 1.0 * 44 | * 29.10.92 Masahiro Iwadare Ver 2.0 * 45 | * 17. 4.93 Masahiro Iwadare Updated for IS Modification * 46 | * * 47 | *********************************************************************/ 48 | 49 | extern int cont_flag; 50 | 51 | 52 | extern int pretab[]; 53 | 54 | void iteration_loop( lame_global_flags *gfp, 55 | FLOAT8 pe[2][2], FLOAT8 ms_ratio[2], 56 | FLOAT8 xr_org[2][2][576], III_psy_ratio ratio[2][2], 57 | III_side_info_t *l3_side, int l3_enc[2][2][576], 58 | III_scalefac_t scalefac[2][2]); 59 | 60 | void VBR_iteration_loop( lame_global_flags *gfp, 61 | FLOAT8 pe[2][2], FLOAT8 ms_ratio[2], 62 | FLOAT8 xr_org[2][2][576], III_psy_ratio ratio[2][2], 63 | III_side_info_t *l3_side, int l3_enc[2][2][576], 64 | III_scalefac_t scalefac[2][2]); 65 | 66 | 67 | 68 | 69 | #define maximum(A,B) ( (A) > (B) ? (A) : (B) ) 70 | #define minimum(A,B) ( (A) < (B) ? (A) : (B) ) 71 | #define signum( A ) ( (A) > 0 ? 1 : -1 ) 72 | 73 | 74 | extern int bit_buffer[50000]; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/reference_output/reference_output_0.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/notebooks/data/benchmarks/MiBench/consumer-lame/reference_output/reference_output_0.mp3 -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/reference_output/reference_output_1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/notebooks/data/benchmarks/MiBench/consumer-lame/reference_output/reference_output_1.mp3 -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/reservoir.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * ISO MPEG Audio Subgroup Software Simulation Group (1996) 3 | * ISO 13818-3 MPEG-2 Audio Encoder - Lower Sampling Frequency Extension 4 | * 5 | * $Id: reservoir.h 33045 2007-01-09 23:44:35Z lattner $ 6 | * 7 | * $Log$ 8 | * Revision 1.1 2007/01/09 23:44:35 lattner 9 | * Readd mibench 10 | * 11 | * Revision 1.1.1.1 2007/01/09 02:55:54 evancheng 12 | * Add selected tests from MiBench 1.0 to LLVM test suite. 13 | * 14 | * Revision 1.4 2000/03/21 23:02:17 markt 15 | * replaced all "gf." by gfp-> 16 | * 17 | * Revision 1.3 2000/03/14 21:01:47 markt 18 | * removed fr_ps struct 19 | * 20 | * Revision 1.2 2000/01/13 16:26:50 takehiro 21 | * moved info.stereo into gf.stereo 22 | * 23 | * Revision 1.1.1.1 1999/11/24 08:43:40 markt 24 | * initial checkin of LAME 25 | * Starting with LAME 3.57beta with some modifications 26 | * 27 | * Revision 1.1 1996/02/14 04:04:23 rowlands 28 | * Initial revision 29 | * 30 | * Received from Mike Coleman 31 | **********************************************************************/ 32 | /* 33 | Revision History: 34 | 35 | Date Programmer Comment 36 | ========== ========================= =============================== 37 | 1995/09/06 mc@fivebats.com created 38 | 39 | */ 40 | 41 | #ifndef RESERVOIR_H 42 | #define RESERVOIR_H 43 | 44 | int ResvFrameBegin( lame_global_flags *gfp,III_side_info_t *l3_side, int mean_bits, int frameLength ); 45 | void ResvMaxBits( int mean_bits, int *targ_bits, int *max_bits, int gr); 46 | void ResvAdjust(lame_global_flags *gfp,gr_info *gi, III_side_info_t *l3_side, int mean_bits ); 47 | void ResvFrameEnd(lame_global_flags *gfp,III_side_info_t *l3_side, int mean_bits ); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/rtp.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct rtpbits { 5 | int sequence:16; /* sequence number: random */ 6 | int pt:7; /* payload type: 14 for MPEG audio */ 7 | int m:1; /* marker: 0 */ 8 | int cc:4; /* number of CSRC identifiers: 0 */ 9 | int x:1; /* number of extension headers: 0 */ 10 | int p:1; /* is there padding appended: 0 */ 11 | int v:2; /* version: 2 */ 12 | }; 13 | 14 | struct rtpheader { /* in network byte order */ 15 | struct rtpbits b; 16 | int timestamp; /* start: random */ 17 | int ssrc; /* random */ 18 | int iAudioHeader; /* =0?! */ 19 | }; 20 | 21 | void initrtp(struct rtpheader *foo); 22 | int sendrtp(int fd, struct sockaddr_in *sSockAddr, struct rtpheader *foo, void *data, int len); 23 | int makesocket(char *szAddr,unsigned short port,int TTL,struct sockaddr_in *sSockAddr); 24 | void rtp_output(char *mp3buffer,int mp3size); 25 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/small.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/notebooks/data/benchmarks/MiBench/consumer-lame/small.wav -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/tables.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 1999 Albert L. Faber 3 | ** 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #ifndef TABLES_H_INCLUDED 21 | #define TABLES_H_INCLUDED 22 | #include "encoder.h" 23 | extern FLOAT8 psy_data[]; 24 | 25 | #define HUFFBITS unsigned long int 26 | #define HTN 34 27 | 28 | struct huffcodetab { 29 | unsigned int xlen; /*max. x-index+ */ 30 | unsigned int linmax; /*max number to be stored in linbits */ 31 | HUFFBITS *table; /*pointer to array[xlen][ylen] */ 32 | unsigned char *hlen; /*pointer to array[xlen][ylen] */ 33 | }; 34 | 35 | extern struct huffcodetab ht[HTN];/* global memory block */ 36 | /* array of all huffcodtable headers */ 37 | /* 0..31 Huffman code table 0..31 */ 38 | /* 32,33 count1-tables */ 39 | 40 | 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/timestatus.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMESTATUS_H_INCLUDED 2 | #define TIMESTATUS_H_INCLUDED 3 | 4 | 5 | void timestatus(int samp_rate,long frameNum,long totalframes, int framesize); 6 | 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Version numbering for LAME. 3 | * 4 | * Copyright (c) 1999 A.L. Faber 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | 23 | #include "version.h" 24 | #include "lame.h" 25 | #include 26 | 27 | static char lpszVersion[80]; 28 | 29 | void lame_print_version(FILE *ofile) { 30 | fprintf(ofile,"LAME version %s (www.sulaco.org/mp3) \n",get_lame_version()); 31 | fprintf(ofile,"GPSYCHO: GPL psycho-acoustic and noise shaping model version %s. \n",get_psy_version()); 32 | #ifdef LIBSNDFILE 33 | fprintf(ofile,"Input handled by libsndfile (www.zip.com.au/~erikd/libsndfile)\n"); 34 | #endif 35 | } 36 | 37 | 38 | char* get_lame_version(void) 39 | { 40 | if (LAME_ALPHAVERSION>0) 41 | sprintf(lpszVersion,"%d.%02d (alpha %d)",LAME_MAJOR_VERSION,LAME_MINOR_VERSION,LAME_ALPHAVERSION); 42 | else if (LAME_BETAVERSION>0) 43 | sprintf(lpszVersion,"%d.%02d (beta %d)",LAME_MAJOR_VERSION,LAME_MINOR_VERSION,LAME_BETAVERSION); 44 | else 45 | sprintf(lpszVersion,"%d.%02d",LAME_MAJOR_VERSION,LAME_MINOR_VERSION); 46 | return lpszVersion; 47 | } 48 | 49 | char* get_psy_version(void) 50 | { 51 | if (PSY_ALPHAVERSION>0) 52 | sprintf(lpszVersion,"%d.%02d (alpha %d)",PSY_MAJOR_VERSION,PSY_MINOR_VERSION,PSY_ALPHAVERSION); 53 | else if (PSY_BETAVERSION>0) 54 | sprintf(lpszVersion,"%d.%02d (beta %d)",PSY_MAJOR_VERSION,PSY_MINOR_VERSION,PSY_BETAVERSION); 55 | else 56 | sprintf(lpszVersion,"%d.%02d",PSY_MAJOR_VERSION,PSY_MINOR_VERSION); 57 | return lpszVersion; 58 | } 59 | 60 | char* get_mp3x_version(void) 61 | { 62 | if (MP3X_ALPHAVERSION>0) 63 | sprintf(lpszVersion,"%d:%02d (alpha %d)",MP3X_MAJOR_VERSION,MP3X_MINOR_VERSION,MP3X_ALPHAVERSION); 64 | else if (MP3X_BETAVERSION>0) 65 | sprintf(lpszVersion,"%d:%02d (beta %d)",MP3X_MAJOR_VERSION,MP3X_MINOR_VERSION,MP3X_BETAVERSION); 66 | else 67 | sprintf(lpszVersion,"%d:%02d",MP3X_MAJOR_VERSION,MP3X_MINOR_VERSION); 68 | return lpszVersion; 69 | } 70 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/consumer-lame/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Version numbering for LAME. 3 | * 4 | * Copyright (c) 1999 A.L. Faber 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 | * Boston, MA 02111-1307, USA. 20 | */ 21 | 22 | #ifndef LAME_H_INCLUDED 23 | #define LAME_H_INCLUDED 24 | 25 | #define LAME_MAJOR_VERSION 3 /* Major version number */ 26 | #define LAME_MINOR_VERSION 70 /* Minor version number */ 27 | #define LAME_ALPHAVERSION 0 /* Set number if this is an alpha version, otherwise zero */ 28 | #define LAME_BETAVERSION 0 /* Set number if this is a beta version, otherwise zero */ 29 | 30 | #define PSY_MAJOR_VERSION 0 /* Major version number */ 31 | #define PSY_MINOR_VERSION 77 /* Minor version number */ 32 | #define PSY_ALPHAVERSION 0 /* Set number if this is an alpha version, otherwise zero */ 33 | #define PSY_BETAVERSION 0 /* Set number if this is a beta version, otherwise zero */ 34 | 35 | #define MP3X_MAJOR_VERSION 0 /* Major version number */ 36 | #define MP3X_MINOR_VERSION 82 /* Minor version number */ 37 | #define MP3X_ALPHAVERSION 0 /* Set number if this is an alpha version, otherwise zero */ 38 | #define MP3X_BETAVERSION 0 /* Set number if this is a beta version, otherwise zero */ 39 | 40 | #include "machine.h" 41 | void lame_print_version(FILE *); 42 | char* get_lame_version(void); /* returns lame version number string */ 43 | char* get_psy_version(void); /* returns psy model version number string */ 44 | char* get_mp3x_version(void); /* returns mp3x version number string */ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | ============================================================== 3 | | | 4 | | readme.txt - by Don Cross | 5 | | | 6 | ============================================================== 7 | 8 | The file FFT.ZIP contains C source code for performing Discrete Fast Fourier 9 | Transforms (DFFTs) and inverse DFFTs. This source code is public domain. 10 | Use at your own risk. For more information, point your web browser at: 11 | 12 | http://www.intersrv.com/~dcross/fft.html 13 | 14 | Also, feel free to send questions/comments about this source code to me 15 | by e-mail at the address above. 16 | 17 | ------------------------------------------------------------------------------ 18 | 19 | *** SMALL REQUESTS **** 20 | 21 | If you want to give away copies of this source code, that's fine, so long 22 | as you do the following: 23 | 24 | - Do not charge any money for this source code, except for possibly a 25 | reasonable fee to cover postage, disk duplication, etc. I wrote this 26 | code and I want it to be FREE to EVERYONE! 27 | 28 | - Do not remove my name, e-mail address, or URL from any of the files in 29 | this collection. 30 | 31 | - Please keep this readme.txt file with the source and headers so that others 32 | can get in touch with me to ask questions and/or find my web page to read 33 | the online tutorial. 34 | 35 | - If you make any modifications to the source code, please add comments to 36 | it which include your name, e-mail address, web page URL (if any), and 37 | explain what you did to the code. 38 | 39 | - If you use this source code in an interesting program, please let me know. 40 | I promise will never try to get money from you, even if you use this code 41 | in a commercial program. I just want to know what kind of clever and 42 | creative things people do with Fourier Transforms. 43 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/Makefile.clang: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # Compile-time flags 15 | CFLAGS = -w 16 | 17 | # Includes 18 | INCLUDES = 19 | 20 | # Library paths 21 | LFLAGS = 22 | 23 | # Linker flags 24 | LIBS = -lm 25 | 26 | # Source files 27 | SRCS = $(wildcard *.c) 28 | 29 | # Object file 30 | OBJS = $(SRCS:.c=.o) 31 | 32 | # 33 | # BUILD 34 | # 35 | 36 | .PHONY: depend clean 37 | 38 | all: $(TARGET) 39 | 40 | $(TARGET): $(OBJS) 41 | @$(CC) -o $(TARGET) $(OBJS) $(LFLAGS) $(LIBS) 42 | 43 | %.o: %.c 44 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 45 | 46 | # 47 | # CLEAN 48 | # 49 | 50 | clean: 51 | @$(RM) -f *.o *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 52 | 53 | cleanup: 54 | @$(RM) -f *.o *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 55 | 56 | # 57 | # DEPEND 58 | # 59 | depend: $(SRCS) 60 | @makedepend $(INCLUDES) $^ 61 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/Makefile.llvm: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | 56 | %.bc: %.c 57 | @$(CC) $(PASSES) $(CFLAGS) $(INCLUDES) -c $< -o $@ 58 | 59 | $(TARGET).o: $(IRS) 60 | @$(LINK) *.bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/Makefile.merge: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: 59 | @$(LINK) *.ll -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.ll a.out* *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.ll a.out* *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/Makefile.opt: -------------------------------------------------------------------------------- 1 | # 2 | # TARGET 3 | # 4 | 5 | TARGET = a.out 6 | 7 | # 8 | # VARIABLES 9 | # 10 | 11 | # Compiler 12 | CC = clang 13 | 14 | # LLVM opt 15 | OPT = opt 16 | 17 | # LLVM linker 18 | LINK = llvm-link 19 | 20 | # LLVM compiler 21 | LLC = llc 22 | 23 | # Compile-time flags 24 | CFLAGS = -Xclang -disable-O0-optnone -w -emit-llvm 25 | 26 | # Includes 27 | INCLUDES = 28 | 29 | # Library paths 30 | LFLAGS = 31 | 32 | # Linker flags 33 | LIBS = -lm 34 | 35 | # Source files 36 | SRCS = $(wildcard *.c) 37 | 38 | # Object file 39 | OBJ = $(TARGET).o 40 | 41 | # LLVM IR files 42 | IRS = $(SRCS:.c=.bc) 43 | 44 | # 45 | # BUILD 46 | # 47 | 48 | .PHONY: depend clean 49 | 50 | all: $(TARGET) 51 | 52 | $(TARGET): $(OBJ) 53 | @$(CC) -o $(TARGET) $(OBJ) $(LFLAGS) $(LIBS) 54 | 55 | %.bc: %.c 56 | @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ 57 | 58 | $(TARGET).o: $(IRS) 59 | @$(LINK) *.bc -o $(TARGET).bc 60 | @$(OPT) $(PASSES) $(TARGET).bc -o $(TARGET)_o.bc 61 | @$(LLC) -filetype=obj $(TARGET)_o.bc -o $@ 62 | 63 | # 64 | # CLEAN 65 | # 66 | 67 | clean: 68 | @$(RM) -f *.o *.bc *~ *.yaml diff.txt output.txt output.all runtime.csv error.log 69 | 70 | cleanup: 71 | @$(RM) -f *.o *.bc *~ *.yaml $(TARGET) diff.txt output.txt output.all runtime.csv error.log 72 | 73 | # 74 | # DEPEND 75 | # 76 | depend: $(SRCS) 77 | @makedepend $(INCLUDES) $^ 78 | 79 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/README: -------------------------------------------------------------------------------- 1 | 2 | ============================================================== 3 | | | 4 | | readme.txt - by Don Cross | 5 | | | 6 | ============================================================== 7 | 8 | The file FFT.ZIP contains C source code for performing Discrete Fast Fourier 9 | Transforms (DFFTs) and inverse DFFTs. This source code is public domain. 10 | Use at your own risk. For more information, point your web browser at: 11 | 12 | http://www.intersrv.com/~dcross/fft.html 13 | 14 | Also, feel free to send questions/comments about this source code to me 15 | by e-mail at the address above. 16 | 17 | ------------------------------------------------------------------------------ 18 | 19 | *** SMALL REQUESTS **** 20 | 21 | If you want to give away copies of this source code, that's fine, so long 22 | as you do the following: 23 | 24 | - Do not charge any money for this source code, except for possibly a 25 | reasonable fee to cover postage, disk duplication, etc. I wrote this 26 | code and I want it to be FREE to EVERYONE! 27 | 28 | - Do not remove my name, e-mail address, or URL from any of the files in 29 | this collection. 30 | 31 | - Please keep this readme.txt file with the source and headers so that others 32 | can get in touch with me to ask questions and/or find my web page to read 33 | the online tutorial. 34 | 35 | - If you make any modifications to the source code, please add comments to 36 | it which include your name, e-mail address, web page URL (if any), and 37 | explain what you did to the code. 38 | 39 | - If you use this source code in an interesting program, please let me know. 40 | I promise will never try to get money from you, even if you use this code 41 | in a commercial program. I just want to know what kind of clever and 42 | creative things people do with Fourier Transforms. 43 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # $1 = compiler 5 | # $2 = sequence 6 | # $3 = working set 7 | # $4 = times 8 | # 9 | 10 | function seconds() { 11 | t=`date +"%H:%M:%S:%N" | awk -F: '{printf "%f", ($1 * 3600) + ($2 * 60) + $3 + ($4 / 1000000000)}'` ; 12 | echo ${t} 13 | } 14 | 15 | function elapsed() { 16 | seconds=`echo "scale=4; ${2}-${1}" | sed -u 's/,/./g' | bc` ; 17 | echo ${seconds} 18 | } 19 | 20 | # Clean up 21 | if [[ ! $1 == "merge" ]]; then 22 | make -f Makefile.${1} cleanup &> /dev/null 23 | fi 24 | rm -f compile_time.yaml binary_size.yaml 25 | 26 | for i in `seq 1 $4`; do 27 | # Get the initial time 28 | initial_time=`seconds` 29 | 30 | # Compile the benchmark 31 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 32 | if [[ $? -eq 2 ]]; then 33 | exit 34 | fi 35 | 36 | # Get the final time 37 | final_time=`seconds` 38 | 39 | # Store the elapsed time 40 | value=`elapsed $initial_time $final_time` 41 | echo "- ${value}" >> compile_time.yaml 42 | 43 | done 44 | 45 | # Store the binary size 46 | value=`ls -l a.out | awk '{print $5}'` 47 | echo "${value}" > binary_size.yaml 48 | 49 | # Store the code size 50 | size a.out | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 51 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/ddc.h: -------------------------------------------------------------------------------- 1 | /*============================================================================ 2 | 3 | ddc.h - Don Cross, October 1992. 4 | 5 | Generic ddclib stuff. 6 | 7 | ============================================================================*/ 8 | 9 | #ifndef __DDC_DDC_H 10 | #define __DDC_DDC_H 11 | 12 | // If you add something to DDCRET, please add the appropriate string 13 | // to the function DDCRET_String() in the file 'source\ddcret.cpp'. 14 | 15 | enum DDCRET 16 | { 17 | DDC_SUCCESS, // The operation succeded 18 | DDC_FAILURE, // The operation failed for unspecified reasons 19 | DDC_OUT_OF_MEMORY, // Operation failed due to running out of memory 20 | DDC_FILE_ERROR, // Operation encountered file I/O error 21 | DDC_INVALID_CALL, // Operation was called with invalid parameters 22 | DDC_USER_ABORT, // Operation was aborted by the user 23 | DDC_INVALID_FILE // File format does not match 24 | }; 25 | 26 | 27 | const char *DDCRET_String ( DDCRET ); // See source\ddcret.cpp 28 | 29 | 30 | #define TRUE 1 31 | #define FALSE 0 32 | 33 | typedef int dBOOLEAN; 34 | 35 | typedef unsigned char BYTE; 36 | 37 | typedef unsigned char UINT8; 38 | typedef signed char INT8; 39 | 40 | typedef unsigned short int UINT16; 41 | typedef signed short int INT16; 42 | typedef unsigned long int UINT32; 43 | typedef signed long int INT32; 44 | 45 | #ifdef __BORLANDC__ 46 | #if sizeof(UINT16) != 2 47 | #error Need to fix UINT16 and INT16 48 | #endif 49 | 50 | #if sizeof(UINT32) != 4 51 | #error Need to fix UINT32 and INT32 52 | #endif 53 | #endif 54 | 55 | #endif /* __DDC_DDC_H */ 56 | 57 | /*--- end of file ddc.h ---*/ 58 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/ddcmath.h: -------------------------------------------------------------------------------- 1 | /*========================================================================== 2 | 3 | ddcmath.h - Don Cross , October 1994. 4 | 5 | Contains useful math stuff. 6 | 7 | ==========================================================================*/ 8 | 9 | #ifndef __ddcmath_h 10 | #define __ddcmath_h 11 | 12 | #define DDC_PI (3.14159265358979323846) 13 | 14 | #endif /* __ddcmath_h */ 15 | 16 | /*--- end of file ddcmath.h ---*/ 17 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/fftmisc.c: -------------------------------------------------------------------------------- 1 | /*============================================================================ 2 | 3 | fftmisc.c - Don Cross 4 | 5 | http://www.intersrv.com/~dcross/fft.html 6 | 7 | Helper routines for Fast Fourier Transform implementation. 8 | Contains common code for fft_float() and fft_double(). 9 | 10 | See also: 11 | fourierf.c 12 | fourierd.c 13 | ..\include\fourier.h 14 | 15 | Revision history: 16 | 17 | 1998 September 19 [Don Cross] 18 | Improved the efficiency of IsPowerOfTwo(). 19 | Updated coding standards. 20 | 21 | ============================================================================*/ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "fourier.h" 28 | 29 | #define TRUE 1 30 | #define FALSE 0 31 | 32 | #define BITS_PER_WORD (sizeof(unsigned) * 8) 33 | 34 | 35 | int IsPowerOfTwo ( unsigned x ) 36 | { 37 | if ( x < 2 ) 38 | return FALSE; 39 | 40 | if ( x & (x-1) ) // Thanks to 'byang' for this cute trick! 41 | return FALSE; 42 | 43 | return TRUE; 44 | } 45 | 46 | 47 | unsigned NumberOfBitsNeeded ( unsigned PowerOfTwo ) 48 | { 49 | unsigned i; 50 | 51 | if ( PowerOfTwo < 2 ) 52 | { 53 | fprintf ( 54 | stderr, 55 | ">>> Error in fftmisc.c: argument %d to NumberOfBitsNeeded is too small.\n", 56 | PowerOfTwo ); 57 | 58 | exit(1); 59 | } 60 | 61 | for ( i=0; ; i++ ) 62 | { 63 | if ( PowerOfTwo & (1 << i) ) 64 | return i; 65 | } 66 | } 67 | 68 | 69 | 70 | unsigned ReverseBits ( unsigned index, unsigned NumBits ) 71 | { 72 | unsigned i, rev; 73 | 74 | for ( i=rev=0; i < NumBits; i++ ) 75 | { 76 | rev = (rev << 1) | (index & 1); 77 | index >>= 1; 78 | } 79 | 80 | return rev; 81 | } 82 | 83 | 84 | double Index_to_frequency ( unsigned NumSamples, unsigned Index ) 85 | { 86 | if ( Index >= NumSamples ) 87 | return 0.0; 88 | else if ( Index <= NumSamples/2 ) 89 | return (double)Index / (double)NumSamples; 90 | 91 | return -(double)(NumSamples-Index) / (double)NumSamples; 92 | } 93 | 94 | 95 | /*--- end of file fftmisc.c---*/ 96 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/fourier.h: -------------------------------------------------------------------------------- 1 | /*============================================================================ 2 | 3 | fourier.h - Don Cross 4 | 5 | http://www.intersrv.com/~dcross/fft.html 6 | 7 | Contains definitions for doing Fourier transforms 8 | and inverse Fourier transforms. 9 | 10 | ============================================================================*/ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* 17 | ** fft() computes the Fourier transform or inverse transform 18 | ** of the complex inputs to produce the complex outputs. 19 | ** The number of samples must be a power of two to do the 20 | ** recursive decomposition of the FFT algorithm. 21 | ** See Chapter 12 of "Numerical Recipes in FORTRAN" by 22 | ** Press, Teukolsky, Vetterling, and Flannery, 23 | ** Cambridge University Press. 24 | ** 25 | ** Notes: If you pass ImaginaryIn = NULL, this function will "pretend" 26 | ** that it is an array of all zeroes. This is convenient for 27 | ** transforming digital samples of real number data without 28 | ** wasting memory. 29 | */ 30 | 31 | void fft_double ( 32 | unsigned NumSamples, /* must be a power of 2 */ 33 | int InverseTransform, /* 0=forward FFT, 1=inverse FFT */ 34 | double *RealIn, /* array of input's real samples */ 35 | double *ImaginaryIn, /* array of input's imag samples */ 36 | double *RealOut, /* array of output's reals */ 37 | double *ImaginaryOut ); /* array of output's imaginaries */ 38 | 39 | 40 | void fft_float ( 41 | unsigned NumSamples, /* must be a power of 2 */ 42 | int InverseTransform, /* 0=forward FFT, 1=inverse FFT */ 43 | float *RealIn, /* array of input's real samples */ 44 | float *ImaginaryIn, /* array of input's imag samples */ 45 | float *RealOut, /* array of output's reals */ 46 | float *ImaginaryOut ); /* array of output's imaginaries */ 47 | 48 | 49 | int IsPowerOfTwo ( unsigned x ); 50 | unsigned NumberOfBitsNeeded ( unsigned PowerOfTwo ); 51 | unsigned ReverseBits ( unsigned index, unsigned NumBits ); 52 | 53 | /* 54 | ** The following function returns an "abstract frequency" of a 55 | ** given index into a buffer with a given number of frequency samples. 56 | ** Multiply return value by sampling rate to get frequency expressed in Hz. 57 | */ 58 | double Index_to_frequency ( unsigned NumSamples, unsigned Index ); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | 65 | /*--- end of file fourier.h ---*/ 66 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/MiBench/telecomm-FFT/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "fourier.h" 6 | 7 | // RNG implemented localy to avoid library incongruences 8 | #ifdef RAND_MAX 9 | #undef RAND_MAX 10 | #endif 11 | #define RAND_MAX 32767 12 | static unsigned long long int next = 1; 13 | 14 | int rand( void ) { 15 | next = next * 1103515245 + 12345; 16 | return (unsigned int)(next / 65536) % RAND_MAX+1; 17 | } 18 | 19 | void srand( unsigned int seed ) { 20 | next = seed; 21 | } 22 | // End of RNG implementation 23 | 24 | int main(int argc, char *argv[]) { 25 | unsigned MAXSIZE; 26 | unsigned MAXWAVES; 27 | unsigned i,j; 28 | float *RealIn; 29 | float *ImagIn; 30 | float *RealOut; 31 | float *ImagOut; 32 | float *coeff; 33 | float *amp; 34 | int invfft=0; 35 | 36 | if (argc<3) 37 | { 38 | printf("Usage: fft -i\n"); 39 | printf("-i performs an inverse fft\n"); 40 | printf("make random sinusoids"); 41 | printf(" is the number of samples\n"); 42 | exit(-1); 43 | } 44 | else if (argc==4) 45 | invfft = !strncmp(argv[3],"-i",2); 46 | MAXSIZE=atoi(argv[2]); 47 | MAXWAVES=atoi(argv[1]); 48 | srand(1); 49 | 50 | RealIn=(float*)malloc(sizeof(float)*MAXSIZE); 51 | ImagIn=(float*)malloc(sizeof(float)*MAXSIZE); 52 | RealOut=(float*)malloc(sizeof(float)*MAXSIZE); 53 | ImagOut=(float*)malloc(sizeof(float)*MAXSIZE); 54 | coeff=(float*)malloc(sizeof(float)*MAXWAVES); 55 | amp=(float*)malloc(sizeof(float)*MAXWAVES); 56 | 57 | /* Makes MAXWAVES waves of random amplitude and period */ 58 | for(i=0;i /dev/null 23 | fi 24 | rm -f compile_time.yaml binary_size.yaml 25 | 26 | for i in `seq 1 $4`; do 27 | # Get the initial time 28 | initial_time=`seconds` 29 | 30 | # Compile the benchmark 31 | make PASSES="${2}" -f Makefile.${1} &> /dev/null 32 | if [[ $? -eq 2 ]]; then 33 | exit 34 | fi 35 | 36 | # Get the final time 37 | final_time=`seconds` 38 | 39 | # Store the elapsed time 40 | value=`elapsed $initial_time $final_time` 41 | echo "- ${value}" >> compile_time.yaml 42 | 43 | done 44 | 45 | # Store the binary size 46 | value=`ls -l a.out | awk '{print $5}'` 47 | echo "${value}" > binary_size.yaml 48 | 49 | # Store the code size 50 | size a.out | tail -n 1 | awk '{printf "text: %s \ndata: %s \nbss: %s\n", $1, $2, $3}' > code_size.yaml 51 | -------------------------------------------------------------------------------- /notebooks/data/benchmarks/Others/Fibonacci/fibonacci.c: -------------------------------------------------------------------------------- 1 | //#include 2 | 3 | int Fib(int x) { 4 | switch(x) { 5 | case 0: 6 | return 0; 7 | case 1: 8 | return 1; 9 | default: 10 | return Fib(x - 1) + Fib(x - 2); 11 | } 12 | } 13 | 14 | int main(){ 15 | printf("%d\n", Fib(10)); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /notebooks/data/sequences/levels.yaml: -------------------------------------------------------------------------------- 1 | O0: 2 | seq: 3 | - -O0 4 | O1: 5 | seq: 6 | - -O1 7 | O2: 8 | seq: 9 | - -O2 10 | O3: 11 | seq: 12 | - -O3 13 | Os: 14 | seq: 15 | - -Os 16 | Oz: 17 | seq: 18 | - -Oz 19 | -------------------------------------------------------------------------------- /notebooks/data/training_data_levels/AnghaBench/extr_accept_fd_leak_main.yaml: -------------------------------------------------------------------------------- 1 | clang: 2 | O0: 3 | goal: 367.0 4 | seq: 5 | - -O0 6 | O1: 7 | goal: 289.0 8 | seq: 9 | - -O1 10 | O2: 11 | goal: 291.0 12 | seq: 13 | - -O2 14 | O3: 15 | goal: 291.0 16 | seq: 17 | - -O3 18 | Os: 19 | goal: 291.0 20 | seq: 21 | - -Os 22 | Oz: 23 | goal: 278.0 24 | seq: 25 | - -Oz 26 | opt: 27 | O0: 28 | goal: 367.0 29 | seq: 30 | - -O0 31 | O1: 32 | goal: 280.0 33 | seq: 34 | - -O1 35 | O2: 36 | goal: 282.0 37 | seq: 38 | - -O2 39 | O3: 40 | goal: 282.0 41 | seq: 42 | - -O3 43 | Os: 44 | goal: 282.0 45 | seq: 46 | - -Os 47 | Oz: 48 | goal: 269.0 49 | seq: 50 | - -Oz 51 | -------------------------------------------------------------------------------- /notebooks/data/training_data_levels/AnghaBench/extr_adv7180_adv7180_probe.yaml: -------------------------------------------------------------------------------- 1 | clang: 2 | O0: 3 | goal: 287.0 4 | seq: 5 | - -O0 6 | O1: 7 | goal: 167.0 8 | seq: 9 | - -O1 10 | O2: 11 | goal: 169.0 12 | seq: 13 | - -O2 14 | O3: 15 | goal: 169.0 16 | seq: 17 | - -O3 18 | Os: 19 | goal: 169.0 20 | seq: 21 | - -Os 22 | Oz: 23 | goal: 169.0 24 | seq: 25 | - -Oz 26 | opt: 27 | O0: 28 | goal: 287.0 29 | seq: 30 | - -O0 31 | O1: 32 | goal: 167.0 33 | seq: 34 | - -O1 35 | O2: 36 | goal: 169.0 37 | seq: 38 | - -O2 39 | O3: 40 | goal: 169.0 41 | seq: 42 | - -O3 43 | Os: 44 | goal: 169.0 45 | seq: 46 | - -Os 47 | Oz: 48 | goal: 169.0 49 | seq: 50 | - -Oz 51 | -------------------------------------------------------------------------------- /notebooks/data/training_data_levels/AnghaBench/extr_aes_rijndaelDecrypt.yaml: -------------------------------------------------------------------------------- 1 | clang: 2 | O0: 3 | goal: 268.0 4 | seq: 5 | - -O0 6 | O1: 7 | goal: 156.0 8 | seq: 9 | - -O1 10 | O2: 11 | goal: 156.0 12 | seq: 13 | - -O2 14 | O3: 15 | goal: 156.0 16 | seq: 17 | - -O3 18 | Os: 19 | goal: 156.0 20 | seq: 21 | - -Os 22 | Oz: 23 | goal: 156.0 24 | seq: 25 | - -Oz 26 | opt: 27 | O0: 28 | goal: 268.0 29 | seq: 30 | - -O0 31 | O1: 32 | goal: 156.0 33 | seq: 34 | - -O1 35 | O2: 36 | goal: 156.0 37 | seq: 38 | - -O2 39 | O3: 40 | goal: 156.0 41 | seq: 42 | - -O3 43 | Os: 44 | goal: 156.0 45 | seq: 46 | - -Os 47 | Oz: 48 | goal: 156.0 49 | seq: 50 | - -Oz 51 | -------------------------------------------------------------------------------- /yacos/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from . import info 18 | from . import model 19 | from . import essential 20 | from . import algorithm 21 | from . import data_processing 22 | 23 | __version__ = '2.0.0' 24 | -------------------------------------------------------------------------------- /yacos/algorithm/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from .metaheuristics import SGA, PSO 18 | from .random_ import Random 19 | from .benchmark_reduction import BenchmarkReduction 20 | from .sequence_reduction import SequenceReduction 21 | from .best_k import BestK 22 | from .batch_elimination import BatchElimination 23 | from .iterative_elimination import IterativeElimination 24 | from .combined_elimination import CombinedElimination 25 | from .improved_batch_elimination import ImprovedBatchElimination 26 | from .cbr import CBR 27 | from .cbr_function import CBR_Function 28 | 29 | __version__ = '1.0.0' 30 | -------------------------------------------------------------------------------- /yacos/data_processing/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from .clustering import Clustering 18 | 19 | __version__ = '2.0.0' 20 | -------------------------------------------------------------------------------- /yacos/essential/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from .io import IO 18 | from .sequence import Sequence 19 | from .goal import Goal 20 | from .engine import Engine 21 | from .similarity import Similarity 22 | from .dataset import Dataset 23 | 24 | __version__ = '1.0.0' 25 | -------------------------------------------------------------------------------- /yacos/info/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | 18 | from . import compy 19 | from . import image 20 | from . import ncc 21 | 22 | __version__ = '2.0.0' 23 | -------------------------------------------------------------------------------- /yacos/info/compy/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2020 Alexander Brauckmann. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from .common import RepresentationBuilder, Sequence, Graph 18 | from .extractors import * 19 | from .ast_graphs import ASTVisitor, ASTDataVisitor, ASTDataCFGVisitor, ASTGraphBuilder 20 | from .llvm_graphs import ( 21 | LLVMCFGVisitor, 22 | LLVMCFGCompactVisitor, 23 | LLVMCFGCallVisitor, 24 | LLVMCFGCallNoRootVisitor, 25 | LLVMCFGCallCompactMultipleEdgesVisitor, 26 | LLVMCFGCallCompactSingleEdgeVisitor, 27 | LLVMCFGCallCompactMultipleEdgesNoRootVisitor, 28 | LLVMCFGCallCompactSingleEdgeNoRootVisitor, 29 | LLVMCDFGVisitor, 30 | LLVMCDFGCompactMultipleEdgesVisitor, 31 | LLVMCDFGCompactSingleEdgeVisitor, 32 | LLVMCDFGCallVisitor, 33 | LLVMCDFGCallNoRootVisitor, 34 | LLVMCDFGCallCompactMultipleEdgesVisitor, 35 | LLVMCDFGCallCompactSingleEdgeVisitor, 36 | LLVMCDFGCallCompactMultipleEdgesNoRootVisitor, 37 | LLVMCDFGCallCompactSingleEdgeNoRootVisitor, 38 | LLVMCDFGPlusVisitor, 39 | LLVMCDFGPlusNoRootVisitor, 40 | LLVMProGraMLVisitor, 41 | LLVMProGraMLNoRootVisitor, 42 | LLVMGraphBuilder 43 | ) 44 | from .syntax_seq import ( 45 | SyntaxSeqVisitor, 46 | SyntaxTokenkindVisitor, 47 | SyntaxTokenkindVariableVisitor, 48 | SyntaxSeqBuilder 49 | ) 50 | from .llvm_seq import LLVMSeqVisitor, LLVMSeqBuilder 51 | from .llvm_info import LLVMNamesBuilder, LLVMInstsBuilder, LLVMWLCostBuilder 52 | from .llvm_vec import LLVMHistogramBuilder, LLVMOpcodesBuilder, LLVMMSFBuilder, LLVMLoopBuilder, LLVMIR2VecBuilder 53 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common compile options 2 | set(compile_options_common 3 | -fno-rtti -fPIC 4 | -Wall -Wextra 5 | # LLVM warnings 6 | -Wno-unused-parameter -Wno-tautological-overlap-compare -Wno-deprecated-copy -Wno-class-memaccess -Wno-maybe-uninitialized 7 | # Clang warnings 8 | -Wno-comment -Wno-strict-aliasing) 9 | 10 | # Common library 11 | add_library(extractors_common 12 | common/clang_driver.cc 13 | common/llvm_driver.cc) 14 | 15 | llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_TARGETS_TO_BUILD} 16 | asmparser 17 | core 18 | linker 19 | bitreader 20 | irreader 21 | ipo 22 | scalaropts 23 | analysis 24 | support 25 | frontendopenmp 26 | option 27 | passes 28 | objcarcopts 29 | coroutines 30 | lto 31 | coverage 32 | aarch64codegen 33 | ) 34 | target_include_directories(extractors_common PUBLIC 35 | . 36 | ${LLVM_INCLUDE_DIRS} 37 | ${CLANG_INCLUDE_DIRS} 38 | ) 39 | target_link_libraries(extractors_common 40 | -Wl,--start-group 41 | ${REQ_LLVM_LIBRARIES} 42 | clangBasic 43 | clangFrontendTool 44 | -Wl,--end-group 45 | ) 46 | target_compile_options(extractors_common PRIVATE 47 | ${compile_options_common} 48 | ) 49 | 50 | # Common tests 51 | add_executable(extractors_common_tests 52 | common/clang_driver_test.cc 53 | ) 54 | target_link_libraries(extractors_common_tests 55 | extractors_common 56 | 57 | gmock 58 | gtest 59 | gtest_main 60 | ) 61 | target_compile_options(extractors_common_tests PRIVATE 62 | -fno-rtti -fPIC 63 | ) 64 | 65 | # LLVM pybind11 module 66 | pybind11_add_module(extractors 67 | extractors.cc 68 | ) 69 | target_link_libraries(extractors PRIVATE 70 | clang_extractor 71 | llvm_extractor 72 | ) 73 | target_compile_options(extractors PRIVATE 74 | -Wno-unused-value 75 | ) 76 | 77 | add_subdirectory(clang_ast) 78 | add_subdirectory(llvm_ir) 79 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from .extractors import ClangDriver 18 | from .extractors import LLVMDriver 19 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/clang_ast/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Extractor library 2 | add_library(clang_extractor 3 | clang_extractor.cc 4 | clang_graph_frontendaction.cc 5 | clang_seq_frontendaction.cc 6 | ) 7 | target_link_libraries(clang_extractor 8 | extractors_common 9 | ) 10 | target_compile_options(clang_extractor PRIVATE 11 | ${compile_options_common} 12 | ) 13 | 14 | # Extractor tests 15 | add_executable(clang_extractor_tests 16 | clang_extractor_test.cc 17 | ) 18 | target_link_libraries(clang_extractor_tests 19 | clang_extractor 20 | 21 | gmock 22 | gtest 23 | gtest_main 24 | ) 25 | target_compile_options(clang_extractor_tests PRIVATE 26 | -fno-rtti -fPIC 27 | ) -------------------------------------------------------------------------------- /yacos/info/compy/extractors/clang_ast/clang_extractor.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "clang_extractor.h" 18 | 19 | #include 20 | 21 | #include "clang/Config/config.h" 22 | #include "clang/Frontend/CompilerInvocation.h" 23 | #include "clang/Lex/PreprocessorOptions.h" 24 | #include "llvm/LinkAllPasses.h" 25 | #include "llvm/Support/Compiler.h" 26 | 27 | #include "clang_seq_frontendaction.h" 28 | #include "clang_graph_frontendaction.h" 29 | 30 | using namespace ::clang; 31 | using namespace ::llvm; 32 | 33 | namespace compy { 34 | namespace clang { 35 | 36 | ClangExtractor::ClangExtractor(ClangDriverPtr clangDriver) 37 | : clangDriver_(clangDriver) {} 38 | 39 | graph::ExtractionInfoPtr ClangExtractor::GraphFromSource(std::string filename) { 40 | compy::clang::graph::ExtractorFrontendAction* fa = 41 | new compy::clang::graph::ExtractorFrontendAction(); 42 | 43 | std::vector<::clang::FrontendAction *> frontendActions; 44 | std::vector<::llvm::Pass *> passes; 45 | 46 | frontendActions.push_back(fa); 47 | 48 | clangDriver_->Invoke(filename, frontendActions, passes); 49 | 50 | return fa->extractionInfo; 51 | } 52 | 53 | seq::ExtractionInfoPtr ClangExtractor::SeqFromSource(std::string filename) { 54 | compy::clang::seq::ExtractorFrontendAction* fa = 55 | new compy::clang::seq::ExtractorFrontendAction(); 56 | 57 | std::vector<::clang::FrontendAction *> frontendActions; 58 | std::vector<::llvm::Pass *> passes; 59 | 60 | frontendActions.push_back(fa); 61 | 62 | clangDriver_->Invoke(filename, frontendActions, passes); 63 | 64 | return fa->extractionInfo; 65 | } 66 | 67 | } // namespace clang 68 | } // namespace compy 69 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/clang_ast/clang_graph_frontendaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include "clang/AST/AST.h" 25 | #include "clang/AST/ExternalASTSource.h" 26 | #include "clang/AST/RecursiveASTVisitor.h" 27 | #include "clang/Frontend/FrontendActions.h" 28 | #include "clang_extractor.h" 29 | #include "llvm/ADT/StringRef.h" 30 | 31 | namespace compy { 32 | namespace clang { 33 | namespace graph { 34 | 35 | class ExtractorASTVisitor 36 | : public ::clang::RecursiveASTVisitor { 37 | public: 38 | ExtractorASTVisitor(::clang::ASTContext &context, 39 | ExtractionInfoPtr extractionInfo) 40 | : context_(context), extractionInfo_(extractionInfo) {} 41 | 42 | bool VisitStmt(::clang::Stmt *s); 43 | bool VisitFunctionDecl(::clang::FunctionDecl *f); 44 | 45 | private: 46 | FunctionInfoPtr getInfo(const ::clang::FunctionDecl &func); 47 | CFGBlockInfoPtr getInfo(const ::clang::CFGBlock &block); 48 | StmtInfoPtr getInfo(const ::clang::Stmt &stmt); 49 | DeclInfoPtr getInfo(const ::clang::Decl &decl); 50 | 51 | private: 52 | ::clang::ASTContext &context_; 53 | ExtractionInfoPtr extractionInfo_; 54 | 55 | std::unordered_map stmtInfos_; 56 | std::unordered_map cfgBlockInfos_; 57 | std::unordered_map declInfos_; 58 | }; 59 | 60 | class ExtractorASTConsumer : public ::clang::ASTConsumer { 61 | public: 62 | ExtractorASTConsumer(::clang::ASTContext &context, 63 | ExtractionInfoPtr extractionInfo); 64 | 65 | bool HandleTopLevelDecl(::clang::DeclGroupRef DR) override; 66 | 67 | private: 68 | ExtractorASTVisitor visitor_; 69 | }; 70 | 71 | class ExtractorFrontendAction : public ::clang::ASTFrontendAction { 72 | public: 73 | std::unique_ptr<::clang::ASTConsumer> CreateASTConsumer( 74 | ::clang::CompilerInstance &CI, ::llvm::StringRef file) override; 75 | 76 | ExtractionInfoPtr extractionInfo; 77 | }; 78 | 79 | } // namespace graph 80 | } // namespace clang 81 | } // namespace compy 82 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/clang_ast/clang_seq_frontendaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "clang/AST/AST.h" 24 | #include "clang/AST/ExternalASTSource.h" 25 | #include "clang/AST/RecursiveASTVisitor.h" 26 | #include "clang/Frontend/FrontendActions.h" 27 | #include "clang_extractor.h" 28 | #include "llvm/ADT/StringRef.h" 29 | 30 | namespace compy { 31 | namespace clang { 32 | namespace seq { 33 | 34 | class ExtractorASTVisitor 35 | : public ::clang::RecursiveASTVisitor { 36 | public: 37 | enum STATE { 38 | Map = 0, 39 | Capture = 1, 40 | }; 41 | 42 | public: 43 | ExtractorASTVisitor(::clang::ASTContext &context, 44 | ExtractionInfoPtr extractionInfo) 45 | : state_(STATE::Map), context_(context), extractionInfo_(extractionInfo) { 46 | init(); 47 | } 48 | 49 | void init(); 50 | void setState(STATE state); 51 | 52 | bool VisitFunctionDecl(::clang::FunctionDecl *f); 53 | bool VisitVarDecl(::clang::VarDecl *decl); 54 | 55 | private: 56 | FunctionInfoPtr getInfo(const ::clang::FunctionDecl &func); 57 | 58 | std::string mapName(const ::clang::NamedDecl &decl); 59 | 60 | private: 61 | STATE state_; 62 | ::clang::ASTContext &context_; 63 | ExtractionInfoPtr extractionInfo_; 64 | 65 | std::unordered_map mappedNames_; 66 | unsigned int num_functions_; 67 | unsigned int num_variables_; 68 | }; 69 | 70 | class ExtractorASTConsumer : public ::clang::ASTConsumer { 71 | public: 72 | ExtractorASTConsumer(::clang::ASTContext &context, 73 | ExtractionInfoPtr extractionInfo); 74 | 75 | bool HandleTopLevelDecl(::clang::DeclGroupRef DR) override; 76 | 77 | private: 78 | ExtractorASTVisitor visitor_; 79 | }; 80 | 81 | class ExtractorFrontendAction : public ::clang::ASTFrontendAction { 82 | public: 83 | std::unique_ptr<::clang::ASTConsumer> CreateASTConsumer( 84 | ::clang::CompilerInstance &CI, ::llvm::StringRef file) override; 85 | 86 | ExtractionInfoPtr extractionInfo; 87 | }; 88 | 89 | } // namespace seq 90 | } // namespace clang 91 | } // namespace compy 92 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/common/clang_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "clang/Frontend/FrontendAction.h" 25 | #include "llvm/IR/LegacyPassManager.h" 26 | #include "llvm/IR/Module.h" 27 | #include "llvm/Pass.h" 28 | 29 | namespace compy { 30 | 31 | class ClangDriver { 32 | public: 33 | enum ProgrammingLanguage { 34 | C = 0, 35 | CPLUSPLUS = 1, 36 | OPENCL = 3 37 | }; 38 | 39 | enum OptimizationLevel { O0 = 0, O1 = 1, O2 = 2, O3 = 3, Os = 4, Oz = 5}; 40 | 41 | enum IncludeDirType { 42 | SYSTEM = 0, 43 | USER = 1, 44 | }; 45 | 46 | public: 47 | ClangDriver(ProgrammingLanguage programmingLanguage, 48 | OptimizationLevel optimizationLevel, 49 | std::vector> includeDirs, 50 | std::vector compilerFlags); 51 | 52 | void addIncludeDir(std::string includeDir, IncludeDirType includeDirType); 53 | void removeIncludeDir(std::string includeDir, IncludeDirType includeDirType); 54 | void setOptimizationLevel(OptimizationLevel optimizationLevel); 55 | 56 | void Invoke(std::string filename, std::vector<::clang::FrontendAction *> frontendActions, 57 | std::vector<::llvm::Pass *> passes); 58 | 59 | private: 60 | std::shared_ptr<::llvm::legacy::PassManager> pm_; 61 | 62 | ProgrammingLanguage programmingLanguage_; 63 | OptimizationLevel optimizationLevel_; 64 | std::vector> includeDirs_; 65 | std::vector compilerFlags_; 66 | 67 | }; 68 | using ClangDriverPtr = std::shared_ptr; 69 | 70 | } // namespace compy 71 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/common/clang_driver_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "clang_driver.h" 18 | 19 | #include 20 | 21 | #include "gmock/gmock.h" 22 | #include "gtest/gtest.h" 23 | 24 | using namespace testing; 25 | using namespace compy; 26 | 27 | class MockPass : public llvm::ModulePass { 28 | public: 29 | char ID = 0; 30 | MockPass() : llvm::ModulePass(ID) {} 31 | 32 | MOCK_METHOD1(runOnModule, bool(llvm::Module &M)); 33 | MOCK_CONST_METHOD1(getAnalysisUsage, void(llvm::AnalysisUsage &au)); 34 | }; 35 | 36 | class ClangDriverFixture : public testing::Test { 37 | protected: 38 | void SetUp() override { 39 | // Init extractor 40 | std::vector> 41 | includeDirs = { 42 | std::make_tuple("/usr/include", 43 | ClangDriver::IncludeDirType::SYSTEM), 44 | std::make_tuple("/usr/include/x86_64-linux-gnu", 45 | ClangDriver::IncludeDirType::SYSTEM), 46 | std::make_tuple( 47 | "/devel/git_3rd/llvm-project/build_release/lib/clang/" 48 | "7.1.0/include/", 49 | ClangDriver::IncludeDirType::SYSTEM)}; 50 | std::vector compilerFlags = {"-Werror"}; 51 | 52 | clang_.reset(new ClangDriver(ClangDriver::ProgrammingLanguage::C, 53 | ClangDriver::OptimizationLevel::O0, 54 | includeDirs, compilerFlags)); 55 | } 56 | 57 | std::shared_ptr clang_; 58 | }; 59 | 60 | // Tests 61 | TEST_F(ClangDriverFixture, CompileWithPassFunction1) { 62 | NiceMock *pass = new NiceMock(); 63 | EXPECT_CALL(*pass, runOnModule(_)).Times(AtLeast(1)); 64 | 65 | std::vector<::clang::FrontendAction *> frontendActions; 66 | std::vector<::llvm::Pass *> passes; 67 | passes.push_back(pass); 68 | 69 | clang_->Invoke("program_k1.c", frontendActions, passes); 70 | } 71 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/common/llvm_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "clang/Frontend/FrontendAction.h" 25 | #include "llvm/IR/LegacyPassManager.h" 26 | #include "llvm/IR/Module.h" 27 | #include "llvm/Pass.h" 28 | 29 | namespace compy { 30 | 31 | class LLVMDriver { 32 | public: 33 | LLVMDriver(std::vector optimizations); 34 | LLVMDriver(); 35 | void addOptimizationFront(std::string optimization); 36 | void addOptimizationsFront(std::vector optimizations); 37 | void addOptimizationBack(std::string optimization); 38 | void addOptimizationsBack(std::vector optimizations); 39 | void removeOptimization(std::string optimization); 40 | void removeOptimizationsFront(int optimizations); 41 | void removeOptimizationsBack(int optimizations); 42 | void setOptimizations(std::vector optimizations); 43 | std::vector getOptimizations(); 44 | void clearOptimizations(); 45 | void Invoke(std::string filename, std::vector<::llvm::Pass *> passes); 46 | 47 | private: 48 | void addOptimizationPasses(); 49 | std::shared_ptr<::llvm::legacy::PassManager> pm_; 50 | std::vector optimizations_; 51 | }; 52 | 53 | using LLVMDriverPtr = std::shared_ptr; 54 | 55 | } // namespace compy 56 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/common/visitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace compy { 20 | 21 | struct IVisitee; 22 | struct IVisitor { 23 | virtual void visit(IVisitee* v) = 0; 24 | }; 25 | 26 | struct IVisitee { 27 | virtual void accept(IVisitor* v) = 0; 28 | }; 29 | 30 | } // namespace compy 31 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Extractor library 2 | add_library(llvm_extractor 3 | llvm_extractor.cc 4 | llvm_graph_pass.cc 5 | llvm_graph_funcinfo.cc 6 | llvm_seq_pass.cc 7 | llvm_msf_pass.cc 8 | llvm_names_pass.cc 9 | llvm_ir2vec_pass.cc 10 | llvm_insts_pass.cc 11 | llvm_histogram_pass.cc 12 | llvm_opcodes_pass.cc 13 | llvm_wl_cost_pass.cc 14 | llvm_wl_cost_funcinfo.cc 15 | llvm_loop_pass.cc 16 | llvm_loop_funcinfo.cc 17 | ) 18 | target_link_libraries(llvm_extractor 19 | wl_static_profiler 20 | extractors_common 21 | libIR2Vec.a 22 | ) 23 | target_compile_options(llvm_extractor PRIVATE 24 | ${compile_options_common} 25 | ) 26 | 27 | # Extractor tests 28 | add_executable(llvm_extractor_tests 29 | llvm_pass_test.cc 30 | llvm_extractor_test.cc 31 | ) 32 | target_link_libraries(llvm_extractor_tests 33 | llvm_extractor 34 | gmock 35 | gtest 36 | gtest_main 37 | ) 38 | target_compile_options(llvm_extractor_tests PRIVATE 39 | -fno-rtti -fPIC 40 | ) 41 | 42 | add_subdirectory(wl_static_profiler) 43 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_graph_funcinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "llvm/Analysis/MemorySSA.h" 25 | #include "llvm/Analysis/TargetTransformInfo.h" 26 | #include "llvm/IR/Function.h" 27 | #include "llvm/Pass.h" 28 | #include "llvm/Support/raw_ostream.h" 29 | #include "wl_static_profiler/block_edge_frequency_pass.h" 30 | #include "llvm_extractor.h" 31 | 32 | namespace compy { 33 | namespace llvm { 34 | namespace graph { 35 | 36 | class FunctionInfoPass : public ::llvm::FunctionPass { 37 | private: 38 | FunctionInfoPtr info_; 39 | 40 | public: 41 | static char ID; 42 | 43 | FunctionInfoPass() : ::llvm::FunctionPass(ID), info_(nullptr) {} 44 | 45 | bool runOnFunction(::llvm::Function &func) override; 46 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 47 | 48 | const FunctionInfoPtr &getInfo() const { return info_; } 49 | FunctionInfoPtr &getInfo() { return info_; } 50 | 51 | private: 52 | std::string getUniqueName(const ::llvm::Value &v); 53 | ArgInfoPtr getInfo(const ::llvm::Argument &arg); 54 | ConstantInfoPtr getInfo(const ::llvm::Constant &con); 55 | BasicBlockInfoPtr getInfo(const ::llvm::BasicBlock &bb); 56 | InstructionInfoPtr getInfo(const ::llvm::Instruction &inst); 57 | MemoryAccessInfoPtr getInfo(::llvm::MemoryAccess &acc); 58 | 59 | private: 60 | std::unordered_map argInfos; 61 | std::unordered_map constantInfos; 62 | std::unordered_map 63 | basicBlockInfos; 64 | std::unordered_map 65 | instructionInfos; 66 | std::unordered_map 67 | memoryAccessInfos; 68 | std::unordered_map valueNames; 69 | }; 70 | 71 | } // namespace graph 72 | } // namespace llvm 73 | } // namespace compy 74 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_graph_pass.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "llvm_graph_pass.h" 18 | 19 | #include 20 | #include 21 | 22 | #include "llvm/Analysis/CallGraph.h" 23 | #include "llvm_graph_funcinfo.h" 24 | 25 | using namespace ::llvm; 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace graph { 30 | 31 | bool ExtractorPass::runOnModule(::llvm::Module &module) { 32 | ExtractionInfoPtr info(new ExtractionInfo()); 33 | 34 | // Collect and dump all the function information 35 | for (auto &func : module.functions()) { 36 | // Skip functions without definition (fwd declarations) 37 | if (func.isDeclaration()) { 38 | continue; 39 | } 40 | 41 | auto &pass = getAnalysis(func); 42 | auto functionInfo = std::move(pass.getInfo()); 43 | info->functionInfos.push_back(std::move(functionInfo)); 44 | } 45 | 46 | // Dump the call graph 47 | info->callGraphInfo.reset(new CallGraphInfo()); 48 | 49 | const auto &callGraph = getAnalysis().getCallGraph(); 50 | for (auto &kv : callGraph) { 51 | auto *func = kv.first; 52 | auto &node = kv.second; 53 | 54 | // Skip the null entry 55 | if (func == nullptr) continue; 56 | 57 | // -1, because the null entry references everything 58 | for (auto &kv : *node) { 59 | // Skip for functions without definition (fwd declarations) 60 | if (kv.second->getFunction()) { 61 | info->callGraphInfo->calls.push_back( 62 | // kv.second->getFunction()->getName()); (CHANGED) 63 | kv.second->getFunction()->getName().str()); 64 | } 65 | } 66 | } 67 | 68 | this->extractionInfo = info; 69 | 70 | // Returning false indicates that we didn't change anything 71 | return false; 72 | } 73 | 74 | void ExtractorPass::getAnalysisUsage(AnalysisUsage &au) const { 75 | au.addRequired(); 76 | au.addRequired(); 77 | au.setPreservesAll(); 78 | } 79 | 80 | char ExtractorPass::ID = 0; 81 | static ::llvm::RegisterPass X("graphExtractor", "GraphExtractor", 82 | true /* Only looks at CFG */, 83 | true /* Analysis Pass */); 84 | 85 | } // namespace graph 86 | } // namespace llvm 87 | } // namespace compy 88 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_graph_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | 28 | namespace compy { 29 | namespace llvm { 30 | namespace graph { 31 | 32 | struct ExtractionInfo; 33 | using ExtractionInfoPtr = std::shared_ptr; 34 | 35 | class ExtractorPass : public ::llvm::ModulePass { 36 | public: 37 | static char ID; 38 | ExtractorPass() : ::llvm::ModulePass(ID) {} 39 | 40 | bool runOnModule(::llvm::Module &M) override; 41 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 42 | 43 | ExtractionInfoPtr extractionInfo; 44 | }; 45 | 46 | } // namespace graph 47 | } // namespace llvm 48 | } // namespace compy 49 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_histogram_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace histogram { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | private: 33 | std::map instructions; 34 | void initInstructions(); 35 | void updateInstruction(std::string key, float value); 36 | public: 37 | static char ID; 38 | ExtractorPass() : ::llvm::ModulePass(ID) {} 39 | 40 | bool runOnModule(::llvm::Module &M) override; 41 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 42 | 43 | ExtractionInfoPtr extractionInfo; 44 | }; 45 | 46 | } // namespace histogram 47 | } // namespace llvm 48 | } // namespace compy 49 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_insts_pass.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "llvm_insts_pass.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace ::llvm; 24 | 25 | namespace compy { 26 | namespace llvm { 27 | namespace insts { 28 | 29 | bool ExtractorPass::runOnModule(::llvm::Module &module) { 30 | ExtractionInfoPtr info(new ExtractionInfo); 31 | 32 | for (const auto &F : module.functions()) { 33 | if (F.isDeclaration()) 34 | continue; 35 | 36 | unsigned instructions = 0; 37 | for (const auto &bb : F.getBasicBlockList()) 38 | for (const auto &inst : bb) 39 | instructions++; 40 | 41 | FunctionInfoPtr functionInfo(new FunctionInfo); 42 | functionInfo->name = F.getName().str(); 43 | functionInfo->instructions = instructions; 44 | 45 | info->functionInfos.push_back(functionInfo); 46 | } 47 | 48 | this->extractionInfo = info; 49 | return false; 50 | } 51 | 52 | void ExtractorPass::getAnalysisUsage(AnalysisUsage &au) const { 53 | au.setPreservesAll(); 54 | } 55 | 56 | char ExtractorPass::ID = 0; 57 | static ::llvm::RegisterPass X("instsExtractor", "InstsExtractor", 58 | true /* Only looks at CFG */, 59 | true /* Analysis Pass */); 60 | 61 | } // namespace insts 62 | } // namespace llvm 63 | } // namespace compy 64 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_insts_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace insts { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | }; 41 | 42 | } // namespace insts 43 | } // namespace llvm 44 | } // namespace compy 45 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_ir2vec_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace ir2vec { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | }; 41 | 42 | } // namespace ir2vec 43 | } // namespace llvm 44 | } // namespace compy 45 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_loop_funcinfo.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright 2021 Anderson Faustino da Silva 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "llvm/Analysis/LoopInfo.h" 26 | #include "llvm/Analysis/DependenceAnalysis.h" 27 | 28 | #include "llvm_extractor.h" 29 | 30 | namespace compy { 31 | namespace llvm { 32 | namespace loop { 33 | 34 | class FunctionInfoPass : public ::llvm::FunctionPass { 35 | private: 36 | FunctionInfoPtr info_; 37 | 38 | std::vector tracking_; 39 | std::map features_; 40 | 41 | void initFeatures(); 42 | void updateFeature(std::string key, float value); 43 | void DependenceCheckFunctionIntern(const ::llvm::Function &F, 44 | ::llvm::DependenceInfo &DI, 45 | std::vector<::llvm::Instruction*> loopInsts); 46 | void DependenceCheckFunctionExtern(const ::llvm::Function &F, 47 | ::llvm::DependenceInfo &DI, 48 | std::vector<::llvm::Instruction*> loopInsts); 49 | void RecursiveIterLoopFramework(const ::llvm::Function &F, 50 | ::llvm::DependenceInfo &DI, 51 | ::llvm::Loop *L, 52 | std::vector<::llvm::Instruction*> defUseOfArrays, 53 | unsigned nesting); 54 | void FeaturesExtractor(::llvm::Function &F, ::llvm::DependenceInfo &DI, ::llvm::LoopInfo &LI); 55 | public: 56 | static char ID; 57 | 58 | FunctionInfoPass() : ::llvm::FunctionPass(ID), info_(nullptr) {} 59 | 60 | bool runOnFunction(::llvm::Function &func) override; 61 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 62 | 63 | const FunctionInfoPtr &getInfo() const { return info_; } 64 | FunctionInfoPtr &getInfo() { return info_; } 65 | }; 66 | 67 | } // namespace loop 68 | } // namespace llvm 69 | } // namespace compy 70 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_loop_pass.cc: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright 2021 Anderson Faustino da Silva 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | // Wu Larus function cost 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "llvm_loop_pass.h" 25 | #include "llvm_loop_funcinfo.h" 26 | 27 | using namespace ::llvm; 28 | 29 | namespace compy { 30 | namespace llvm { 31 | namespace loop { 32 | 33 | bool ExtractorPass::runOnModule(::llvm::Module &module) { 34 | ExtractionInfoPtr info(new ExtractionInfo); 35 | 36 | // Collect the function information 37 | for (auto &func : module.functions()) { 38 | // Skip functions without definition (fwd declarations) 39 | if (func.isDeclaration()) 40 | continue; 41 | 42 | auto &pass = getAnalysis(func); 43 | auto functionInfo = std::move(pass.getInfo()); 44 | info->functionInfos.push_back(std::move(functionInfo)); 45 | } 46 | 47 | this->extractionInfo = info; 48 | return false; 49 | } 50 | 51 | void ExtractorPass::getAnalysisUsage(AnalysisUsage &au) const { 52 | au.addRequired(); 53 | au.setPreservesAll(); 54 | } 55 | 56 | char ExtractorPass::ID = 0; 57 | static ::llvm::RegisterPass X("loopExtractor", "Loop Features Extractor", 58 | true /* Only looks at CFG */, 59 | true /* Analysis Pass */); 60 | 61 | } // namespace loop´ 62 | } // namespace llvm 63 | } // namespace compy 64 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_loop_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace loop { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | 41 | }; 42 | 43 | } // namespace loop 44 | } // namespace llvm 45 | } // namespace compy 46 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_msf_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace msf { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | private: 33 | std::map features; 34 | void initFeatures(); 35 | void updateFeature(std::string key, float value); 36 | public: 37 | static char ID; 38 | ExtractorPass() : ::llvm::ModulePass(ID) {} 39 | 40 | bool runOnModule(::llvm::Module &M) override; 41 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 42 | 43 | ExtractionInfoPtr extractionInfo; 44 | }; 45 | 46 | } // namespace msf 47 | } // namespace llvm 48 | } // namespace compy 49 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_names_pass.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "llvm_names_pass.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace ::llvm; 24 | 25 | namespace compy { 26 | namespace llvm { 27 | namespace names { 28 | 29 | bool ExtractorPass::runOnModule(::llvm::Module &module) { 30 | ExtractionInfoPtr info(new ExtractionInfo); 31 | 32 | for (const auto &F : module.functions()) { 33 | if (F.isDeclaration()) 34 | continue; 35 | 36 | FunctionInfoPtr functionInfo(new FunctionInfo); 37 | functionInfo->name = F.getName().str(); 38 | info->functionInfos.push_back(functionInfo); 39 | } 40 | 41 | for (const auto &G : module.getGlobalList()) { 42 | GlobalInfoPtr globalInfo(new GlobalInfo); 43 | globalInfo->name = G.getName().str(); 44 | info->globalInfos.push_back(globalInfo); 45 | } 46 | 47 | this->extractionInfo = info; 48 | return false; 49 | } 50 | 51 | void ExtractorPass::getAnalysisUsage(AnalysisUsage &au) const { 52 | au.setPreservesAll(); 53 | } 54 | 55 | char ExtractorPass::ID = 0; 56 | static ::llvm::RegisterPass X("namesExtractor", "NamesExtractor", 57 | true /* Only looks at CFG */, 58 | true /* Analysis Pass */); 59 | 60 | } // namespace names 61 | } // namespace llvm 62 | } // namespace compy 63 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_names_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace names { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | }; 41 | 42 | } // namespace names 43 | } // namespace llvm 44 | } // namespace compy 45 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_opcodes_pass.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "llvm_opcodes_pass.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "llvm/Analysis/CallGraph.h" 25 | #include 26 | #include "llvm/IR/AssemblyAnnotationWriter.h" 27 | #include "llvm/IR/CFG.h" 28 | #include "llvm/IR/Instruction.h" 29 | #include "llvm/IR/Instructions.h" 30 | #include "llvm/IR/Operator.h" 31 | #include "llvm/IR/Value.h" 32 | 33 | #include "llvm/Transforms/IPO.h" 34 | 35 | using namespace ::llvm; 36 | 37 | namespace compy { 38 | namespace llvm { 39 | namespace opcodes { 40 | 41 | bool ExtractorPass::runOnModule(::llvm::Module &module) { 42 | ExtractionInfoPtr info(new ExtractionInfo); 43 | 44 | for (const auto &F : module.functions()) { 45 | if (F.isDeclaration()) 46 | continue; 47 | 48 | std::vector opcodes; 49 | for (const auto &bb : F.getBasicBlockList()) 50 | for (const auto &inst : bb) 51 | opcodes.push_back(inst.getOpcodeName()); 52 | 53 | FunctionInfoPtr functionInfo(new FunctionInfo); 54 | functionInfo->name = F.getName().str(); 55 | functionInfo->opcodes = opcodes; 56 | info->functionInfos.push_back(functionInfo); 57 | } 58 | 59 | this->extractionInfo = info; 60 | return false; 61 | } 62 | 63 | void ExtractorPass::getAnalysisUsage(AnalysisUsage &au) const { 64 | au.setPreservesAll(); 65 | } 66 | 67 | char ExtractorPass::ID = 0; 68 | static ::llvm::RegisterPass X("opcodesExtractor", "OpcodesExtractor", 69 | true /* Only looks at CFG */, 70 | true /* Analysis Pass */); 71 | 72 | } // namespace opcodes 73 | } // namespace llvm 74 | } // namespace compy 75 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_opcodes_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace opcodes { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | }; 41 | 42 | } // namespace opcodes 43 | } // namespace llvm 44 | } // namespace compy 45 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_seq_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Alexander Brauckmann 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace seq { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | }; 41 | 42 | } // namespace seq 43 | } // namespace llvm 44 | } // namespace compy 45 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_wl_cost_funcinfo.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include "llvm_wl_cost_funcinfo.h" 21 | 22 | using namespace ::llvm; 23 | 24 | namespace compy { 25 | namespace llvm { 26 | namespace wlcost { 27 | 28 | bool FunctionInfoPass::runOnFunction(::llvm::Function &func) { 29 | // create a new info object and invalidate the old one 30 | info_ = FunctionInfoPtr(new FunctionInfo()); 31 | 32 | info_->name = func.getName().str(); 33 | info_->recipThroughput = 0.0; 34 | info_->latency = 0.0; 35 | info_->codeSize = 0.0; 36 | info_->oneCost = 0.0; 37 | 38 | auto *TTI = &getAnalysis().getTTI(func); 39 | BlockEdgeFrequencyPass *BEFP = &getAnalysis(); 40 | 41 | for (auto &bb : func.getBasicBlockList()) { 42 | double BB_freq = BEFP->getBlockFrequency(&bb); 43 | for (auto &inst : bb) { 44 | info_->recipThroughput += BB_freq * TTI->getInstructionCost( 45 | &inst, 46 | TTI->TCK_RecipThroughput 47 | ); 48 | info_->latency += BB_freq * TTI->getInstructionCost( 49 | &inst, 50 | TTI->TCK_Latency 51 | ); 52 | info_->codeSize += BB_freq * TTI->getInstructionCost( 53 | &inst, 54 | TTI->TCK_CodeSize 55 | ); 56 | info_->oneCost += BB_freq * 1.0; 57 | } 58 | } 59 | 60 | // indicate that nothing was changed 61 | return false; 62 | } 63 | 64 | void FunctionInfoPass::getAnalysisUsage(AnalysisUsage &au) const { 65 | au.addRequired(); 66 | au.addRequired(); 67 | au.setPreservesAll(); 68 | } 69 | 70 | char FunctionInfoPass::ID = 0; 71 | 72 | static RegisterPass X("wlfuncinfo", "Function Info Extractor", 73 | true /* Only looks at CFG */, 74 | true /* Analysis Pass */); 75 | 76 | } // namespace cost 77 | } // namespace llvm 78 | } // namespace compy 79 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_wl_cost_funcinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "llvm/Analysis/MemorySSA.h" 25 | #include "llvm/Analysis/TargetTransformInfo.h" 26 | #include "wl_static_profiler/block_edge_frequency_pass.h" 27 | #include "llvm_extractor.h" 28 | 29 | namespace compy { 30 | namespace llvm { 31 | namespace wlcost { 32 | 33 | class FunctionInfoPass : public ::llvm::FunctionPass { 34 | private: 35 | FunctionInfoPtr info_; 36 | 37 | public: 38 | static char ID; 39 | 40 | FunctionInfoPass() : ::llvm::FunctionPass(ID), info_(nullptr) {} 41 | 42 | bool runOnFunction(::llvm::Function &func) override; 43 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 44 | 45 | const FunctionInfoPtr &getInfo() const { return info_; } 46 | FunctionInfoPtr &getInfo() { return info_; } 47 | }; 48 | 49 | } // namespace cost 50 | } // namespace llvm 51 | } // namespace compy 52 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_wl_cost_pass.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Wu Larus function cost 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm_wl_cost_pass.h" 24 | #include "llvm_wl_cost_funcinfo.h" 25 | 26 | using namespace ::llvm; 27 | 28 | namespace compy { 29 | namespace llvm { 30 | namespace wlcost { 31 | 32 | bool ExtractorPass::runOnModule(::llvm::Module &module) { 33 | ExtractionInfoPtr info(new ExtractionInfo); 34 | 35 | // Collect the function information 36 | for (auto &func : module.functions()) { 37 | // Skip functions without definition (fwd declarations) 38 | if (func.isDeclaration()) 39 | continue; 40 | 41 | auto &pass = getAnalysis(func); 42 | auto functionInfo = std::move(pass.getInfo()); 43 | info->functionInfos.push_back(std::move(functionInfo)); 44 | } 45 | 46 | this->extractionInfo = info; 47 | return false; 48 | } 49 | 50 | void ExtractorPass::getAnalysisUsage(AnalysisUsage &au) const { 51 | au.addRequired(); 52 | au.setPreservesAll(); 53 | } 54 | 55 | char ExtractorPass::ID = 0; 56 | static ::llvm::RegisterPass X("wlCostExtractor", "Wu-Larus Cost Extractor", 57 | true /* Only looks at CFG */, 58 | true /* Analysis Pass */); 59 | 60 | } // namespace cost 61 | } // namespace llvm 62 | } // namespace compy 63 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/llvm_wl_cost_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "llvm/IR/Module.h" 24 | #include "llvm/Pass.h" 25 | #include "llvm_extractor.h" 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace wlcost { 30 | 31 | class ExtractorPass : public ::llvm::ModulePass { 32 | public: 33 | static char ID; 34 | ExtractorPass() : ::llvm::ModulePass(ID) {} 35 | 36 | bool runOnModule(::llvm::Module &M) override; 37 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 38 | 39 | ExtractionInfoPtr extractionInfo; 40 | 41 | }; 42 | 43 | } // namespace cost 44 | } // namespace llvm 45 | } // namespace compy 46 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/wl_static_profiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Extractor library 2 | add_library(wl_static_profiler 3 | block_edge_frequency_pass.cc 4 | branch_heuristics_info.cc 5 | branch_prediction_info.cc 6 | branch_prediction_pass.cc 7 | ) 8 | target_link_libraries(wl_static_profiler 9 | extractors_common 10 | ) 11 | target_compile_options(wl_static_profiler PRIVATE 12 | ${compile_options_common} 13 | ) 14 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/wl_static_profiler/LICENSE: -------------------------------------------------------------------------------- 1 | University of Illinois/NCSA Open Source License 2 | 3 | Copyright (c) The LLVM Compiler Infrastructure. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation files 7 | (the "Software"), to deal with the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | * Redistributions of source code must retain the above copyright notice, 14 | this list of conditions and the following disclaimers. 15 | 16 | * Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimers in the 18 | documentation and/or other materials provided with the distribution. 19 | 20 | * Neither the names of [fullname], [project] nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this Software without specific prior written permission. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 25 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH 30 | THE SOFTWARE. 31 | 32 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/wl_static_profiler/block_edge_frequency_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed under the University of Illinois Open Source 3 | License. See LICENSE for details. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "llvm/Pass.h" 9 | #include "llvm/IR/InstrTypes.h" 10 | #include "llvm/IR/BasicBlock.h" 11 | #include "llvm/IR/Function.h" 12 | #include "llvm/ADT/SmallVector.h" 13 | #include "llvm/ADT/SmallPtrSet.h" 14 | #include "llvm/Analysis/LoopInfo.h" 15 | #include "llvm/Analysis/Passes.h" 16 | #include "llvm/Support/Compiler.h" 17 | #include "llvm/Support/CommandLine.h" 18 | #include "llvm/Support/Debug.h" 19 | #include "llvm/Support/Format.h" 20 | #include "llvm/Support/raw_ostream.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace compy { 28 | namespace llvm { 29 | namespace wlcost { 30 | 31 | class BranchPredictionPass; 32 | 33 | class BlockEdgeFrequencyPass : public ::llvm::FunctionPass { 34 | public: 35 | typedef std::pair Edge; 36 | private: 37 | static const double epsilon_; 38 | 39 | ::llvm::LoopInfo *loopInfo_; 40 | BranchPredictionPass *branchPredictionPass_; 41 | 42 | std::set notVisited_; 43 | std::set loopsVisited_; 44 | std::map backEdgeProbabilities_; 45 | std::map edgeFrequencies_; 46 | std::map blockFrequencies_; 47 | 48 | void markReachable(::llvm::BasicBlock *root); 49 | void propagateLoop(const ::llvm::Loop *loop); 50 | void propagateFreq(::llvm::BasicBlock *head); 51 | 52 | public: 53 | static char ID; 54 | 55 | BlockEdgeFrequencyPass() : ::llvm::FunctionPass(ID) {} 56 | 57 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 58 | bool runOnFunction(::llvm::Function &func) override; 59 | 60 | double getEdgeFrequency(const ::llvm::BasicBlock *src, const ::llvm::BasicBlock *dst) const; 61 | double getEdgeFrequency(Edge &edge) const; 62 | double getBlockFrequency(const ::llvm::BasicBlock *BB) const; 63 | double getBackEdgeProbabilities(Edge &edge); 64 | 65 | }; 66 | 67 | } // namespace graph 68 | } // namespace llvm 69 | } // namespace compy 70 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/wl_static_profiler/branch_prediction_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed under the University of Illinois Open Source 3 | License. See LICENSE for details. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "llvm/IR/BasicBlock.h" 9 | #include "llvm/IR/Function.h" 10 | #include "llvm/IR/InstrTypes.h" 11 | #include "llvm/IR/Instructions.h" 12 | #include "llvm/IR/Dominators.h" 13 | #include "llvm/ADT/SmallPtrSet.h" 14 | #include "llvm/ADT/SmallVector.h" 15 | #include "llvm/ADT/SmallSet.h" 16 | #include "llvm/Analysis/LoopInfo.h" 17 | 18 | #include 19 | #include 20 | 21 | namespace compy { 22 | namespace llvm { 23 | namespace wlcost { 24 | 25 | class BranchPredictionInfo { 26 | public: 27 | typedef std::pair Edge; 28 | private: 29 | std::set listBackEdges_, listExitEdges_; 30 | std::map backEdgesCount_; 31 | std::set listCalls_, listStores_; 32 | 33 | ::llvm::DominatorTree *dominatorTree_; 34 | ::llvm::PostDominatorTree *postDominatorTree_; 35 | ::llvm::LoopInfo *loopInfo_; 36 | 37 | void findBackAndExitEdges(::llvm::Function &F); 38 | void findCallsAndStores(::llvm::Function &F); 39 | public: 40 | explicit BranchPredictionInfo(::llvm::DominatorTree *DT, ::llvm::LoopInfo *LI, 41 | ::llvm::PostDominatorTree *PDT = NULL); 42 | 43 | void buildInfo(::llvm::Function &F); 44 | unsigned countBackEdges(::llvm::BasicBlock *BB) const; 45 | bool callsExit(::llvm::BasicBlock *BB) const; 46 | bool isBackEdge(const Edge &edge) const; 47 | bool isExitEdge(const Edge &edge) const; 48 | bool hasCall(const ::llvm::BasicBlock *BB) const; 49 | bool hasStore(const ::llvm::BasicBlock *BB) const; 50 | 51 | inline ::llvm::DominatorTree *getDominatorTree() const { return dominatorTree_; } 52 | inline ::llvm::PostDominatorTree *getPostDominatorTree() const { return postDominatorTree_; } 53 | inline ::llvm::LoopInfo *getLoopInfo() const { return loopInfo_; } 54 | }; 55 | 56 | } // namespace cost 57 | } // namespace llvm 58 | } // namespace compy 59 | -------------------------------------------------------------------------------- /yacos/info/compy/extractors/llvm_ir/wl_static_profiler/branch_prediction_pass.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed under the University of Illinois Open Source 3 | License. See LICENSE for details. 4 | */ 5 | 6 | #pragma once 7 | 8 | 9 | #include "llvm/Pass.h" 10 | #include "llvm/IR/BasicBlock.h" 11 | #include "llvm/IR/Function.h" 12 | #include "llvm/IR/Constants.h" 13 | #include "llvm/IR/InstrTypes.h" 14 | #include "llvm/IR/Instructions.h" 15 | #include "llvm/IR/Dominators.h" 16 | #include "llvm/ADT/SmallSet.h" 17 | #include "llvm/Analysis/Passes.h" 18 | #include "llvm/Analysis/PostDominators.h" 19 | #include "llvm/Analysis/LoopInfo.h" 20 | #include "llvm/Support/Compiler.h" 21 | #include "llvm/Support/CommandLine.h" 22 | #include "llvm/Support/Debug.h" 23 | #include "llvm/Support/Format.h" 24 | #include "llvm/Support/raw_ostream.h" 25 | 26 | #include "branch_heuristics_info.h" 27 | 28 | #include 29 | 30 | namespace compy { 31 | namespace llvm { 32 | namespace wlcost { 33 | 34 | class BranchPredictionPass : public ::llvm::FunctionPass { 35 | public: 36 | typedef std::pair Edge; 37 | private: 38 | BranchPredictionInfo *branchPredictionInfo_; 39 | BranchHeuristicsInfo *branchHeuristicsInfo_; 40 | 41 | std::map edgeProbabilities_; 42 | 43 | void calculateBranchProbabilities(::llvm::BasicBlock *BB); 44 | void addEdgeProbability(BranchHeuristics heuristic, 45 | const ::llvm::BasicBlock *root, 46 | Prediction pred); 47 | public: 48 | 49 | static char ID; 50 | 51 | BranchPredictionPass() : ::llvm::FunctionPass(ID), branchPredictionInfo_(nullptr), branchHeuristicsInfo_(nullptr) {} 52 | ~BranchPredictionPass() { Clear(); } 53 | 54 | bool runOnFunction(::llvm::Function &func) override; 55 | void getAnalysisUsage(::llvm::AnalysisUsage &au) const override; 56 | 57 | double getEdgeProbability(const ::llvm::BasicBlock *src, const ::llvm::BasicBlock *dst) const; 58 | double getEdgeProbability(Edge &edge) const; 59 | const BranchPredictionInfo *getInfo() const; 60 | void Clear(); 61 | 62 | }; 63 | 64 | } // namespace cost 65 | } // namespace llvm 66 | } // namespace compy 67 | -------------------------------------------------------------------------------- /yacos/info/compy/llvm_seq_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2020 Alexander Brauckmann. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | import os 18 | import sys 19 | 20 | from absl import logging as lg 21 | 22 | from yacos.info.compy.llvm_seq import LLVMSeqBuilder 23 | 24 | 25 | program_1fn_2 = """ 26 | int bar(int a) { 27 | if (a > 10) 28 | return a; 29 | return -1; 30 | } 31 | """ 32 | 33 | 34 | program_fib = """ 35 | int fib(int x) { 36 | switch(x) { 37 | case 0: 38 | return 0; 39 | case 1: 40 | return 1; 41 | default: 42 | return fib(x-1) + fib(x-2); 43 | } 44 | } 45 | """ 46 | 47 | 48 | def verify_data_dir(): 49 | top_dir = os.path.join(os.environ.get('HOME'), '.local') 50 | if not os.path.isdir(os.path.join(top_dir, 'yacos')): 51 | lg.error('YaCoS data does not exist.') 52 | sys.exit(1) 53 | 54 | 55 | def test_construct_with_custom_visitor(): 56 | """Construction.""" 57 | verify_data_dir() 58 | filename = os.path.join(os.environ.get('HOME'), 59 | '.local', 60 | 'yacos', 61 | 'tests', 62 | 'program_1fn_2.c') 63 | builder = LLVMSeqBuilder() 64 | info = builder.source_to_info(filename) 65 | _ = builder.info_to_representation(info) 66 | 67 | 68 | def test_plot(tmpdir): 69 | """General tests: Plot.""" 70 | verify_data_dir() 71 | filename = os.path.join(os.environ.get('HOME'), 72 | '.local', 73 | 'yacos', 74 | 'tests', 75 | 'program_fib.c') 76 | builder = LLVMSeqBuilder() 77 | info = builder.source_to_info(filename) 78 | seq = builder.info_to_representation(info) 79 | 80 | outfile = os.path.join(tmpdir, "syntax_seq.png") 81 | seq.draw(path=outfile, width=8) 82 | 83 | assert os.path.isfile(outfile) 84 | -------------------------------------------------------------------------------- /yacos/info/image/__init__.py: -------------------------------------------------------------------------------- 1 | from .extractor import Prog2Image, LBPif, LBPeq, bit2vec 2 | -------------------------------------------------------------------------------- /yacos/info/ncc/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Scalable Parallel Computing Lab, ETH Zurich 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /yacos/info/ncc/__init__.py: -------------------------------------------------------------------------------- 1 | from .rgx_utils import * 2 | from .task_utils import llvm_ir_to_trainable 3 | from .extractor import Inst2Vec 4 | from . import inst2vec 5 | -------------------------------------------------------------------------------- /yacos/info/ncc/inst2vec/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComputerSystemsLaboratory/YaCoS/3706327fdeeedcab0fcbdeca04f8d5b2555e4d6a/yacos/info/ncc/inst2vec/__init__.py -------------------------------------------------------------------------------- /yacos/model/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2021 Anderson Faustino da Silva. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from .net_model import NetModel 18 | from .representation_extractor import RepresentationExtractor 19 | from .graph_from_sequences import GraphFromSequences 20 | 21 | 22 | __version__ = '2.1.0' 23 | -------------------------------------------------------------------------------- /yacos/model/representation_extractor.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from yacos.essential import Engine 4 | from yacos.info.ncc import Inst2Vec 5 | 6 | class RepresentationExtractor: 7 | 8 | @staticmethod 9 | def process_inst2vec(benchmark_dir, 10 | compile_system='opt', 11 | opt_set='-O0'): 12 | """ 13 | Static Method to get inst2vec features from benchmark 14 | Parameters 15 | ---------- 16 | benchmark_dir: str 17 | The directory that benchmark is stored into file system 18 | compile_system: str 19 | The compile system that will be used to build the IR and get representation 20 | The directory of benchmark must have a Makefile.compile_system (e.g. Makefile.opt) 21 | and compile.sh script 22 | opt_set: str 23 | The optimization set that will be used to extract the representation 24 | 25 | Return 26 | ------ 27 | The inst2vec matrix 28 | """ 29 | Engine.compile(benchmark_dir, compile_system, opt_set) 30 | Engine.disassemble(benchmark_dir, 'a.out_o') 31 | 32 | spl = os.path.split(benchmark_dir) 33 | while (spl[1] == ''): 34 | spl = os.path.split(spl[0]) 35 | bench_name = spl[1] 36 | spl2 = os.path.split(spl[0]) 37 | while (spl2[1] == ''): 38 | spl2 = os.path.split(spl2[0]) 39 | benchmarks_directory = spl2[0] 40 | bench_suite = spl2[1] 41 | 42 | benchmark = '.'.join([bench_suite,bench_name]) 43 | Inst2Vec.prepare_benchmark(benchmark, benchmarks_directory) 44 | #print(benchmark) 45 | rep = Inst2Vec.extract() 46 | values = list(rep.values()) 47 | values = values[0] 48 | 49 | Engine.cleanup(benchmark_dir, compile_system) 50 | 51 | Inst2Vec.remove_data_directory() 52 | 53 | return values 54 | 55 | @staticmethod 56 | def get_inst2vec_features(directory, 57 | compile_system='opt', 58 | opt_set='-O0'): 59 | vec = RepresentationExtractor.process_inst2vec(directory, 60 | compile_system, 61 | opt_set) 62 | acc_col = vec.sum(axis=0) 63 | rep = acc_col.tolist()[0] 64 | return rep --------------------------------------------------------------------------------