Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
monkins1010 authored Feb 6, 2019
1 parent 16c4bcb commit afd29cc
Show file tree
Hide file tree
Showing 7 changed files with 2,193 additions and 1,904 deletions.
15 changes: 14 additions & 1 deletion Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

#define HIGH_RESOURCE true
#define NVML false
#define CPU_SHARES false
#define CPU_SHARES false
#define BENCHMARK false

#if HIGH_RESOURCE
#define DEFAULT_BLOCK_SIZE 512
#define DEFAULT_THREADS_PER_BLOCK 1024
#else
#define DEFAULT_BLOCK_SIZE 512
#define DEFAULT_THREADS_PER_BLOCK 512
#endif

#if CPU_SHARES
#define WORK_PER_THREAD 256
#else
#define WORK_PER_THREAD 256
#endif
152 changes: 77 additions & 75 deletions Log.h
Original file line number Diff line number Diff line change
@@ -1,98 +1,100 @@
#pragma once
#pragma comment(lib,"Ws2_32.lib")
#pragma comment(lib, "Ws2_32.lib")

#include <fstream>
#include <chrono>
#include <cstring>
#include <iostream>
#include <string>

#ifdef _WIN32
#include <Windows.h>
#elif __linux__
#define boolean bool
#define byte uint8_t
#endif
#include <iostream>
#include <string>
#include <chrono>

#define LOG_FILE "cuda-miner.log"

using namespace std;

class Log {
private:
public:
static inline bool& log()
{
static bool opt = true;
return opt;
}
// TODO(mks): Rework logging.
extern bool verboseOutput;
extern char outputBuffer[8192];
extern void vprintf(char* toprint);
extern void promptExit(int exitCode);

static void setEnabled(bool enabled) {
log() = enabled;
}

static void info(char* toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile.write(toLog, strlen(toLog));
logfile.write("\n", 2);
logfile.close();
}
}
class Log {
public:
static inline bool& log() {
static bool opt = true;
return opt;
}

static void info(string &toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile << toLog << endl;
logfile.close();
}
}
static void setEnabled(bool enabled) { log() = enabled; }

static void warn(char* toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile.write("[WARN] ", 8);
logfile.write(toLog, strlen(toLog));
logfile.write("\n", 2);
logfile.close();
}
}
static void info(char* toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile.write(toLog, strlen(toLog));
logfile.write("\n", 2);
logfile.close();
}
}

static void warn(string &toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile << "[WARN] " << toLog << endl;
logfile.close();
}
}
static void info(string& toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile << toLog << endl;
logfile.close();
}
}

static void warn(char* toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile.write("[WARN] ", 8);
logfile.write(toLog, strlen(toLog));
logfile.write("\n", 2);
logfile.close();
}
}

static void error(char* toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile.write("[ERROR] ", 9);
logfile.write(toLog, strlen(toLog));
logfile.write("\n", 2);
logfile.close();
}
}
static void warn(string& toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile << "[WARN] " << toLog << endl;
logfile.close();
}
}

static void error(char* toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile.write("[ERROR] ", 9);
logfile.write(toLog, strlen(toLog));
logfile.write("\n", 2);
logfile.close();
}
}

static void error(string &toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile << "[ERROR] " << toLog << endl;
logfile.close();
}
}
static void error(string& toLog) {
if (log()) {
static std::ofstream logfile;
logfile = ofstream();
logfile.open(LOG_FILE, ios::app | ios::out);
logfile << "[ERROR] " << toLog << endl;
logfile.close();
}
}
};
Loading

0 comments on commit afd29cc

Please sign in to comment.