Skip to content

Instantly share code, notes, and snippets.

@jatesy
jatesy / kernel
Created April 1, 2014 18:32
Graphic Processing Units(GPU) programming: Sorting, implemented parallel in OpenCL
__kernel void vector_sort(__global int *A, __global int *B) {
//Get the index of the current element
int i = get_global_id(0);
int size = 1024; //We can change the size of array to 2048, 4096, 8192, 16384 and 32768
int j = 0;
// Do the operation of sorting
int p = 0;
for(j = 0; j < size; j++)
@jatesy
jatesy / kernel
Created April 1, 2014 18:31
Graphic Processing Units(GPU) programming: Vector addition, implemented parallel in OpenCL
__kernel void vector_add(__global int *A, __global int *B, __global int *C) {
//Get the index of the current element
int i = get_global_id(0);
int size = 1024;
//Initialize the two input vectors
A[i] = i;
B[i] = size - i;
@jatesy
jatesy / Array_reduction
Created April 1, 2014 18:25
Graphic Processing Units(GPU) programming: Array reduction algorithm implemented parallel in Cuda, taking branch divergence into account and using shared memory.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
// Thread block size
#define BLOCK_SIZE 512
// Size of Array
@jatesy
jatesy / Hotel_reserve
Created April 1, 2014 18:21
A hotel reservation system implemented in functional language(Standard ML)
(*The signature includes the total number of 2-double-bed romms,queen-bed rooms and king-bed rooms accordingly
in a hotel. Also the requirements of minimum number of nights and number limit of occupancy must be met by
any reservation*)
signature ROOMDETAIL =
sig
val doubleAvailable:int;
val queenAvailable:int;
val kingAvailable:int;
val minnights:int option;
@jatesy
jatesy / Vector_add
Created April 1, 2014 18:19
Graphic Processing Units(GPU) programming: Vectors addition implemented parallel in Cuda
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
// block size
#define BLOCK_SIZE 512
#define VECTOR_SIZE 100 // We can change the value of W to 200, 400, 800, 1600, 3200
@jatesy
jatesy / Matrix_multiplication
Created April 1, 2014 18:17
Graphic Processing Units(GPU) programming: Matrix multiplication implemented parallel in Cuda
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
// Thread block size
#define BLOCK_SIZE 8 //We can change this to 16, 32, 64, 128, 256, 512 and 1024
// Matrix dimensions
@jatesy
jatesy / Process scheduler
Last active April 17, 2023 23:28
The simulation of a system process scheduler, which can implement scheduling algorithms including First Come First Serve(FCFS), RoundRobin, Last Come First Serve(LCFS) and Shortest Job First(SJF). The system is to be implemented as a Discrete Event Simulation (DES). Implemented in C++.
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<string>
#include<iostream>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
@jatesy
jatesy / Linker
Created April 1, 2014 17:49
linker takes individually compiled modules and creates a single executable by resolving external symbol references (e.g. variables and functions) and module relative addressing by assigning global addresses after placing the modules’ object code at global addresses. Implemented in C++.
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<string>
#include<iostream>
using namespace std;
#define MAX 1000