49 #include <sys/types.h> 61 #define HPCRUN_SAMPLE_PROB "HPCRUN_PROCESS_FRACTION" 62 #define DEFAULT_PROB 0.1 64 #define HASH_PRIME 2001001003 100 if (strchr(str,
'/') !=
NULL) {
101 if (sscanf(str,
"%d/%d", &x, &y) == 2 && y > 0) {
102 ans = (float)x / (
float)y;
109 if (sscanf(str,
"%f", &ans) < 1) {
134 uint64_t a, b, x, rand;
139 fd = open(
"/dev/urandom", O_RDONLY);
141 read(fd, &rand,
sizeof(rand));
145 gettimeofday(&tv,
NULL);
146 x = (((uint64_t)
OSUtil_hostid()) << 24) + (tv.tv_usec << 4) + rand;
147 x = (x & ~(((uint64_t) 15) << 60)) %
HASH_PRIME;
212 EMSG(
"malformed probability in %s (%s), using default value of %f",
static char * sample_prob_str
static float random_hash_prob(void)
void hpcrun_sample_prob_mesg(void)
static int prob_str_broken
static float string_to_prob(char *str)
#define HPCRUN_SAMPLE_PROB
int hpcrun_sample_prob_active(void)
void hpcrun_sample_prob_init(void)
static int sample_prob_ans
ssize_t MONITOR_EXT_WRAP_NAME() read(int fd, void *buf, size_t count)