Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah committed Jul 31, 2011
2 parents 4fa2569 + 904a4de commit 36bcbf4
Show file tree
Hide file tree
Showing 29 changed files with 390 additions and 350 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Jeff Bezanson <jeff.bezanson@gmail.com> <bezanson@scooby-doo.csail.mit.edu>
Jeff Bezanson <jeff.bezanson@gmail.com> <bezanson@shaggy.csail.mit.edu>
Jeff Bezanson <jeff.bezanson@gmail.com> <bezanson@caspian.caspian.mit.edu>
Jeff Bezanson <jeff.bezanson@gmail.com> <vcloud@julia02.domain.local>
Jeff Bezanson <jeff.bezanson@gmail.com> <bezanson@beagle.darwinproject.mit.edu>
Jeff Bezanson <jeff.bezanson@gmail.com> <jeff.bezanson@gmail.com>
Stefan Karpinski <stefan@karpinski.org> <stefan.karpinski@post.harvard.edu>
Stefan Karpinski <stefan@karpinski.org> <stefan.karpinski@gmail.com>
Expand Down
32 changes: 0 additions & 32 deletions attic/examples.j

This file was deleted.

42 changes: 0 additions & 42 deletions attic/loopnest.j

This file was deleted.

5 changes: 0 additions & 5 deletions attic/nbits.c

This file was deleted.

74 changes: 0 additions & 74 deletions attic/start.j

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DSFMT_VER = 2.1
OPENBLAS_VER = v0.1alpha2
LAPACK_VER = 3.3.1
ARPACK_VER = 96
FFTW_VER = 3.3-beta1
FFTW_VER = 3.3
UNWIND_VER = 0.99

## high-level setup ##
Expand Down Expand Up @@ -322,7 +322,7 @@ clean-unwind:
rm -rf $(LIBUNWIND_TARGET_OBJ) $(LIBUNWIND_TARGET_SOURCE)

distclean-unwind:
rm -rf libunwind-$(UWIND_VER).tar.gz libunwind-$(UNWIND_VER)
rm -rf libunwind-$(UNWIND_VER).tar.gz libunwind-$(UNWIND_VER)

## phony targets ##

Expand Down
4 changes: 2 additions & 2 deletions j/combinatorics.j
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function insertionsort(a::Vector, lo, hi)
j = i
x = a[i]
while j > lo
if x > a[j-1]
if x >= a[j-1]
break
end
a[j] = a[j-1]
Expand Down Expand Up @@ -124,7 +124,7 @@ function insertionsort(a::Vector, p::Vector{Size}, lo, hi)
x = a[i]
xp = p[i]
while j > lo
if x > a[j-1]
if x >= a[j-1]
break
end
a[j] = a[j-1]
Expand Down
8 changes: 4 additions & 4 deletions j/complex.j
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## generic complex number definitions ##

abstract Complex <: Number
abstract Complex{T<:Real} <: Number

iscomplex(x::Complex) = true
iscomplex(x) = false
Expand Down Expand Up @@ -37,7 +37,7 @@ end

## packed complex float types ##

bitstype 128 Complex128 <: Complex
bitstype 128 Complex128 <: Complex{Float64}

function complex128(r::Float64, i::Float64)
box(Complex128,
Expand Down Expand Up @@ -72,7 +72,7 @@ function write(s, z::Complex128)
write(s,imag(z))
end

bitstype 64 Complex64 <: Complex
bitstype 64 Complex64 <: Complex{Float32}

function complex64(r::Float32, i::Float32)
box(Complex64,
Expand Down Expand Up @@ -119,7 +119,7 @@ complex(x::Float) = complex(x, zero(x))

## complex with arbitrary component type ##

type ComplexPair{T<:Real} <: Complex
type ComplexPair{T<:Real} <: Complex{T}
re::T
im::T
end
Expand Down
84 changes: 77 additions & 7 deletions j/darray.j
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,6 @@ function ref{T}(d::DArray{T}, i::Index)
end

ref(d::DArray) = d
#ref(d::DArray, I::Range1{Index}) = ref(d, (I,))
#ref{distdim}(d::DArray{Any,1,distdim},I::Range1{Index}) = ref(d, (I,))
#ref{T,distdim}(d::DArray{T,1,distdim},I::Range1{Index}) = ref(d, (I,))
#ref{T}(d::DArray{T}, I::Range1{Index}...) = ref(d, I)
#ref{T}(d::DArray{T}, ::()) = ()

#function ref{T}(d::DArray{T}, I::(Range1{Index}...,))
function ref{T}(d::DArray{T}, I::Range1{Index}...)
(pmap, dist) = locate(d, I[d.distdim])
A = Array(T, map(range -> length(range), I))
Expand All @@ -339,9 +332,15 @@ function ref{T}(d::DArray{T}, I::Range1{Index}...)
return A
end


ref(d::DArray, I::Range1{Index}, j::Index) = d[I, j:j]
ref(d::DArray, i::Index, J::Range1{Index}) = d[i:i, J]

ref(d::DArray, I::Union(Index,Range1{Index})...) =
d[ntuple(length(I),i->(isa(I[i],Index) ? (I[i]:I[i]) : I[i] ))...]



function ref{T}(d::DArray{T}, I::Vector{Index}...)
(pmap, dist, perm) = locate(d, I[d.distdim])
A = Array(T, map(range -> length(range), I))
Expand Down Expand Up @@ -373,6 +372,9 @@ end
ref(d::DArray, I::Vector{Index}, j::Index) = d[I, [j]]
ref(d::DArray, i::Index, J::Vector{Index}) = d[[i], J]

ref(d::DArray, I::Union(Index,Vector{Index})...) =
d[ntuple(length(I),i->(isa(I[i],Index) ? [I[i]] : I[i] ))...]

assign(d::DArray, v::AbstractArray, i::Index) =
invoke(assign, (DArray, Any, Index), d, v, i)

Expand All @@ -392,6 +394,74 @@ function assign(d::DArray, v, i::Index)
d
end

#TODO: Fix this
assign(d::DArray, v) = error("distributed arrays of dimension 0 not supported")

#TODO: check for same size
function assign(d::DArray, v, I::Range1{Index}...)
(pmap, dist) = locate(d, I[d.distdim])
if length(pmap) == 1 && pmap[1] == d.localpiece
offs = d.dist[pmap[1]]-1
J = ntuple(length(size(d)), i -> (i == d.distdim ? I[i]-offs :
I[i]))
localize(d)[J...] = v
return d
end
refs = Array(Union(DArray,RemoteRef),length(pmap))
for p = 1:length(pmap)
offs = I[d.distdim][1] - 1
J = ntuple(length(size(d)),i->(i==d.distdim ? (dist[p]:(dist[p+1]-1))-offs :
(1:length(I[i]))))
K = ntuple(length(size(d)),i->(i==d.distdim ? (dist[p]:(dist[p+1]-1)) :
I[i]))
refs[p] = remote_call(pmap[p], assign, d, v[J...], K...)
end
for p = 1:length(pmap)
if isa(refs[p], RemoteRef); wait(refs[p]); end
end
return d
end

#TODO: check for same size
function assign(d::DArray, v, I::Vector{Index}...)
(pmap, dist, perm) = locate(d, I[d.distdim])
if length(pmap) == 1 && pmap[1] == d.localpiece
offs = d.dist[pmap[1]]-1
J = ntuple(length(size(d)), i -> (i == d.distdim ? I[i]-offs :
I[i]))
localize(d)[J...] = v
return d
end
refs = Array(Union(DArray,RemoteRef),length(pmap))
n = length(perm)
j = 1
II = I[d.distdim][perm] #the sorted indexes in the distributed dimension
for p = 1:length(pmap)
if dist[p] > II[j]; continue; end
lower = j
while j <= n && II[j] < dist[p+1]
j += 1
end
J = ntuple(length(size(d)),i->(i==d.distdim ? perm[lower:(j-1)] :
(1:length(I[i]))))
K = ntuple(length(size(d)),i->(i==d.distdim ? II[lower:(j-1)] :
I[i]))
refs[p] = remote_call(pmap[p], assign, d, v[J...], K...)
end
for p = 1:length(pmap)
if isa(refs[p], RemoteRef); wait(refs[p]); end
end
return d
end

assign(d::DArray, v::AbstractArray, i::Index, is::Index...) =
invoke(assign, (DArray, Any, Index...), d, v, i, is...)

assign(d::DArray, v, I::Union(Index,Range1{Index})...) =
assign(d,v,ntuple(length(I),i->(isa(I[i],Index) ? (I[i]:I[i]) : I[i] ))...)

assign(d::DArray, I::Union(Index,Vector{Index})...) =
assign(d,v,ntuple(length(I),i->(isa(I[i],Index) ? [I[i]] : I[i] ))...)

## matrix multiply ##

Expand Down
4 changes: 2 additions & 2 deletions j/inference.j
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function abstract_eval_expr(e, vtypes, sv::StaticVarInfo)
elseif is(e.head,:quote)
return typeof(e.args[1])
elseif is(e.head,:method)
return Any-->Any
return Function
elseif is(e.head,:static_typeof)
t = abstract_eval(e.args[1], vtypes, sv)
# intersect with Any to remove Undef
Expand All @@ -605,7 +605,7 @@ function abstract_eval_constant(x::ANY)
return Type{x}
end
if isa(x,LambdaStaticData)
return Any-->Any
return Function
end
return typeof(x)
end
Expand Down
7 changes: 4 additions & 3 deletions j/multi.j
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type Worker
fd = ccall(:connect_to_host, Int32,
(Ptr{Uint8}, Int16), host, port)
if fd == -1
error("could not connect to $hostname:$port, errno=$(errno())\n")
error("could not connect to $host:$port, errno=$(errno())\n")
end
Worker(host, port, fd, fdio(fd))
end
Expand Down Expand Up @@ -961,8 +961,9 @@ function start_remote_workers(machines, cmds)
end
w = cell(n)
for i=1:n
w[i] = Worker(machines[i], read(outs[i],Int16))
readline(outs[i]) # read and ignore hostname
port = read(outs[i],Int16)
hostname = readline(outs[i])[1:end-1]
w[i] = Worker(hostname, port)
end
w
end
Expand Down
Loading

0 comments on commit 36bcbf4

Please sign in to comment.