hpc-intro icon indicating copy to clipboard operation
hpc-intro copied to clipboard

Create parallel-fortran example

Open bkmgit opened this issue 3 years ago • 14 comments

It would be helpful to have examples in a number of programming languages, to allow choice and comparison. This is for Fortran, but other languages would be nice to add as well.

bkmgit avatar Apr 18 '21 11:04 bkmgit

As a practitioner, I find this very cool, and welcome the contribution. For our learners, the focus of this lesson should be on using the HPC machinery, and the high-level Python language is the best fit for that constraint. I suggest we begin planning an "HPC Programming" lesson and consider moving this Fortran code there.

tkphd avatar Apr 18 '21 12:04 tkphd

  • We should not force everyone to use Python, while it is useful for scripting and increasing programmer productivity, it has serious drawbacks for efficiency, see for example https://ioinformatics.org/journal/INFOL026.pdf
  • One of the aims of parallelization is to reduce time to solution, since both human time and computer time are important, it is good to make people aware that expending more human time to use a less productive language can lead to reduced computation time.
  • Allowing people to contribute different parallel versions is the way to go
  • The artificial memory utilization in the Python program is needed in Python because loops without automatic numpy vectorization are slow. Tradeoffs of speed for memory are common in many algorithm implementations, but probably not needed in all the implementations.

bkmgit avatar Apr 18 '21 13:04 bkmgit

I completely agree, @bkmgit: I use C++ & CUDA for my HPC work, with some Python glue. We are not trying to force people to use Python, and certainly are not suggesting people use vanilla Python for high-performance applications.

Fundamentally, the HPC Intro lesson is not about the code, it's about the infrastructure: how to connect, plan & launch jobs, and manage file inputs & outputs. Python, as a high-level and reasonably human-readable language, allows us to focus on the pedagogical goals without getting bogged explaining the language. Fortran achieves its performance because of the fact that it is a low-level language. I could explain the code you submitted to newbies, but I really wouldn't want to unless that was the only teaching goal. Hence my suggestion to partition it into a separate, code-centric, lesson. It's possible we could provide the Fortran version as an alternative episode, so if you know your learners are more familiar with Fortran than they are with Python, you could teach to their strengths. Given the rise of Python over the past decade, I'm not sure how realistic the notion is, but it's not impossible.

There has been a lot of discussion around the curriculum and teaching goals of HPC Intro. We would do well to revisit the over-arching curriculum of our lessons as a whole, and figure out how to smoothly chain from one lesson to the next in building a workshop. Your experience teaching the material is high value, and I look forward to ironing out the designs with you.

tkphd avatar Apr 18 '21 13:04 tkphd

Expect to test out:

  • C
  • C++
  • Java
  • Scala
  • Go
  • R
  • Chapel
  • Julia
  • Rust
  • Perl
  • Lua

One can even use map-reduce for this problem, which may be helpful for people using big data frameworks

bkmgit avatar Apr 18 '21 14:04 bkmgit

The aim should be that course participants can choose the language they are most familiar with for execution, with instructor using a common high level explanation.

bkmgit avatar Apr 18 '21 14:04 bkmgit

The conventional Carpentries approach is to have the Learners and Instructor typing the same thing, to remain engaged and get used to keystrokes. For an individual following a web tutorial, it could make sense to offer all these options for comfort, but the Carpentries exists because that style of learning is not as effective as a guided tutorial working through common material.

I see that you're passionate about providing options and helping people learn in their preferred languages. Have you received strong feedback from learners that Python is unacceptable?

tkphd avatar Apr 18 '21 14:04 tkphd

So we can do an effective test of this, it would be great to add templates for code blocks of

  • language-fortran
  • language-c
  • language-cpp
  • language-java
  • language-scala
  • language-go
  • language-r
  • language-chapel
  • language-julia
  • language-rust
  • language-perl
  • language-lua

Where can these be added?

bkmgit avatar Apr 18 '21 14:04 bkmgit

KNOWN_CODEBLOCKS in bin/lesson_check.py

tkphd avatar Apr 18 '21 14:04 tkphd

Recommend making this WIP Ep. 19, so the "consecutive numbering" check can pass.

tkphd avatar Apr 18 '21 16:04 tkphd

Is it possible to have 16 which has Python as default and gives links to other options, or just lists all the possible language options, and then 16-a 16-b etc for other language possibilities?

bkmgit avatar Apr 18 '21 16:04 bkmgit

No. Lessons must be numbered consecutively.

tkphd avatar Apr 18 '21 16:04 tkphd

If you want options, the episode would have to be snippetized.

tkphd avatar Apr 18 '21 16:04 tkphd

No. Lessons must be numbered consecutively.

Possibly a minor sidebar, but I think lessons can be nonconsecutive since the merger of PR #263 , closing issue #230. Actual nonsequential lessons were never implemented, but it's now a policy question, and not a technical question.

reid-a avatar Apr 18 '21 20:04 reid-a

Ok, the snippets option may be good here. Most procedural languages would have a very similar format.

bkmgit avatar Apr 19 '21 06:04 bkmgit