Skip to content

Instantly share code, notes, and snippets.

View alphaville's full-sized avatar
:octocat:
(De)coding

Pantelis Sopasakis alphaville

:octocat:
(De)coding
View GitHub Profile
@alphaville
alphaville / tutorial-utils.h
Last active August 29, 2015 13:58
CUDA - First steps
/*
* tutorial-utils.h
*
* Created on: Apr 5, 2014
* Author: chung
*/
#ifndef TUTORIAL_UTILS_H_
#define TUTORIAL_UTILS_H_
@alphaville
alphaville / CUDA_streams.cu
Created April 6, 2014 17:01
CUDA Streams
__global__ void initialize_vec(int *a) {
int tid = blockIdx.x;
a[tid] = tid;
}
void do_stream_init(void) {
/* Declarations */
int *d_a, *d_b;
int *h_a;
int i;
@alphaville
alphaville / cuda-error-handling.cuh
Created April 8, 2014 16:00
CUDA Error Handling Functions
#define CUDA_CALL(value) do { \
cudaError_t _m_cudaStat = value; \
if (_m_cudaStat != cudaSuccess) { \
fprintf(stderr, "Error %s at line %d in file %s\n", \
cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__); \
exit(1); \
} } while(0)
#define CUBLAS_CALL(value) do { \
cublasStatus_t _m_status = value; \
@alphaville
alphaville / parallel-cublas-operations.cu
Last active August 29, 2015 13:58
Execute lots of matrix-matrix multiplications in CUDA using CUBLAS and different handles. CURAND is used to initialize the matrices with random data. The data are initially packed in a large vector to avoid excessive cudaMalloc calls.
// Compile using the following commands:
// nvcc -I/usr/local/cuda-5.0/samples/common/inc -I/usr/local/cuda-5.0/samples/7_CUDALibraries -G -g -O3 -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "parallel-cublas-operations.d" "parallel-cublas-operations.cu"
// nvcc --compile -G -I/usr/local/cuda-5.0/samples/common/inc -I/usr/local/cuda-5.0/samples/7_CUDALibraries -O3 -g -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -x cu -o "parallel-cublas-operations.o" "parallel-cublas-operations.cu"
/* Includes */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <cuda_runtime.h>
21:46:38 **** Build of configuration Debug for project pQP ****
make all
Building file: ../src/pQP.cu
Invoking: NVCC Compiler
/usr/local/cuda-6.0/bin/nvcc -I/usr/local/cula/include/ -I/home/chung/lapack-3.5.0/lapacke/include -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "src/pQP.d" "../src/pQP.cu"
/usr/local/cuda-6.0/bin/nvcc --compile -G -I/usr/local/cula/include/ -I/home/chung/lapack-3.5.0/lapacke/include -O0 -g -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -x cu -o "src/pQP.o" "../src/pQP.cu"
Finished building: ../src/pQP.cu
Building target: pQP
Invoking: NVCC Linker
#
# mexopts.sh Shell script for configuring MEX-file creation script,
# mex. These options were tested with the specified compiler.
#
# usage: Do not call this file directly; it is sourced by the
# mex shell script. Modify only if you don't like the
# defaults after running mex. No spaces are allowed
# around the '=' in the variable assignment.
#
# Note: For the version of system compiler supported with this release,
% Define the matrices of the system:
A = [0 1; -0.25 1];
B = [0; 1];
C = [1 0.5];
D = 0;
% Define the state-space system using ss:
sysStruct = struct('A',A,'B',B,'C',C,'D',D);
% Provide the set of disturbances
sysStruct.D_poly=0.01*unitbox(2,1);
% Define the constraints:
@alphaville
alphaville / isBouded.m
Last active August 29, 2015 14:02
Modified file isBounded.m to accomodate polyhedrons with equality constaints
function tf = isBounded(P)
%
% ISBOUNDED: Test if a polyhedron is bounded.
% ============================================
%
%
% SYNTAX
% ------
%
% tf = P.isBounded
% If you need to know the ancestor of node #123, you do:
TREE.ancestor(123)
% If you need to access all children of node #12 you do
TREE.children{12}
% and you get an array
% The leave nodes are stored at
TREE.leaves
{
"study": [
{
"uuid": "IUC5-89019c4a-acc8-4457-8a5a-4db66cd16ff3",
"owner": {
"substance": {
"uuid": "IUC4-d0966414-0e9b-3610-ab7d-7d27848027e2"
},
"company": {
"uuid": "IUC4-44bf02d8-47c5-385d-b203-9a8f315911cb",