Skip to content

Instantly share code, notes, and snippets.

View ArchRobison's full-sized avatar

Arch D. Robison ArchRobison

  • Nvidia
  • Champaign, IL
View GitHub Profile
@ArchRobison
ArchRobison / gist:9808976
Created March 27, 2014 14:38
Example using Julia and LLVM trunk. SLPVectorizer appears to have generated superfluious extracts.
$ cat vadd.jl
function vadd( a::NTuple{4,Float64}, b::NTuple{4,Float64} )
(a[1]+b[1],a[2]+b[2],a[3]+b[3],a[4]+b[4])
end
function vadd_one!(arr::Array{Float64, 1})
len = length(arr) # assuming len multiple of 4
one = (1.0, 1.0, 1.0, 1.0)
@inbounds for i = 1:4:len
inp = (arr[i], arr[i+1], arr[i+2], arr[i+3])
@ArchRobison
ArchRobison / gist:9809496
Created March 27, 2014 15:01
Example of @simd and 32-bit floating point.
$ cat v.jl
function vadd_one!(arr::Array{Float32, 1})
@simd for i = 1:length(arr)
@inbounds arr[i] += 1
end
end
code_llvm(vadd_one!,(Array{Float32, 1},))
$ julia v.jl
@ArchRobison
ArchRobison / gist:9944313
Created April 2, 2014 22:13
Excerpt of Julia LLVM code from LLVM trunk (pre-3.5 LLVM)
L.preheader: ; preds = %top
%.op = add i64 %0, 1, !dbg !9
%8 = select i1 %2, i64 %.op, i64 1, !dbg !9
%9 = sub i64 %8, %5, !dbg !9
%xtraiter = and i64 %9, 7
switch i64 %xtraiter, label %L.unr [
i64 0, label %L.preheader.split
i64 1, label %L.unr22
i64 2, label %L.unr18
i64 3, label %L.unr14
@ArchRobison
ArchRobison / gist:a7c4cf396c5332a4ddd2
Created May 1, 2014 14:59
Patch to Julia sources to quiet Intel(R) VTune(TM) Amplifier warning about "sigal stack".
--- a/src/init.c
+++ b/src/init.c
@@ -64,6 +64,9 @@ extern BOOL (WINAPI *hSymRefreshModuleList)(HANDLE);
#include <sched.h> // for setting CPU affinity
#endif
+#undef SIGSTKSZ
+#define SIGSTKSZ (64*1024)
+
char *julia_home = NULL;
::::::::::::::
test1.jl
::::::::::::::
# Example from early discussion.
# Has constant lower bound, expression as upper bound, and no reductions.
function test1( a, x, y )
@simd for i=1:length(x)
@inbounds y[i] = y[i]+a*x[i]
end
end
$ cat y.jl
cat: y.jl: No such file or directory
$ cat /tmp/y.jl
function saxpy( a, x, y )
@simd for i=1:length(x)
@inbounds y[i] = y[i]+a*x[i]
end
end
code_native( saxpy, (Float32,Array{Float32,1},Array{Float32,1}) )
@ArchRobison
ArchRobison / gist:d3601433d160b05ed5ee
Created June 25, 2014 17:56
patch to LLVM 3.3 to work around Intel VTune Amplifier bug. For Julia, apply to julia/deps/llvm-3.3/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
--- IntelJITEventListener.cpp.orig 2014-05-15 13:45:30.079547337 -0500
+++ IntelJITEventListener.cpp 2014-05-15 13:46:43.647359854 -0500
@@ -174,6 +174,11 @@
FunctionMessage.line_number_table = 0;
}
+#define AMPLIFIER_BUG_WORKAROUND 1
+#if AMPLIFIER_BUG_WORKAROUND
+ for( unsigned i=FunctionMessage.line_number_size; i-->0; )
+ FunctionMessage.line_number_table[i].LineNumber = i>0 ? FunctionMessage.line_number_table[i-1].LineNumber : 0;
julia> Pkg.add("MPI")
INFO: Installing MPI v0.2.2
INFO: Building MPI
INFO: Attempting to Create directory /nfs/fx/disks/fx_home_disk2/adrobiso/.julia/v0.3/MPI/deps/build
INFO: Directory /nfs/fx/disks/fx_home_disk2/adrobiso/.julia/v0.3/MPI/deps/build already created
INFO: Changing Directory to /nfs/fx/disks/fx_home_disk2/adrobiso/.julia/v0.3/MPI/deps/build
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find MPI_C (missing: MPI_C_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
$ rm -rf build
$ julia build.jl
INFO: Attempting to Create directory /nfs/fx/disks/fx_home_disk2/adrobiso/.julia/v0.3/MPI/deps/build
INFO: Changing Directory to /nfs/fx/disks/fx_home_disk2/adrobiso/.julia/v0.3/MPI/deps/build
-- The Fortran compiler identification is GNU
-- The C compiler identification is GNU 4.8.2
-- Check for working Fortran compiler: /bin/f95
-- Check for working Fortran compiler: /bin/f95 -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
@ArchRobison
ArchRobison / gist:34a021a5d668026e35b3
Created October 17, 2014 21:35
Running MPI.jl examples
$ for f in *.jl; do echo $f; mpiexec -np 4 julia $f; done
01-hello.jl
Hello world, I am 1 of 4Hello world, I am 3 of 4Hello world, I am 2 of 4Hello world, I am 0 of 4
02-broadcast.jl
------------------------------------------------------------------------------
Running on 4 processes
------------------------------------------------------------------------------