File: delay.c

package info (click to toggle)
gasnet 2025.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,424 kB
  • sloc: ansic: 114,758; cpp: 5,158; sh: 4,847; makefile: 2,715; perl: 1,774
file content (37 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*   $Source: bitbucket.org:berkeleylab/gasnet.git/tests/delay.c $
 * Description: 
 * Copyright 2004, The Regents of the University of California
 * Terms of use are as specified in license.txt
 */


#include <float.h>
#include <gasnetex.h>
#include <gasnet_tools.h>

static volatile float x, y;
static volatile float z = (1.00001);

float test_bogus(void) { /* ensure the values escape (otherwise x is dead) */
 return x+y+z;
}

                                                                                                              
void test_delay (int64_t n, int pollcnt)
{
  int64_t i,j;


  y = z;
  x = 1.0;
  if (pollcnt) { /* include pollcnt AMPolls, evenly interspersed */
    int64_t n_chunk = n / (pollcnt+1);
    for (j=0; j<pollcnt; j++) {
      for (i=0; i<n_chunk; i++) { x *= y; }
      gasnet_AMPoll();
    }
    for (i=0; i<n_chunk; i++) { x *= y; }
  } else {
    for (i=0; i<n; i++) { x *= y; }
  }
}