Skip to content

Commit

Permalink
Updates ldpc_codegen.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Adomas Baliuka authored and Adomas Baliuka committed May 17, 2023
1 parent 6aafb99 commit c0ed083
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions codes/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.0"
manifest_format = "2.0"
project_hash = "a14c573cb65f43bdc2910ceedeb98b7d0eb9a774"
project_hash = "8114c5ad6136e70bdacde4a1c369d8782486892a"

[[deps.ArgParse]]
deps = ["Logging", "TextWrap"]
Expand Down Expand Up @@ -117,9 +117,9 @@ version = "0.3.21+4"

[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "7302075e5e06da7d000d9bfa055013e3e85578ca"
git-tree-sha1 = "a5aef8d4a6e8d81f171b2bd4be5265b01384c74c"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.5.9"
version = "2.5.10"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
Expand Down
2 changes: 1 addition & 1 deletion codes/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
LDPCStorage = "d46d874d-5773-4ce9-8adb-568101dc8882"

[compat]
julia = "1.6.2"
julia = "1.8"
25 changes: 14 additions & 11 deletions codes/ldpc_codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function parse_my_args(args)
arg_type = ValidPath
help = "Path to .alist or .json file containing the LDPC code.
For .bincsc.json files, raw LDPC storage is supported.
For qccsc.json files, quasi-cyclic-exponents are supported"
For .qccsc.json files, quasi-cyclic-exponents are supported"
"--output_path"
default = "autogen_ldpc_matrix_csc.hpp"
arg_type = String
help = "Path to put the automatically generated C++ file containing the LDPC code.
If the file extension is .cscmat, a compressed sparse column storage of the full matrix
If the file extension is .bincsc.json, a compressed sparse column storage of the full matrix
(actual binary matrix, not QC-exponents) is written instead."
end

Expand Down Expand Up @@ -73,29 +73,32 @@ end


"""
Converts all `.cscmat` files in the folder given by `input_folder_path` to same name `.cscmat`
files in the `output_folder_path`. Each input file is assumed to contain QC exponents.
Converts all `.qccsc.json` files in the folder given by `input_folder_path` to same name with extension `.bincsc.json`
files in the `output_folder_path`.
Each input file is assumed to contain QC exponents for an LDPC matrix (as defined by the `.qccsc.json` format).
The output files store the full binary LDPC matrix, which can be used as input to the C++ programs.
Warning: this may overwrite pre-existing files in the output folder.
"""
function convert_all_to_loadable_cscmat(
function convert_all_qc_to_binary(
input_folder_path::AbstractString, output_folder_path::AbstractString;
verbose=false
)
isdir(input_folder_path) || error("`$input_folder_path` is not a valid folder path.")
isdir(output_folder_path) || mkdir(output_folder_path)

file_paths = readdir(input_folder_path; join=true)
filter!(p -> LDPCStorage.file_extension(p) == ".cscmat", file_paths)
filter!(p -> endswith(p, ".qccsc.json"), file_paths)
verbose && @info "Converting $(length(file_paths)) files."

for p in file_paths
H = load_cscmat_standard_or_qc_exponents(p)
save_to_cscmat(H, joinpath(output_folder_path, basename(p));
allow_omit_entries_if_only_stored_ones=true,)
end
H = LDPCStorage.load_ldpc_from_json(p; expand_qc_exponents_to_binary=true)

verbose && @info "Converted $(size(file_paths)) files."
# store file with same name but replaced file extension reflecting contents
out_file_path = joinpath(output_folder_path, basename(p)[1:end-11]*".bincsc.json")
LDPCStorage.save_to_bincscjson(out_file_path, H)
verbose && @info "Converted `$p` -> `$out_file_path`."
end
return nothing
end

Expand Down

0 comments on commit c0ed083

Please sign in to comment.