16 {
18 const char*
names[
NUM_EVENTS] = {
"READ_CALLS",
"READ_BYTES",
"READ_USEC",
"READ_WOULD_BLOCK",
"SOCK_READ_CALLS",
"SOCK_READ_BYTES",
"SOCK_READ_USEC",
"SOCK_READ_WOULD_BLOCK",
"WRITE_BYTES",
"WRITE_CALLS",
"WRITE_WOULD_BLOCK",
"WRITE_USEC",
"SOCK_WRITE_BYTES",
"SOCK_WRITE_CALLS",
"SOCK_WRITE_USEC"};
20
21
23
26 fprintf(
stderr,
"PAPI_library_init version mismatch\n");
27 exit(1);
28 }
29
30
32 fprintf(
stderr,
"Error creating event set\n");
33 exit(2);
34 }
35
37 printf("This program will listen on port 3490, and write data received to standard output AND socket\n"
38 "In the output ensure that the following identities hold:\n"
39 "READ_* == SOCK_READ_*\n"
40 "WRITE_{CALLS,BYTES} = 2 * SOCK_WRITE_{CALLS,BYTES}\n"
41 "SOCK_READ_BYTES == SOCK_WRITE_BYTES\n");
43 int e;
44 int event_code;
48 fprintf(
stderr,
"Error getting code for %s\n",
names[e]);
49 exit(2);
50 }
53 fprintf(
stderr,
"Error adding %s to event set\n",
names[e]);
54 exit(2);
55 }
56 }
57
58 int bytes = 0;
60
61 int sockfd, n_sockfd, sin_size, len;
62 char *host_addr;
63 struct sockaddr_in my_addr;
64 struct sockaddr_in their_addr;
65 my_addr.sin_family = AF_INET;
66 my_addr.sin_port = htons(
PORT);
67 my_addr.sin_addr.s_addr = INADDR_ANY;
68
69 sockfd = socket(AF_INET, SOCK_STREAM, 0);
70 if (sockfd < 0) {
71 perror("socket");
72 exit(1);
73 }
74 if ((bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr))) == -1) {
75 perror("bind");
76 exit(1);
77 }
78 listen(sockfd, 10);
79 if ((n_sockfd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) {
80 perror("accept");
81 exit(1);
82 }
84
85
87 fprintf(
stderr,
"Error in PAPI_start\n");
88 exit(1);
89 }
90
91 while ((bytes =
read(n_sockfd,
buf, 1024)) > 0) {
94 }
95
97
98
100 fprintf(
stderr,
"Error in PAPI_stop\n");
101 }
102
104 printf("----\n");
107 }
109 return 0;
110}
ssize_t write(int fd, const void *buf, size_t count)
ssize_t read(int fd, void *buf, size_t count)
const char * names[NUM_EVENTS]
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
initialize the PAPI library.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
static long long values[NUM_EVENTS]
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_pass(const char *filename)