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

Tests and bugfix for sharedarrays #11252

Merged
merged 1 commit into from
May 13, 2015
Merged

Tests and bugfix for sharedarrays #11252

merged 1 commit into from
May 13, 2015

Conversation

kshyatt
Copy link
Contributor

@kshyatt kshyatt commented May 13, 2015

randn(S) where S is a SharedArray would error out with a convert error. Added a test for this, rand(S), reshape, similar, and sdata.

@@ -249,7 +249,7 @@ function rand!{T}(S::SharedArray{T})
end

function randn!(S::SharedArray)
f = S->map!(x->randn, S.loc_subarr_1d)
f = S->map!(x->randn(), S.loc_subarr_1d)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason this can't just be:

f = S->randn!(S.loc_subarr_1d)

(similarly for rand!)

cc @carlobaldassi

Copy link
Member

Choose a reason for hiding this comment

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

I think it's because that variable is a SubArray, for which rand! and randn! were not defined in 0.3.
It could be changed now I suppose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked randn! with @simonster's suggestion on 0.4 and it works.

Copy link
Member

Choose a reason for hiding this comment

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

It seems to be only defined for AbstractArray{Float64} though, while it would be nice to keep the SharedArray code generic (for example, in the previous version it was generically and uniformly failing... ehm).
See also #9836.

On the other hand, rand! should be fine AFAICT.

Copy link
Member

Choose a reason for hiding this comment

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

The discussion in #9836 suggests that converting the result of randn() to other floating point types is not quite right. If we're not defining randn!(::Array{Float32}) because of this, then I don't think randn!(::SharedArray{Float32}) should work either.

Copy link
Member

Choose a reason for hiding this comment

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

Computing in 64 bit and converting to 32 should be mostly fine, from what I gather. But I'm ok with the proposed change anyway, it makes sense to rely on any implementation AbstractArray provides.

@carlobaldassi
Copy link
Member

Wow, this has been there for quite a while. Thanks!

carlobaldassi added a commit that referenced this pull request May 13, 2015
Tests and bugfix for sharedarrays
@carlobaldassi carlobaldassi merged commit 7a30edd into master May 13, 2015
@kshyatt kshyatt deleted the ksh/sharedarray branch May 13, 2015 02:51
kshyatt added a commit that referenced this pull request May 18, 2015
(cherry picked from commit 7cbbfd2)
ref PR #11252

reshape(d,(50,)) throws ErrorException on release-0.3
@tkelman
Copy link
Contributor

tkelman commented May 18, 2015

backported in 4d66b75, with one small change where the exception type was different on release-0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants