Skip to content

Commit dbc37b3

Browse files
changed defines to enum class
1 parent f0ae727 commit dbc37b3

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

Simulator/Core/GPUModel.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "AllVertices.h"
1414
#include "Connections.h"
1515
#include "Global.h"
16-
#include "NvtxHelper.h"
1716

1817
#ifdef PERFORMANCE_METRICS
1918
float g_time;
@@ -187,11 +186,9 @@ void GPUModel::calcSummationPoint()
187186
int blocksPerGrid
188187
= (Simulator::getInstance().getTotalVertices() + threadsPerBlock - 1) / threadsPerBlock;
189188

190-
nvtxPushColor("calcSummation", GREEN);
191189
calcSummationPointDevice<<<blocksPerGrid, threadsPerBlock>>>(
192190
Simulator::getInstance().getTotalVertices(), allVerticesDevice_, synapseIndexMapDevice_,
193191
allEdgesDevice_);
194-
nvtxPop();
195192
}
196193

197194
/// Update the connection of all the Neurons and Synapses of the simulation.

Simulator/Utils/NvtxHelper.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
/**
2+
* @file NvtxHelper.cpp
3+
*
4+
* @ingroup Simulator/Utils
5+
*
6+
* @brief Helper functions to enable nvtx profiling
7+
* When ENABLE_NVTX is false the functions are replaced with blank inline functions which are removed by the compiler
8+
* This file is only included in the utils library when ENABLE_CUDA=YES
9+
*/
10+
111
#include "NvtxHelper.h"
212
#include <cuda_runtime.h>
313
#include <nvToolsExt.h>
414

5-
void nvtxPushColor(const std::string &name, uint32_t color)
15+
void nvtxPushColor(const std::string &name, Color pColor)
616
{
717
nvtxEventAttributes_t eventAttrib = {};
818
eventAttrib.version = NVTX_VERSION;
919
eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1020
eventAttrib.colorType = NVTX_COLOR_ARGB;
11-
eventAttrib.color = color;
21+
eventAttrib.color = static_cast<uint32_t>(pColor);
1222
eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
1323
eventAttrib.message.ascii = name.c_str();
1424

Simulator/Utils/NvtxHelper.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1+
/**
2+
* @file NvtxHelper.h
3+
*
4+
* @ingroup Simulator/Utils
5+
*
6+
* @brief Helper functions to enable nvtx profiling
7+
* When ENABLE_NVTX is false the functions are replaced with blank inline functions which are removed by the compiler
8+
*/
9+
110
#ifndef NVTX_HELPER_H
211
#define NVTX_HELPER_H
312

413
#include <cstdint>
514
#include <string>
615

716
// Define NVTX colors (ARGB format)
8-
#define RED 0xFFFF0000 // Red
9-
#define GREEN 0xFF00FF00 // Green
10-
#define BLUE 0xFF0000FF // Blue
11-
#define YELLOW 0xFFFFFF00 // Yellow
12-
#define ORANGE 0xFFFFA500 // Orange
13-
#define PURPLE 0xFF800080 // Purple
17+
enum class Color : std::uint32_t {
18+
RED = 0xFFFF0000,
19+
GREEN = 0xFF00FF00,
20+
BLUE = 0xFF0000FF,
21+
YELLOW = 0xFFFFFF00,
22+
ORANGE = 0xFFFFA500,
23+
PURPLE = 0xFF800080
24+
};
1425

1526
#ifdef ENABLE_NVTX
1627

1728
// Function to push an NVTX range with a given name and color
18-
void nvtxPushColor(const std::string &name, uint32_t color);
29+
void nvtxPushColor(const std::string &name, Color pColor);
1930

2031
// Function to pop the most recent NVTX range
2132
void nvtxPop();
2233

2334
#else
24-
inline void nvtxPushColor(const std::string &, uint32_t)
35+
inline void nvtxPushColor(const std::string &, Color)
2536
{
2637
}
2738
inline void nvtxPop()

0 commit comments

Comments
 (0)