Scatter tutorial - Supercomputing and Parallel Programming in Python and MPI 9
Skills:
Tool Use & Function Calling80%
Key Takeaways
This video tutorial covers the use of scatter in MPI for Python, a technique for distributing data across multiple nodes in a supercomputing system. The tutorial demonstrates how to use the scatter function from the mpi4py library to divide a list of objects among nodes and explains the importance of ensuring that the number of objects does not exceed the number of nodes.
Full Transcript
hello everyone and welcome to another MPI for Python tutorial video for high performance computing supercomputing and parallel programming so in the last video we covered broadcasting now it's how we could take one variable or object and pass it to every other node in the system so we could share that variable amongst everybody so that was broadcasting I think that was fairly simple to understand next up we have what's known as scatter and gather so what scatter is gonna do is say in the master node we have a group of objects so let's say we have a list what we can do is we can take that list and you do scatter and it's gonna take that list explode the list and send it in parts to each of the nodes it's gonna divide up that list and send it to each of the nodes and then what gather does is basically the opposite of that so it's gonna take all the objects from all of the nodes gather them together and go to the target which usually will be the master node so with that let's go ahead and get started so as usual what we're gonna want to do is from MPI 4 equals MPI comm underscore world size equals get size man all these upper cases are killing me break equals calmed I get underscore rank okay that's all we need for this so then what we're gonna have is just the same kind of thing that we've had for quite a few of these is just when the if rank equals 0 what do we want to do we're gonna say data equals and then we're gonna make a generator here and generate a dynamic list of all of the ranks we could make a simple one but like we've got hard code it but that's not a good idea anyways data is going to equal this generator and what we're going to do is we're gonna say data equals x plus 1 to the power of X for X in range of size for X range even if you want it so that's what data is gonna be so basically if data is gonna be X plus 1 to the power of itself for each of the X's in the range of size which is referencing how big is this how big is this supercomputer in nodes this just basically makes sure that we will have one object per node it's just you know some sort of just arbitrary object that we're gonna give it so anyways mm-hmm once we've done that let's print out what we have just so you understand so you can see what data actually represents just in case you're not totally following what's happening here so we're gonna say we will be scattering and then data simple enough next we're gonna say else data equals none and you should kind of recognize this from before and then we come down here we say data equals calm dot scatter what are we scattering well data and from where that's gonna be Ruth zero now what we're gonna do is print rank rank and data okay so let's save that let me move it to news and then we'll come over to the master node up arrow and now I've changed mind s89 hit enter and again we're using five here Oh what have we done oh we've typo'd fantastic why didn't anybody tell me okay import okay so here we have we will be scattering and then it says we're gonna be scattering a 1/2 964 and 625 so you could hard-code on just a list right of 1/2 964 625 or whatever variables you want but you can see what it's done here is it scattered this stuff so rank 0 has data what data did bring 0 get it got the 1 Rank 1 got what data the 2 ring 2 got the 9 and so on so that should be a pretty easy to understand example of what scatter does it's just gonna kind of take everything and go picking just divert our divers just diversify it but at the same time I guess the word I'm looking for is scatter what if we did for X in range of size +5 right so what if we made that size a little bit bigger here Barrow let's see what happens so what happens in this case is in order to have scattered this stuff we wanted to be able to send multiple variables to some of these right so we were expecting only 5 and we wound up with 10 now first off I wouldn't be surprised if there was some way in this scatter call are the actual scatter command to scatter multiple at the same time you could make the object itself a an array right we've seen that we can pass an array or I guess it's not really a you could pass a numpy array or a Python list but anyway you'll want to just keep it in mind that you can't send more variables then you're ready to accept or more objects then you're ready to accept so if you're going to do this you would need to first divide it up by size so you would take the list maybe div by size in them say put X many variables and something like that you can even use modulo to round it off so let's say you had nine nine objects that you wanted to pass you could use the modulo to put everything in in one group and then modulo the rest so something like that anyways I might have a more in-depth example of scatter later I'll have to look through the documentation that would make sure there is an already like a prebuilt command within scatter that allows to do this before we go coding our on so anyways that's gonna conclude this tutorial video hopefully you guys enjoy in the next video what we talking about is gather so anyways stay tuned to the next video as always thanks for watching thanks for all the support and subscriptions and until next time
Original Description
Supercomputer Playlist: http://www.youtube.com/watch?v=13x90STvKnQ&list=PLQVvvaa0QuDf9IW-fe6No8SCw-aVnCfRi&feature=share
In this mpi4py video, you are shown how to use scatter and what it is.
http://seaofbtc.com
http://sentdex.com
http://hkinsley.com
https://twitter.com/sentdex
Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: Tool Use & Function Calling
View skill →
🎓
Tutor Explanation
DeepCamp AI