Skip to content

Instantly share code, notes, and snippets.

@nesteruk
Created September 17, 2013 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesteruk/6599547 to your computer and use it in GitHub Desktop.
Save nesteruk/6599547 to your computer and use it in GitHub Desktop.
This CUDA kernel just blue-screened by machine
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cmath>
using namespace std;
__device__ __inline__ float trim(unsigned char value)
{
return fminf((unsigned char)255, fmaxf(value, (unsigned char)0));
}
__device__ __inline__ float poly(float x, float a, float b, float c)
{
return a*x*x*x+b*x*x+c*x;
}
__global__ void kernel(unsigned char* img, const float* a)
{
int ix = blockIdx.x;
int iy = threadIdx.x;
int tid = iy*blockDim.x + ix;
float x = (float)ix / blockDim.x;
float y = (float)iy / gridDim.x;
double z = cosf((sinf(((cosf((x == 0.0f ? x : 1.0f/x)) > 0.0f ? sqrt(cosf((x == 0.0f ? x : 1.0f/x))) : -sqrt(-cosf((x == 0.0f ? x : 1.0f/x)))) < sinhf(powf(powf(y,x),(0.954833f < y ? 0.954833f : y))) ? (cosf((x == 0.0f ? x : 1.0f/x)) > 0.0f ? sqrt(cosf((x == 0.0f ? x : 1.0f/x))) : -sqrt(-cosf((x == 0.0f ? x : 1.0f/x)))) : sinhf(powf(powf(y,x),(0.954833f < y ? 0.954833f : y))))) > tanhf(((((x+0.69573f) > powf(x,y) ? (x+0.69573f) : powf(x,y))*sinhf(cosf(y))) > 0.0f ? sqrt((((x+0.69573f) > powf(x,y) ? (x+0.69573f) : powf(x,y))*sinhf(cosf(y)))) : -sqrt(-(((x+0.69573f) > powf(x,y) ? (x+0.69573f) : powf(x,y))*sinhf(cosf(y)))))) ? sinf(((cosf((x == 0.0f ? x : 1.0f/x)) > 0.0f ? sqrt(cosf((x == 0.0f ? x : 1.0f/x))) : -sqrt(-cosf((x == 0.0f ? x : 1.0f/x)))) < sinhf(powf(powf(y,x),(0.954833f < y ? 0.954833f : y))) ? (cosf((x == 0.0f ? x : 1.0f/x)) > 0.0f ? sqrt(cosf((x == 0.0f ? x : 1.0f/x))) : -sqrt(-cosf((x == 0.0f ? x : 1.0f/x)))) : sinhf(powf(powf(y,x),(0.954833f < y ? 0.954833f : y))))) : tanhf(((((x+0.69573f) > powf(x,y) ? (x+0.69573f) : powf(x,y))*sinhf(cosf(y))) > 0.0f ? sqrt((((x+0.69573f) > powf(x,y) ? (x+0.69573f) : powf(x,y))*sinhf(cosf(y)))) : -sqrt(-(((x+0.69573f) > powf(x,y) ? (x+0.69573f) : powf(x,y))*sinhf(cosf(y))))))));
img[tid*4+0] = trim(poly(z,a[0],a[1],a[2]) * 255.0f);
img[tid*4+1] = trim(poly(z,a[3],a[4],a[5]) * 255.0f);
img[tid*4+2] = trim(poly(z,a[6],a[7],a[8]) * 255.0f);
img[tid*4+3] = 255;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment