/* Copyright (C) 2009-2010 The Trustees of Indiana University. */ /* */ /* Use, modification and distribution is subject to the Boost Software */ /* License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at */ /* http://www.boost.org/LICENSE_1_0.txt) */ /* */ /* Authors: Jeremiah Willcock */ /* Andrew Lumsdaine */ #include #include #include #include #include #include #include #ifdef __MTA__ #include #endif #ifdef GRAPH_GENERATOR_OMP #include #endif /* Simplified interface to build graphs with scrambled vertices. */ #include "graph_generator.h" #include "utils.h" #ifndef GRAPH_GENERATOR_MPI void make_graph(int log_numverts, int64_t M, uint64_t userseed1, uint64_t userseed2, int64_t* nedges_ptr_in, packed_edge** result_ptr_in) { /* Add restrict to input pointers. */ int64_t* restrict nedges_ptr = nedges_ptr_in; packed_edge* restrict* restrict result_ptr = result_ptr_in; /* Spread the two 64-bit numbers into five nonzero values in the correct * range. */ uint_fast32_t seed[5]; make_mrg_seed(userseed1, userseed2, seed); *nedges_ptr = M; packed_edge* edges = (packed_edge*)xmalloc(M * sizeof(packed_edge)); *result_ptr = edges; /* In OpenMP and XMT versions, the inner loop in generate_kronecker_range is * parallel. */ generate_kronecker_range(seed, log_numverts, 0, M, edges); } #endif /* !GRAPH_GENERATOR_MPI */ /* PRNG interface for implementations; takes seed in same format as given by * users, and creates a vector of doubles in a reproducible (and * random-access) way. */ void make_random_numbers( /* in */ int64_t nvalues /* Number of values to generate */, /* in */ uint64_t userseed1 /* Arbitrary 64-bit seed value */, /* in */ uint64_t userseed2 /* Arbitrary 64-bit seed value */, /* in */ int64_t position /* Start index in random number stream */, /* out */ double* result /* Returned array of values */ ) { int64_t i; uint_fast32_t seed[5]; make_mrg_seed(userseed1, userseed2, seed); mrg_state st; mrg_seed(&st, seed); mrg_skip(&st, 2, 0, 2 * (uint64_t)position); /* Each double takes two PRNG outputs */ for (i = 0; i < nvalues; ++i) { result[i] = mrg_get_double_orig(&st); } }