Skip to content

Instantly share code, notes, and snippets.

View roastduck's full-sized avatar

Shizhi Tang roastduck

View GitHub Profile
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Session extends CI_Session{
private $sess_use_redis = TRUE;
private $redis = '';
public function __construct($params = array()) {
//parent::__construct();
$this->CI =& get_instance();
@roastduck
roastduck / odd_even_sort.cpp
Created July 12, 2017 07:28
Parallel odd-even sort implemented on MPI
#ifndef DEBUG
#define NDEBUG
#endif
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <mpi.h>
@roastduck
roastduck / floyd.cu
Created August 6, 2017 08:57
Blocked Floyd–Warshall algorithm implemented with CUDA
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cuda_runtime.h>
#ifdef DUAL_GPU
#include <omp.h>
#endif
#ifndef NDEBUG
#define CHKERR(call) assert((call) == cudaSuccess) // no NDEBUG, so assert must be performed
@roastduck
roastduck / Main.java
Created August 30, 2017 08:56
LL(1) parser example for a simple context-free language
/*
Original grammer:
EXPR -> FIRST_ITEM | EXPR '+' ITEM | EXPR '-' ITEM
ITEM -> VALUE | ITEM '*' VALUE | ITEM '/' VALUE
FIRST_ITEM -> FIRST_VALUE | FIRST_ITEM '*' VALUE | FIRST_ITEM '/' VALUE
VALUE -> number | '(' EXPR ')'
FIRST_VALUE -> VALUE | '-' VALUE
Modified grammer to be LL(1)
EXPR -> ITEM EXPRSUFFIX | '-' ITEM EXPRSUFFIX
@roastduck
roastduck / hook.cpp
Created March 25, 2019 12:34
cuDNN logger using LD_PRELOAD
// compile: g++ -O2 -g -Wall -fPIC -shared hook.cpp -o hook.so -ldl -L/usr/local/cuda-10.0/extras/cudnn-7.4.2/lib64 -lcudnn -lcublas -lcudart
#include <cassert>
#include <mutex>
#include <string>
#include <fstream>
#include <iostream>
#include <type_traits>
#include <unordered_map>
@roastduck
roastduck / main.c
Created December 12, 2019 12:30
malloc
#define NDEBUG
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "solve.h"
#include "utils.h"