Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jd/debug lodf #60

Merged
merged 56 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
51abb8a
add debugging code
jd-lara Sep 26, 2023
ea07a25
add more checking
jd-lara Sep 26, 2023
6465028
one more test
jd-lara Sep 26, 2023
6556db8
remove write to vector option
jd-lara Sep 26, 2023
2fcb7a4
split phases
jd-lara Sep 26, 2023
3fe37e7
fix typo
jd-lara Sep 26, 2023
5904898
fix typo
jd-lara Sep 26, 2023
4825d8b
try single solve call
jd-lara Sep 27, 2023
cdbed5d
fix index
jd-lara Sep 27, 2023
b40b98b
try total
jd-lara Sep 27, 2023
9d8fe72
test sequential solves
jd-lara Sep 27, 2023
01e4496
next try
jd-lara Sep 27, 2023
550fdd3
use correct stage
jd-lara Sep 27, 2023
b2e08c1
test using chunks
jd-lara Sep 27, 2023
92dd80f
update calculations
jd-lara Sep 27, 2023
6c35043
increase chunk size
jd-lara Sep 27, 2023
93cc28b
fix indexing
jd-lara Sep 27, 2023
220c25b
fix tmp size
jd-lara Sep 27, 2023
de38f02
address last chunk
jd-lara Sep 27, 2023
35ca575
add sequential Pardiso solve
jd-lara Sep 27, 2023
68f0e76
formatter
jd-lara Sep 27, 2023
7b6a8c7
fix indexing
jd-lara Sep 27, 2023
cde0367
count on 0
jd-lara Sep 27, 2023
2886e34
one more fix to indexing
jd-lara Sep 27, 2023
5f7736c
remove logging
jd-lara Sep 28, 2023
0d78a5d
enable single call
jd-lara Sep 28, 2023
c26a18c
increase LODF chunk size
jd-lara Sep 28, 2023
9a9badd
reduce chunk size
jd-lara Sep 28, 2023
3037b53
try using copyto
jd-lara Sep 28, 2023
a5b6e4c
use dot
jd-lara Sep 28, 2023
ee06bf8
not call release all
jd-lara Sep 28, 2023
2e1eb70
call pardiso again after release
jd-lara Sep 28, 2023
643f7d3
one more try
jd-lara Sep 28, 2023
62370e4
change iparm 12
jd-lara Sep 28, 2023
8e3708f
call pardiso after release
jd-lara Sep 28, 2023
4351315
try with deepcopy
jd-lara Sep 28, 2023
a14f032
try to multiply
jd-lara Sep 28, 2023
e56491b
change order of operations
jd-lara Sep 28, 2023
77b36f1
dont store in full_BA
jd-lara Sep 28, 2023
fd84136
add logging
jd-lara Sep 28, 2023
90cf324
fix to LODF
jd-lara Sep 28, 2023
53b09f8
revert changes
jd-lara Sep 28, 2023
b240879
update pariso params
jd-lara Sep 28, 2023
03acf04
remove messaging
jd-lara Sep 28, 2023
6fa823c
use mkl linear algebra
jd-lara Sep 28, 2023
10781b8
update pardiso calls
jd-lara Sep 28, 2023
54a644c
change parameters pardiso LODF
jd-lara Sep 28, 2023
5780ac9
readd release
jd-lara Sep 28, 2023
a471447
reduce chunk size
jd-lara Sep 28, 2023
96975cc
bump chunk size
jd-lara Sep 28, 2023
d2ed1ac
bump chunk size
jd-lara Sep 28, 2023
08f168d
use openblas again
jd-lara Sep 29, 2023
8fb402b
se lapack directly
jd-lara Sep 29, 2023
451381c
add MKL again
jd-lara Sep 29, 2023
9eea136
update lodf LAPACK code
jd-lara Sep 29, 2023
74e093f
update lodf klu
jd-lara Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ const MiB = KiB * KiB
const GiB = MiB * KiB
const MAX_CACHE_SIZE_MiB = 100
const ROW_PERSISTENT_CACHE_WARN = 1 * GiB

DEFAULT_LODF_CHUNK_SIZE = 10_000
94 changes: 73 additions & 21 deletions src/lodf_calculations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,73 @@
return lodf_t
end

function _pardiso_sequential_LODF!(

Check warning on line 131 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L131

Added line #L131 was not covered by tests
lodf_t::Matrix{Float64},
A::SparseArrays.SparseMatrixCSC{Float64, Int},
ptdf_denominator_t::Matrix{Float64},
chunk_size::Int = DEFAULT_LODF_CHUNK_SIZE,
)
linecount = size(lodf_t, 1)
ps = Pardiso.MKLPardisoSolver()
Pardiso.pardisoinit(ps)

Check warning on line 139 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L137-L139

Added lines #L137 - L139 were not covered by tests
#Pardiso.set_msglvl!(ps, Pardiso.MESSAGE_LEVEL_ON)

Pardiso.set_phase!(ps, Pardiso.ANALYSIS)
Pardiso.pardiso(

Check warning on line 143 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L142-L143

Added lines #L142 - L143 were not covered by tests
ps,
lodf_t,
A,
ptdf_denominator_t,
)

Pardiso.set_phase!(ps, Pardiso.NUM_FACT)
Pardiso.pardiso(

Check warning on line 151 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L150-L151

Added lines #L150 - L151 were not covered by tests
ps,
A,
Float64[],
)
Pardiso.set_phase!(ps, Pardiso.SOLVE_ITERATIVE_REFINE)
i_count = 1
tmp = zeros(Float64, linecount, chunk_size)
while i_count <= linecount
edge = min(i_count + chunk_size - 1, linecount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
edge = min(i_count + chunk_size - 1, linecount)
edge = min(i_count + chunk_size - 1, linecount)

if linecount - edge <= 0
tmp = tmp[:, 1:(edge - i_count + 1)]

Check warning on line 162 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L156-L162

Added lines #L156 - L162 were not covered by tests
end
Pardiso.pardiso(

Check warning on line 164 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L164

Added line #L164 was not covered by tests
ps,
tmp,
A,
ptdf_denominator_t[:, i_count:edge],
)
lodf_t[:, i_count:edge] .= tmp
i_count = edge + 1
end
Pardiso.set_phase!(ps, Pardiso.RELEASE_ALL)
return

Check warning on line 174 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L170-L174

Added lines #L170 - L174 were not covered by tests
end

function _pardiso_single_LODF!(
lodf_t::Matrix{Float64},
A::SparseArrays.SparseMatrixCSC{Float64, Int},
ptdf_denominator_t::Matrix{Float64},
chunk_size::Int = DEFAULT_LODF_CHUNK_SIZE,
)
linecount = size(lodf_t, 1)
ps = Pardiso.MKLPardisoSolver()
Pardiso.pardisoinit(ps)
#Pardiso.set_msglvl!(ps, Pardiso.MESSAGE_LEVEL_ON)
Pardiso.pardiso(
ps,
lodf_t,
A,
ptdf_denominator_t,
)
Pardiso.set_phase!(ps, Pardiso.RELEASE_ALL)
return
end


jd-lara marked this conversation as resolved.
Show resolved Hide resolved
jd-lara marked this conversation as resolved.
Show resolved Hide resolved
function _calculate_LODF_matrix_MKLPardiso(
a::SparseArrays.SparseMatrixCSC{Int8, Int},
ptdf::Matrix{Float64},
Expand All @@ -145,28 +212,13 @@
push!(m_V, 1 - ptdf_denominator_t[iline, iline])
end
end

# intialize MKLPardiso
ps = Pardiso.MKLPardisoSolver()
defaults = Pardiso.get_iparms(ps)
Pardiso.set_iparm!(ps, 1, 1)
for (ix, v) in enumerate(defaults[2:end])
Pardiso.set_iparm!(ps, ix + 1, v)
end
Pardiso.set_iparm!(ps, 2, 2)
Pardiso.set_iparm!(ps, 59, 2)
Pardiso.set_iparm!(ps, 6, 1)
# inizialize matrix for evaluation
lodf_t = zeros(linecount, linecount)
# solve system
Pardiso.pardiso(
ps,
lodf_t,
SparseArrays.sparse(m_I, m_I, m_V),
ptdf_denominator_t,
)
Pardiso.set_phase!(ps, Pardiso.RELEASE_ALL)
# set diagonal to -1
A = SparseArrays.sparse(m_I, m_I, m_V)
if linecount > DEFAULT_LODF_CHUNK_SIZE
_pardiso_sequential_LODF!(lodf_t, A, ptdf_denominator_t)

Check warning on line 218 in src/lodf_calculations.jl

View check run for this annotation

Codecov / codecov/patch

src/lodf_calculations.jl#L218

Added line #L218 was not covered by tests
else
_pardiso_single_LODF!(lodf_t, A, ptdf_denominator_t)
end
lodf_t[LinearAlgebra.diagind(lodf_t)] .= -1.0
return lodf_t
end
Expand Down
Loading