From e509185c8d08f5d5bfc24857cca6e9f8d1a16a5c Mon Sep 17 00:00:00 2001 From: henricasanova Date: Fri, 20 May 2016 21:50:33 -1000 Subject: [PATCH] Adding more content to Topic #1 --- 000_objectives.md | 45 +++++++------- _config.yml | 11 +++- _includes/head.html | 1 + index.md | 4 +- public/syntax.css | 60 ++++++++++++++++++ .../1D.html | 8 +++ .../2D.html | 8 +++ .../about.html | 61 ------------------- .../compute_julia_pixel.c | 56 +++++++++++++++++ .../index.html | 39 +++--------- .../introduction.html | 61 +++++++++++++++++++ .../julia_accordion.html | 38 ++++++++++++ .../sequential.html | 23 +++++++ .../sequential_step1.html | 36 +++++++++++ .../sequential_step2.html | 1 + 15 files changed, 334 insertions(+), 118 deletions(-) create mode 100644 public/syntax.css create mode 100644 topic_basics_of_distributed_memory_programming/1D.html create mode 100644 topic_basics_of_distributed_memory_programming/2D.html delete mode 100644 topic_basics_of_distributed_memory_programming/about.html create mode 100644 topic_basics_of_distributed_memory_programming/compute_julia_pixel.c create mode 100644 topic_basics_of_distributed_memory_programming/introduction.html create mode 100644 topic_basics_of_distributed_memory_programming/julia_accordion.html create mode 100644 topic_basics_of_distributed_memory_programming/sequential.html create mode 100644 topic_basics_of_distributed_memory_programming/sequential_step1.html create mode 100644 topic_basics_of_distributed_memory_programming/sequential_step2.html diff --git a/000_objectives.md b/000_objectives.md index 601d2d7..76c7223 100644 --- a/000_objectives.md +++ b/000_objectives.md @@ -4,18 +4,17 @@ title: About description: Curricular information --- -

Target audience

- +
Students/Researchers/Practitioners who want to complement their learning with hands-on experience with distributed-memory programming, message-passing, MPI, and high performance computing
+
Instructors who want to provide students with compelling hands-on experiences as part of the coursework they develop
+
@@ -25,13 +24,13 @@ Target audience Prerequisites - +
+
Access to a Linux (virtual) machine
+
Some Computer Science background (i.e., a few courses)
+
Basic C programming skills (i.e., a 1-semester course)
+
Elementary Linux command-line skills
+
Access to MPI documentation/tutorials
+
@@ -48,12 +47,12 @@ Learning Objectives programs that run on distributed-memory architectures, using the MPI standard. Specific learning objectives include: - +
+
Learn the fundamentals of the MPI API
+
Understand general distributed-memory programming and learn standard solutions
+
Learn how to implement distributed-memory programs, going from traditional "rigid" programs to more "dynamic" programs
+
Understand and experience performance trade-offs when implementing and executing distributed-memory programs on ranges of distributed-memory platforms
+
@@ -67,11 +66,11 @@ While many curricular materials have been developed for teaching message-passing this CourseWare relies on the use of _simulation_, which has the following advantages: - +
+
No need to have access to a distributed-memory platform
+
Ability to run many experiments quickly and reproducibly on one's own computer
+
Ability to explore arbitrary "what if?" scenarios, in particular to experience performance trade-offs first-hand
+
This CourseWare uses SMPI (Simulated MPI), diff --git a/_config.yml b/_config.yml index e83807d..a726437 100644 --- a/_config.yml +++ b/_config.yml @@ -1,6 +1,13 @@ # Dependencies -markdown: redcarpet -highlighter: pygments +#markdown: redcarpet +#highlighter: pygments + +markdown: kramdown +kramdown: + hard_wrap: false + input: GFM + syntax_highlighter: pygments + # Permalinks permalink: pretty diff --git a/_includes/head.html b/_includes/head.html index 0a5fbe8..32d09aa 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -15,6 +15,7 @@ + diff --git a/index.md b/index.md index 4efcd68..2e65ec9 100644 --- a/index.md +++ b/index.md @@ -6,7 +6,6 @@ navigate: false ---
-

SMPI CourseWare is a set of hands-on pedagogic materials focused on teaching high performance computing and distributed memory computing in simulation. This is @@ -23,8 +22,7 @@ to be included into existing courses.

Using the navigation bar on the left you can see the specific learning objectives, and explore the covered topics. Each topic consists of - short tutorial information and of many hands-on activities. Topic #0 is a good place to start :) + short tutorial information and of many hands-on activities. Topic #0 is a good place to start.

-
diff --git a/public/syntax.css b/public/syntax.css new file mode 100644 index 0000000..2774b76 --- /dev/null +++ b/public/syntax.css @@ -0,0 +1,60 @@ +.highlight { background: #ffffff; } +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #aaaaaa } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #000080 } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ diff --git a/topic_basics_of_distributed_memory_programming/1D.html b/topic_basics_of_distributed_memory_programming/1D.html new file mode 100644 index 0000000..131bdb8 --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/1D.html @@ -0,0 +1,8 @@ + +
2A
+
2B
+
2C
\ No newline at end of file diff --git a/topic_basics_of_distributed_memory_programming/2D.html b/topic_basics_of_distributed_memory_programming/2D.html new file mode 100644 index 0000000..131bdb8 --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/2D.html @@ -0,0 +1,8 @@ + +
2A
+
2B
+
2C
\ No newline at end of file diff --git a/topic_basics_of_distributed_memory_programming/about.html b/topic_basics_of_distributed_memory_programming/about.html deleted file mode 100644 index f890b2a..0000000 --- a/topic_basics_of_distributed_memory_programming/about.html +++ /dev/null @@ -1,61 +0,0 @@ - -

This topic consists of 3 activities, each described in its own tab above, which should be done in sequence. - It introduces basic but essential concepts for distributed-memory programming, such as: -

- - - -

- In this topic we do not focus on performance at all, and we implement a "toy" application that - computes a Julia set and saves it as a bitmap file for display. Below is (a low-res version of) the - Julia set we will compute: -

- -

- - -

- - -
-
- - What is a Julia set? -
-
-
-

A Julia set is a fractal, i.e., an object that is self-similar across scales (you "zoom in" - and you keep seeing similar structures/features). It is a generalization - of the famous Mandelbrot set[Wikipedia], - which adorns many T-shirts (search for "Mandelbrot zoom" for psychedelic videos).

- -

The particular Julia set - that we compute here is defined as follows. Given z a point in the 2-D complex plane, we compute the - series defined as: -

    -
  • z0 = z
  • -
  • zn+1 = zn2 + c
  • -
- where c is a chosen complex number. The set in the picture above is for c = -0.79 + i * 0.15. Different - values of c lead to different pictures, and there are known values that produce "pretty" pictures. -

-

- The color of a pixel corresponding to point z is then determined based on the number of iterations - before the modulus of zn is above 2 (or until a maximum number of iterations - is reached). -

-

- Not to worries, code is provided for you for the above. However, feel free to tweak it to create different - images, or to find out more about Julia sets[Wikipedia]. -

- - - -
-
-
diff --git a/topic_basics_of_distributed_memory_programming/compute_julia_pixel.c b/topic_basics_of_distributed_memory_programming/compute_julia_pixel.c new file mode 100644 index 0000000..6dbb9e1 --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/compute_julia_pixel.c @@ -0,0 +1,56 @@ + +/* + * compute_julia_pixel(): compute RBG values of a pixel in a + * particular Julia set image. + * + * In: + * (x,y): pixel coordinates + * (width, height): image dimensions + * tint_bias: a float to "tweak" the tint (1.0 is "no tint") + * Out: + * rgb: an already-allocated 3-byte array into which R, G, and B + * values are written. + * + * Return: + * 0 in success, -1 on failure + * + */ + +int compute_julia_pixel(int x, int y, int width, int height, float tint_bias, unsigned char *rgb) { + + // Check coordinates + if ((x < 0) || (x >= width) || (y < 0) || (y >= height)) { + fprintf(stderr,"Invalid (%d,%d) pixel coordinates in a %d x %d image\n", x, y, width, height); + return -1; + } + + // "Zoom in" to a pleasing view of the Julia set + float X_MIN = -1.6, X_MAX = 1.6, Y_MIN = -0.9, Y_MAX = +0.9; + float float_y = (Y_MAX - Y_MIN) * (float)y / height + Y_MIN ; + float float_x = (X_MAX - X_MIN) * (float)x / width + X_MIN ; + + // Point that defines the Julia set + float julia_real = -.79; + float julia_img = .15; + + // Maximum number of iteration + int max_iter = 300; + + // Compute the complex series convergence + float real=float_y, img=float_x; + int num_iter = max_iter; + while (( img * img + real * real < 2 * 2 ) && ( num_iter > 0 )) { + float xtemp = img * img - real * real + julia_real; + real = 2 * img * real + julia_img; + img = xtemp; + num_iter--; + } + + // Paint pixel based on how many iterations were used, using some funky colors + float color_bias = (float) num_iter / max_iter; + rgb[0] = (num_iter == 0 ? 200 : - 500.0 * pow(tint_bias, 1.2) * pow(color_bias, 1.6)); + rgb[1] = (num_iter == 0 ? 100 : -255.0 * pow(color_bias, 0.3)); + rgb[2] = (num_iter == 0 ? 100 : 255 - 255.0 * pow(tint_bias, 1.2) * pow(color_bias, 3.0)); + + return 0; +} \ No newline at end of file diff --git a/topic_basics_of_distributed_memory_programming/index.html b/topic_basics_of_distributed_memory_programming/index.html index 1dbeef6..038065a 100644 --- a/topic_basics_of_distributed_memory_programming/index.html +++ b/topic_basics_of_distributed_memory_programming/index.html @@ -2,46 +2,27 @@ +
- {% include_relative topic_basics_of_distributed_memory_programming/about.html %} + {% include_relative topic_basics_of_distributed_memory_programming/introduction.html %}
+ +
- -
2A
-
2B
-
2C
+ {% include_relative topic_basics_of_distributed_memory_programming/sequential.html %}
+
- -
3A
-
3B
-
3C
+ {% include_relative topic_basics_of_distributed_memory_programming/1D.html %}
+
- -
3A
-
3B
-
3C
+ {% include_relative topic_basics_of_distributed_memory_programming/2D.html %}
- - - diff --git a/topic_basics_of_distributed_memory_programming/introduction.html b/topic_basics_of_distributed_memory_programming/introduction.html new file mode 100644 index 0000000..668d1df --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/introduction.html @@ -0,0 +1,61 @@ +
+ +

Overview

+ +

This topic introduces basic but essential concepts for distributed-memory programming + (Single-Program Multiple-Data (SPMD) programming style, the use of process rank to distribute work among processes, + local vs. Global indices for 1-D and 2-D data distribution of arrays, simple message-passing to coordinate processes). + The focus is not on performance but on correctness. +

+ +

+ Goal: To implement several versions of a "toy" parallel application that + computes the Julia set displayed below and saves it as a bitmap file: +

+ +

+ + +

+ + {% include_relative topic_basics_of_distributed_memory_programming/julia_accordion.html %} + +
+ +
+

Roadmap

+

This topic consists of 3 activities, each described in its own tab above, which should be done in + sequence: +

+ + +
+ + +
+

What to turn in

+

You should turn in a single archive (or a github repo) with: +

+
All source code
+
XML platform files (see details in the activities)
+
A Makefile with: +
+
A "default" target that compiles all sources to generate all required executables
+
A "run" target that runs all programs (or that displays a message detailing individual targets to run each program)
+
+
+
A README file with answers to the questions asked in the activities
+
+

+
\ No newline at end of file diff --git a/topic_basics_of_distributed_memory_programming/julia_accordion.html b/topic_basics_of_distributed_memory_programming/julia_accordion.html new file mode 100644 index 0000000..75e50c2 --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/julia_accordion.html @@ -0,0 +1,38 @@ + + + + +
+
+ + What is a Julia set? +
+
+
+

A Julia set is a fractal, i.e., an object that is self-similar across scales (you "zoom in" + and you keep seeing similar structures/features). It is a generalization + of the famous Mandelbrot set[Wikipedia], + which adorns many T-shirts (search for "Mandelbrot zoom" for psychedelic videos).

+ +

The particular Julia set + that we compute here is defined as follows. Given z a point in the 2-D complex plane, we compute the + series defined as: +

    +
  • z0 = z
  • +
  • zn+1 = zn2 + c
  • +
+ where c = -0.79 + i * 0.15. Different + values of c lead to different images, we know many values that produce "pretty" images. +

+

+ The color of a pixel corresponding to point z is determined based on the number of iterations + before the modulus of zn is above 2 (or until a maximum number of iterations + is reached). +

+

+ Not to worry, code is provided for you for the above. However, feel free to tweak it to create different + images and to find out more about Julia sets[Wikipedia]. +

+
+
+
diff --git a/topic_basics_of_distributed_memory_programming/sequential.html b/topic_basics_of_distributed_memory_programming/sequential.html new file mode 100644 index 0000000..11dfa3a --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/sequential.html @@ -0,0 +1,23 @@ +In this activity we develop a simple sequential (i.e., non-parallel) programs that computes a +Julia set and saves it to a bitmap file. We break it down into the two steps below: +
+ + + +
+ + {% include_relative topic_basics_of_distributed_memory_programming/sequential_step1.html %} + +
+ + + +
+ + {% include_relative topic_basics_of_distributed_memory_programming/sequential_step2.html %} + + +
\ No newline at end of file diff --git a/topic_basics_of_distributed_memory_programming/sequential_step1.html b/topic_basics_of_distributed_memory_programming/sequential_step1.html new file mode 100644 index 0000000..0d5fc11 --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/sequential_step1.html @@ -0,0 +1,36 @@ +Implement a C (or C++) program called sequential_julia (source file sequential_julia.c) that: + +
+
Takes a single command-line argument, n, an integer that's strictly positive.
+
Allocates an 1-D char array of (n*840)*(2*n*840)*3 elements. This array is used to + store an + image with height (in pixels) of n*840, width (in pixels) of 2*n*840, where each pixel is encoded using 3 bytes (RBG + values). +
+
Fills this array with pixel values corresponding to the Julia set.
+
+ +

+ To make the above easier you are provided with one helper C function, compute_julia_pixel(), to which + you pass the (x,y) coordinates of a pixed, the (width, height) dimensions of the image, a "tint" float (pass 1.0 + for now), and a pointer to 3 contiguous bytes. These bytes are set to appropriate RGB values (Red Green Blue) for + displaying the Julia set. + [Download + source of compute_julia_pixel()] +

+ +
+
+ + See the source of compute_julia_pixel() +
+
+
+ + {% highlight Java %} + {% include_relative topic_basics_of_distributed_memory_programming/compute_julia_pixel.c %} + {% endhighlight %} +
+
+
+ diff --git a/topic_basics_of_distributed_memory_programming/sequential_step2.html b/topic_basics_of_distributed_memory_programming/sequential_step2.html new file mode 100644 index 0000000..2fd9f95 --- /dev/null +++ b/topic_basics_of_distributed_memory_programming/sequential_step2.html @@ -0,0 +1 @@ +TBD \ No newline at end of file