Skip to content

Commit

Permalink
build based on 575526c
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Sep 7, 2023
1 parent 33f0d35 commit 26d27a0
Show file tree
Hide file tree
Showing 19 changed files with 438 additions and 543 deletions.
18 changes: 9 additions & 9 deletions dev/core/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/develop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
-3.8788212776372465e-5
-7.376592164341867e-6
]
end</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../gpu/">« Accelerations</a><a class="docs-footer-nextpage" href="../quad/">Example: Quadrotor »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Wednesday 6 September 2023 21:31">Wednesday 6 September 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
end</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../gpu/">« Accelerations</a><a class="docs-footer-nextpage" href="../quad/">Example: Quadrotor »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Wednesday 6 September 2023 22:02">Wednesday 6 September 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
1 change: 0 additions & 1 deletion dev/distillation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ using ExaModels, NLPModelsIpopt

m = distillation_column_model(10)
ipopt(m)

2 changes: 1 addition & 1 deletion dev/distillation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
end</code></pre><pre><code class="nohighlight hljs">distillation_column_model (generic function with 2 methods)</code></pre><pre><code class="language-julia hljs">using ExaModels, NLPModelsIpopt

m = distillation_column_model(10)
ipopt(m)</code></pre><pre><code class="nohighlight hljs">&quot;Execution stats: first-order stationary&quot;</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../quad/">« Example: Quadrotor</a><a class="docs-footer-nextpage" href="../opf/">Example: Optimal Power Flow »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Wednesday 6 September 2023 21:31">Wednesday 6 September 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
ipopt(m)</code></pre><pre><code class="nohighlight hljs">&quot;Execution stats: first-order stationary&quot;</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../quad/">« Example: Quadrotor</a><a class="docs-footer-nextpage" href="../opf/">Example: Optimal Power Flow »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Wednesday 6 September 2023 22:02">Wednesday 6 September 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
74 changes: 23 additions & 51 deletions dev/gpu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,43 @@
# Also, if you're using NVIDIA GPUs, make sure to have installed appropriate drivers.

# Let's say that our CPU code is as follows.
function luksan_vlcek_obj(x,i)
return 100*(x[i-1]^2-x[i])^2+(x[i-1]-1)^2
function luksan_vlcek_obj(x, i)
return 100 * (x[i-1]^2 - x[i])^2 + (x[i-1] - 1)^2
end

function luksan_vlcek_con(x,i)
return 3x[i+1]^3+2*x[i+2]-5+sin(x[i+1]-x[i+2])sin(x[i+1]+x[i+2])+4x[i+1]-x[i]exp(x[i]-x[i+1])-3
function luksan_vlcek_con(x, i)
return 3x[i+1]^3 + 2 * x[i+2] - 5 + sin(x[i+1] - x[i+2])sin(x[i+1] + x[i+2]) + 4x[i+1] -
x[i]exp(x[i] - x[i+1]) - 3
end

function luksan_vlcek_x0(i)
return mod(i,2)==1 ? -1.2 : 1.0
return mod(i, 2) == 1 ? -1.2 : 1.0
end

function luksan_vlcek_model(N)

c = ExaCore()
x = variable(
c, N;
start = (luksan_vlcek_x0(i) for i=1:N)
)
constraint(
c,
luksan_vlcek_con(x,i)
for i in 1:N-2)
objective(
c,
luksan_vlcek_obj(x,i)
for i in 2:N)

x = variable(c, N; start = (luksan_vlcek_x0(i) for i = 1:N))
constraint(c, luksan_vlcek_con(x, i) for i = 1:N-2)
objective(c, luksan_vlcek_obj(x, i) for i = 2:N)

return ExaModel(c)
end

# Now we simply modify this by
function luksan_vlcek_model(N, backend = nothing)

c = ExaCore(backend) # specify the backend
x = variable(
c, N;
start = (luksan_vlcek_x0(i) for i=1:N)
)
constraint(
c,
luksan_vlcek_con(x,i)
for i in 1:N-2)
objective(
c,
luksan_vlcek_obj(x,i)
for i in 2:N)

x = variable(c, N; start = (luksan_vlcek_x0(i) for i = 1:N))
constraint(c, luksan_vlcek_con(x, i) for i = 1:N-2)
objective(c, luksan_vlcek_obj(x, i) for i = 2:N)

return ExaModel(c)
end


# The acceleration can be done simply by specifying the backend. In particular, for multi-threaded CPUs,
using ExaModels, NLPModelsIpopt, KernelAbstractions
using ExaModels, NLPModelsIpopt, KernelAbstractions

m = luksan_vlcek_model(10, CPU())
ipopt(m)
Expand All @@ -80,25 +63,14 @@ ipopt(m)
# In the case we have arrays for the data, what we need to do is to simply convert the array types to the corresponding device array types. In particular,

function cuda_luksan_vlcek_model(N)
c = ExaCore(CUDABackend())
c = ExaCore(CUDABackend())
d1 = CuArray(1:N-2)
d2 = CuArray(2:N)
d3 = CuArray([luksan_vlcek_x0(i) for i=1:N])

x = variable(
c, N;
start = d3
)
constraint(
c,
luksan_vlcek_con(x,i)
for i in d1
)
objective(
c,
luksan_vlcek_obj(x,i)
for i in d2
)
d3 = CuArray([luksan_vlcek_x0(i) for i = 1:N])

x = variable(c, N; start = d3)
constraint(c, luksan_vlcek_con(x, i) for i in d1)
objective(c, luksan_vlcek_obj(x, i) for i in d2)

return ExaModel(c)
end
Expand Down
Loading

0 comments on commit 26d27a0

Please sign in to comment.