Files
@ 3ffeb97c88a7
Branch filter:
Location: CSY/reowolf/examples/bench_28/main.c - annotation
3ffeb97c88a7
1.3 KiB
text/x-csrc
Add docs for implementing infinite types in a value based language.
Since we are a value based language and do not have the concept of
pointers, then if we want to lay out the memory of datatypes we run
into a problem when the types represent recursive datastructures:
these are infinite in size. So we have an algorithm for turning
some types into pointer-like things, such that we can lay everything
out in memory.
Since we are a value based language and do not have the concept of
pointers, then if we want to lay out the memory of datatypes we run
into a problem when the types represent recursive datastructures:
these are infinite in size. So we have an algorithm for turning
some types into pointer-like things, such that we can lay everything
out in memory.
b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 b972060a1f92 | #include <time.h>
#include "../../reowolf.h"
#include "../utility.c"
int main(int argc, char** argv) {
int i, rounds;
char optimized = argv[1][0];
rounds = atoi(argv[2]);
printf("optimized %c, rounds %d\n", optimized, rounds);
unsigned char pdl[] = "";
Arc_ProtocolDescription * pd = protocol_description_parse(pdl, sizeof(pdl)-1);
printf("Error str `%s`\n", reowolf_error_peek(NULL));
Connector * c = connector_new_with_id(pd, 0);
PortId ports[6];
for(i=0; i<3; i++) {
connector_add_port_pair(c, &ports[i*2+0], &ports[i*2+1]);
}
connector_add_component(c, "sync", 4, ports+1, 2);
if(optimized=='y') {
connector_add_component(c, "forward", 7, ports+3, 2);
} else {
connector_add_component(c, "sync", 4, ports+3, 2);
}
connector_connect(c, -1);
printf("Error str `%s`\n", reowolf_error_peek(NULL));
size_t msg_len = 1000;
char * msg = malloc(msg_len);
memset(msg, 42, msg_len);
clock_t begin = clock();
for (i=0; i<rounds; i++) {
connector_put_bytes(c, ports[0], msg, msg_len);
connector_get(c, ports[5]);
connector_sync(c, -1);
}
clock_t end = clock();
double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("Time Spent: %f\n", time_spent);
free(msg);
return 0;
}
|