Skip to content

Instantly share code, notes, and snippets.

View vtjnash's full-sized avatar

Jameson Nash vtjnash

View GitHub Profile
# This stripped down example that has odd performance.
# It takes about 4 seconds to compile and allocates about 550MB of memory
type T1Type
f1::Float64
end
T1Type() = T1Type(
0.0)
type Ts
T1::T1Type
@vtjnash
vtjnash / testcp.cxx
Last active August 29, 2015 14:02 — forked from ihnorton/testcp.cxx
// envtest.cpp : Defines the entry point for the console application.
//
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int _tmain()
{
@vtjnash
vtjnash / openblas-dllinit-safe.patch
Created June 21, 2014 23:37
safe DLLInit openblas
--- xianyi-OpenBLAS-347dded/exports/gensymbol 2014-06-10 09:55:47.000000000 -0400
+++ openblas-v0.2.9/exports/gensymbol 2014-06-21 19:27:06.368557354 -0400
@@ -81,6 +81,8 @@
@misc_no_underscore_objs = (
goto_set_num_threads,
openblas_get_config,
+ gotoblas_init,
+ gotoblas_quit,
);
@vtjnash
vtjnash / find_library2.md
Created June 29, 2014 15:14
julep: find_library version 2

The goal of this gist is to make find_library lazy, so that it is more efficient, general/generic, and runtime-intelligent. These changes will be pervasive to also making ccall and dlopen more flexible.

function find_library(...) -> 
# some definitions:
immutable NArgsOut{N}
NArgsOut() = ((isa(N,Int) && N>=-1) || error("nargsout must be ≥ -1"); new())
end
nargsout(N::Integer) = NArgsOut{int(N)}()
# null behavior example:
f(::NArgsOut{-1}) = f() # -1 is a sentinal value and should have no effect on the output
@vtjnash
vtjnash / julia_bt.md
Last active August 29, 2015 14:04
julep: exception backtraces

ref: JuliaLang/julia#7633 (comment)

type ExceptionData <: Exception
  error::Exception
  backtrace::Array{Any}
end
ExceptionData(err) = ExceptionData(err, {})
~/Documents/no-backup/julia/base$ lldb -- ../usr/bin/julia-debug --build x sysimg.jl
Current executable set to '../usr/bin/julia-debug' (x86_64).
(lldb) break set -n jl_throw
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 10078 launched: '../usr/bin/julia-debug' (x86_64)
1 location added to breakpoint 1
exports.jl
base.jl
# BEFORE:
function PolynomialRing{T <: Ring}(::Type{T}, s::String)
S = symbol(s)
T1 = Poly{T, S}
T2 = T
# Conversions and promotions
eval(:(Base.convert(::Type{$T1}, x::$T) = Poly($T1, [x])))
eval(:(Base.promote_rule(::Type{$T1}, ::Type{$T}) = $T1))
@vtjnash
vtjnash / cfunction_lambdas.md
Created February 10, 2015 00:47
cfunction lambdas

cfunction lambda can be created in the following fashion:

  • create a wrapper cfunction cache that is specialized on the exact function type signature, but reserve one register in that function
  • have this function call as jl_apply_generic(%R9, args, nargs)
  • return a stub function, manually created, that does a movq $fptr %R9; movq $lambda, %RAX; jmp %RAX
@vtjnash
vtjnash / ex.md
Last active August 29, 2015 14:19 — forked from ihnorton/ex.md
%jl_value_t = type { %jl_value_t* }
declare void @jl_throw_with_superfluous_argument(%jl_value_t*, i32)
@jl_domain_exception = external global %jl_value_t*

define double @julia_gv_67043(i64) {
top:
  %1 = call double inttoptr (i64 339752784 to double (double, double)*)(double 1.000000e+00, double 0.000000e+00)
  %2 = sitofp i64 %0 to double
  %3 = call double inttoptr (i64 339772768 to double (double, double)*)(double %1, double %2)