Eliminated MSVC warnings

This commit is contained in:
Andrey Guskov
2015-01-26 16:26:07 +04:00
parent 05a64f1302
commit ed53df90a4
10 changed files with 31 additions and 26 deletions

View File

@@ -35,6 +35,8 @@
#define NOMINMAX #define NOMINMAX
#pragma warning (disable: 4244) #pragma warning (disable: 4244)
#pragma warning (disable: 4305) #pragma warning (disable: 4305)
// preventing MSVC fopen() deprecation complaints
#define _CRT_SECURE_NO_DEPRECATE
#endif #endif
#include <stdio.h> #include <stdio.h>

View File

@@ -34,6 +34,8 @@
#include "instrument.h" #include "instrument.h"
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <iomanip>
#include <sstream>
#include <string> #include <string>
#include <map> #include <map>
@@ -46,7 +48,7 @@ struct CallInfo {
static std::map<std::string, CallInfo> callInfo; static std::map<std::string, CallInfo> callInfo;
int countbits(int i) { int countbits(uint64_t i) {
int ret = 0; int ret = 0;
while (i) { while (i) {
if (i & 0x1) if (i & 0x1)
@@ -61,13 +63,12 @@ int countbits(int i) {
// command-line flag is given while compiling. // command-line flag is given while compiling.
void void
ISPCInstrument(const char *fn, const char *note, int line, uint64_t mask) { ISPCInstrument(const char *fn, const char *note, int line, uint64_t mask) {
char sline[16]; std::stringstream s;
sprintf(sline, "%04d", line); s << fn << "(" << std::setfill('0') << std::setw(4) << line << ") - "
std::string s = std::string(fn) + std::string("(") + std::string(sline) + << note;
std::string(") - ") + std::string(note);
// Find or create a CallInfo instance for this callsite. // Find or create a CallInfo instance for this callsite.
CallInfo &ci = callInfo[s]; CallInfo &ci = callInfo[s.str()];
// And update its statistics... // And update its statistics...
++ci.count; ++ci.count;

View File

@@ -89,7 +89,7 @@ int main(int argc, char** argv) {
int nframes = test_iterations[2]; int nframes = test_iterations[2];
double ispcCycles = 1e30; double ispcCycles = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (unsigned int i = 0; i < test_iterations[0]; ++i) {
framebuffer.clear(); framebuffer.clear();
reset_and_start_timer(); reset_and_start_timer();
for (int j = 0; j < nframes; ++j) for (int j = 0; j < nframes; ++j)
@@ -123,7 +123,7 @@ int main(int argc, char** argv) {
#endif // __cilk #endif // __cilk
double serialCycles = 1e30; double serialCycles = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (unsigned int i = 0; i < test_iterations[1]; ++i) {
framebuffer.clear(); framebuffer.clear();
reset_and_start_timer(); reset_and_start_timer();
for (int j = 0; j < nframes; ++j) for (int j = 0; j < nframes; ++j)

View File

@@ -99,7 +99,7 @@ int main(int argc, char *argv[]) {
// time of three runs. // time of three runs.
// //
double minISPC = 1e30; double minISPC = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (unsigned int i = 0; i < test_iterations[0]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf); mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf);
double dt = get_elapsed_mcycles(); double dt = get_elapsed_mcycles();
@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
// minimum time. // minimum time.
// //
double minSerial = 1e30; double minSerial = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (unsigned int i = 0; i < test_iterations[1]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf); mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf);
double dt = get_elapsed_mcycles(); double dt = get_elapsed_mcycles();

View File

@@ -110,7 +110,7 @@ int main(int argc, char *argv[]) {
// time of three runs. // time of three runs.
// //
double minISPC = 1e30; double minISPC = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (unsigned int i = 0; i < test_iterations[0]; ++i) {
// Clear out the buffer // Clear out the buffer
for (unsigned int i = 0; i < width * height; ++i) for (unsigned int i = 0; i < width * height; ++i)
buf[i] = 0; buf[i] = 0;
@@ -130,7 +130,7 @@ int main(int argc, char *argv[]) {
// minimum time. // minimum time.
// //
double minSerial = 1e30; double minSerial = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (unsigned int i = 0; i < test_iterations[1]; ++i) {
// Clear out the buffer // Clear out the buffer
for (unsigned int i = 0; i < width * height; ++i) for (unsigned int i = 0; i < width * height; ++i)
buf[i] = 0; buf[i] = 0;

View File

@@ -95,7 +95,7 @@ int main(int argc, char *argv[]) {
// time of three runs. // time of three runs.
// //
double minISPC = 1e30; double minISPC = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (unsigned int i = 0; i < test_iterations[0]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
noise_ispc(x0, y0, x1, y1, width, height, buf); noise_ispc(x0, y0, x1, y1, width, height, buf);
double dt = get_elapsed_mcycles(); double dt = get_elapsed_mcycles();
@@ -115,7 +115,7 @@ int main(int argc, char *argv[]) {
// minimum time. // minimum time.
// //
double minSerial = 1e30; double minSerial = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (unsigned int i = 0; i < test_iterations[1]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
noise_serial(x0, y0, x1, y1, width, height, buf); noise_serial(x0, y0, x1, y1, width, height, buf);
double dt = get_elapsed_mcycles(); double dt = get_elapsed_mcycles();

View File

@@ -211,7 +211,7 @@ int main(int argc, char *argv[]) {
// Run 3 iterations with ispc + 1 core, record the minimum time // Run 3 iterations with ispc + 1 core, record the minimum time
// //
double minTimeISPC = 1e30; double minTimeISPC = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (uint i = 0; i < test_iterations[0]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
raytrace_ispc(width, height, baseWidth, baseHeight, raster2camera, raytrace_ispc(width, height, baseWidth, baseHeight, raster2camera,
camera2world, image, id, nodes, triangles); camera2world, image, id, nodes, triangles);
@@ -231,7 +231,7 @@ int main(int argc, char *argv[]) {
// Run 3 iterations with ispc + 1 core, record the minimum time // Run 3 iterations with ispc + 1 core, record the minimum time
// //
double minTimeISPCtasks = 1e30; double minTimeISPCtasks = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (uint i = 0; i < test_iterations[1]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
raytrace_ispc_tasks(width, height, baseWidth, baseHeight, raster2camera, raytrace_ispc_tasks(width, height, baseWidth, baseHeight, raster2camera,
camera2world, image, id, nodes, triangles); camera2world, image, id, nodes, triangles);
@@ -252,7 +252,7 @@ int main(int argc, char *argv[]) {
// minimum time. // minimum time.
// //
double minTimeSerial = 1e30; double minTimeSerial = 1e30;
for (int i = 0; i < test_iterations[2]; ++i) { for (uint i = 0; i < test_iterations[2]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
raytrace_serial(width, height, baseWidth, baseHeight, raster2camera, raytrace_serial(width, height, baseWidth, baseHeight, raster2camera,
camera2world, image, id, nodes, triangles); camera2world, image, id, nodes, triangles);

View File

@@ -37,6 +37,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <string>
#include <sstream>
#include <cassert> #include <cassert>
#include <iomanip> #include <iomanip>
#include "../timing.h" #include "../timing.h"
@@ -61,9 +63,9 @@ static void progressBar(const int x, const int n, const int width = 50)
bstr += "]"; bstr += "]";
// print percentage // print percentage
char pstr0[32]; std::stringstream pstr0;
sprintf(pstr0, " %2d %c ", static_cast<int>(f*100.0),'%'); pstr0 << " " << static_cast<int>(f*100.0) << " % ";
const std::string pstr(pstr0); const std::string pstr(pstr0.str());
std::copy(pstr.begin(), pstr.end(), bstr.begin() + (width/2-2)); std::copy(pstr.begin(), pstr.end(), bstr.begin() + (width/2-2));
std::cout << bstr; std::cout << bstr;

View File

@@ -102,7 +102,7 @@ int main(int argc, char *argv[]) {
// the minimum time of three runs. // the minimum time of three runs.
// //
double minTimeISPC = 1e30; double minTimeISPC = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (unsigned int i = 0; i < test_iterations[0]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
loop_stencil_ispc(0, 6, width, Nx - width, width, Ny - width, loop_stencil_ispc(0, 6, width, Nx - width, width, Ny - width,
width, Nz - width, Nx, Ny, Nz, coeff, vsq, width, Nz - width, Nx, Ny, Nz, coeff, vsq,
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
// the minimum time of three runs. // the minimum time of three runs.
// //
double minTimeISPCTasks = 1e30; double minTimeISPCTasks = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (unsigned int i = 0; i < test_iterations[1]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
loop_stencil_ispc_tasks(0, 6, width, Nx - width, width, Ny - width, loop_stencil_ispc_tasks(0, 6, width, Nx - width, width, Ny - width,
width, Nz - width, Nx, Ny, Nz, coeff, vsq, width, Nz - width, Nx, Ny, Nz, coeff, vsq,
@@ -140,7 +140,7 @@ int main(int argc, char *argv[]) {
// minimum time. // minimum time.
// //
double minTimeSerial = 1e30; double minTimeSerial = 1e30;
for (int i = 0; i < test_iterations[2]; ++i) { for (unsigned int i = 0; i < test_iterations[2]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
loop_stencil_serial(0, 6, width, Nx-width, width, Ny - width, loop_stencil_serial(0, 6, width, Nx-width, width, Ny - width,
width, Nz - width, Nx, Ny, Nz, coeff, vsq, width, Nz - width, Nx, Ny, Nz, coeff, vsq,

View File

@@ -163,7 +163,7 @@ int main(int argc, char *argv[]) {
// time of three runs. // time of three runs.
// //
double minISPC = 1e30; double minISPC = 1e30;
for (int i = 0; i < test_iterations[0]; ++i) { for (unsigned int i = 0; i < test_iterations[0]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
volume_ispc(density, n, raster2camera, camera2world, volume_ispc(density, n, raster2camera, camera2world,
width, height, image); width, height, image);
@@ -184,7 +184,7 @@ int main(int argc, char *argv[]) {
// tasks; report the minimum time of three runs. // tasks; report the minimum time of three runs.
// //
double minISPCtasks = 1e30; double minISPCtasks = 1e30;
for (int i = 0; i < test_iterations[1]; ++i) { for (unsigned int i = 0; i < test_iterations[1]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
volume_ispc_tasks(density, n, raster2camera, camera2world, volume_ispc_tasks(density, n, raster2camera, camera2world,
width, height, image); width, height, image);
@@ -205,7 +205,7 @@ int main(int argc, char *argv[]) {
// minimum time. // minimum time.
// //
double minSerial = 1e30; double minSerial = 1e30;
for (int i = 0; i < test_iterations[2]; ++i) { for (unsigned int i = 0; i < test_iterations[2]; ++i) {
reset_and_start_timer(); reset_and_start_timer();
volume_serial(density, n, raster2camera, camera2world, volume_serial(density, n, raster2camera, camera2world,
width, height, image); width, height, image);