Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows compile issues #89

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
endif()


################################################################################
# Cross Platform Definitions
################################################################################

if(MSVC)
# Make M_PI (found in <cmath>) available on Windows
add_definitions(/D_USE_MATH_DEFINES)
endif(MSVC)


###############################################################################
# Warning for Thrust-related Bug
###############################################################################
Expand Down Expand Up @@ -189,23 +199,21 @@ warn_path_cuda("C_INCLUDE_PATH")
# Executables
###############################################################################
set(HASEonGPU_NAME "calcPhiASE")

file(GLOB SRCFILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c*")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

if(NOT MPI_FOUND)
LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/include/calc_phi_ase_mpi.cc)
LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/src/calc_phi_ase_mpi.cc)
endif()

if(Boost_MPI_FOUND)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include/graybat)
else ()
LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/include/calc_phi_ase_graybat.cc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/graybat)
else()
LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/src/calc_phi_ase_graybat.cc)
endif()

cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

cuda_add_executable(${HASEonGPU_NAME} ${SRCFILES})

target_link_libraries(${HASEonGPU_NAME} ${LIBS} ${CUDA_CUDART_LIBRARY})


Expand Down
1 change: 0 additions & 1 deletion src/calc_phi_ase.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/


#define _USE_MATH_DEFINES /* make M_PI known for windows */
#include <cmath>
#include <cassert>
#include <cstdlib>
Expand Down
40 changes: 40 additions & 0 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include <iostream>

#ifdef _WIN32
#include <Windows.h>
#endif

#include <logging.hpp>


Expand All @@ -35,29 +39,65 @@ std::ostream& dout(unsigned activation_level) {
}

if(activation_level & V_ERROR){
#ifdef _WIN32
HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
return std::cerr << "[ERROR] ";
#else
return std::cerr << "\033[0;" << COLOR_ERROR << "m[ERROR] ";
#endif
}

if(activation_level & V_WARNING){
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
return std::cerr << "[WARNING] ";
#else
return std::cerr << "\033[0;" << COLOR_WARN << "m[WARNING] ";
#endif
}

if(activation_level & V_INFO){
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
return std::cerr << "[INFO] ";
#else
//return std::cout << "\033[0;" << COLOR_INFO << "m[INFO] ";
return std::cout << "\033[0" << "m[INFO] ";
#endif
}

if(activation_level & V_STAT){
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
return std::cerr << "[STATISTIC] ";
#else
//return std::cout << "\033[0;" << COLOR_STATISTIC << "m[STATISTIC] ";
return std::cout << "\033[0" << "m[STATISTIC] ";
#endif
}

if(activation_level & V_PROGRESS){
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
return std::cerr << "[PROGRESS] ";
#else
return std::cout << "\033[0" << "m[PROGRESS] ";
#endif
}

if(activation_level & V_DEBUG){
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
return std::cerr << "[DEBUG] ";
#else
return std::cerr << "\033[0;" << COLOR_DEBUG << "m[DEBUG] ";
#endif
}


Expand Down
1 change: 0 additions & 1 deletion src/mesh.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <string>
#include <cassert>
#include <cfloat>
#define _USE_MATH_DEFINES /* make M_PI known for windows */
#include <cmath>
#include <algorithm>

Expand Down
1 change: 0 additions & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#define _USE_MATH_DEFINES /* make M_PI known for windows */
#include <cmath> /* M_PI */
#include <string> /* string */
#include <vector> /* vector */
Expand Down
32 changes: 30 additions & 2 deletions src/progressbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ void printWave(std::ostream &stream, unsigned tic, int progress, int length){
}


/**
* @brief prints a simplistic line of ascii-art
*
* @param stream the stream to which to write the output
* @param progress the progress of the whole process (i.e. 90, if the process ranges
* from 0-100 and the progress is at 90%
* progress must be <= length! (normalize progress in order to acheive this)
* @param length the length of the finished bar.
* length must be at least as long as the progress!
*/
void printBar(std::ostream &stream, int progress, int length){
for (int i = 0; i<progress; ++i){
stream << "#";
}
for (int i = 0; i < length - progress; ++i){
stream << " ";
}
}


/**
* Writes the time in a human-friendly way
*
Expand Down Expand Up @@ -102,11 +122,15 @@ std::string humanRepresentation(chr::duration<float> const time){

void fancyProgressBar(const unsigned nTotal){

#ifdef _WIN32
const int length = 16;
#else
const int length = 50;
#endif

//use maxNTotal to find the global maximum between multiple calling threads
static unsigned maxNTotal = 0;
static chr::time_point<chr::steady_clock> startTime;
static chr::time_point < chr::steady_clock::time_point::clock > startTime;
static unsigned part = 0;

//find the starting time of the whole progress
Expand All @@ -127,8 +151,12 @@ void fancyProgressBar(const unsigned nTotal){
const auto timeRemaining = timeTotal-timeSpent;

dout(V_PROGRESS | V_NOLABEL) << "\r";
dout(V_PROGRESS) << "Progress: [";
dout(V_PROGRESS) << "[";
#ifdef _WIN32
printBar(dout(V_PROGRESS | V_NOLABEL), int(percentage*length), length);
#else
printWave(dout(V_PROGRESS | V_NOLABEL), tic, int(percentage*length), length);
#endif
dout(V_PROGRESS | V_NOLABEL) << "] ";

dout(V_PROGRESS | V_NOLABEL) << std::setfill(' ') << std::setw(3) << int(percentage*100) << "%";
Expand Down
36 changes: 35 additions & 1 deletion src/ray_histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <map>
#include <cmath>

#ifdef _WIN32
#include <Windows.h>
#endif

#include <logging.hpp>

void ray_histogram(const std::vector<unsigned> totalRays, const unsigned max, const double mseThreshold, const std::vector<double> mseValues){
Expand Down Expand Up @@ -56,6 +60,7 @@ void ray_histogram(const std::vector<unsigned> totalRays, const unsigned max, co

std::map<unsigned,unsigned>::iterator itG;
std::map<unsigned,unsigned>::iterator itR;
#ifndef _WIN32
for(itG=histGreen.begin(), itR=histRed.begin(); itG!=histGreen.end(); ++itG, ++itR){
dout(V_STAT) << std::setw(fillwidth) << std::setfill(' ') << itG->first << " (";
dout(V_STAT | V_NOLABEL) << "\033[0;32m" << std::setw(log10(totalRays.size())+3) << itG->second << "x";
Expand All @@ -66,7 +71,7 @@ void ray_histogram(const std::vector<unsigned> totalRays, const unsigned max, co
// set color = green
dout(V_STAT | V_NOLABEL) << "\033[0;32m";
for(unsigned j=0;j< ceil(maxLength*(float(itG->second)/totalRays.size())) ; ++j){
dout(V_STAT | V_NOLABEL) << "#";
dout(V_STAT | V_NOLABEL) << "#";
}

// set color = red
Expand All @@ -76,4 +81,33 @@ void ray_histogram(const std::vector<unsigned> totalRays, const unsigned max, co
}
dout(V_STAT | V_NOLABEL) << std::endl;
}

#else
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for(itG=histGreen.begin(), itR=histRed.begin(); itG!=histGreen.end(); ++itG, ++itR){
dout(V_STAT) << std::setw(fillwidth) << std::setfill(' ') << itG->first << " (";
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
dout(V_STAT | V_NOLABEL) << std::setw(log10(totalRays.size())+3) << itG->second << "x";
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
dout(V_STAT | V_NOLABEL) << " / ";
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
dout(V_STAT | V_NOLABEL) << std::setw(log10(totalRays.size())+3) << itR->second << "x";
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
dout(V_STAT | V_NOLABEL) << "):";

// set color = green
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
for(unsigned j=0;j< ceil(maxLength*(float(itG->second)/totalRays.size())) ; ++j){
dout(V_STAT | V_NOLABEL) << "#";
}

// set color = red
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
for(unsigned j=0;j< ceil(maxLength*(float(itR->second)/totalRays.size())) ; ++j){
dout(V_STAT | V_NOLABEL) << "#";
}
dout(V_STAT | V_NOLABEL) << std::endl;
}
#endif

}
2 changes: 1 addition & 1 deletion src/reflection.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


#include <cassert>
#define _USE_MATH_DEFINES /* make M_PI known for windows */
#include <cmath> /* M_PI */

#include <reflection.hpp>
#include <mesh.hpp>
#include <geometry.hpp>
Expand Down
6 changes: 6 additions & 0 deletions src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ const std::string DeviceMode::CPU = "cpu";

const std::string ParallelMode::NONE = "no_parallel_mode";
const std::string ParallelMode::THREADED = "threaded";

#if defined(MPI_FOUND)
const std::string ParallelMode::MPI = "mpi";
#endif

#if defined(BOOST_MPI_FOUND) || defined(ZMQ_FOUND)
const std::string ParallelMode::GRAYBAT = "graybat";
#endif

const std::string CompSwitch::parallel_mode = "parallel-mode";
const std::string CompSwitch::device_mode = "device-mode";
Expand Down
2 changes: 1 addition & 1 deletion src/write_to_vtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ std::vector<double> compareVtk(std::vector<double> compare, const fs::path filen
double smallDiff = 10;

// No compare vtk was given
if(!filename.compare("")){
if(!filename.compare(fs::path(""))){
return std::vector<double>();
}
dout(V_INFO) << "Compare solution with " << filename << std::endl;
Expand Down