Skip to content

Instantly share code, notes, and snippets.

View morris821028's full-sized avatar
💭
I may be slow to respond.

Morris Yang, Shiang-Yun Yang morris821028

💭
I may be slow to respond.
View GitHub Profile
@morris821028
morris821028 / sched_test.cpp
Created November 3, 2015 14:17
RTS hw version 2
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define _GNU_SOURCE
#include <pthread.h>
#include <unistd.h>
#include <sched.h>
#include <errno.h>
@morris821028
morris821028 / script.sh
Created March 11, 2016 01:38
Build LLVM
mkdir -p ~/LLVM && cd ~/LLVM
wget -O - http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz | tar Jxf -
wget -O - http://llvm.org/releases/3.7.1/cfe-3.7.1.src.tar.xz | \
tar Jxf - -C llvm-3.7.1.src/tools
cd /home/morris1028/LLVM/hw1
mkdir build && cd build
cmake /home/morris1028/LLVM/llvm-3.7.1.src
@morris821028
morris821028 / add.py
Created March 11, 2016 01:40
TA work: add student account on server
import os
student = open('students')
for line in student.readlines():
line = line[:-1]
print line
cmd = "useradd -m -s /bin/bash -d /home/pp2016/%s %s" % (line, line)
psw = "echo %s:%s | chpasswd" % (line, line)
print cmd
@morris821028
morris821028 / 10091. Fast Matrix Multiplication (OpenCL).c
Last active April 16, 2016 14:58
Judge Girl 10091. Fast Matrix Multiplication (OpenCL)
#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <CL/cl.h>
#define MAXGPU 8
#define MAXN 2048
@morris821028
morris821028 / main.c
Created April 17, 2016 14:26
Judge Girl - Fast Matrix Multiplication (OpenMP) duff's device solution
#include <stdio.h>
#include "matrix.h"
// #define DEBUG
#define UINT unsigned long
#define MAXN 2048
void rand_gen(UINT c, int N, UINT A[][MAXN]) {
UINT x = 2, n = N*N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
@morris821028
morris821028 / img2txt.py
Created April 18, 2016 06:11
Image Process - Generator Testdata - Online Judge
import sys
import Image
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
for infile in sys.argv[1:]:
try:
im = Image.open(infile)
width = im.size[0]
height = im.size[1]
@morris821028
morris821028 / nvprof.sh
Created May 3, 2016 02:50
OpenCL Profiler Script on nVidia Driver
#!/bin/bash
TEXT_RED=`tput setaf 1`
TEXT_GREEN=`tput setaf 2`
TEXT_RESET=`tput sgr0`
CONFIG_FILE=nvvp.cfg
if [ ! -f $CONFIG_FILE ];
then
echo "[ERROR] Profile config file ${TEXT_RED}nvvp.cfg${TEXT_RESET} does not exist."
@morris821028
morris821028 / nvprof.sh
Created May 14, 2016 02:17
CUDA Profiler Script on nVidia Driver
#!/bin/bash
TEXT_RED=`tput setaf 1`
TEXT_GREEN=`tput setaf 2`
TEXT_RESET=`tput sgr0`
CONFIG_FILE=nvvp.cfg
if [ ! -f $CONFIG_FILE ];
then
echo "[ERROR] Profile config file ${TEXT_RED}nvvp.cfg${TEXT_RESET} does not exist."
@morris821028
morris821028 / main.c
Created September 24, 2016 01:47
[debug] Judge Girl 33. Intersections Submission 73738
#include<stdio.h>
int main(void)
{
int a[101][101]={0},n,i,j,k,A=0,B=0,C=0,D=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
@morris821028
morris821028 / fig-parallel-n.tex
Last active December 14, 2016 03:02
Paper pgfplot example
\begin{tikzpicture}[scale=0.4,font=\sffamily]
\begin{axis}[
xlabel={Processor $p$},
ylabel={Time (second)},
xmin=1, xmax=16,
ymin=0, ymax=1.2,
scaled ticks = false,
tick label style={/pgf/number format/fixed},
xtick={1, 2, 4, 8, 16},
ytick={0, 0.2, 0.4, 0.6, 0.8, 1, 1.2},