Commit 9f2cba75 authored by CHAMONT David's avatar CHAMONT David
Browse files

Prepare C++ On Demand

parent d9bbf1f5
# Where to chat about this course ?
We currently use [this discord server](https://discord.gg/MycuXgV3). So that we can better know each other, please add some information into your discord profile. Also, you can say a few words about why you care about C++, in the welcome channel.
## Tips and tricks
A key features in Discord : most important & everlasting messages are "pinned". So to see those messages, one should click on the "pinned messages" icon on the top right corner of the main frame.
\ No newline at end of file
# Use of predefined docker images
If you want to run the notebooks locally on your workstation, the image to be used for most notebooks and examples is `gitlab-registry.in2p3.fr/chamont/modernscientificcpp/default:v4`.
In case you need a more advanced compiler features, which cannot be handled by the xeus-cling notebook kernel, you should rather rely on `gitlab-registry.in2p3.fr/chamont/modernscientificcpp/advanced:v4`. This image should be used for the advanced notebooks where the kernel is a Python one, and the extracts execution is delegated to the underlying system, through %%file and ! magic instructions.
So to start a container with any of those images :
```
docker run -it --rm -p 8888:8888 -v $PWD:/work -w /work <THE-IMAGE-PATH> bash
```
Then you can start the usual notebook server:
```
jupyter notebook --no-browser --allow-root --ip=0.0.0.0
```
Or the lab:
```
jupyter-lab --no-browser --allow-root --ip=0.0.0.0
```
\ No newline at end of file
Also install `git-lfs`.
# Prepare yourself for the lessons
The prerequisites for this lesssons are given in `en.prerequisites.md`, together with links to courses and online tutorials which may help to fill the gaps.
For communication with the teachers and other students, you are asked to connect on this server: `https://discord.gg/KgDmf3zr`. Some more information is given in `en.chatroom.md`.
As better described in `en.teaching-material.md`, the material will be made available, progressively, on [this public project](https://gitlab.in2p3.fr/chamont/modernscientificcpp).
The file `en.installation.md` try to sum up what to install if you want to run the examples on your machine, with or without notebooks, barebone or through docker (in the later case, additional instructions are found in `en.docker.md`). You can also, at least at the beginning, simply use http://coliru.stacked-crooked.com/. Finally, if you have an account in the RENATER federation, you may use `https://jupyterhub.ijclab.in2p3.fr/` (see `en.jupyterhub.md`).
# What should I install ?
## For raw compilation : a C++17 compiler
The more we progress in the lessons, the more advanced C++ features we will use: mostly C++17, and C++20 for few demonstrations. It is therefore adviced to have a recent enough compiler, such as **gcc 9**, or even **gcc 11.2** which we use for the preparation of this course. You will find [here](https://en.cppreference.com/w/cpp/compiler_support) the table of which C++ feature is supported by which compiler version. You should be aware that there is often a distinction between language syntax and standard library : a compiler version which supports C++17 language features does not necessarily supports the C++17 standard library. Generally, the support for syntax is implemented first, and the library novelties comes with a later version.
## GNU time
For some of the exercices, you will need to have **GNU time** installed where you want to execute the scripts. Try the command `\time -f "%U" echo toto` to check if it works fine. The `\` is there to avoid that bash use its own internal time command. If it does not work properly, try `conda install -c conda-forge time` (for example).
## If you want to work with thenotebooks
Most of the education materials is given as notebooks. You can read them on the [public project](https://gitlab.in2p3.fr/chamont/modernscientificcpp), and copy/paste the C++ extracts. Yet, if you want to play the notebooks directly on your machine, you will need to install:
1. `git` and `git-lfs` so to dowload the files (see en.teaching-material.md) ;
2. [jupyter](https://jupyter.org/) ecosystem ;
3. [xeus-cling](https://xeus-cling.readthedocs.io/en/latest/) C++ kernels for notebooks.
The jupyter notebooks tools are part of the [anaconda3 distribution](https://www.anaconda.com/). One can also use `miniconda` for a more focused installation (see below).
## Basic installation and setup with miniconda
[Miniconda](https://docs.conda.io/en/latest/miniconda.html) may be installed this way:
```
MINICONDA_ROOT=/opt/miniconda3
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p ${MINICONDA_ROOT}
rm Miniconda3-latest-Linux-x86_64.sh
${MINICONDA_ROOT}/bin/conda init bash
```
Thus, the following installation should bring you anything listed before:
```
conda update -y conda
conda install -y -c conda-forge mamba
mamba install -y -c conda-forge jupyter
mamba install -y -c conda-forge notebook
mamba install -y -c conda-forge jupyterlab
mamba install -y -c conda-forge xeus-cling
mamba install -y -c conda-forge nbdime
mamba install -y -c conda-forge time
mamba install -y -c conda-forge gxx
```
## With docker
We have also prepared some docker images with anything pre-installed, if you have docker on your machine. See en.docker.md .
# How to use `https://jupyterhub.ijclab.in2p3.fr/`
UNDER WORK.
\ No newline at end of file
# About this course notebooks
The use of notebooks is not completely mandatory : you can read them on the [public project](https://gitlab.in2p3.fr/chamont/modernscientificcpp), and copy/paste the C++ extracts to your prefered editor. Else, if you want to play with the notebooks,
please look at the notebook section in file `en.instalation.md`.
## Two kind of notebooks
Most of the notebooks are relying on the **xeus-cling** C++17 kernel, which will directly "interpret" the code.
For few features which are not supported by the xeus-cling kernel (user defined literals, execution strategies, C++20 features), we use the magic command `%%file` and `!` so that the code is written to a temporary file, and the code compiled and executed by the underlying shell. In such a case, a python kernel is enough.
## Notebooks vs git versioning
One issue when working with notebooks : when using a notebook, you generally modifies it (at least the output of the code cells). If the teacher ask you to `git pull` a new version of it, you may face merging confilcts.
The usual dirty workaround applies : before pulling, either move globally your modified notebooks to a private git branch, or move/copy them to a backup directory.
If you prefer to solve the conflicts, `git diff` will not help much. The right command is rather `nbdiff` , which is not available by default (till now) in the linux distributions. You will need to install the `nbdime` package first, for example with the command `conda install -y -c conda-forge nbdime` .
\ No newline at end of file
# Pre-requisites: not for beginners
So to take full profit of the lessons and exercices in this project, you are expected to have regularly programmed in old (<11) C++. If not, some events and resources for beginners are given below.
## HSF training
- [HEP C++ Course and Hands-on Training](https://indico.cern.ch/category/11733/)
- [Basic Modern C++](https://hsf-training.github.io/hsf-training-cpp-webpage/)
## Online free resources
- [Zeste de Savoir](https://zestedesavoir.com/tutoriels/822/la-programmation-en-c-moderne/)
- [Learn Cpp](https://www.learncpp.com/)
- [begin(c++)](https://gist.github.com/johnmcfarlane/1b2d9c83e4d3f700ba61e2df4077c613?utm_source=newsletter&utm_medium=email&utm_campaign=c_resources_for_your_holidays&utm_term=2021-12-14)
## Private courses
- In Paris-Saclay area, [Code Reckons](https://www.codereckons.com/formations)
- At CERN, [C++ Introduction](https://lms.cern.ch/ekp/servlet/ekp?PX=N&TEACHREVIEW=N&PTX=&CID=EKP000043329&TX=FORMAT1&LANGUAGE_TAG=en&DECORATEPAGE=N)
- At CERN, [Advanced C++](https://lms.cern.ch/ekp/servlet/ekp?TX=FORMAT1&LOTYPE=R&CID=EKP000043824)
# Pedagogic material
## Html
The material will be made available, progressively, on [this public project](https://gitlab.in2p3.fr/chamont/modernscientificcpp) of the IN2P3 gitlab server. There, one cam download a `zip` or `tar`file with anything included : lessons, videos, notebooks, exercises.
## Git
Also, on can clone the project with the command `git clone https://gitlab.in2p3.fr/chamont/modernscientificcpp.git`. If you want to get the videos, previously install `git-lfs` on top of `git`.
## Problem: `server certificate verification failed. CAfile: none CRLfile: none`
This problem is rather common. It means your machine is probably not up to date for the package ca-certificates, and lack the recent letsencrypt certficates. Can be solved with something like `apt upgrade ca-certificates` (to be investiogated).
# Starting point of the course
Depending on your prefered language:
* [Français](fr.index.md)
* [English](en.index.md)
# Credits
This project is mainly made of content written by David Chamont (CNRS) over many years. Vincent Rouvreau (INRIA) has contributed few documents when helping for a 2018 session. Olga Abramkina and Karim Hasnaoui (CNRS) have transated into english a large part of the course, for the PRACE session at the beginning of 2021.
The final common day, more dedicated to the scientific computing facets, largely benefits from debates and experiments with the members of the IN2P3 project [Reprises](https://reprises.in2p3.fr/)(french only): Hadrien Grasland, Pierre Aubert, Vincent Lafage, etc.
\ No newline at end of file
# Modern Scientific C++
This set of notebooks will guide you through the modern C++ syntax. It will be the basement for the later understanding of modern C++ standard library, your first tool for scientific computing. You can download this training materials thanks to the commmand:
```sh
git clone https://gitlab.in2p3.fr/chamont/modernscientificcpp.git ModernScientificCpp
```
The course is organized as an alternation of days in common (physically or virtually) and weeks of intersession during which you have to do exercises individually, at a rate of 1h30 per day.
## [First collective day](1-ClassRoom/en.index.md)
Revisions and first introduction to new syntax. We take this opportunity to get to know each other, create accounts on the forum that will be used during the intersessional period, and to become familiar with notebooks.
* Morning 1 (1h30) : [Get in touch](1-ClassRoom/1-GetInTouch/)
* Morning 2 (1h30) : [Revisions](1-ClassRoom/2-Reminders/en.0-index.ipynb)
* Afternoon 1 (1h30) : [New syntax](1-ClassRoom/3-NewSyntaxes/en.0-index.ipynb)
* Afternoon 2 (1h30) : [Coding dojo](1-ClassRoom/4-CodingDojo/en.index.md)
## [First inter-session](2-HomeWork/en.index.md)
More in-depth study of **new C++ syntax**, and work on **personal code**.
* Day 1 (1h30) : [General modernization](2-HomeWork/1-ModernizeYourCode/en.0-index.ipynb)
* Day 2 (1h30) : [Better use of references and pointers](2-HomeWork/2-ReferencesAndPointers/en.0-index.ipynb)
* Day 3 (1h30) : [Always more templates](2-HomeWork/3-Generic/en.0-index.ipynb)
* Day 4 (1h30) : [First steps in functional programming](2-HomeWork/4-Functional/en.0-index.ipynb)
<!-->
## [Second collective day](3-ClassRoom/en.index.md)
Topics more focused on the standard library, new good practices, and various programming styles.
* Morning 1 (1h30) : [Cpp Core Guidelines & Guideline Support Library](3-ClassRoom/1-CoreGuidelines/README.md)
* Morning 2 (1h30) : [Template meta-programming](3-ClassRoom/2-TemplateMetaProgramming/README.md)
* Afternoon 1 (1h30) : [Functional programming](3-ClassRoom/3-FunctionalProgramming/README.md)
* Afternoon 2 (1h30) : [Concurrent programming](3-ClassRoom/4-ConcurrentProgramming/README.md)
## [Second intersession](4-HomeWork/en.index.md)
Read the [core guidelines](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines),
practice the **new standard library**, and work on your **personal code**.
## [Third collective day](5-ClassRoom/en.index.md)
Some themes more specific to scientific computing: giving units to values, control the accuracy of its calculation, optimize its data structure. Plus an overview of C++20.
* Morning 1 (1h30) : [Quantities and units](1-QuantitiesAndUnits/en.0-index.ipynb)
* Morning 2 (1h30) : [Floating point computing](2-FloatingPointComputing/en.0-index.ipynb)
* Afternoon 1 (1h30) : [Optimisation](3-Optimisation/en.0-index.ipynb)
* Afternoon 2 (1h30) : [A glimpse to C++20](4-Cpp20Glimpse/en.0-index.ipynb)
-->
## Some external resources
References
* [Cpp Reference](cppreference.com/)
* [Learn Cpp](https://www.learncpp.com/)
Tools
* [CoLiRu](http://coliru.stacked-crooked.com/)
* [Compiler Explorer](https://godbolt.org/)
Blogs
* [Modernes Cpp](http://modernescpp.com/)
* [Simplify C++](https://arne-mertz.de)
* [Fluent C++](https://www.fluentcpp.com/)
\ No newline at end of file
# Cpp Scientifique Moderne
Dans un premier temps, cet ensemble de feuilles Jupyter va vous guider à travers la syntaxe du C++ moderne. Cela vous servira de base pour pour comprendre la bibliothèque standard, dans un deuxième temps. Enfin, nous terminerons avec des thématiques spécifiques au calcul scientifique en C++. Vous pouvez récupérez le contenu de ce cours à l'aide de la commande :
```sh
git clone https://gitlab.in2p3.fr/chamont/modernscientificcpp.git ModernScientificCpp
```
Le cours est organisé comme une alternance de journées en commun (phyisquement ou virtuellement) et de semaines d'intersession pendants lesquelles vous devez effectuer des exercices individuellement, à raison d'1h30 par jour.
## [1er jour ensemble](1-ClassRoom/fr.index.md)
Révisions et première introduction aux nouvelles syntaxes.
On en profite pour faire connaissance, créer les comptes sur
le forum qui servira pendant les intersessions, et se familiariser
avec les notebooks.
* Matin 1 (1h30) : [Contact](1-ClassRoom/1-GetInTouch/)
* Matin 2 (1h30) : [Révisions](1-ClassRoom/2-Reminders/fr.0-index.md)
* Aprem 1 (1h30) : [Nouvelles syntaxes](1-ClassRoom/3-NewSyntaxes/fr.0-index.ipynb)
* Aprem 2 (1h30) : [Coding dojo](1-ClassRoom/4-CodingDojo/fr.index.md)
<!--
## [1ere inter-session, 4 jours](2-HomeWork/fr.index.md)
Retour plus appronfondi sur la **nouvelle syntaxe** C++,
et travail sur vos **codes personnels**.
* Jour 1 (1h30) : [Modernisation générale](2-HomeWork/1-ModernizeYourCode/fr.0-index.md)
* Jour 2 (1h30) : [Amélioration des réferences et des pointeurs](2-HomeWork/2-ReferencesAndPointers/)
* Jour 3 (1h30) : [Développement des patrons](2-HomeWork/3-Generic/)
* Jour 4 (1h30) : [Premiers pas fonctionels](2-HomeWork/4-Functional/)
## [2eme jour ensemble](3-ClassRoom/fr.index.md)
Thèmes plus axés sur la bibliothèque standard, les nouvelles bonnes
pratiques, et les styles de programmation.
* Matin 1 (1h30) : [Cpp Core Guidelines & Guideline Support Library](3-ClassRoom/1-CoreGuidelines/README.md)
* Matin 2 (1h30) : [Meta-programmation à base de patrons](3-ClassRoom/2-TemplateMetaProgramming/README.md)
* Aprem 1 (1h30) : [Programmation fonctionnelle](3-ClassRoom/3-FunctionalProgramming/README.md)
* Aprem 2 (1h30) : [Programmation concurrente](3-ClassRoom/4-ConcurrentProgramming/README.md)
## [2eme inter-session, 4 jours](4-HomeWork/fr.index.md)
Lecture des [consignes de codage](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines),
entrainement à la **nouvelle bibliotheque** C++, et travail sur les **codes personnels**.
## [3eme jour ensemble](5-ClassRoom/fr.index.md)
Quelques thèmes plus spécifiques au calcul scientifique : donner des unités aux valeurs,
controler la précision de son calcul, optimiser sa structure de données. Plus un apercu
de C++20.
* Matin 1 (1h30) : [Grandeurs et unites](1-QuantitiesAndUnits/fr.0-index.ipynb)
* Matin 2 (1h30) : [Precision flottante](2-FloatingPointComputing/fr.0-index.ipynb)
* Aprem 1 (1h30) : [Optimisation des performances](3-Optimisation/fr.0-index.md)
* Aprem 2 (1h30) : [Apercu de C++20](4-Cpp20Glimpse/fr.0-index.md)
-->
## Quelques ressources extérieures
Références
* [Cpp Reference](cppreference.com/)
* [Learn Cpp](https://www.learncpp.com/)
* [Zeste de Savoir](https://zestedesavoir.com/tutoriels/822/la-programmation-en-c-moderne/)
Outils en ligne
* [CoLiRu](http://coliru.stacked-crooked.com/)
* [Compiler Explorer](https://godbolt.org/)
Blogs
* [Modernes Cpp](http://modernescpp.com/)
* [Simplify C++](https://arne-mertz.de)
* [Fluent C++](https://www.fluentcpp.com/)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment