Skip to content
Snippets Groups Projects
Commit a4c36f1b authored by Miroslav Kratochvil's avatar Miroslav Kratochvil :bicyclist:
Browse files

fixes

parent 6fe99148
No related branches found
No related tags found
2 merge requests!138[release] Regular merge of develop,!131julia training slides for 2022-06-08
This commit is part of merge request !131. Comments created here will be created in the context of that merge request.
......@@ -25,10 +25,17 @@
# Basic parallel processing
**Using Threads:**
**Using `Threads`:**
1. start Julia with parameter `-t N`
2. parallelize any loops with `Threads.@threads`
2. parallelize (some) loops with `Threads.@threads`
```julia
a = zeros(100000)
Threads.@threads for i = eachindex(a)
a[i] = hardfunction(i)
end
```
**Using `Distributed`:**
......@@ -38,6 +45,8 @@ addprocs(N)
newVector = pmap(function, oldVector)
```
We will use the `Distributed` approach.
# How to design for parallelization?
......@@ -53,7 +62,7 @@ newVector = pmap(function, oldVector)
- parallelize programs using `pmap` and `dmapreduce` (DistributedData.jl)
- Decompose more advanced programs into *tasks with dependencies*
- Dagger.jl
- `make -jN` is a surprisingly good tool for parallelization!
- `make -jN` may be a surprisingly good tool for parallelization!
......
......@@ -22,8 +22,9 @@
<style>
code {border: 2pt dotted #f80; padding: .4ex; border-radius: .7ex; color:#444; }
pre code {border: 0;}
.reveal pre code {border: 0; font-size: 18pt; line-height:27pt;}
em {color: #e02;}
li {margin-bottom: 1ex;}
div.leader {font-size:400%; font-weight:bold; margin: 1em;}
section {padding-bottom: 10em;}
</style>
......@@ -12,38 +12,28 @@ Expressions and types You can discover types of stuff using `typeof`.
Common types:
- `Bool`
```julia
false, true
```
- `Char`
```julia
'a', 'b', ...
```
- `String`
```julia
"some random text"
```
- `Int`
```julia
1, 0, -1,
1, 0, -1, ...
```
- `Float64`
```julia
1.1, -1e6, ...
1.1, 0, -1, ...
```
# Types may have parameters (usually "contained type")
- `Vector{Int}`
......@@ -76,7 +66,7 @@ false, true
Types possess a single supertype, which allows you to easily group
multiple types under e.g. `Real`, `Function`, `Type`, `Any`, ...
```julia
<pre style="font-size: 90%; line-height:120%;"><code class="language-julia hljs">
julia> Int
Int64
......@@ -94,9 +84,9 @@ Number
julia> Int.super.super.super.super.super
Any
```
These are useful when restricting what can go into your functions!
</code></pre>
Useful for restricting your functions to work on reasonable subsets of inputs.
......@@ -345,12 +335,15 @@ person["age"]
indexof(v::Vector) = Dict(v .=> eachindex(v))
```
- Sets are value-less dictionaries.
- Sets are value-less dictionaries (i.e., the elements are unique keys)
```julia
function unique(x)
elems = Set{eltype(x)}()
push!.(Ref(elems), x)
return collect(elems)
end
julia> x=Set([1,2,3,2,1]);
julia> println(x)
Set([2, 3, 1])
julia> push!(x,5);
julia> push!(x,5);
julia> println(x)
Set([5, 2, 3, 1])
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment