All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 063422d4 authored by Robert Ricci's avatar Robert Ricci

Sigh, more 'porting'. In gcc 2.95, we have to use std::random() to

disambiguate from boost's random() function. But, for some reason,
with 3.x, random() doesn't live in the std:: namespace. Macro-ize it.
parent d7f45ef6
......@@ -58,7 +58,7 @@ inline int accept(double change, double temperature)
} else {
p = expf(change/temperature) * 1000;
}
r = random() % 1000;
r = RANDOM() % 1000;
if (r < p) {
return 1;
}
......@@ -182,8 +182,8 @@ tb_pnode *find_pnode_connected(vvertex vv, tb_vnode *vn) {
visit_order[i] = *vedge_it;
}
for (int i = 0; i < visit_order.size(); i++) {
int i1 = random() % visit_order.size();
int i2 = random() % visit_order.size();
int i1 = RANDOM() % visit_order.size();
int i2 = RANDOM() % visit_order.size();
vedge tmp = visit_order[i1];
visit_order[i1] = visit_order[i2];
visit_order[i2] = tmp;
......@@ -241,8 +241,8 @@ tb_pnode *find_pnode(tb_vnode *vn)
traversal_order[i] = i;
}
for (int i = 0; i < num_types; i++) {
int i1 = random() % num_types;
int i2 = random() % num_types;
int i1 = RANDOM() % num_types;
int i2 = RANDOM() % num_types;
int tmp = traversal_order[i1];
traversal_order[i1] = traversal_order[i2];
traversal_order[i2] = tmp;
......@@ -451,7 +451,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
absassignment[*vit] = vn->assignment;
abstypes[*vit] = vn->type;
} else {
unassigned_nodes.push(vvertex_int_pair(*vit,random()));
unassigned_nodes.push(vvertex_int_pair(*vit,RANDOM()));
}
}
......@@ -585,7 +585,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
assert(!get(vvertex_pmap,vv)->assigned);
unassigned_nodes.pop();
} else {
int start = random()%nnodes;
int start = RANDOM()%nnodes;
int choice = start;
while (get(vvertex_pmap,virtual_nodes[choice])->fixed) {
choice = (choice +1) % nnodes;
......@@ -626,7 +626,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
// Actually find a pnode
tb_pnode *newpnode = NULL;
if ((use_connected_pnode_find != 0)
&& ((random() % 1000) < (use_connected_pnode_find * 1000))) {
&& ((RANDOM() % 1000) < (use_connected_pnode_find * 1000))) {
newpnode = find_pnode_connected(vv,vn);
}
if (newpnode == NULL) {
......@@ -641,7 +641,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
if (newpnode == NULL) {
// We're not going to be re-assigning this one
#ifndef SMART_UNMAP
unassigned_nodes.push(vvertex_int_pair(vv,random()));
unassigned_nodes.push(vvertex_int_pair(vv,RANDOM()));
#endif
// need to free up nodes
#ifdef SMART_UNMAP
......@@ -656,7 +656,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
pclass_vector *acceptable_types = tt.second;
// Find a node to kick out
bool foundnode = false;
int offi = random();
int offi = RANDOM();
int index;
for (int i = 0; i < size; i++) {
index = (i + offi) % size;
......@@ -675,14 +675,14 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
assert((*acceptable_types)[index]->used_members[vn->type]->size());
tb_pclass::tb_pnodeset::iterator it =
(*acceptable_types)[index]->used_members[vn->type]->begin();
int j = random() %
int j = RANDOM() %
(*acceptable_types)[index]->used_members[vn->type]->size();
while (j > 0) {
it++;
j--;
}
tb_vnode_set::iterator it2 = (*it)->assigned_nodes.begin();
int k = random() % (*it)->assigned_nodes.size();
int k = RANDOM() % (*it)->assigned_nodes.size();
while (k > 0) {
it2++;
k--;
......@@ -693,13 +693,13 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
newpnode = *it;
remove_node(toremove);
unassigned_nodes.push(vvertex_int_pair(toremove,
random()));
RANDOM()));
} else {
cerr << "Failed to find a replacement!" << endl;
}
#else
int start = random()%nnodes;
int start = RANDOM()%nnodes;
int toremove = start;
#ifdef SMART_UNMAP
......@@ -748,7 +748,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
RDEBUG(cout << "removing: freeing up nodes" << endl;)
remove_node(virtual_nodes[toremove]);
unassigned_nodes.push(vvertex_int_pair(virtual_nodes[toremove],
random()));
RANDOM()));
}
continue;
#endif /* SMART_UNMAP */
......@@ -786,12 +786,12 @@ void anneal(bool scoring_selftest, double scale_neighborhood,
}
}
if (add_node(vv,newpos,false,false) != 0) {
unassigned_nodes.push(vvertex_int_pair(vv,random()));
unassigned_nodes.push(vvertex_int_pair(vv,RANDOM()));
continue;
}
} else {
#ifdef SMART_UNMAP
unassigned_nodes.push(vvertex_int_pair(vv,random()));
unassigned_nodes.push(vvertex_int_pair(vv,RANDOM()));
#endif
if (freednode) {
continue;
......
......@@ -14,8 +14,10 @@
#if __GNUC__ == 3 && __GNUC_MINOR__ > 0
#include <ext/hash_map>
using namespace __gnu_cxx;
#define RANDOM() random()
#else
#include <hash_map>
#define RANDOM() std::random()
#endif
#include "config.h"
......
......@@ -1067,7 +1067,7 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
int index;
if (!deterministic && !greedy_link_assignment) {
float choice;
choice = random()%(int)total_weight;
choice = RANDOM()%(int)total_weight;
for (index = 0;index < resolution_index;++index) {
switch (resolutions[index].type_used) {
case tb_link_info::LINK_DIRECT:
......
......@@ -77,10 +77,10 @@ crope tb_vclass::choose_type()
{
// This may take some tweaking - i.e. might want to make more
// efficient, although members is usually a very small hash.
if (random()%2 == 0) {
if (RANDOM()%2 == 0) {
return dominant;
}
int r = random()%members.size();
int r = RANDOM()%members.size();
members_map::iterator dit;
for (dit=members.begin();dit != members.end();++dit) {
if (r == 0) break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment