Skip to content

Instantly share code, notes, and snippets.

View rharriso's full-sized avatar

Ross Harrison rharriso

View GitHub Profile
@rharriso
rharriso / https-redirect-docker-sc-tcp.config
Last active March 6, 2020 13:50
HTTPs redirection with Websockets
###################################################################################################
#### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
####
#### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
#### except in compliance with the License. A copy of the License is located at
####
#### http://aws.amazon.com/apache2.0/
####
#### or in the "license" file accompanying this file. This file is distributed on an "AS IS"
#### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@rharriso
rharriso / add_copyright_exif.rb
Last active November 18, 2019 08:23
Paperclip processor for adding copyright info to uploaded files
@rharriso
rharriso / elb-http-redirect-tcp.diff
Created May 24, 2019 18:07
Change from provided https redirect config
diff --git a/.ebextensions/https-redirect-docker-sc.config b/.ebextensions/https-redirect-docker-sc.config
index fa2fbdc..5ea1cae 100644
--- a/.ebextensions/https-redirect-docker-sc.config
+++ b/.ebextensions/https-redirect-docker-sc.config
@@ -33,14 +33,14 @@ files:
default "upgrade";
"" "";
}
-
+
@rharriso
rharriso / init-pixel-counts-thrust.cu
Created October 23, 2018 02:02
init pixel counts thrust
const int PIXEL_COUNT = 500 * 500;
auto pixelCounts = thrust::device_vector<unsigned int>(PIXEL_COUNT);
thrust::fill(pixelCounts.begin(), pixelCounts.end(), 0);
@rharriso
rharriso / init-pixels-cuda.cu
Created October 23, 2018 02:01
Initialize Body Counts Cuda
const int PIXEL_COUNT = 500 * 500;
usigned int *pixelBodyCounts;
cudaMallocManaged(&pixelBodyCounts, PIXEL_COUNT * sizeof(unsigned int));
initZeros<<<numBlocks, blockSize>>>(pixelBodyCounts);
// do stuff with the pixels
cudaFree(pixelBodyCounts);
@rharriso
rharriso / Thrust Prof
Created October 14, 2018 23:46
Looking at Thrust: Thrust Prof Output
==24803== NVPROF is profiling process 24803, command: ./main-thrust
==24803== Profiling application: ./main-thrust
==24803== Profiling result:
Type Time(%) Time Calls Avg Min Max Name
GPU activities: 74.98% 157.91ms 2 78.954ms 77.478ms 80.430ms void thrust::cuda_cub::core::_kernel_agent<thrust::cuda_cub::__parallel_for::ParallelForAgent<thrust::cuda_cub::__transform::unary_transform_f<thrust::counting_iterator<unsigned int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::detail::normal_iterator<thrust::device_ptr<float>>, thrust::cuda_cub::__transform::no_stencil_tag, initRandomPrg, thrust::cuda_cub::__transform::always_true_predicate>, long>, thrust::cuda_cub::__transform::unary_transform_f<thrust::counting_iterator<unsigned int, thrust::use_default, thrust::use_default, thrust::use_default>, thrust::detail::normal_iterator<thrust::device_ptr<float>>, thrust::cuda_cub::__transform::no_stencil_tag, initRandomPrg, thrust::cuda_cub
@rharriso
rharriso / main-thrust.cu
Last active October 14, 2018 23:37
Looking At Thrust: Thrust Snippet
struct initRandomPrg {
float minValue, maxValue;
__host__ __device__
initRandomPrg(float _mnV=0.f, float _mxV=1.f) : minValue(_mnV), maxValue(_mxV) {};
__host__ __device__
float operator()(const unsigned int n) const {
thrust::default_random_engine rng;
thrust::uniform_real_distribution<float> dist(minValue, maxValue);
@rharriso
rharriso / Makefile
Last active October 14, 2018 23:35
Looking at Cuda and Thrust: Makefile
CC:=/usr/local/cuda-9.1/bin/nvcc
PROF:=/usr/local/cuda-9.1/bin/nvprof
run: main-cuda.cuda
./main-cuda.cuda
prof: main-cuda main-cpu main-thrust
${PROF} ./main-cuda
@echo
${PROF} ./main-thrust
@rharriso
rharriso / cuda prof
Created October 14, 2018 23:26
Looking at Thust: Cuda Prof
==21393== Profiling application: ./main-cuda.cuda
==21393== Profiling result:
Type Time(%) Time Calls Avg Min Max Name
GPU activities: 73.42% 227.76ms 2 113.88ms 113.37ms 114.40ms void initRandom<float>(float*, float, float)
26.58% 82.465ms 10 8.2465ms 4.8140ms 39.102ms void add<float>(float*, float*, float*)
API calls: 61.88% 310.24ms 11 28.204ms 4.8177ms 227.74ms cudaDeviceSynchronize
32.78% 164.31ms 3 54.771ms 49.680us 164.11ms cudaMallocManaged
4.87% 24.428ms 3 8.1428ms 8.1220ms 8.1685ms cudaFree
0.32% 1.6288ms 12 135.74us 19.770us 559.03us cudaLaunch
0.11% 528.26us 94 5.6190us 240ns 229.88us cuDeviceGetAttribute
@rharriso
rharriso / main-cuda.cu
Last active October 14, 2018 23:13
Looking at Thrust: cuda snippet
// add two arrays
template<typename T>
__global__ void add(T *output, T *inputA, T *inputB) {
int idx = (blockIdx.x * blockDim.x) + threadIdx.x;
output[idx] = inputA[idx] + inputB[idx];
}
template<typename T>
__global__ void initRandom(T *arr, float minValue, float maxValue) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;