3 research outputs found

    A methodology for speeding up loop kernels by exploiting the software information and the memory architecture

    Get PDF
    It is well-known that today׳s compilers and state of the art libraries have three major drawbacks. First, the compiler sub-problems are optimized separately; this is not efficient because the separate sub-problems optimization gives a different schedule for each sub-problem and these schedules cannot coexist as the refining of one, causes the degradation of another. Second, they take into account only part of the specific algorithm׳s information. Third, they take into account only a few hardware architecture parameters. These approaches cannot give an optimal solution. In this paper, a new methodology/pre-compiler is introduced, which speeds up loop kernels, by overcoming the above problems. This methodology solves four of the major scheduling sub-problems, together as one problem and not separately; these are the sub-problems of finding the schedules with the minimum numbers of (i) L1 data cache accesses, (ii) L2 data cache accesses, (iii) main memory data accesses, (iv) addressing instructions. First, the exploration space (possible solutions) is found according to the algorithm׳s information, e.g. array subscripts. Then, the exploration space is decreased by orders of magnitude, by applying constraint propagation to the software and hardware parameters. We take the C-code and the memory architecture parameters as input and we automatically produce a new faster C-code; this code cannot be obtained by applying the existing compiler transformations to the original code. The proposed methodology has been evaluated for five well-known algorithms in both general and embedded processors; it is compared with gcc and clang compilers and also with iterative compilation

    A Methodology for Speeding up MVM for Regular, Toeplitz and Bisymmetric Toeplitz Matrices

    No full text
    The Matrix Vector Multiplication algorithm is an important kernel in most varied domains and application areas and the performance of its implementations highly depends on the memory utilization and data locality. In this paper, a new methodology for MVM including different types of matrices, i.e. Regular, Toeplitz and Bisymmetric Toeplitz, is presented in detail. This methodology achieves higher execution speed than the software state of the art library, ATLAS (speedup from 1.2 up to 4.4), and other conventional software implementations, for both general (SIMD unit is used) and embedded processors. This is achieved by fully and simultaneously exploiting the combination of software and hardware parameters as one problem and not separately

    Compiler development methodology which utilizes the hardware parameters and the software model

    No full text
    The existing state of the art (SOA) compilers, have 3 major disadvantages. Firstly, the back-end compilerphases - subproblems (e.g. transformations, scheduling, register allocation) are optimized separately;these subproblems depend on each other and they should be optimized together as one problem and notseparately. Secondly, the existing SOA compilers do not effectively utilize the software characteristics(e.g. algorithm structure, data reuse). Thirdly, they do not effectively utilize the hardware parameters.In this PhD dissertation, new methodologies have been developed speeding up software kernels,by solving the sub-problems of finding the schedules with the minimum numbers of i) L1 data cacheaccesses, ii) L2 data cache accesses, iii) main memory accesses and iv) addressing instructions, as oneproblem and not separately. This is achieved by fully exploiting the software information and the memoryhierarchy parameters. This is the first time a methodology optimizes the above sub-problems in this way.The proposed methodologies fully utilize the software characteristics. The algorithm structure (e.g.FFT data flow graph consists of butterfly operations while the gauss blur algorithm consists of array maskoperations), the algorithm individual characteristics (e.g. symmetry of Toeplitz matrix), the data patterns(e.g. matrix elements are multiplied by a mask), data reuse, production-consumption of intermediateresults and algorithm's parallelism, are utilized as one problem and not separately.The proposed methodologies fully utilize the major architecture parameters. The memory architecture(e.g. shared L2/L3 cache), the size of the register file, the number of the levels of data cachehierarchy, the data cache sizes, the data cache associativities, the data cache line sizes, the number ofthe function units, the number of the function units can run in parallel and the number of the CPU coresare utilized as one problem and not separately. By utilizing the hardware and software constraints theexploration space is orders of magnitude decreased.In this PhD dissertation, new speeding-up methodologies are developed for i) Matrix Matrix Multiplication(MMM) algorithm, ii) Matrix Vector Multiplication (MVM) algorithm, iii) Fast Fourier Transform(FFT), iv) Canny algorithm and Hough Transform. Also, a new compilation methodology whichfully exploits the memory architecture and the software characteristics, is developed. This methodologycan be applied in software kernels whose i) execution paths are known at compile time and thus they donot depend on the data, ii) all array subscripts are linear equations of the iterators (which in most casesdo). The above methodologies refer to both embedded and general purpose processors (usage of theSIMD technology). The summary of the above methodologies is given below.A Methodology for speeding-up Matrix Matrix Multiplication (MMM) algorithm: A new methodologyfor Matrix Matrix Multiplication using SIMD (Single Instruction Multiple Data) unit and not, at oneand more cores having a shared cache, is presented. The proposed methodology partitions the MMMmatrices into smaller sub-matrices fitting in the data cache memories and into register file according tothe memory hierarchy architecture parameters. This is the first time for MMM algorithm that equationscontaining the data cache associativity values, are given. To fully utilize the memory hierarchy, a newthe data array layout is proposed. The proposed methodology is from 1.1 up to 3.5 times faster than oneof the SOA software libraries for linear algebra, ATLAS.A Fast Fourier Transform (FFT) speeding-up methodology: A new Fast Fourier Transform methodology is presented which fully utilizes the individual algorithm characteristics and the memory hierarchyarchitecture parameters. FFT data flow graph (DFG) is partitioned into patterns and into sub-FFTs. Eachpattern consists of butterflies according to the number of the registers. The selection of the exact butterflieseach pattern contains, has been made by maximizing the production-consumption of the butterfliesintermediate results. Also, the patterns are executed in that order, minimizing the data reuse of the FFTtwiddle factors. The FFT data flow graph is partitioned into sub-FFTs according to the number of thelevels and the sizes of data cache. The proposed methodology is faster from 1.1 up to 1.8 times in contrastto the SOA FFT library, FFTW. This is the first time that an FFT methodology fully utilizes thememory hierarchy architecture parameters.A methodology for speeding-up Matrix Vector Multiplication (MVM) algorithm for regular, Toeplitzand Bisymmetric Toeplitz matrices: A new methodology for MVM including different types of matrices,is presented. The above matrices have a special structure, a small number of different elements and largedata reuse. The proposed methodology partitions the MVM matrices into smaller sub-matrices fitting inthe data cache memories and into register file according to the memory hierarchy architecture parameters.To fully utilize the memory hierarchy, a new data array layout is proposed. The proposed methodologyuses the standard algorithm for matrix vector multiplication, i.e. each row of A is multiplied by X.However, for Bisymmetric Toeplitz (BT) and Toeplitz (T) matrices, MVM can also be implemented byusing FFT; although in this paper we use the standard MVM algorithm, we show that for large inputsizes, the MVM using FFT performs much better. The proposed methodology achieves speedup from1.2 up to 4.4 over the SOA libraries, ATLAS.A Methodology for Speeding Up Edge and Line Detection Algorithms: A new Methodology forSpeeding Up Edge and Line Detection Algorithms focusing on memory architecture utilization is presented.This methodology achieves i) a smaller number of load/store and arithmetic instructions, ii) asmaller number of data cache accesses and data cache misses in memory hierarchy and iii) a smalleralgorithm memory size, in contrast to the SOA library of OpenCV. This is achieved by: i) utilizing theproduction-consumption of intermediate results - merging all Canny kernels to one and pipelining thekernels to comply with the data dependences, ii) reducing the number and the size of the arrays, iii)writing the data into the new reduced size arrays in a circular way, iv) applying loop tiling for the registerfile and data cache, according to the size of the memories and associativity and v) finding the data arrayslayout according to the data cache associativity. The proposed methodology achieves speedup from 1.27up to 2.2 over the OpenCV SOA library.Compilation methodology: A new compilation methodology which fully exploits the memory architectureand the software characteristics is presented. This is the first time that a methodology optimizesthe subproblems explained above as one problem and not separately, for a loop-kernel. The proposedmethodology takes as input C-code kernels and it produces new software kernels with a new iterationspace, which may not be given by applying existing compiler transformations to original code. Firstly, theexploration space is found according to the s/w characteristics; it is described by mathematical equationsand inequalities that are derived from the array subscripts, the combination of common array references,loop iterators, loop bounds and data dependences. Then, the exploration space is orders of magnitudedecreased by applying constraint propagation of the h/w and s/w parameters. The register file and the data cache sizes are fully exploited by producing register file and data cache inequalities which containi) the tiles sizes of each array, ii) the shape of each array tile. Also, new data array layouts are found,according to the data cache associativity. The final schedule is found by choosing the best combinationof the number of i) L1 data cache accesses, ii) L2 data cache accesses, iii) main memory data accessesand iv) addressing instructions. The proposed methodology is evaluated to five well-known algorithmsand speedups from 2 up to 18 over the target gcc compiler are obtained.Οι υπάρχοντες μεταγλωττιστές, έχουν τρία βασικά μειονεκτήματα i) όλα τα υπό-προβλήματα τηςμεταγλώττισης (π.χ. μετασχηματισμοί, εύρεση χρονοπρογραμματισμού, ανάθεση καταχωρητών)βελτιστοποιούνται ξεχωριστά (εκτός από μεμονωμένες περιπτώσεις όπου βελτιστοποιούνταικάποια στάδια μαζί - συνήθως 2), παρόλο που υπάρχει εξάρτηση μεταξύ τους, ii) δενεκμεταλλεύονται αποδοτικά όλα τα χαρακτηριστικά του προγράμματος εισόδου (π.χ. δομή τουεκάστοτε αλγορίθμου, επαναχρησιμοποίηση δεδομένων), iii) δεν εκμεταλλεύονται αποδοτικά τιςπαραμέτρους της αρχιτεκτονικής.Στη παρούσα διδακτορική διατριβή, αναπτύχθηκαν μεθοδολογίες οι οποίες αντιμετωπίζουντα προβλήματα εύρεσης χρονοπρογραμματισμών με τον ελάχιστο αριθμό i) προσβάσεων στηνκρυφή μνήμη δεδομένων L1, ii) προσβάσεων στην κρυφή μνήμη L2, iii) προσβάσεων στην κύριαμνήμη, iv) πράξεων διευθυνσιοδότησης, μαζί σαν ενιαίο πρόβλημα και όχι ξεχωριστά, για έναkernel. Αυτό επιτυγχάνεται αντιμετωπίζοντας τα χαρακτηριστικά του λογισμικού και τις τιςβασικές παραμέτρους της αρχιτεκτονικής μαζί σαν ενιαίο πρόβλημα. Είναι η πρώτη φορά πουμια μεθοδολογία αντιμετωπίζει τα παραπάνω προβλήματα με αυτό τον τρόπο.Οι προτεινόμενες μεθοδολογίες εκμεταλλεύονται τα χαρακτηριστικά του προγράμματοςεισόδου. Η δομή του εκάστοτε αλγορίθμου (π.χ. ο FFT αποτελείται από πράξεις πεταλούδωνενώ ο αλγόριθμος αφαίρεσης θορύβου - Gauss Blur αποτελείται από πράξεις μάσκας στοιχείων),τα ιδιαίτερα χαρακτηριστικά του (π.χ. συμμετρία Toeplitz πίνακα), η ύπαρξη προτύπων-patterns(π.χ. στοιχεία πινάκων πολλαπλασιάζονται με μάσκα), η επαναχρησιμοποίηση των δεδομένων,η παραγωγή-κατανάλωση ενδιάμεσων αποτελεσμάτων και η παραλληλία του αλγορίθμου,αντιμετωπίζονται μαζί σαν ενιαίο πρόβλημα.Οι προτεινόμενες μεθοδολογίες εκμεταλλεύονται τις βασικές παραμέτρους τηςαρχιτεκτονικής. Η αρχιτεκτονική της μνήμης (π.χ. κοινή L2, L3), το πλήθος των καταχωρητών,ο αριθμός των κρυφών μνημών δεδομένων, τα μεγέθη, οι συσχετιστικότητες (assosiativity)και τα μεγέθη των γραμμών των κρυφών μνημών, ο αριθμός των λειτουργικών μονάδων, οαριθμός των λειτουργικών μονάδων που λειτουργούν παράλληλα και ο αριθμός των πυρήνων(cores) του επεξεργαστή, αντιμετωπίζονται μαζί σαν ενιαίο πρόβλημα. Με την αξιοποίησητων χαρακτηριστικών του εκάστοτε αλγορίθμου και των παραμέτρων της αρχιτεκτονικής,αποκλείονται πιθανές λύσεις και ο χώρος εξερεύνησης μειώνεται ραγδαία (τάξεις μεγέθους).Στη παρούσα διδακτορική διατριβή, αναπτύχθηκαν μεθοδολογίες αύξησης της ταχύτηταςτου λογισμικού α) του Πολλαπλασιασμού Πίνακα επί Πίνακα (ΠΠΠ), β) του ΠολλαπλασιασμούΠίνακα επί διάνυσμα (ΠΠΔ), γ) του Fast Fourier Transform (FFT), δ) του αλγορίθμου Cannyκαι του μετασχηματισμού του Hough (αλγόριθμοι ανίχνευσης ακμών και ευθειών αντίστοιχα).Επίσης, αναπτύχθηκε μεθοδολογία μεταγλώττισης η οποία εκμεταλλεύεται τα χαρακτηριστικάτου λογισμικού και τις παραμέτρους της ιεραρχίας μνήμης. Η μεθοδολογία μπορεί να εφαρμοστείσε πυρήνες λογισμικού, στους οποίους α) τα μονοπάτια εκτέλεσης είναι γνωστά κατά τημεταγλώττιση και συνεπώς δεν εξαρτώνται από τα δεδομένα, β) οι δείκτες όλων των subscriptsνα είναι γραμμικές εξισώσεις των iterators (που ισχύει στις περισσότερες περιπτώσεις). Οι μεθοδολογίες αφορούν ενσωματωμένους και γενικού σκοπού επεξεργαστές (χρήση μονάδαςSIMD για περαιτέρω αύξηση της ταχύτητας). Ακολουθεί σύντομη περίληψη αυτών.Μεθοδολογία αύξησης της ταχύτητας του Πολλαπλασιασμού Πίνακα επί Πίνακα (ΠΠΠ):Αναπτύχθηκε μεθοδολογία αύξησης της ταχύτητας του ΠΠΠ για α) μονοπύρηνους επεξεργαστές(1 core), β) επεξεργαστές με πολλούς πυρήνες οι οποίοι συνδέονται με κοινή μνήμη. Ηπροτεινόμενη μεθοδολογία χωρίζει του πίνακες του αλγορίθμου σε μικρότερους οι οποίοι χωράνεστις κρυφές μνήμες και στο αρχείο καταχωρητών. Είναι η πρώτη φορά για τον ΠΠΠ πουεισάγονται εξισώσεις οι οποίες αξιοποιούν τα associativities των κρυφών μνημών. Για τη πλήρηαξιοποίηση της ιεραρχίας της μνήμης προτείνεται νέος τρόπος αποθήκευσης των στοιχείων στηκύρια μνήμη (data array layout). Επίσης, προτείνεται διαφορετικός χρονοπρογραμματισμός σεεπίπεδο στοιχείων και σε επίπεδο υπό-πινάκων. Η προτεινόμενη μεθοδολογία επιτυγχάνει από1.1 έως 3.5 φορές μικρότερο χρόνο εκτέλεσης από τη βιβλιοθήκη του ATLAS, η οποία αποτελείμια από τις ταχύτερες βιβλιοθήκες.Μεθοδολογία αύξησης της ταχύτητας του Fast Fourier Transform (FFT): Αναπτύχθηκεμεθοδολογία αύξησης της ταχύτητας του FFT αξιοποιώντας πλήρως τα ιδιαίτεραχαρακτηριστικά του αλγορίθμου και τις παραμέτρους της ιεραρχίας της μνήμης. Το διάγραμμαροής δεδομένων (Data Flow Graph – DFG) του FFT, χωρίζεται σε πρότυπα (patterns) και σε υπό-FFTs. Κάθε πρότυπο, αποτελείται από πεταλούδες, σύμφωνα με το πλήθος των καταχωρητώντου επεξεργαστή. Η επιλογή των πεταλούδων κάθε προτύπου έχει γίνει με τέτοιο τρόπο ώστε ναμεγιστοποιείται η παραγωγή-κατανάλωση των ενδιάμεσων αποτελεσμάτων. Η σειρά εκτέλεσηςτων προτύπων είναι αυτή η οποία δίνει τη μέγιστη επαναχρησιμοποίηση των συντελεστών τουFFT. Ο DFG του FFT χωρίζεται σε υπό-FFTs σύμφωνα με τον αριθμό και τα μεγέθη των κρυφώνμνημών δεδομένων. Η προτεινόμενη μεθοδολογία δίνει από 1.1 μέχρι 1.8 φορές μικρότερο χρόνοεκτέλεσης από τη βιβλιοθήκη του FFTW, η οποία παρέχει ταχύτατο χρόνο εκτέλεσης. Είναι ηπρώτη φορά για τον FFT που μια μεθοδολογία λαμβάνει υπόψη τις παραμέτρους της ιεραρχίαςμνήμης και του αρχείου καταχωρητών.Μεθοδολογία αύξησης της ταχύτητας του Πολλαπλασιασμού Πίνακα επί Διάνυσμα (ΠΠΔ)για Toeplitz, Bisymetric (BT), Toeplitz (Τ) και κανονικούς πίνακες: Αναπτύχθηκε μεθοδολογίααύξησης της ταχύτητας του ΠΠΔ. Οι παραπάνω πίνακες έχουν ιδιαίτερη δομή, μικρόαριθμό διαφορετικών στοιχείων και μεγάλη επαναχρησιμοποίηση, χαρακτηριστικά τα οποίααξιοποιούνται πλήρως. Η προτεινόμενη μεθοδολογία χωρίζει τους πίνακες του αλγορίθμου σεμικρότερους οι οποίοι χωράνε στις κρυφές μνήμες και στο αρχείο καταχωρητών σύμφωνα μετον αριθμό τα μεγέθη και τα associativities των κρυφών μνημών. Για τη πλήρη αξιοποίηση τηςιεραρχίας μνήμης προτείνεται νέος τρόπος αποθήκευσης των στοιχείων του πίνακα (data arraylayout) στη κύρια μνήμη. Η προτεινόμενη μεθοδολογία χρησιμοποιεί τον κανονικό αλγόριθμοΠΠΔ (γραμμή επί στήλη). Ωστόσο, για BT και T πίνακες, ο ΠΠΔ μπορεί να υλοποιηθεί με χρήσητου FFT επιτυγχάνοντας μικρότερη πολυπλοκότητα για μεγάλα μεγέθη πινάκων (έγινε ανάλυσηκαι σύγκριση των δύο αλγορίθμων θεωρητικά και πειραματικά). Η προτεινόμενη μεθοδολογίαγια κανονικούς πίνακες συγκρίνεται με τη βιβλιοθήκη του ATLAS, επιτυγχάνοντας από 1.2 μέχρι4.4 φορές μικρότερο χρόνο εκτέλεσης. Μεθοδολογία αύξησης της ταχύτητας του αλγόριθμου ανίχνευσης ακμών και ευθειών(αλγόριθμος του Canny και μετασχηματισμός του Hough): Αναπτύχθηκε μεθοδολογία η οποίαεπιτυγχάνει i) μικρότερο αριθμό εντολών ανάγνωσης/εγγραφής και διευθυνσιοδότησης, ii)μικρότερο αριθμό προσβάσεων και αστοχιών στην ιεραρχία μνήμης και iii) μικρότερο μέγεθοςαπαιτούμενης μνήμης του αλγορίθμου, εν συγκρίσει με την βιβλιοθήκη OpenCV η οποίαπαρέχει ταχύτατο χρόνο εκτέλεσης στους αλγορίθμους επεξεργασίας εικόνων. Τα παραπάνωεπιτυγχάνονται: α) αξιοποιώντας την παραγωγή-κατανάλωση των στοιχείων των πινάκωνκαι την παραλληλία του αλγορίθμου - τα τέσσερα kernels του Canny συγχωνεύονται σε ένα,διασωληνώνοντας (pipelining) τους πυρήνες για να διατηρηθούν οι εξαρτήσεις των δεδομένων,β) μειώνοντας τον αριθμό και το μέγεθος των πινάκων, γ) γράφοντας τα δεδομένα σε νέουςμειωμένων διαστάσεων πίνακες με κυκλικό τρόπο, δ) χωρίζοντας τους πίνακες σε μικρότερουςοι οποίοι χωράνε στο αρχείο καταχωρητών και στη κρυφή μνήμη δεδομένων σύμφωνα μετο μέγεθος των κρυφών μνημών και του associativity, ε) βρίσκοντας τον βέλτιστο τρόποαποθήκευσης των πινάκων (data array layout) στην κύρια μνήμη σύμφωνα με τη συσχετιστικότητα(associativity) της κρυφής μνήμης. Η προτεινόμενη μεθοδολογία δίνει από 1.27 μέχρι 2.2 φορέςμικρότερο χρόνο εκτέλεσης από τη βιβλιοθήκη OpenCV (αναπτύχθηκε από την Intel και είναιγραμμένη σε χαμηλό επίπεδο), η οποία παρέχει ταχύτατο χρόνο εκτέλεσης.Μεθοδολογία μεταγλώττισης: Αναπτύχθηκε μεθοδολογία μεταγλώττισης η οποίααντιμετωπίζει τα προβλήματα εύρεσης χρονοπρογραμματισμών με τον ελάχιστο αριθμό i)προσβάσεων στην κρυφή μνήμη δεδομένων L1, ii) προσβάσεων στην κρυφή μνήμη L2, iii)προσβάσεων στην κύρια μνήμη, iv) πράξεων διευθυνσιοδότησης, μαζί σαν ενιαίο πρόβλημακαι όχι ξεχωριστά, για ένα kernel. Η προτεινόμενη μεθοδολογία λαμβάνει ως είσοδο kernelsσε C-κώδικα και παράγει νέα επιτυγχάνοντας είτε υψηλή απόδοση είτε τον ελάχιστοαριθμό προσβάσεων σε δεδομένη μνήμη. Αρχικά βρίσκεται ο χώρος εξερεύνησης με βάσητα χαρακτηριστικά του λογισμικού. Ο χώρος εξερεύνησης περιγράφεται από μαθηματικέςεξισώσεις και ανισότητες οι οποίες προέρχονται από τα subscripts των πινάκων, τους iterators,τα όρια των βρόχων και τις εξαρτήσεις των δεδομένων. Αυτός ο χώρος εξερεύνησης δενμπορεί να παραχθεί με την εφαρμογή υπαρχόντων μετασχηματισμών στον αρχικό C-κώδικα.Κατόπιν, ο χώρος εξερεύνησης μειώνεται τάξεις μεγέθους εφαρμόζοντας διάδοση περιορισμών(constraint propagation) των παραμέτρων του λογισμικού και αυτών της αρχιτεκτονικής τηςμνήμης. Το αρχείο καταχωρητών (register file) και τα μεγέθη των κρυφών μνημών αξιοποιούνταιπλήρως παράγοντας ανισότητες για κάθε μνήμη οι οποίες περιέχουν α) τα μεγέθη των tiles πουαπαιτούνται για κάθε πίνακα, β) το σχήμα κάθε tile. Επίσης, βρίσκεται ο βέλτιστος τρόποςαποθήκευσης των στοιχείων των πινάκων στη κύρια μνήμη, σύμφωνα με τη συσχετιστικότητα(associativity) των κρυφών μνημών. Η προτεινόμενη μεθοδολογία εφαρμόστηκε σε 5 ευρέωςδιαδεδομένους αλγορίθμους και επιτυγχάνει αύξηση της ταχύτητας (speedup) από 2 έως 18φορές (έγινε σύγκριση του αρχικού C κώδικα και του C κώδικα έπειτα από την εφαρμογή τηςπροτεινόμενης μεθοδολογίας – η μεταγλώττιση έγινε με τον gcc compiler)
    corecore