Skip to content

Instantly share code, notes, and snippets.

View amitmurthy's full-sized avatar

Amit Murthy amitmurthy

  • Bangalore, India
View GitHub Profile
@amitmurthy
amitmurthy / mapshmem.jl
Last active December 16, 2015 18:28
shmem and mmap
using Base.FS
# Below constants are vaid for Ubuntu. May be different for OSX
const PROT_READ = 0x01
const PROT_WRITE = 0x02
const MAP_SHARED = 0x01
type ShmemVar
v_name::Symbol
v_type::Type
@amitmurthy
amitmurthy / gist:6218188
Last active December 21, 2015 00:09
valgrind output with MEMDEBUG for issue # 4016
==9578== Invalid write of size 8
==9578== at 0xD54A1AD: dlasq2_ (in /home/amitm/Work/julia/julia/usr/lib/libopenblas.so)
==9578== by 0xD549A79: dlasq1_ (in /home/amitm/Work/julia/julia/usr/lib/libopenblas.so)
==9578== by 0xD52AD17: dbdsqr_ (in /home/amitm/Work/julia/julia/usr/lib/libopenblas.so)
==9578== by 0xD549018: dlasdq_ (in /home/amitm/Work/julia/julia/usr/lib/libopenblas.so)
==9578== by 0xD527B46: dbdsdc_ (in /home/amitm/Work/julia/julia/usr/lib/libopenblas.so)
==9578== by 0xD3ED52A: zgesdd_ (in /home/amitm/Work/julia/julia/usr/lib/libopenblas.so)
==9578== by 0x40B3726: ???
==9578== by 0x40B2DBA: ???
==9578== by 0x40B287A: ???
@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)
@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)
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 / 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;
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 / 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
import MPI
function do_sendrecv(N)
comm = MPI.COMM_WORLD
MPI.Barrier(comm)
rank = MPI.Comm_rank(comm)
size = MPI.Comm_size(comm)