Skip to content

Instantly share code, notes, and snippets.

View xianyi's full-sized avatar
😆

Zhang Xianyi xianyi

😆
View GitHub Profile
@xianyi
xianyi / gist:2517475
Created April 28, 2012 09:33
Patch for my_mbind in OpenBLAS
diff --git a/common_linux.h b/common_linux.h
index b0381d9..8d9019a 100644
--- a/common_linux.h
+++ b/common_linux.h
@@ -76,8 +76,8 @@ static inline int my_mbind(void *addr, unsigned long len, int mode,
#endif
#else
//Fixed randomly SEGFAULT when nodemask==NULL with above Linux 2.6.34
-// unsigned long null_nodemask=0;
- return syscall(SYS_mbind, addr, len, mode, nodemask, maxnode, flags);
@xianyi
xianyi / as
Created June 20, 2012 02:39
Replace the native OS X assembler (/usr/bin/as) by a script which calls the clang assembler. (http://old.nabble.com/Re%3a-gcc,-as,-AVX,-binutils-and-MacOS-X-10.7-p32584737.html)
#!/bin/sh
HAS_INPUT_FILE=0
ARGS=$@
while [ $# -ne 0 ]; do
ARG=$1
# Skip options
if [ $ARG == "-arch" ] || [ $ARG == "-o" ]; then
# Skip next token
shift
shift
@xianyi
xianyi / test_vaddpd.s
Created June 20, 2012 14:53
Test the binary code of Clang and GCC
.text
.globl test
test:
vaddpd 2*8(%rbx,%r10,1),%xmm13,%xmm13
ret
@xianyi
xianyi / test_dgetrf.c
Created February 12, 2013 16:31
Test dgetrf. gcc -o test test_dgetrf.c -I OpenBLAS_install/include OpenBLAS_install/lib/libopenblas.a -lpthread -lgfortran
#include <stdio.h>
#include "cblas.h"
#include "lapacke.h"
int main(int argc, char* argv[])
{
int* ipiv;
int info;
int i, j;
int n;
@xianyi
xianyi / time_dgemm_int64.c
Created June 14, 2013 00:30
timming dgemm with int64 interface.
#include "stdio.h"
#include "stdlib.h"
#include "sys/time.h"
#include "time.h"
extern void dgemm_(char*, char*, long*, long*,long*, double*, double*, long*, double*, long*, double*, double*, long*);
long main(long argc, char* argv[])
{
long i;
@xianyi
xianyi / time_dgemm.c
Created June 14, 2013 07:07
timming dgemm gcc -o time_dgemm time_dgemm.c /your/path/libopenblas.a ./time_dgemm <m> <n> <k> e.g. ./time_dgemm 1000 1000 1000
#include "stdio.h"
#include "stdlib.h"
#include "sys/time.h"
#include "time.h"
extern void dgemm_(char*, char*, int*, int*,int*, double*, double*, int*, double*, int*, double*, double*, int*);
int main(int argc, char* argv[])
{
int i;
@xianyi
xianyi / time_clbas_dgemm.c
Created June 14, 2013 16:17
timing cblas dgemm.
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include "cblas.h"
int main(int argc, char* argv[])
{
int i;
/***************************************************************************
Copyright (c) 2013, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
@xianyi
xianyi / test_cblas_dgemm.c
Created October 11, 2013 06:59
cc -static -o test_cblas_open test_cblas_dgemm.c -I /opt/OpenBLAS/include/ -L/opt/OpenBLAS/lib -lopenblas -lpthread -lgfortran
#include <cblas.h>
#include <stdio.h>
void main()
{
int i=0;
double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);
@xianyi
xianyi / test_dgeqrt3_int64.c
Last active February 15, 2017 21:10
compile OpenBLAS with INTERFACE64=1. clang/gcc -o test test_dgeqrt3_int64.c /your/path/libopenblas.a
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
extern void dgeqrt3_(long * m, long *n, double * a, long *lda, double *t, long *ldt, long*info);
int main(int argc, char**argv)
{
int in, i;
long n,info=1;