Write DArray to HDF5/JLD without first converting to Array

未關閉
#108 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
julia

研究方向

從 issue 的 write_darray 和 read_darray 範例開始,包括 jldopen、localindexes、localpart 和 remotecall_wait。研究 DistributedArrays 和 HDF5/JLD 層如何表示一個分散式變數,而不是每個程序一個物件。完成的標準是存在一種受支援的方法,可以在不將 DArray 收集到本機且不建立 2n+2 個檔案變數的情況下寫入和讀取 DArray。

由索引模型根據 Issue 內容生成。

描述

It would be useful to have a way to write DArrays to file without first collecting all of the data on the local process. I found a pretty hacky way of doing this that looks like this:

function write_darray{T<:AbstractFloat}(filepath::AbstractString, darr::DArray{T})
    function write_localpart(pid::Int)
        jldopen(filepath, "r+") do file
            write(file, "inds$pid", collect(localindexes(darr)))
            write(file, "arr$pid", localpart(darr))
        end
    end

    # Write DArray metadata
    jldopen(filepath, "w") do file
        write(file, "dims", darr.dims)
        write(file, "pids", collect(darr.pids))
    end

    # For each process, write the local indices and local part
    for pid in darr.pids
        remotecall_wait(pid, write_localpart, pid)
        sleep(0.001) # This is for some reason necessary, or else HDF5 complains that the new object already exists
    end
end

function read_darray(filepath::AbstractString)
    file = jldopen(filepath, "r")
    dims = read(file, "dims")
    pids = read(file, "pids")
    out = zeros(dims...)

    # Reassemble local parts
    for pid in pids
        inds = read(file, "inds$pid")
        out[inds...] = read(file, "arr$pid")
    end

    close(file)
    return out
end

However, there must be a better way than this, especially one that would create a single variable in the file filepath (rather than 2n+2 in my case, where n is the number of processes the DArray is stored on).

主要語言
Julia
星號
205
分支
34
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

JuliaParallel/DistributedArrays.jl 的其他 Issue

查看 JuliaParallel/DistributedArrays.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。