Skip to content

Commit

Permalink
misc: fix MSVC compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
9prady9 committed Jan 19, 2018
1 parent 75e6016 commit 38c14c8
Show file tree
Hide file tree
Showing 34 changed files with 2,440 additions and 2,432 deletions.
8 changes: 4 additions & 4 deletions examples/cpu/bubblechart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ int main(void)
std::mt19937_64 gen(r());

std::uniform_int_distribution<int> uDist(20, 80);
std::uniform_real_distribution<float> cDist(0.2, 0.6);
std::uniform_real_distribution<float> fDist(0.4, 0.6);
std::uniform_real_distribution<float> cDist(0.2f, 0.6f);
std::uniform_real_distribution<float> fDist(0.4f, 0.6f);

auto clr = std::bind(cDist, gen);
auto rnd = std::bind(uDist, e1);
Expand Down Expand Up @@ -80,9 +80,9 @@ int main(void)
/* Create several plot objects which creates the necessary
* vertex buffer objects to hold the different plot types
*/
forge::Plot plt1 = chart.plot(cosData.size()/2, forge::f32,
forge::Plot plt1 = chart.plot((unsigned)(cosData.size()/2), forge::f32,
FG_PLOT_LINE, FG_MARKER_TRIANGLE); //or specify a specific plot type
forge::Plot plt2 = chart.plot(tanData.size()/2, forge::f32,
forge::Plot plt2 = chart.plot((unsigned)(tanData.size()/2), forge::f32,
FG_PLOT_LINE, FG_MARKER_CIRCLE); //last parameter specifies marker shape

/* Set plot colors */
Expand Down
4 changes: 2 additions & 2 deletions examples/cpu/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

const unsigned DIMX = 640;
const unsigned DIMY = 480;
const float PI = 3.14159265359;
const float PI = 3.14159265359f;
const float MINIMUM = 1.0f;
const float MAXIMUM = 20.f;
const float STEP = 2.0f;
Expand Down Expand Up @@ -61,7 +61,7 @@ int main(void)
divPoints.setLegend("Convergence Points");
divPoints.setMarkerSize(24);

forge::VectorField field = chart.vectorField(NELEMS*NELEMS, forge::f32);
forge::VectorField field = chart.vectorField((unsigned)(NELEMS*NELEMS), forge::f32);
field.setColor(0.f, 0.6f, 0.3f, 1.f);

std::vector<float> points;
Expand Down
12 changes: 6 additions & 6 deletions examples/cpu/histogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ float interp(float x0, float x1, float alpha)

PerlinNoise::PerlinNoise()
{
std::srand(std::time(0));
std::srand((unsigned)(std::time(0)));

for(unsigned i=0; i < IMGW; i++)
{
Expand Down Expand Up @@ -216,11 +216,11 @@ void kernel(Bitmap& bmp)
float u = x/(float)(bmp.width);
float v = y/(float)(bmp.height);

unsigned char noiseVal = 255 * perlin.noise(u, v);
bmp.ptr[offset*4 + 0] = noiseVal;
bmp.ptr[offset*4 + 1] = noiseVal;
bmp.ptr[offset*4 + 2] = noiseVal;
bmp.ptr[offset*4 + 3] = 255;
unsigned char noiseVal = (unsigned char)(255 * perlin.noise(u, v));
bmp.ptr[offset*4 + 0] = noiseVal;
bmp.ptr[offset*4 + 1] = noiseVal;
bmp.ptr[offset*4 + 2] = noiseVal;
bmp.ptr[offset*4 + 3] = 255;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/cpu/plot3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const unsigned DIMY = 800;
static const float ZMIN = 0.1f;
static const float ZMAX = 10.f;

const float DX = 0.005;
const size_t ZSIZE = (ZMAX-ZMIN)/DX+1;
const float DX = 0.005f;
const size_t ZSIZE = (size_t)((ZMAX-ZMIN)/DX+1);

using namespace std;

Expand All @@ -31,9 +31,9 @@ void generateCurve(float t, float dx, std::vector<float> &vec )
vec.clear();
for (int i=0; i < (int)ZSIZE; ++i) {
float z = ZMIN + i*dx;
vec.push_back(cos(z*t+t)/z);
vec.push_back(sin(z*t+t)/z);
vec.push_back(z+0.1*sin(t));
vec.push_back((float)(cos(z*t+t)/z));
vec.push_back((float)(sin(z*t+t)/z));
vec.push_back((float)(z+0.1*sin(t)));
}
}

Expand Down Expand Up @@ -74,7 +74,7 @@ int main(void)
copyToGLBuffer(handle, (ComputeResourceHandle)function.data(), plot3.verticesSize());

do {
t+=0.01;
t+=0.01f;
generateCurve(t, DX, function);
copyToGLBuffer(handle, (ComputeResourceHandle)function.data(), plot3.verticesSize());
wnd.draw(chart);
Expand Down
8 changes: 4 additions & 4 deletions examples/cpu/plotting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ int main(void)
/* Create several plot objects which creates the necessary
* vertex buffer objects to hold the different plot types
*/
forge::Plot plt0 = chart.plot(sinData.size()/2, forge::f32); //create a default plot
forge::Plot plt1 = chart.plot(cosData.size()/2, forge::f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type
forge::Plot plt2 = chart.plot(tanData.size()/2, forge::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape
forge::Plot plt3 = chart.plot(logData.size()/2, forge::f32, FG_PLOT_SCATTER, FG_MARKER_CROSS);
forge::Plot plt0 = chart.plot((unsigned)(sinData.size()/2), forge::f32); //create a default plot
forge::Plot plt1 = chart.plot((unsigned)(cosData.size()/2), forge::f32, FG_PLOT_LINE, FG_MARKER_NONE); //or specify a specific plot type
forge::Plot plt2 = chart.plot((unsigned)(tanData.size()/2), forge::f32, FG_PLOT_LINE, FG_MARKER_TRIANGLE); //last parameter specifies marker shape
forge::Plot plt3 = chart.plot((unsigned)(logData.size()/2), forge::f32, FG_PLOT_SCATTER, FG_MARKER_CROSS);

/*
* Set plot colors
Expand Down
4 changes: 2 additions & 2 deletions examples/cpu/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

const unsigned DIMX = 640;
const unsigned DIMY = 480;
const float PI = 3.14159265359;
const float PI = 3.14159265359f;
const float MINIMUM = 1.0f;
const float MAXIMUM = 20.f;
const float STEP = 2.0f;
const int NELEMS = (MAXIMUM-MINIMUM+1)/STEP;
const int NELEMS = (int)((MAXIMUM-MINIMUM+1)/STEP);

using namespace std;

Expand Down
6 changes: 3 additions & 3 deletions examples/cpu/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ static const float YMIN = -32.0f;
static const float YMAX = 32.0f;

const float DX = 0.25;
const size_t XSIZE = (XMAX-XMIN)/DX;
const size_t YSIZE = (YMAX-YMIN)/DX;
const size_t XSIZE = (size_t)((XMAX-XMIN)/DX);
const size_t YSIZE = (size_t)((YMAX-YMIN)/DX);

void genSurface(float dx, std::vector<float> &vec )
{
Expand All @@ -33,7 +33,7 @@ void genSurface(float dx, std::vector<float> &vec )
for(float y=YMIN; y < YMAX; y+=dx) {
vec.push_back(x);
vec.push_back(y);
float z = sqrt(x*x+y*y) + 2.2204e-16;
float z = sqrt(x*x+y*y) + 2.2204e-16f;
vec.push_back(sin(z)/z);
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/cuda/bubblechart.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
const unsigned DIMX = 1000;
const unsigned DIMY = 800;

static const float DX = 0.1;
static const float DX = 0.1f;
static const float FRANGE_START = 0.f;
static const float FRANGE_END = 2 * 3.141592f;
static const size_t DATA_SIZE = (FRANGE_END - FRANGE_START) / DX;
static const size_t DATA_SIZE = (size_t)((FRANGE_END - FRANGE_START) / DX);

curandState_t* state;

Expand Down
10 changes: 5 additions & 5 deletions examples/cuda/field.cu
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ int main(void)
divPoints.setLegend("Convergence Points");
divPoints.setMarkerSize(24);

size_t npoints = NELEMS*NELEMS;
size_t npoints = (size_t)(NELEMS*NELEMS);

forge::VectorField field = chart.vectorField(npoints, forge::f32);
forge::VectorField field = chart.vectorField((unsigned)(npoints), forge::f32);
field.setColor(0.f, 0.6f, 0.3f, 1.f);

FORGE_CUDA_CHECK(cudaMalloc((void**)&dpoints, 8*sizeof(unsigned)));
Expand Down Expand Up @@ -113,8 +113,8 @@ void pointGenKernel(float* points, float* dirs, int nelems, float minimum, float
void generatePoints(float* points, float* dirs)
{
static dim3 threads(8, 8);
dim3 blocks(divup(NELEMS, threads.x),
divup(NELEMS, threads.y));
dim3 blocks(divup((int)(NELEMS), threads.x),
divup((int)(NELEMS), threads.y));

pointGenKernel<<<blocks, threads>>>(points, dirs, NELEMS, MINIMUM, STEP);
pointGenKernel<<<blocks, threads>>>(points, dirs, (int)(NELEMS), MINIMUM, STEP);
}
6 changes: 3 additions & 3 deletions examples/cuda/plot3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const unsigned DIMY = 800;
static const float ZMIN = 0.1f;
static const float ZMAX = 10.f;

const float DX = 0.005;
const size_t ZSIZE = (ZMAX-ZMIN)/DX+1;
const float DX = 0.005f;
const size_t ZSIZE = (size_t)((ZMAX-ZMIN)/DX+1);

void kernel(float t, float dx, float* dev_out);

Expand Down Expand Up @@ -64,7 +64,7 @@ int main(void)
copyToGLBuffer(handle, (ComputeResourceHandle)dev_out, plot3.verticesSize());

do {
t+=0.01;
t+=0.01f;
kernel(t, DX, dev_out);
copyToGLBuffer(handle, (ComputeResourceHandle)dev_out, plot3.verticesSize());
wnd.draw(chart);
Expand Down
4 changes: 2 additions & 2 deletions examples/cuda/plotting.cu
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
const unsigned DIMX = 1000;
const unsigned DIMY = 800;

static const float dx = 0.1;
static const float dx = 0.1f;
static const float FRANGE_START = 0.f;
static const float FRANGE_END = 2 * 3.141592f;
static const size_t DATA_SIZE = ( FRANGE_END - FRANGE_START ) / dx;
static const size_t DATA_SIZE = (size_t)(( FRANGE_END - FRANGE_START ) / dx);

void kernel(float* dev_out, int functionCode);

Expand Down
2 changes: 1 addition & 1 deletion examples/cuda/stream.cu
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const unsigned DIMY = 480;
const float MINIMUM = 1.0f;
const float MAXIMUM = 20.f;
const float STEP = 2.0f;
const int NELEMS = (MAXIMUM-MINIMUM+1)/STEP;
const int NELEMS = (int)((MAXIMUM-MINIMUM+1)/STEP);

void generateColors(float* colors);

Expand Down
4 changes: 2 additions & 2 deletions examples/cuda/surface.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const float YMIN = -8.0f;
const float YMAX = 8.f;

const float DX = 0.5;
const size_t XSIZE = (XMAX-XMIN)/DX;
const size_t YSIZE = (YMAX-YMIN)/DX;
const size_t XSIZE = (size_t)((XMAX-XMIN)/DX);
const size_t YSIZE = (size_t)((YMAX-YMIN)/DX);

void kernel(float dx, float* dev_out);

Expand Down
8 changes: 4 additions & 4 deletions examples/opencl/bubblechart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ using namespace std;
const unsigned DIMX = 1000;
const unsigned DIMY = 800;

static const float DX = 0.1;
static const float DX = 0.1f;
static const float FRANGE_START = 0.f;
static const float FRANGE_END = 2 * 3.141592f;
static const int DATA_SIZE = (FRANGE_END - FRANGE_START) / DX;
static const int DATA_SIZE = (int)((FRANGE_END - FRANGE_START) / DX);

#define USE_FORGE_OPENCL_COPY_HELPERS
#include <ComputeCopy.h>
Expand Down Expand Up @@ -92,7 +92,7 @@ void kernel(cl::Buffer& devOut, int fnCode, int outFlags,
static cl::Program prog;
static cl::Kernel randKernel, colorsKernel, mapKernel;

std::srand(std::time(0));
std::srand((unsigned)(std::time(0)));

if (compileFlag) {
try {
Expand All @@ -116,7 +116,7 @@ void kernel(cl::Buffer& devOut, int fnCode, int outFlags,
}

static const NDRange local(32);
NDRange global(local[0] * divup(DATA_SIZE, local[0]));
NDRange global(local[0] * divup(DATA_SIZE, (int)(local[0])));

mapKernel.setArg(0, devOut);
mapKernel.setArg(1, fnCode);
Expand Down
6 changes: 5 additions & 1 deletion examples/opencl/cl_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#define CL_HPP_TARGET_OPENCL_VERSION 120

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#include <CL/cl2.hpp>
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

#include <sstream>
#include <algorithm>
Expand Down Expand Up @@ -84,7 +88,7 @@ bool checkGLInterop(const cl::Platform &plat, const cl::Device &pDevice, const

if (err != CL_SUCCESS) return false;

int num = ret / sizeof(cl_device_id);
int num = (int)(ret / sizeof(cl_device_id));
devices.resize(num);

// Check if current device is present in the associated devices
Expand Down
8 changes: 4 additions & 4 deletions examples/opencl/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void generatePoints(cl::Buffer& points, cl::Buffer& dirs,
}

static const NDRange local(8, 8);
NDRange global(local[0] * divup(NELEMS, local[0]),
local[1] * divup(NELEMS, local[1]));
NDRange global(local[0] * divup((int)(NELEMS), (int)(local[0])),
local[1] * divup((int)(NELEMS), (int)(local[1])));

pointGenKernel.setArg(0, points);
pointGenKernel.setArg(1, dirs);
Expand Down Expand Up @@ -120,9 +120,9 @@ int main(void)
divPoints.setLegend("Convergence Points");
divPoints.setMarkerSize(24);

size_t npoints = NELEMS*NELEMS;
size_t npoints = (size_t)(NELEMS*NELEMS);

forge::VectorField field = chart.vectorField(npoints, forge::f32);
forge::VectorField field = chart.vectorField((unsigned)(npoints), forge::f32);
field.setColor(0.f, 0.6f, 0.3f, 1.f);

/*
Expand Down
4 changes: 2 additions & 2 deletions examples/opencl/fractal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void kernel(cl::Buffer& devOut, cl::CommandQueue& queue)
auto juliaOp = cl::KernelFunctor<Buffer, unsigned, unsigned>(kern);

static const NDRange local(8, 8);
NDRange global(local[0] * divup(DIMX, local[0]),
local[1] * divup(DIMY, local[1]));
NDRange global(local[0] * divup(DIMX, (int)(local[0])),
local[1] * divup(DIMY, (int)(local[1])));

juliaOp(EnqueueArgs(queue, global, local), devOut, DIMX, DIMY);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/opencl/histogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void kernel(cl::Buffer& image, cl::Buffer& base, cl::Buffer& perlin,
static cl::Kernel initKernel, computeKernel, normKernel, fillKernel;
static cl::Kernel memSetKernel, genHistogram, genHistColors;

std::srand(std::time(0));
std::srand((unsigned)(std::time(0)));

if (compileFlag) {
try {
Expand Down Expand Up @@ -193,8 +193,8 @@ void kernel(cl::Buffer& image, cl::Buffer& base, cl::Buffer& perlin,
}

static const NDRange local(16, 16);
NDRange global(local[0] * divup(IMGW, local[0]),
local[1] * divup(IMGH, local[1]));
NDRange global(local[0] * divup(IMGW, (int)(local[0])),
local[1] * divup(IMGH, (int)(local[1])));

float persistence = 0.5f;
float amp = 1.0f;
Expand Down
6 changes: 3 additions & 3 deletions examples/opencl/plot3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const unsigned DIMY = 800;
static const float ZMIN = 0.1f;
static const float ZMAX = 10.f;

const float DX = 0.005;
static const unsigned ZSIZE = (ZMAX-ZMIN)/DX+1;
const float DX = 0.005f;
static const unsigned ZSIZE = (unsigned)((ZMAX-ZMIN)/DX+1);

using namespace std;

Expand Down Expand Up @@ -118,7 +118,7 @@ int main(void)
copyToGLBuffer(handle, (ComputeResourceHandle)devOut(), plot3.verticesSize());

do {
t+=0.01;
t+=0.01f;
kernel(devOut, queue, t);
copyToGLBuffer(handle, (ComputeResourceHandle)devOut(), plot3.verticesSize());
wnd.draw(chart);
Expand Down
4 changes: 2 additions & 2 deletions examples/opencl/plotting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ using namespace std;
const unsigned DIMX = 1000;
const unsigned DIMY = 800;

const float dx = 0.1;
const float dx = 0.1f;
const float FRANGE_START = 0.f;
const float FRANGE_END = 2 * 3.141592f;
const unsigned DATA_SIZE = ( FRANGE_END - FRANGE_START ) / dx;
const unsigned DATA_SIZE = (unsigned)(( FRANGE_END - FRANGE_START ) / dx);

#define USE_FORGE_OPENCL_COPY_HELPERS
#include <ComputeCopy.h>
Expand Down
Loading

0 comments on commit 38c14c8

Please sign in to comment.