Commit 486e7cac authored by CHAMONT David's avatar CHAMONT David
Browse files

Apres On-Demand Floating Point

parent b2f3e1ce
......@@ -170,7 +170,7 @@
" unsigned n, d ;\n",
" \n",
" friend std::weak_ordering operator<=>( Rational const & lhs, Rational const & rhs )\n",
" { return (lhs.n*rhs.d)<=>(lhs.n*rhs.d) ; }\n",
" { return (lhs.n*rhs.d)<=>(lhs.d*rhs.n) ; }\n",
" } ;\n",
" \n",
"std::ostream & operator<<( std::ostream & os, std::weak_ordering cmp )\n",
......@@ -382,7 +382,7 @@
"\n",
"We are not fully happy with the default implementation of `<=>`for our `Complex` class below.\n",
"1. Modify it so that the ordering is based on the norm of the complexes.\n",
"2. Because you do not use any more the default implementation of `<=>`m you had to prived also an implementation for `==`. What happens if you deduce it from `<=>` (using `(((*this)<=>other)==0)`) ?\n",
"2. Because you do not use any more the default implementation of `<=>` you had to provide also an implementation for `==`. What happens if you deduce it from `<=>` (using `(((*this)<=>other)==0)`) ?\n",
"3. Try to restore the default implementation for `==` only."
]
},
......
......@@ -28,13 +28,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.1.h\n"
]
}
],
"source": [
"%%file tmp.chrono.1.h\n",
"\n",
......@@ -46,13 +54,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.2.h\n"
]
}
],
"source": [
"%%file tmp.chrono.2.h\n",
"\n",
......@@ -67,13 +83,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.3.h\n"
]
}
],
"source": [
"%%file tmp.chrono.3.h\n",
"\n",
......@@ -93,13 +117,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.cpp\n"
]
}
],
"source": [
"%%file tmp.chrono.cpp\n",
"\n",
......@@ -121,13 +153,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.sh\n"
]
}
],
"source": [
"%%file tmp.chrono.sh\n",
"\n",
......@@ -138,13 +178,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.525744\r\n",
"\r\n",
"real\t0m2.457s\r\n",
"user\t0m2.457s\r\n",
"sys\t0m0.000s\r\n"
]
}
],
"source": [
"!bash -l ./tmp.chrono.sh 1024 100000"
]
......@@ -193,13 +245,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.sh\n"
]
}
],
"source": [
"%%file tmp.chrono.sh\n",
"\n",
......@@ -218,13 +278,32 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.525744\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"(~ 0.000 s)\n"
]
}
],
"source": [
"!bash -l tmp.chrono.sh 1024 100000"
]
......@@ -255,13 +334,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.2.h\n"
]
}
],
"source": [
"%%file tmp.chrono.2.h\n",
"\n",
......@@ -286,7 +373,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {
"slideshow": {
"slide_type": "skip"
......@@ -299,13 +386,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(generate: 29 us)\n",
"0.525744\n"
]
}
],
"source": [
"!./tmp.chrono.exe 1024 100000"
]
......@@ -548,7 +644,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.9.12"
}
},
"nbformat": 4,
......
......@@ -26,13 +26,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing tmp.chrono.1.h\n"
]
}
],
"source": [
"%%file tmp.chrono.1.h\n",
"\n",
......@@ -44,13 +52,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing tmp.chrono.2.h\n"
]
}
],
"source": [
"%%file tmp.chrono.2.h\n",
"\n",
......@@ -65,13 +81,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing tmp.chrono.3.h\n"
]
}
],
"source": [
"%%file tmp.chrono.3.h\n",
"\n",
......@@ -91,13 +115,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing tmp.chrono.cpp\n"
]
}
],
"source": [
"%%file tmp.chrono.cpp\n",
"\n",
......@@ -119,13 +151,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing tmp.chrono.sh\n"
]
}
],
"source": [
"%%file tmp.chrono.sh\n",
"\n",
......@@ -136,13 +176,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.525744\r\n",
"\r\n",
"real\t0m2.706s\r\n",
"user\t0m2.706s\r\n",
"sys\t0m0.000s\r\n"
]
}
],
"source": [
"!bash -l ./tmp.chrono.sh 1024 100000"
]
......@@ -191,13 +243,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.sh\n"
]
}
],
"source": [
"%%file tmp.chrono.sh\n",
"\n",
......@@ -216,13 +276,32 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.525744\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"tmp.chrono.sh: line 9: time: command not found\n",
"(~ 0.000 s)\n"
]
}
],
"source": [
"!bash -l tmp.chrono.sh 1024 100000"
]
......@@ -253,13 +332,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting tmp.chrono.2.h\n"
]
}
],
"source": [
"%%file tmp.chrono.2.h\n",
"\n",
......@@ -284,7 +371,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {
"slideshow": {
"slide_type": "skip"
......@@ -297,13 +384,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(generate: 30 us)\n",
"0.525744\n"
]
}
],
"source": [
"!./tmp.chrono.exe 1024 100000"
]
......@@ -394,7 +490,7 @@
"source": [
"# Exercise\n",
"\n",
"The code below defines some kind of \"meta-function\" `time()`, which takes as input another function `f`, and a set of arguments to be used for a call to `f`.\n",
"The code below defines some kind of \"high-order function\" `time()`, which takes as input another function `f`, and a set of arguments to be used for a call to `f`.\n",
"1. You are asked to complete the definition of `time`, with `chrono` features, so to compute, display and compare the execution time of `analyse1` and `analyse2`.\n",
"2. Try to write a Python script which will run the program 10 times, and compute the mean execution time of `generate`, `analyse1` and `analyse2`...\n",
"3. ...And/or try with [QuickBench](https://www.quick-bench.com/)."
......@@ -444,7 +540,7 @@
" {\n",
" double val = 1 ; \n",
" for ( int j=0 ; j<power ; ++j )\n",
" val *= data ;\n",
" { val *= data ; }\n",
" res += val ;\n",
" }\n",
" return res ;\n",
......@@ -546,7 +642,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.9.12"
}
},
"nbformat": 4,
......
......@@ -481,7 +481,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.9.12"
}
},
"nbformat": 4,
......
......@@ -8,7 +8,7 @@
}
},
"source": [
"# The price of basic operations"
"# The versatile price of basic operations"
]
},
{
......@@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 340,
"execution_count": 10,
"metadata": {
"slideshow": {
"slide_type": "skip"
......@@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 359,
"execution_count": 11,
"metadata": {
"slideshow": {
"slide_type": "skip"
......@@ -159,7 +159,7 @@
" else:\n",
" print(line)\n",
"\n",
"# Repeat timig\n",
"# Repeat timing\n",
"\n",
"for irun in range(NB_RUNS):\n",
" for line in run(run_cmd):\n",
......@@ -189,7 +189,7 @@
},
{