COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
graph_generator.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2010 The Trustees of Indiana University. */
2/* */
3/* Use, modification and distribution is subject to the Boost Software */
4/* License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at */
5/* http://www.boost.org/LICENSE_1_0.txt) */
6/* */
7/* Authors: Jeremiah Willcock */
8/* Andrew Lumsdaine */
9
10#ifndef GRAPH_GENERATOR_H
11#define GRAPH_GENERATOR_H
12
13#include "user_settings.h"
14#include <stdlib.h>
15#include <stdint.h>
16#include <stdio.h>
17
18#ifndef __STDC_FORMAT_MACROS
19#define __STDC_FORMAT_MACROS
20#endif
21#include <inttypes.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#ifdef GENERATOR_USE_PACKED_EDGE_TYPE
28
29typedef struct packed_edge {
32 uint32_t high; /* v1 in high half, v0 in low half */
34
35static inline int64_t get_v0_from_edge(const packed_edge* p) {
36 return (p->v0_low | ((int64_t)((int16_t)(p->high & 0xFFFF)) << 32));
37}
38
39static inline int64_t get_v1_from_edge(const packed_edge* p) {
40 return (p->v1_low | ((int64_t)((int16_t)(p->high >> 16)) << 32));
41}
42
43static inline void write_edge(packed_edge* p, int64_t v0, int64_t v1) {
44 p->v0_low = (uint32_t)v0;
45 p->v1_low = (uint32_t)v1;
46 p->high = ((v0 >> 32) & 0xFFFF) | (((v1 >> 32) & 0xFFFF) << 16);
47}
48
49#else
50
51typedef struct packed_edge {
52 int64_t v0;
53 int64_t v1;
55
56static inline int64_t get_v0_from_edge(const packed_edge* p) {
57 return p->v0;
58}
59
60static inline int64_t get_v1_from_edge(const packed_edge* p) {
61 return p->v1;
62}
63
64static inline void write_edge(packed_edge* p, int64_t v0, int64_t v1) {
65 p->v0 = v0;
66 p->v1 = v1;
67}
68
69#endif
70
71/* Generate a range of edges (from start_edge to end_edge of the total graph),
72 * writing into elements [0, end_edge - start_edge) of the edges array. This
73 * code is parallel on OpenMP and XMT; it must be used with
74 * separately-implemented SPMD parallelism for MPI. */
76 const uint_fast32_t seed[5] /* All values in [0, 2^31 - 1) */,
77 int logN /* In base 2 */,
78 int64_t start_edge, int64_t end_edge /* Indices (in [0, M)) for the edges to generate */,
79 packed_edge* edges /* Size >= end_edge - start_edge */
80);
81
82#ifdef __cplusplus
83}
84#endif
85
86#endif /* GRAPH_GENERATOR_H */
void generate_kronecker_range(const uint_fast32_t seed[5], int logN, int64_t start_edge, int64_t end_edge, packed_edge *edges)
long int64_t
Definition compat.h:21
unsigned int uint32_t
Definition stdint.h:80
uint32_t uint_fast32_t
Definition stdint.h:110
uint32_t v1_low
uint32_t v0_low