-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to disable various multithreading features
- Loading branch information
Showing
6 changed files
with
178 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
module Defaults | ||
Some default values and settings for MPSKit. | ||
""" | ||
module Defaults | ||
|
||
using Preferences | ||
import KrylovKit: GMRES, Arnoldi | ||
|
||
const eltype = ComplexF64 | ||
const maxiter = 100 | ||
const tolgauge = 1e-14 | ||
const tol = 1e-12 | ||
const verbose = true | ||
|
||
_finalize(iter, state, opp, envs) = (state, envs) | ||
|
||
const linearsolver = GMRES(; tol, maxiter) | ||
const eigsolver = Arnoldi(; tol, maxiter) | ||
|
||
# Preferences | ||
# ----------- | ||
|
||
function set_parallelization(options::Pair{String, Bool}...) | ||
for (key, val) in options | ||
if !(key in ("sites", "derivatives", "transfers")) | ||
throw(ArgumentError("Invalid option: \"$(key)\"")) | ||
end | ||
|
||
@set_preferences!("parallelize_$key" => val) | ||
end | ||
|
||
sites = @load_preference("parallelize_sites", nothing) | ||
derivatives = @load_preference("parallelize_derivatives", nothing) | ||
transfers = @load_preference("parallelize_derivatives", nothing) | ||
@info "Parallelization changed; restart your Julia session for this change to take effect!" sites derivatives transfers | ||
return nothing | ||
end | ||
|
||
const parallelize_sites = @load_preference("parallelize_sites", Threads.nthreads() > 1) | ||
const parallelize_derivatives = @load_preference("parallelize_derivatives", Threads.nthreads() > 1) | ||
const parallelize_transfers = @load_preference("parallelize_transfers", Threads.nthreads() > 1) | ||
|
||
end |