 So yeah, so we've got Well, I guess we have enough time to go over these exercises before going through a break and then wrapping up so Yes, yeah, so so if you cast your mind back to two hour ago or something like that We were talking about Chadman like a parallelism and in that in those times We were talking about how do you how can you even leverage one machine? So so now we're talking about one computer. How can we leverage resources available there? So we we saw the big picture that okay, there are these supercomputers where you can have like Thousands of computers that you can get there eventually if your program or problem is such that it It can leverage it but even in those machines. They are still They are still single machines So even with this said memory parallelization you can get a lot done and many like simplest way programs simplest Things you need to parallelize are in the shared memory realm. So let's look at the exercise so we can Get a grasp on this Okay, I'll scroll back down to them So are we going over them should we go over a few? Yes, what would you recommend we do We don't see that many bowls on the people manage to do them or not Yes People go up to that hack empty. Yeah, so here we are Um, so yeah, you can vote here what you thought of them and Yeah, I guess let's just go quickly. So we're because everyone's getting tired of yeah, yeah I guess I haven't been here for so long. Let's let's do the exercise one. I think that's that's a good example Let's just run with that run with multiple CPUs and then You can You can check solution if you don't want to but I think it's very quick to write yourself So yeah got a cat on keyboard situation Do you want me to take over now? I can still do it. I'll let you know if it gets too bad So, okay, bigger examples of the pie thing. So Should we do this with S run? Yes, let's just use S run. So, of course, all of these can be and should be done with the slurms scripts So, so if you're like actually running something you don't want to always look up the parameters The S run parameters and that sort of thing. So it's much better idea to write the slurms script but for these demos and Testing stuff out S run is good option as well. So let's add the numbers If you Okay, if we start with one processor Yeah, or is restart. Let's start with one. Yeah Okay, and should I use time on here? For example, like oh, you can use SF Look at it afterwards Let's do it this way So notice I'm putting time inside of S run to measure how long this takes Your time is is this kind of like Program that you can use to to time time the execution of some other program But using SF is the like the better way. It's you just need to then put the Yeah, so you notice that we're not seeing anything right now and that's because of the buffer So it's waiting until enough is written before it appears on our screen. Yes, and it's it's it's doing the calculation now Do you know how long it should take? I think it was something like maybe we should take one zero out or something. I think it was Would well, I think it was around maybe Two minutes or something with one cps. So maybe it will take a bit more too long. So Yeah, I just pushed control C. Yeah So maybe if you See to cancel. So yeah, maybe maybe if you take one one zero Yeah, so now it should take what was it's out two minutes or 12 seconds or something maybe Yeah And I got this currency. Okay. There we go. So we see the usual high estimate here And we also see this timing information. So it says 8.57 user seconds at this much time elapsed. So this is how much time happened on The walk walk. So real time. This is how much computation it did Yeah, you can use SF to check the same thing, but but yeah It's good enough. Yeah, if you so let's go. Yeah, let's try with two processors So now we expect something like four seconds because the previous one was 8.6 So with a good Packalization like it's probably not going to be that. Yeah, so it was 5.5 and if you try with four Okay What's interesting Let's do it with four first. Yeah, yeah, I would guess something like three seconds, so Or four seconds, maybe yeah, okay, so So remember total CPU time and wall time so notice this is what I was gonna show So if we compare these the CPU time actually went up and The wall time Went down so basically it completed faster but it used more CPUs in total because We're using two CPUs for a slightly longer time. Yeah, and the difference here. It's not so much Yeah, like the difference most likely from the 8.5 to 10 is the 1.5 that you need to set up all of the infrastructure for the multi-processing like you need to like Create the multiple processes and that sort of thing and that like takes time Yeah, so in this case like it probably takes the one one second and it doesn't matter if it's 4 or 2 or 4 if you create the infrastructure, then it's already done Yes, okay But but do you want to quickly show like the optimized version? So so that okay like the indie So so just to integrate like in the I think it was exercise four or five Scroll down Yeah, no, sorry the excess three So so there's an okay much version there that uses non pie and non pie has these like vectorized Array, so if you're not doing individual like calculations, but you're doing like a bunch of calculus at the same time Using this better better the library is so if you try to run the optimized version if you increase the number to to this kind of like If you give one But you don't need to do multiple processors like you you can do it all with one processor Like see this but that's one like Yeah There's a equals Yeah, okay, so what so this is like a optimized version of low like slightly optimized I didn't like go through the full like checking of but it's much faster, but if you try this out Okay. Yeah, it's like Okay, there's no num pies me Maybe you need to load the module load. Yeah. Yeah, I can't Did I have none by installed on my Why what did yeah interesting? Yeah Well, yeah, you need to load Okay, but this is something we didn't realize Yeah, so now it's running a 10 times bigger prayer problem So it's running 10 times bigger problem and it took like two seconds. So like the speed up. It's like It's 10 times Times four. So it's like 40 times faster or something. So like like buy small lot changes in your code You can usually get much more speed up than just adding more processes there So it's usually good idea to check what you're like before starting parallelization It's usually a good idea to like check is your code doing actually what you wanted to do and can you do it using some Better libraries because like this is something that happens all the time. It's just putting more more like Power to the to the problem doesn't necessarily make it run any faster Oh, you don't get the same kind of benefit as optimization. Yeah. Yeah Okay, uh Are we good then let's see Do we have any? Yeah, so I mentioned here like the three hundred percent CPU They mean is in the time commanded basically used multiple CPUs. So it's used 30 Three three and one third of a CPU. So yeah for so Yeah, I guess you could say if we were using four CPUs that would mean that we were it took 10 seconds and used Used about 33 seconds of CPU time Inside of there. Yeah There was a good question, how was this parallel so this was using pythons multi-processing module So it basically started like this separate Python processes that each one is Applicate this function. Yeah So so there was basically a list and then it was like each of these Processors got its own list, but you can look at the code itself But many problems parallelize this so for example like our parallel package Matlab Matlab parallel pool Python multi-processing Python numpy like numpy libraries that Python Users often use they use this so-called open MP parallelization Which is the same parallelization that's used by our are itself uses this Open MP parallelization So so you can get multi-processing without doing any changes to your code like in the background It's it can use this parallelization Like our futures use this parallelization There's this like million libraries that use this kind of a parallelization scheme like open MP, which is this Kind of like a coding paradigm. You can use that to create parallel programs This this like you like this is the word salad part. So, so let's not go there. Yeah, but you can find them There's information on the web page, but and there's like if you have any questions does your program parallelize There's the in the exercise for there's like certain words that you can usually set check on your Programs documentation that usually point to like that the program is using some parallelization Like like some of these words are used in the documentation usually to mean like okay Like how many workers do I want to start and stuff like that? So, yeah But this is something that we don't want to get into because it's a it's a whole kind of words Yeah, okay, um Should we go to a break and come back in 10 minutes? And then we will wrap up with the advanced parallelization types of things which includes GPU and MPI Yeah, let's do that Okay, so break until Oh Five past. Yeah, and do remember to ask questions in the notes because then we can answer like is this is The parallelization you mean asking the notes Yeah, okay. See you soon. Bye