Skip to content

Instantly share code, notes, and snippets.

View amitmurthy's full-sized avatar

Amit Murthy amitmurthy

  • Bangalore, India
View GitHub Profile
addprocs(1)
@everywhere function echo_on_sock(s, N)
while true
try
read(s, Float64, (N,))
write(s, fill(Float64(myid()), N))
catch e
#println("closed by remote $e")
addprocs(1)
const rr1=RemoteRef()
const rr2=RemoteRef(2)
@everywhere function do_sendrecv(N, rr1, rr2)
myid() == 1 && print("$N : ")
if myid() == 1
rr_put = rr2
import MPI
function do_sendrecv(N)
comm = MPI.COMM_WORLD
MPI.Barrier(comm)
rank = MPI.Comm_rank(comm)
size = MPI.Comm_size(comm)
@amitmurthy
amitmurthy / OSX Travis Build Failure
Created April 2, 2015 03:50
OSX Travis Build Failure
travis_fold:start:system_info
Build system information
Build language: cpp
travis_fold:end:system_info

travis_fold:start:git.checkout
travis_time:start:21ded7df
type DArray{T,N,A} <: AbstractArray{T,N}
dims::NTuple{N,Int}
chunks::Array{RemoteRef,N}
pmap::Array{Int,N} # pmap[i]==p ⇒ processor p has piece i
indexes::Array{NTuple{N,UnitRange{Int}},N} # indexes held by piece i
cuts::Vector{Vector{Int}} # cuts[d][i] = first index of chunk i in dimension d
function DArray(dims, chunks, pmap, indexes, cuts)
# check invariants
if size(chunks) != size(indexes)
type DArray{T,N,A} <: AbstractArray{T,N}
dims::NTuple{N,Int}
chunks::Array{RemoteRef,N}
pmap::Array{Int,N} # pmap[i]==p ⇒ processor p has piece i
indexes::Array{NTuple{N,UnitRange{Int}},N} # indexes held by piece i
cuts::Vector{Vector{Int}} # cuts[d][i] = first index of chunk i in dimension d
function DArray(dims, chunks, pmap, indexes, cuts)
# check invariants
if size(chunks) != size(indexes)
@amitmurthy
amitmurthy / ptest.jl
Last active August 29, 2015 14:10
ptest.jl
const A = randn(1000, 1000);
const numx = 10_000;
const v = randn(1000, numx);
addprocs(4)
@sync begin
let A2=A, v2=v, numx2=numx
for p in workers()
@spawnat p global const A = A2;
np = 8
nt = 10000
pids = addprocs(np)
using SyncObjects
ts = tspace()
#Launch processes on each worker that simulates CPU intensive / blocking stuff for a random amount of time
@amitmurthy
amitmurthy / segfault_slow_fs
Created January 15, 2014 06:37
segfault on slow fs
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+1000 (2014-01-15 06:28 UTC)
_/ |\__'_|_|_|\__'_| | Commit 714fa07 (0 days old master)
|__/ | x86_64-linux-gnu
julia> function file_io(secs)
@amitmurthy
amitmurthy / mmap and pfork
Created September 13, 2013 06:10
Example of anonymous mmap and pfork
# Constants valid on Linux
const PROT_READ = 0x01
const PROT_WRITE = 0x02
const MAP_SHARED = 0x01
@linux_only const MAP_ANONYMOUS = 0x20
@osx_only const MAP_ANONYMOUS = 0x1000
function anon_mmap(t::Type, n::Int)
x = ccall(:mmap, Ptr{Void}, (Ptr{Void}, Csize_t, Cint, Cint, Cint, FileOffset), C_NULL, sizeof(t) * n, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0)