Skip to content

Instantly share code, notes, and snippets.

View andreasnoack's full-sized avatar

Andreas Noack andreasnoack

View GitHub Profile
@andreasnoack
andreasnoack / GF2type.jl
Created February 21, 2014 11:05
GF(2) Gaussian elimination
import Base: &,|,<,+,-,*,/,abs,and_int,box,convert,div,or_int,rem,promote_rule,show,udiv_int,ult_int,unbox,urem_int,xor_int
bitstype 8 GF2 <: Unsigned
convert(::Type{GF2}, x::GF2) = x
convert(::Type{GF2}, x::Uint8) = box(GF2,unbox(Uint8,x))
convert(::Type{GF2}, x::Number) = convert(GF2,uint8(x))
convert(::Type{Int8}, x::GF2) = box(Int8,unbox(GF2,x))
convert(::Type{Uint8}, x::GF2) = box(Uint8,unbox(GF2,x))
convert(::Type{Uint64}, x::GF2) = uint64(uint8(x))
gf2(x::Number) = convert(GF2,x)
promote_rule(::Type{GF2},::Type{Uint64}) = Uint64
@andreasnoack
andreasnoack / gist:9f3f63d7f1d00a07359b
Created October 21, 2014 14:54
A new RNG for Julia
module XORShift
import Base.rand
type XORShiftStar1024 <: AbstractRNG
p::Int
state::Vector{Uint64}
end
XORShiftStar() = XORShiftStar1024(1, rand(Uint64, 16))
module Random123
macro skein_mk_64(hi32, lo32)
return :($lo32 + (convert(Uint64, $hi32) << 32))
end
const SKEIN_KS_PARITY64 = @skein_mk_64(0x1BD11BDA, 0xA9FC1A22)
const SKEIN_KS_PARITY32 = 0x1BD11BDA
rotl(x::Uint64, N::Integer) = (x << (N & 63)) | (x >> ((64 - N) & 63))
const R_64x2_0_0 = 16
module LC
const MC = 384
const KC = 384
const NC = 4096
const MR = 4
const NR = 4
const _A = Array(Float64, MC*KC)
@andreasnoack
andreasnoack / unicodespy.jl
Created September 14, 2015 08:37
Print sparsity pattern in terminal with unicode charaters
type SpyMatrix{T}
data::Matrix{T}
sz::Tuple{Int,Int}
end
function spy2(A::SparseMatrixCSC, s1 = 40, s2 = 80)
m, n = size(A)
c = A.colptr
r = A.rowval
B = zeros(Int, s1, s2)
module PageRank
function kronGraph500NoPerm(scl, EdgesPerVertex)
# Graph500NoPerm: Generates graph edges using the same 2x2 Kronecker algorithm (R-MAT) as the Graph500 benchmark, but no permutation of vertex labels is performed.
# IO user function.
# Usage:
# [StartVertex EndVertex] = Graph500NoPerm(scl,edgefactor)
# Inputs:
# scl = integer scale factor that sets the max number of vertices to 2^scl
# EdgesPerVertex = sets the total number of edges to M = K*N;
@andreasnoack
andreasnoack / roundtrip.jl
Last active August 11, 2016 23:43
Compute round trips with different transports in Julia
if isempty(ARGS)
error("you'll have to tell me what to do")
end
if ARGS[1] == "remotecall"
# if length(ARGS) != 4
# error("when specifying the remotecall option you'd have to supply three argument")
# end
if ARGS[2] == "slurm"
@andreasnoack
andreasnoack / roundtrip_timings_MPI.txt
Created August 11, 2016 23:29
Timings of the roundtrip benchmark - Four processes - One on each one - C3DDB cluster
Who am I? Rank 2 on node314
Who am I? Rank 3 on node315
Who am I? Rank 0 on node312
Who am I? Rank 1 on node313
INFO: Data: 2^0 Int(s)
5.507469177246094e-5 seconds
0.00011396408081054688 seconds
3.886222839355469e-5 seconds
0.00427699089050293 seconds
function parsemachine(f::String)
wks = []
for s in eachline(f)
l = split(s)
push!(wks, (l[1], parse(Int, l[2])))
end
return wks
end
addprocs(parsemachine(ENV["PE_HOSTFILE"]))
KNL:
1241 ./operators.jl 276 afoldl(::Base.#*, ::Float64, ::Stat...
1443 ...rc/bivariate_normals.jl 428 Celeste.Model.GalaxyCacheComponent{...
1554 ...ic_vi/elbo_objective.jl 282 accumulate_source_pixel_brightness!...
1973 ...tic_vi/maximize_elbo.jl 74 (::Celeste.DeterministicVI.##538#54...
1980 ...6/Optim/src/optimize.jl 251 optimize(::Optim.TwiceDifferentiabl...
1980 ...6/Optim/src/optimize.jl 207 update_h!
2246 ...ic_vi/elbo_objective.jl 407 add_pixel_term!(::Celeste.Determini...
2355 ...e/src/model/fsm_util.jl 325 accum_galaxy_pos!(::Celeste.Model.B...