A Quick Intro to Compilers, Flags and Makefiles

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is up everybody in this video we're covering a lot of things this video mostly relates to practive for Tripoli 3096 but if you found your way to this video anyway I hope you learned something so let's just go ahead and dive straight into the video this is some general terminology you should know a toolchain is a set of tools to aid development but typically contains the debugger and compiler for particular languages and the instruction set architectures a compiler takes human readable code and turns it into machine readable code that's a rarely simplified definition but it works for our purposes flags are options passed the compiler and are generally language and hardware dependent a quick note on C and C++ compilers first your source files are compiled into object files object files are then linked together into a binary and boundaries are what we execute on the architecture that they were compiled for now that we've got introductions out the way let's get down to business this is make it's a program that's used to help automate the compilation and build process compiling can get pretty complicated pretty quickly and make is a way that can help simplify it C make exists as a more advanced feature rich version of me which is meant to be used for cross compilation being feature-rich makes it more complicated so we're not gonna talk about it now in order to create a make file you need to create a file called make file in the root directory of your project as follows and if we open it up we can see that this is the make file for crack two let's work through it line by line make files have tabs as a part of their syntax I don't like using tabs in my code so this first line allows us to use spaces instead next we define the compiler that we're going to use we're using the compiler that's specific to the raspberry pi we're using the C++ compiler that makes use of hardware floating-point even though our source code is written in C one of the libraries we use is written in C++ so we just use a mix of the two next up we have our compiler flex we've included the math library and the real time library as a default as you work through prac two you'll have to change the section a little bit then we have links to our custom libraries tools is where we're keeping our timing library next up we just have some folder definitions this helps me turn our code and now it's on to the rules the default rule is run when we call make and we can see that three things happen we compile the prac to source we compile the timing library and then we link them into a binary which we can execute the next rule is a similar rule for the multi-threaded implementation of the practical it's pretty similar to the default rule but you can see that we've included the pthread library as well this library is what enables multi-threading then we have a run rule which runs our card and we also have a run threaded version which runs the threaded implementation then we also have a make clean rule which is I'm sure something you've had an angry Guardian shouts at you but in this context that's a rule that cleans out compiled files this is useful if you move over to another compiler or architecture and need to recompile the libraries and boundaries because remember each compiler works for a particular architecture we can't run code compiled for the raspberry pi on our desktop PCs for example next let's talk about software acceleration compilers are written by really smart people who really know how to optimize code and now code is routing better compilers to better optimize that code as a result of these available optimizations there's some useful compiler flags that you can use to try speed up your code they're available in the pragma you'll watch how they are on screen to be aware when using some of them as they may affect your results we can also use specialized Hardware on the CPU to increase performance arm CPUs have a bunch of different instruction sets that enable hardware level floating-point optimizations try running through these and see what you get in terms of speed up the final optimization you're going to make full is practical is multi-threading note that more threads doesn't always equate to more performance as there's overhead associated with creating and merging threats anyway guys that's it for now I've left a link to my patreon in the description down below I'd really appreciate it if you checked it out stay well and cheers for now
Info
Channel: Keegan C
Views: 3,691
Rating: 4.9080458 out of 5
Keywords: EEE3096S, UCT, Engineering, C++, Compilers, Benchmarking, Memes
Id: XkITUjMg0s4
Channel Id: undefined
Length: 4min 15sec (255 seconds)
Published: Sun Jul 28 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.