Skip to content

Instantly share code, notes, and snippets.

@whchung
whchung / Makefile
Created October 17, 2017 15:11
simple_dispatch for gfx803
LFLAGS= -Wl,--unresolved-symbols=ignore-in-shared-libs
CC := gcc
C_FILES := $(wildcard *.c)
OBJ_FILES := $(notdir $(C_FILES:.c=.o))
all: simple_dispatch
@whchung
whchung / SemaDecl.diff
Created January 20, 2017 09:21
patch to Sema to change parameters and return values for FunctionDecl to generic address space
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index cf493e5..ea88055 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -8375,6 +8375,67 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
assert(R.getTypePtr()->isFunctionType());
+ // HCC generic address space hack
+ bool genericHack = false;
@whchung
whchung / 0_reuse_code.js
Created August 15, 2016 04:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@whchung
whchung / fp_extend.cpp
Last active July 1, 2016 02:43
Sample code to use __fp16 in HCC. Adopted __gnu_f2h_ieee() and __gnu_h2f_ieee() from compiler-rt in LLVM
#include <limits.h>
#include <stdint.h>
typedef uint16_t src_t;
typedef uint16_t src_rep_t;
#define SRC_REP_C UINT16_C
static const int srcSigBits = 10;
#define src_rep_t_clz __builtin_clz
typedef float dst_t;
@whchung
whchung / parboil_bfs.diff
Created June 27, 2016 02:08
parboil_bfs.diff
iff --git a/benchmarks/bfs/src/hip/kernel.cc b/benchmarks/bfs/src/hip/kernel.cc
index 985436d..89f8c2e 100644
--- a/benchmarks/bfs/src/hip/kernel.cc
+++ b/benchmarks/bfs/src/hip/kernel.cc
@@ -225,16 +225,17 @@ BFS_in_GPU_kernel(grid_launch_parm lp,
int tid = hipBlockIdx_x*MAX_THREADS_PER_BLOCK + hipThreadIdx_x;
if( tid<no_of_nodes)
{
- int pid;
- if(tot_sum == 0)//this is the first BFS level of current kernel call
@whchung
whchung / main.cpp
Last active June 6, 2016 03:02 — forked from LWisteria/main.cpp
C++AMP vector_add
// export PATH=${PATH}:/opr/rocm/bin
// hcc `clamp-config --cxxflags` -g -O3 -o obj/main.o -c main.cpp
// hcc -o vector_add obj/main.o `clamp-config --ldflags`
#include <iostream>
#include <algorithm>
#include <numeric>
#include <array>
#include <amp.h>
@whchung
whchung / test_fma.cpp
Last active May 21, 2016 01:01
FMA test submitted by @NEELMCW
// build it: hcc `hcc-config --cxxflags --ldflags` -lhc_am test.cpp -lm
#include "hc.hpp"
#include "hc_math.hpp"
#include "hc_am.hpp"
#include <iostream>
#include <iomanip>
#define VECTOR_SIZE 1024 * 1024
// XFAIL: Linux
// RUN: %hc %s -lhc_am -o %t.out && %t.out
#include <hc.hpp>
#include <grid_launch.h>
#include <hc_am.hpp>
#include <iostream>
#include <random>
@whchung
whchung / kernel_dispatch_latency.cpp
Created February 23, 2016 07:46
HSA kernel dispatch latency benchmark
// XFAIL: Linux
// RUN: %hc %s -o %t.out && %t.out
#include <hc.hpp>
#include <iostream>
#include <random>
#include <time.h>
@whchung
whchung / hc_array_add_dgpu.cpp
Created January 20, 2016 14:51
HC vector addition which works on both APU and dGPU
// build with:
// hcc `hcc-config --cxxflags --ldflags` hc_array_add_dgpu.cpp
#include <iostream>
#include <random>
#include <hc.hpp>
int main ()
{
// define inputs and output