Commit 32bde4df authored by Jaco Hofmann's avatar Jaco Hofmann

Fixes memcheck example

parent a6a8b210
......@@ -31,7 +31,7 @@ set(FF_ROOT "$ENV{FF_ROOT}")
endif (${REQUIRES_FASTFLOW})
# link_directories(${TAPASCO_HOME}/arch/lib/${ARCH} ${TAPASCO_HOME}/arch/lib/${ARCH}/static ${TAPASCO_HOME}/platform/lib/${ARCH} ${TAPASCO_HOME}/platform/lib/${ARCH}/static)
link_directories(${TAPASCO_HOME}/arch/lib/${ARCH}/static ${TAPASCO_HOME}/platform/lib/${ARCH}/static)
link_directories(${TAPASCO_HOME}/arch/lib/${ARCH} ${TAPASCO_HOME}/platform/lib/${ARCH})
include_directories(${TAPASCO_HOME}/arch/common/include ${TAPASCO_HOME}/platform/common/include ${FF_ROOT})
......@@ -82,7 +82,8 @@ static int runTest(int const s)
assert(rarr != NULL);
// get tapasco handle
tapasco_handle_t h = tapasco_device_alloc(dev, arr_szs[s] * sizeof(int), 0);
tapasco_handle_t h;
tapasco_device_alloc(dev, &h, arr_szs[s] * sizeof(int), 0);
std::cout << s << ": handle = 0x" << std::hex << std::setfill('0')
<< std::setw(8) << static_cast<uint32_t>(h)
<< ", size = " << arr_szs[s] * sizeof(int) << " bytes"
......@@ -112,7 +113,7 @@ static int runTest(int const s)
merr += 1;
}
__sync_add_and_fetch(&errs, merr);
tapasco_device_free(dev, h);
tapasco_device_free(dev, h, 0);
if (! merr)
std::cout << s << ": Array size " << arr_szs[s] << " ("
......@@ -167,7 +168,7 @@ int main(int argc, char **argv)
std::vector<ff_node *> f;
for (int i = 0; i < sysconf(_SC_NPROCESSORS_CONF); ++i)
f.push_back(new Worker);
Emitter e;
Collector c;
ff_farm<> farm(f, &e, &c);
......@@ -176,7 +177,7 @@ int main(int argc, char **argv)
farm.cleanup_workers();
farm.run_and_wait_end();
if (! errs)
if (! errs)
std::cout << "SUCCESS!" << std::endl;
else
std::cerr << "FAILURE" << std::endl;
......
......@@ -75,7 +75,7 @@ static void *test_thread(void *p)
long int s;
while ((s = __atomic_sub_fetch(&runs, 1, __ATOMIC_SEQ_CST)) > 0) {
s = s % sc;
//printf("%ld: Checking array size %zd (%zd byte) ...\n",
//printf("%ld: Checking array size %zd (%zd byte) ...\n",
// s, arr_szs[s], arr_szs[s] * sizeof(int));
// allocate and fill array
int *arr = (int *)malloc(arr_szs[s] * sizeof(int));
......@@ -86,7 +86,8 @@ static void *test_thread(void *p)
assert(rarr != NULL);
// get tapasco handle
tapasco_handle_t h = tapasco_device_alloc(dev, arr_szs[s] * sizeof(int), 0);
tapasco_handle_t h;
tapasco_device_alloc(dev, &h, arr_szs[s] * sizeof(int), 0);
// printf("%ld: handle = 0x%08lx, size = %zd bytes\n", s,
// (unsigned long)h, arr_szs[s] * sizeof(int));
assert((unsigned long)h > 0);
......@@ -113,7 +114,7 @@ static void *test_thread(void *p)
merr += 1;
}
__atomic_add_fetch(&errs, merr, __ATOMIC_SEQ_CST);
tapasco_device_free(dev, h);
tapasco_device_free(dev, h, 0);
if (! merr)
/*printf("%ld: Array size %zd (%zd byte) ok!\n",
......@@ -157,7 +158,7 @@ int main(int argc, char **argv) {
pthread_join(thrds[s], NULL);
}
if (! errs)
if (! errs)
printf("\nSUCCESS\n");
else
fprintf(stderr, "\nFAILURE\n");
......
......@@ -73,7 +73,7 @@ int main(int argc, char **argv) {
check_fpga(tapasco_create_device(ctx, 0, &dev, 0));
for (int s = 0; s < sizeof(arr_szs) / sizeof(*arr_szs) && errs == 0; ++s) {
printf("Checking array size %zd (%zd byte) ...\n",
printf("Checking array size %zd (%zd byte) ...\n",
arr_szs[s], arr_szs[s] * sizeof(int));
// allocate and fill array
int *arr = (int *)malloc(arr_szs[s] * sizeof(int));
......@@ -83,7 +83,8 @@ int main(int argc, char **argv) {
int *rarr = (int *)malloc(arr_szs[s] * sizeof(int));
// get fpga handle
tapasco_handle_t h = tapasco_device_alloc(dev, arr_szs[s] * sizeof(int), 0);
tapasco_handle_t h;
tapasco_device_alloc(dev, &h, arr_szs[s] * sizeof(int), 0);
printf("handle = 0x%08lx\n", (unsigned long)h);
check((unsigned long)h);
......@@ -92,7 +93,7 @@ int main(int argc, char **argv) {
check_fpga(tapasco_device_copy_to(dev, arr, h, arr_szs[s] * sizeof(int), 0));
check_fpga(tapasco_device_copy_from(dev, h, rarr, arr_szs[s] * sizeof(int), 0));
tapasco_device_free(dev, h);
tapasco_device_free(dev, h, 0);
int merr = compare_arrays(arr, rarr, arr_szs[s]);
errs =+ merr;
......@@ -108,7 +109,7 @@ int main(int argc, char **argv) {
free(rarr);
}
if (! errs)
if (! errs)
printf("\nSUCCESS\n");
else
fprintf(stderr, "\nFAILURE\n");
......
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