summaryrefslogtreecommitdiff
path: root/BFS/support
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-05-14 13:43:55 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2025-05-14 13:43:55 +0200
commit4052d7b4c0e1a59419f07642b9a33088f5745d28 (patch)
tree23fb0907d1ffad55331e0e8fcf71ac2d876f4851 /BFS/support
parentaed00e149b8a3677a89416eaa112ea6c5249150b (diff)
BFS: AspectC++ (and behaviour model) support
Diffstat (limited to 'BFS/support')
-rw-r--r--BFS/support/common.h25
-rw-r--r--BFS/support/graph.h133
-rw-r--r--BFS/support/params.h67
-rw-r--r--BFS/support/timer.h31
-rw-r--r--BFS/support/utils.h10
5 files changed, 0 insertions, 266 deletions
diff --git a/BFS/support/common.h b/BFS/support/common.h
deleted file mode 100644
index 5f2aa0d..0000000
--- a/BFS/support/common.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _COMMON_H_
-#define _COMMON_H_
-
-#define ROUND_UP_TO_MULTIPLE_OF_2(x) ((((x) + 1)/2)*2)
-#define ROUND_UP_TO_MULTIPLE_OF_8(x) ((((x) + 7)/8)*8)
-#define ROUND_UP_TO_MULTIPLE_OF_64(x) ((((x) + 63)/64)*64)
-
-#define setBit(val, idx) (val) |= (1 << (idx))
-#define isSet(val, idx) ((val) & (1 << (idx)))
-
-struct DPUParams {
- uint32_t dpuNumNodes; /* The number of nodes assigned to this DPU */
- uint32_t numNodes; /* Total number of nodes in the graph */
- uint32_t dpuStartNodeIdx; /* The index of the first node assigned to this DPU */
- uint32_t dpuNodePtrsOffset; /* Offset of the node pointers */
- uint32_t level; /* The current BFS level */
- uint32_t dpuNodePtrs_m;
- uint32_t dpuNeighborIdxs_m;
- uint32_t dpuNodeLevel_m;
- uint32_t dpuVisited_m;
- uint32_t dpuCurrentFrontier_m;
- uint32_t dpuNextFrontier_m;
-};
-
-#endif
diff --git a/BFS/support/graph.h b/BFS/support/graph.h
deleted file mode 100644
index 2a19f67..0000000
--- a/BFS/support/graph.h
+++ /dev/null
@@ -1,133 +0,0 @@
-
-#ifndef _GRAPH_H_
-#define _GRAPH_H_
-
-#include <assert.h>
-#include <stdio.h>
-
-#include "common.h"
-#include "utils.h"
-
-struct COOGraph {
- uint32_t numNodes;
- uint32_t numEdges;
- uint32_t *nodeIdxs;
- uint32_t *neighborIdxs;
-};
-
-struct CSRGraph {
- uint32_t numNodes;
- uint32_t numEdges;
- uint32_t *nodePtrs;
- uint32_t *neighborIdxs;
-};
-
-static struct COOGraph readCOOGraph(const char *fileName)
-{
-
- struct COOGraph cooGraph;
-
- // Initialize fields
- FILE *fp = fopen(fileName, "r");
- uint32_t numNodes, numCols;
- assert(fscanf(fp, "%u", &numNodes));
- assert(fscanf(fp, "%u", &numCols));
- if (numNodes == numCols) {
- cooGraph.numNodes = numNodes;
- } else {
- PRINT_WARNING
- (" Adjacency matrix is not square. Padding matrix to be square.");
- cooGraph.numNodes = (numNodes > numCols) ? numNodes : numCols;
- }
- if (cooGraph.numNodes % 64 != 0) {
- PRINT_WARNING
- (" Adjacency matrix dimension is %u which is not a multiple of 64 nodes.",
- cooGraph.numNodes);
- cooGraph.numNodes += (64 - cooGraph.numNodes % 64);
- PRINT_WARNING
- (" Padding to %u which is a multiple of 64 nodes.",
- cooGraph.numNodes);
- }
- assert(fscanf(fp, "%u", &cooGraph.numEdges));
- cooGraph.nodeIdxs =
- (uint32_t *) malloc(cooGraph.numEdges * sizeof(uint32_t));
- cooGraph.neighborIdxs =
- (uint32_t *) malloc(cooGraph.numEdges * sizeof(uint32_t));
-
- // Read the neighborIdxs
- for (uint32_t edgeIdx = 0; edgeIdx < cooGraph.numEdges; ++edgeIdx) {
- uint32_t nodeIdx;
- assert(fscanf(fp, "%u", &nodeIdx));
- cooGraph.nodeIdxs[edgeIdx] = nodeIdx;
- uint32_t neighborIdx;
- assert(fscanf(fp, "%u", &neighborIdx));
- cooGraph.neighborIdxs[edgeIdx] = neighborIdx;
- }
-
- return cooGraph;
-
-}
-
-static void freeCOOGraph(struct COOGraph cooGraph)
-{
- free(cooGraph.nodeIdxs);
- free(cooGraph.neighborIdxs);
-}
-
-static struct CSRGraph coo2csr(struct COOGraph cooGraph)
-{
-
- struct CSRGraph csrGraph;
-
- // Initialize fields
- csrGraph.numNodes = cooGraph.numNodes;
- csrGraph.numEdges = cooGraph.numEdges;
- csrGraph.nodePtrs =
- (uint32_t *)
- calloc(ROUND_UP_TO_MULTIPLE_OF_2(csrGraph.numNodes + 1),
- sizeof(uint32_t));
- csrGraph.neighborIdxs =
- (uint32_t *)
- malloc(ROUND_UP_TO_MULTIPLE_OF_8
- (csrGraph.numEdges * sizeof(uint32_t)));
-
- // Histogram nodeIdxs
- for (uint32_t i = 0; i < cooGraph.numEdges; ++i) {
- uint32_t nodeIdx = cooGraph.nodeIdxs[i];
- csrGraph.nodePtrs[nodeIdx]++;
- }
-
- // Prefix sum nodePtrs
- uint32_t sumBeforeNextNode = 0;
- for (uint32_t nodeIdx = 0; nodeIdx < csrGraph.numNodes; ++nodeIdx) {
- uint32_t sumBeforeNode = sumBeforeNextNode;
- sumBeforeNextNode += csrGraph.nodePtrs[nodeIdx];
- csrGraph.nodePtrs[nodeIdx] = sumBeforeNode;
- }
- csrGraph.nodePtrs[csrGraph.numNodes] = sumBeforeNextNode;
-
- // Bin the neighborIdxs
- for (uint32_t i = 0; i < cooGraph.numEdges; ++i) {
- uint32_t nodeIdx = cooGraph.nodeIdxs[i];
- uint32_t neighborListIdx = csrGraph.nodePtrs[nodeIdx]++;
- csrGraph.neighborIdxs[neighborListIdx] =
- cooGraph.neighborIdxs[i];
- }
-
- // Restore nodePtrs
- for (uint32_t nodeIdx = csrGraph.numNodes - 1; nodeIdx > 0; --nodeIdx) {
- csrGraph.nodePtrs[nodeIdx] = csrGraph.nodePtrs[nodeIdx - 1];
- }
- csrGraph.nodePtrs[0] = 0;
-
- return csrGraph;
-
-}
-
-static void freeCSRGraph(struct CSRGraph csrGraph)
-{
- free(csrGraph.nodePtrs);
- free(csrGraph.neighborIdxs);
-}
-
-#endif
diff --git a/BFS/support/params.h b/BFS/support/params.h
deleted file mode 100644
index f9169bc..0000000
--- a/BFS/support/params.h
+++ /dev/null
@@ -1,67 +0,0 @@
-
-#ifndef _PARAMS_H_
-#define _PARAMS_H_
-
-#include "common.h"
-#include "utils.h"
-
-static void usage()
-{
- PRINT("\nUsage: ./program [options]"
- "\n"
- "\nBenchmark-specific options:"
- "\n -f <F> input matrix file name (default=data/roadNet-CA.txt)"
- "\n"
- "\nGeneral options:"
- "\n -v <V> verbosity" "\n -h help" "\n\n");
-}
-
-typedef struct Params {
- const char *fileName;
- unsigned int verbosity;
-#if NUMA
- struct bitmask *bitmask_in;
- int numa_node_cpu;
-#endif
-} Params;
-
-static struct Params input_params(int argc, char **argv)
-{
- struct Params p;
- p.fileName = "data/roadNet-CA.txt";
- p.verbosity = 0;
-#if NUMA
- p.bitmask_in = NULL;
- p.numa_node_cpu = -1;
-#endif
- int opt;
- while ((opt = getopt(argc, argv, "f:v:hA:C:")) >= 0) {
- switch (opt) {
- case 'f':
- p.fileName = optarg;
- break;
- case 'v':
- p.verbosity = atoi(optarg);
- break;
-#if NUMA
- case 'A':
- p.bitmask_in = numa_parse_nodestring(optarg);
- break;
- case 'C':
- p.numa_node_cpu = atoi(optarg);
- break;
-#endif
- case 'h':
- usage();
- exit(0);
- default:
- PRINT_ERROR("Unrecognized option!");
- usage();
- exit(0);
- }
- }
-
- return p;
-}
-
-#endif
diff --git a/BFS/support/timer.h b/BFS/support/timer.h
deleted file mode 100644
index 63b5567..0000000
--- a/BFS/support/timer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#ifndef _TIMER_H_
-#define _TIMER_H_
-
-#include <stdio.h>
-#include <sys/time.h>
-
-typedef struct Timer {
- struct timeval startTime[8];
- struct timeval stopTime[8];
- double time[8];
-} Timer;
-
-static void startTimer(Timer *timer, int i, int rep)
-{
- if (rep == 0) {
- timer->time[i] = 0.0;
- }
- gettimeofday(&timer->startTime[i], NULL);
-}
-
-static void stopTimer(Timer *timer, int i)
-{
- gettimeofday(&timer->stopTime[i], NULL);
- timer->time[i] +=
- (timer->stopTime[i].tv_sec -
- timer->startTime[i].tv_sec) * 1000000.0 +
- (timer->stopTime[i].tv_usec - timer->startTime[i].tv_usec);
-}
-
-#endif
diff --git a/BFS/support/utils.h b/BFS/support/utils.h
deleted file mode 100644
index ccd8fbd..0000000
--- a/BFS/support/utils.h
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#ifndef _UTILS_H_
-#define _UTILS_H_
-
-#define PRINT_ERROR(fmt, ...) fprintf(stderr, "\033[0;31mERROR:\033[0m " fmt "\n", ##__VA_ARGS__)
-#define PRINT_WARNING(fmt, ...) fprintf(stderr, "\033[0;35mWARNING:\033[0m " fmt "\n", ##__VA_ARGS__)
-#define PRINT_INFO(cond, fmt, ...) if(cond) printf("\033[0;32mINFO:\033[0m " fmt "\n", ##__VA_ARGS__);
-#define PRINT(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
-
-#endif