This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function simplefun(x,funcopts::Options) | |
@defaults funcopts a=3 b=2 c=2*b | |
println(a) | |
println(b) | |
println(c) | |
@check_used funcopts | |
end | |
function complexfun(x,opts::Options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
step(i::Int) = 1 | |
type ForwardSubarrayIterator | |
sub_min::Vector{Int} | |
sub_max::Vector{Int} | |
inc::Vector{Int} | |
pos::Vector{Int} | |
index::Int # the current linear index | |
end | |
function ForwardSubarrayIterator(dims::Dims,ind::RangeIndex...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v = zeros(10) # the "output" of the thread computation | |
index1 = [1,2,4,8] # the elements handled by thread 1 | |
index2 = [3,5,6] # the elements handled by thread 2 | |
indexwarmup = [7,10] # elements handled on warmup | |
# The function run by each thread | |
function fillvals(out, index, val) | |
out[index] = val | |
return nothing | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayref_boundscheck_inloop(A::Matrix, I::AbstractVector{Int}, J::AbstractVector{Int}) | |
X = similar(A, ref_shape(I, J)) | |
storeind = 1 | |
for j = J | |
for i = I | |
if i < 1 || i > size(A,1) || j < 1 || j > size(A,2) | |
throw(BoundsError()) | |
end | |
X[storeind] = A[i,j] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("color.jl") | |
require("options.jl") | |
import OptionsMod.* | |
require("setutils.jl") | |
# Plain arrays can be treated as images. Other types will have | |
# metadata associated, make yours a child of one of the following: | |
abstract ImageMeta # image with metadata | |
abstract ImageDirect <: ImageMeta # each pixel has own value/color | |
abstract ImageIndexed <: ImageMeta # indexed images (i.e., lookup table) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test(m, n, k) | |
A = randn(m, n) | |
@time begin | |
s = 0.0 | |
for j = 1:k | |
for i = 1:length(A) | |
s += A[i] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Clang.wrap_c | |
if (!has(ENV, "JULIAHOME")) | |
error("Please set JULIAHOME variable to the root of your julia install") | |
end | |
clang_includes = map(x->joinpath(ENV["JULIAHOME"], x), [ | |
"deps/llvm-3.2/build/Release/lib/clang/3.2/include", | |
"deps/llvm-3.2/include", | |
"deps/llvm-3.2/include", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Winston | |
n = [ntuple(length(sizes), i->prod(sizes[i]))...] | |
for i = 1:length(Ts) | |
p = FramedPlot() | |
setattr(p.x1, "log", true) | |
r = results[:,2,i] ./ results[:,:,i] | |
r = r[:,[1,3,4]] | |
ccopy = Curve(n, r[:,1], "color", "green") | |
setattr(ccopy, "label", "copy") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function new_jl_spawn(cmd::Ptr{Uint8}, argv::Ptr{Ptr{Uint8}}, loop::Ptr{Void}, pp::Base.Process, | |
in, out, err) | |
proc = Base.c_malloc(int(ccall(:jl_sizeof_uv_process_t,Csize_t,()))) | |
@show proc | |
error = ccall(:jl_spawn, Int32, | |
(Ptr{Uint8}, Ptr{Ptr{Uint8}}, Ptr{Void}, Ptr{Void}, Any, Int32, | |
Ptr{Void}, Int32, Ptr{Void}, Int32, Ptr{Void}, | |
Int32), | |
cmd, argv, loop, proc, pp, Base.uvtype(in), | |
Base.uvhandle(in), Base.uvtype(out), Base.uvhandle(out), Base.uvtype(err), Base.uvhandle(err), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: test test2 test3 | |
JULIADIR = $(HOME)/src/julia | |
JULIALIB = $(JULIADIR)/usr/lib | |
OPENBLASDIR = $(JULIADIR)/deps/openblas-develop | |
UNWINDDIR = $(JULIADIR)/deps/libunwind-1.1 | |
# LDFLAGS = -Wl,-no_compact_unwind | |
LDFLAGS = | |
CC = gcc |
OlderNewer