diff --git a/examples/aobench_instrumented/ao.cpp b/examples/aobench_instrumented/ao.cpp index d8145757..f77d3f6a 100644 --- a/examples/aobench_instrumented/ao.cpp +++ b/examples/aobench_instrumented/ao.cpp @@ -35,6 +35,8 @@ #define NOMINMAX #pragma warning (disable: 4244) #pragma warning (disable: 4305) +// preventing MSVC fopen() deprecation complaints +#define _CRT_SECURE_NO_DEPRECATE #endif #include diff --git a/examples/aobench_instrumented/instrument.cpp b/examples/aobench_instrumented/instrument.cpp index 0aaebe9e..649bf9ae 100644 --- a/examples/aobench_instrumented/instrument.cpp +++ b/examples/aobench_instrumented/instrument.cpp @@ -34,6 +34,8 @@ #include "instrument.h" #include #include +#include +#include #include #include @@ -46,7 +48,7 @@ struct CallInfo { static std::map callInfo; -int countbits(int i) { +int countbits(uint64_t i) { int ret = 0; while (i) { if (i & 0x1) @@ -61,13 +63,12 @@ int countbits(int i) { // command-line flag is given while compiling. void ISPCInstrument(const char *fn, const char *note, int line, uint64_t mask) { - char sline[16]; - sprintf(sline, "%04d", line); - std::string s = std::string(fn) + std::string("(") + std::string(sline) + - std::string(") - ") + std::string(note); + std::stringstream s; + s << fn << "(" << std::setfill('0') << std::setw(4) << line << ") - " + << note; // Find or create a CallInfo instance for this callsite. - CallInfo &ci = callInfo[s]; + CallInfo &ci = callInfo[s.str()]; // And update its statistics... ++ci.count; diff --git a/examples/deferred/main.cpp b/examples/deferred/main.cpp index d7f62f50..3f86258d 100644 --- a/examples/deferred/main.cpp +++ b/examples/deferred/main.cpp @@ -89,7 +89,7 @@ int main(int argc, char** argv) { int nframes = test_iterations[2]; double ispcCycles = 1e30; - for (int i = 0; i < test_iterations[0]; ++i) { + for (unsigned int i = 0; i < test_iterations[0]; ++i) { framebuffer.clear(); reset_and_start_timer(); for (int j = 0; j < nframes; ++j) @@ -123,7 +123,7 @@ int main(int argc, char** argv) { #endif // __cilk double serialCycles = 1e30; - for (int i = 0; i < test_iterations[1]; ++i) { + for (unsigned int i = 0; i < test_iterations[1]; ++i) { framebuffer.clear(); reset_and_start_timer(); for (int j = 0; j < nframes; ++j) diff --git a/examples/mandelbrot/mandelbrot.cpp b/examples/mandelbrot/mandelbrot.cpp index 44ed508b..3372d7df 100644 --- a/examples/mandelbrot/mandelbrot.cpp +++ b/examples/mandelbrot/mandelbrot.cpp @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) { // time of three runs. // 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(); mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf); double dt = get_elapsed_mcycles(); @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { // minimum time. // 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(); mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf); double dt = get_elapsed_mcycles(); diff --git a/examples/mandelbrot_tasks/mandelbrot_tasks.cpp b/examples/mandelbrot_tasks/mandelbrot_tasks.cpp index 682987ae..44e5cf4d 100644 --- a/examples/mandelbrot_tasks/mandelbrot_tasks.cpp +++ b/examples/mandelbrot_tasks/mandelbrot_tasks.cpp @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) { // time of three runs. // 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 for (unsigned int i = 0; i < width * height; ++i) buf[i] = 0; @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) { // minimum time. // 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 for (unsigned int i = 0; i < width * height; ++i) buf[i] = 0; diff --git a/examples/noise/noise.cpp b/examples/noise/noise.cpp index 866340e0..d22d49ce 100644 --- a/examples/noise/noise.cpp +++ b/examples/noise/noise.cpp @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) { // time of three runs. // 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(); noise_ispc(x0, y0, x1, y1, width, height, buf); double dt = get_elapsed_mcycles(); @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) { // minimum time. // 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(); noise_serial(x0, y0, x1, y1, width, height, buf); double dt = get_elapsed_mcycles(); diff --git a/examples/rt/rt.cpp b/examples/rt/rt.cpp index 8f61656a..08fc575d 100644 --- a/examples/rt/rt.cpp +++ b/examples/rt/rt.cpp @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) { // Run 3 iterations with ispc + 1 core, record the minimum time // 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(); raytrace_ispc(width, height, baseWidth, baseHeight, raster2camera, 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 // 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(); raytrace_ispc_tasks(width, height, baseWidth, baseHeight, raster2camera, camera2world, image, id, nodes, triangles); @@ -252,7 +252,7 @@ int main(int argc, char *argv[]) { // minimum time. // 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(); raytrace_serial(width, height, baseWidth, baseHeight, raster2camera, camera2world, image, id, nodes, triangles); diff --git a/examples/sort/sort.cpp b/examples/sort/sort.cpp index 69e537a1..fc2d27b8 100644 --- a/examples/sort/sort.cpp +++ b/examples/sort/sort.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include #include "../timing.h" @@ -61,9 +63,9 @@ static void progressBar(const int x, const int n, const int width = 50) bstr += "]"; // print percentage - char pstr0[32]; - sprintf(pstr0, " %2d %c ", static_cast(f*100.0),'%'); - const std::string pstr(pstr0); + std::stringstream pstr0; + pstr0 << " " << static_cast(f*100.0) << " % "; + const std::string pstr(pstr0.str()); std::copy(pstr.begin(), pstr.end(), bstr.begin() + (width/2-2)); std::cout << bstr; diff --git a/examples/stencil/stencil.cpp b/examples/stencil/stencil.cpp index 5a7a9b23..add05821 100644 --- a/examples/stencil/stencil.cpp +++ b/examples/stencil/stencil.cpp @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) { // the minimum time of three runs. // 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(); loop_stencil_ispc(0, 6, width, Nx - width, width, Ny - width, width, Nz - width, Nx, Ny, Nz, coeff, vsq, @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) { // the minimum time of three runs. // 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(); loop_stencil_ispc_tasks(0, 6, width, Nx - width, width, Ny - width, width, Nz - width, Nx, Ny, Nz, coeff, vsq, @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) { // minimum time. // 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(); loop_stencil_serial(0, 6, width, Nx-width, width, Ny - width, width, Nz - width, Nx, Ny, Nz, coeff, vsq, diff --git a/examples/volume_rendering/volume.cpp b/examples/volume_rendering/volume.cpp index c79809f8..2605e320 100644 --- a/examples/volume_rendering/volume.cpp +++ b/examples/volume_rendering/volume.cpp @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) { // time of three runs. // 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(); volume_ispc(density, n, raster2camera, camera2world, width, height, image); @@ -184,7 +184,7 @@ int main(int argc, char *argv[]) { // tasks; report the minimum time of three runs. // 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(); volume_ispc_tasks(density, n, raster2camera, camera2world, width, height, image); @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) { // minimum time. // 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(); volume_serial(density, n, raster2camera, camera2world, width, height, image);