Skip to content

Commit

Permalink
move Mmap and SharedArrays to stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Sep 29, 2017
1 parent 68e3901 commit 6004f43
Show file tree
Hide file tree
Showing 18 changed files with 376 additions and 340 deletions.
12 changes: 4 additions & 8 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1014,14 +1014,6 @@ isempty(::Task) = error("isempty not defined for Tasks")
@deprecate Array(::Type{T}, m::Integer,n::Integer) where {T} Array{T}(Int(m),Int(n))
@deprecate Array(::Type{T}, m::Integer,n::Integer,o::Integer) where {T} Array{T}(Int(m),Int(n),Int(o))

# Likewise for SharedArrays
@deprecate SharedArray(::Type{T}, dims::Dims{N}; kwargs...) where {T,N} SharedArray{T}(dims; kwargs...)
@deprecate SharedArray(::Type{T}, dims::Int...; kwargs...) where {T} SharedArray{T}(dims...; kwargs...)
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple{N,Int}, offset; kwargs...) where {T,N},
SharedArray{T}(filename, dims, offset; kwargs...))
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple, offset; kwargs...) where {T},
SharedArray{T}(filename, dims, offset; kwargs...))

@noinline function is_intrinsic_expr(@nospecialize(x))
Base.depwarn("is_intrinsic_expr is deprecated. There are no intrinsic functions anymore.", :is_intrinsic_expr)
return false
Expand Down Expand Up @@ -1381,6 +1373,10 @@ end
export Test
deprecate(@__MODULE__, :Test)

@deprecate_moved SharedArray "SharedArrays" true true

@deprecate_binding Mmap nothing true ", run `using Mmap` instead"

# PR #21709
@deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected)
@deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected)
Expand Down
9 changes: 0 additions & 9 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export
Sys,
Libc,
Libdl,
Mmap,
LinAlg,
BLAS,
LAPACK,
Expand Down Expand Up @@ -104,9 +103,6 @@ export
AbstractSerializer,
SerializationState,
Set,
SharedArray,
SharedMatrix,
SharedVector,
StepRange,
StepRangeLen,
StridedArray,
Expand Down Expand Up @@ -1088,11 +1084,6 @@ export
HTML,
Text,

# shared arrays
sdata,
indexpids,
localindexes,

# paths and file names
abspath,
basename,
Expand Down
5 changes: 0 additions & 5 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ using .Serializer
import .Serializer: serialize, deserialize
include("channels.jl")

# memory-mapped and shared arrays
include("mmap.jl")
import .Mmap

# utilities - timing, help, edit
include("deepcopy.jl")
include("interactiveutil.jl")
Expand Down Expand Up @@ -413,7 +409,6 @@ include("asyncmap.jl")

include("distributed/Distributed.jl")
using .Distributed
include("sharedarray.jl")

# code loading
include("loading.jl")
Expand Down
19 changes: 13 additions & 6 deletions doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ end

# Documenter Setup.

symlink_q(tgt, link) = isfile(link) || symlink(tgt, link)
cp_q(src, dest) = isfile(dest) || cp(src, dest)

# make links for stdlib package docs
if Sys.iswindows()
cp("../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
cp("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
cp_q("../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
cp_q("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
cp_q("../stdlib/Mmap/docs/src/index.md", "src/stdlib/mmap.md")
cp_q("../stdlib/SharedArrays/docs/src/index.md", "src/stdlib/sharedarrays.md")
else
symlink("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
symlink("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
symlink_q("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
symlink_q("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
symlink_q("../../../stdlib/Mmap/docs/src/index.md", "src/stdlib/mmap.md")
symlink_q("../../../stdlib/SharedArrays/docs/src/index.md", "src/stdlib/sharedarrays.md")
end

const PAGES = [
Expand Down Expand Up @@ -126,11 +133,11 @@ const PAGES = [
],
]

using DelimitedFiles, Test
using DelimitedFiles, Test, Mmap, SharedArrays

makedocs(
build = joinpath(pwd(), "_build/html/en"),
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test],
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays],
clean = false,
doctest = "doctest" in ARGS,
linkcheck = "linkcheck" in ARGS,
Expand Down
6 changes: 4 additions & 2 deletions doc/src/manual/parallel-computing.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,9 @@ julia> addprocs(3)
3
4
julia> S = SharedArray{Int,2}((3,4), init = S -> S[Base.localindexes(S)] = myid())
julia> @everywhere using SharedArrays
julia> S = SharedArray{Int,2}((3,4), init = S -> S[localindexes(S)] = myid())
3×4 SharedArray{Int64,2}:
2 2 3 4
2 3 3 4
Expand All @@ -874,7 +876,7 @@ julia> S
2 7 4 4
```

[`Base.localindexes`](@ref) provides disjoint one-dimensional ranges of indexes, and is sometimes
[`SharedArrays.localindexes`](@ref) provides disjoint one-dimensional ranges of indexes, and is sometimes
convenient for splitting up tasks among processes. You can, of course, divide the work any way
you wish:

Expand Down
2 changes: 2 additions & 0 deletions doc/src/stdlib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
delimitedfiles.md
test.md
mmap.md
sharedarrays.md
2 changes: 2 additions & 0 deletions doc/src/stdlib/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
* [Dynamic Linker](@ref)
* [Profiling](@ref lib-profiling)
* [SIMD Support](@ref)
* [Memory-mapped I/O](@ref)
* [Shared Arrays](@ref)
8 changes: 0 additions & 8 deletions doc/src/stdlib/io-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ Base.Multimedia.TextDisplay
Base.Multimedia.istextmime
```

## Memory-mapped I/O

```@docs
Base.Mmap.Anonymous
Base.Mmap.mmap
Base.Mmap.sync!
```

## Network I/O

```@docs
Expand Down
10 changes: 0 additions & 10 deletions doc/src/stdlib/parallel.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ Base.cluster_cookie()
Base.cluster_cookie(::Any)
```

## Shared Arrays

```@docs
Base.SharedArray
Base.procs(::SharedArray)
Base.sdata
Base.indexpids
Base.localindexes
```

## Multi-Threading

This experimental interface supports Julia's multi-threading capabilities. Types and functions
Expand Down
2 changes: 2 additions & 0 deletions stdlib/DelimitedFiles/src/DelimitedFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ __precompile__(true)

module DelimitedFiles

using Mmap

import Base: _default_delims, tryparse_internal, show

export readdlm, writedlm
Expand Down
7 changes: 7 additions & 0 deletions stdlib/Mmap/docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Memory-mapped I/O

```@docs
Mmap.Anonymous
Mmap.mmap
Mmap.sync!
```
File renamed without changes.
2 changes: 2 additions & 0 deletions test/mmap.jl → stdlib/Mmap/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Test, Mmap

file = tempname()
write(file, "Hello World\n")
t = b"Hello World"
Expand Down
9 changes: 9 additions & 0 deletions stdlib/SharedArrays/docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Shared Arrays

```@docs
SharedArrays.SharedArray
SharedArrays.procs(::SharedArray)
SharedArrays.sdata
SharedArrays.indexpids
SharedArrays.localindexes
```
27 changes: 24 additions & 3 deletions base/sharedarray.jl → stdlib/SharedArrays/src/SharedArrays.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

import .Serializer: serialize_cycle_header, serialize_type, writetag, UNDEFREF_TAG
import .Distributed: RRID, procs
module SharedArrays

using Mmap, Base.Distributed

import Base: length, size, ndims, IndexStyle, reshape, convert, deepcopy_internal, serialize, deserialize,
show, getindex, setindex!, fill!, rand!, similar, reduce, map!, copy!, unsafe_convert
import Base.Random
import Base.Serializer: serialize_cycle_header, serialize_type, writetag, UNDEFREF_TAG
import Base.Distributed: RRID, procs
import Base.Filesystem: JL_O_CREAT, JL_O_RDWR, S_IRUSR, S_IWUSR

export SharedArray, SharedVector, SharedMatrix, sdata, indexpids, localindexes

mutable struct SharedArray{T,N} <: DenseArray{T,N}
id::RRID
Expand Down Expand Up @@ -663,6 +673,17 @@ end

shm_unlink(shm_seg_name) = ccall(:shm_unlink, Cint, (Cstring,), shm_seg_name)
shm_open(shm_seg_name, oflags, permissions) = ccall(:shm_open, Cint,
(Cstring, Cint, Cmode_t), shm_seg_name, oflags, permissions)
(Cstring, Cint, Base.Cmode_t), shm_seg_name, oflags, permissions)

end # os-test

# 0.7 deprecations

@deprecate SharedArray(::Type{T}, dims::Dims{N}; kwargs...) where {T,N} SharedArray{T}(dims; kwargs...)
@deprecate SharedArray(::Type{T}, dims::Int...; kwargs...) where {T} SharedArray{T}(dims...; kwargs...)
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple{N,Int}, offset; kwargs...) where {T,N},
SharedArray{T}(filename, dims, offset; kwargs...))
@deprecate(SharedArray(filename::AbstractString, ::Type{T}, dims::NTuple, offset; kwargs...) where {T},
SharedArray{T}(filename, dims, offset; kwargs...))

end # module
Loading

0 comments on commit 6004f43

Please sign in to comment.