Commit 55ad20bf authored by Jens Korinth's avatar Jens Korinth

Fix examples to work with current APIs

* done: arrayinit, arraysum, basic_test, warraw
* others still missing
* need to unify the tests, basic_test is a good start
* should rename warraw to arrayupdate and remove warraw refs
parent 2ee7b740
......@@ -6,7 +6,7 @@ include (../examples.cmake)
include_directories(../../kernel/arrayinit)
add_executable(arrayinit arrayinit-example.c ../../kernel/arrayinit/arrayinit.c)
target_link_libraries(arrayinit rt pthread tapasco platform)
target_link_libraries(arrayinit rt pthread tapasco platform atomic)
set_target_properties(arrayinit PROPERTIES COMPILE_FLAGS "-g -Wall -Werror -std=gnu99 -Wno-unused-label")
install(TARGETS arrayinit
......
......@@ -88,25 +88,26 @@ int main(int argc, char **argv)
for (int run = 0; run < RUNS; ++run) {
// allocate mem on device and copy array part
tapasco_handle_t h = tapasco_device_alloc(dev, SZ * sizeof(int), 0);
tapasco_handle_t h;
check_tapasco(tapasco_device_alloc(dev, &h, SZ * sizeof(int), 0));
check(h != 0);
// get a job id and set argument to handle
tapasco_job_id_t j_id = tapasco_device_acquire_job_id(dev, 11,
TAPASCO_ACQUIRE_JOB_ID_BLOCKING);
TAPASCO_DEVICE_ACQUIRE_JOB_ID_BLOCKING);
check(j_id > 0);
check_tapasco(tapasco_device_job_set_arg(dev, j_id, 0, sizeof(h), &h));
// shoot me to the moon!
check_tapasco(tapasco_device_job_launch(dev, j_id,
TAPASCO_JOB_LAUNCH_BLOCKING));
TAPASCO_DEVICE_JOB_LAUNCH_BLOCKING));
// get the result
check_tapasco(tapasco_device_copy_from(dev, h, &arr[SZ * run],
SZ * sizeof(int), TAPASCO_COPY_BLOCKING));
SZ * sizeof(int), TAPASCO_DEVICE_COPY_BLOCKING));
unsigned int errs = check_array(&arr[SZ * run], SZ);
printf("\nRUN %d %s\n", run, errs == 0 ? "OK" : "NOT OK");
tapasco_device_free(dev, h);
tapasco_device_free(dev, h, 0);
tapasco_device_release_job_id(dev, j_id);
}
......
......@@ -7,7 +7,7 @@ include (../examples.cmake)
include_directories(../../kernel/arraysum)
add_executable(arraysum arraysum-example.c ../../kernel/arraysum/arraysum.c)
target_link_libraries(arraysum rt pthread tapasco platform)
target_link_libraries(arraysum rt pthread tapasco platform atomic)
set_target_properties(arraysum PROPERTIES COMPILE_FLAGS "-g -Wall -Werror -std=gnu99 -Wno-unused-label")
install(TARGETS arraysum
......
......@@ -4,7 +4,7 @@ set (CMAKE_INSTALL_PREFIX "..")
include (../examples.cmake)
add_executable(basic_test basic_test.cpp)
target_link_libraries(basic_test rt pthread tapasco platform)
target_link_libraries(basic_test rt pthread tapasco platform atomic)
set_target_properties(basic_test PROPERTIES COMPILE_FLAGS "-g -Wall -Werror -O3 -std=c++11")
install(TARGETS basic_test
......
......@@ -44,7 +44,6 @@
#define TEST_3
using namespace std;
using namespace tapasco;
#define SZ 256
#define RUNS 100000
......@@ -52,7 +51,7 @@ using namespace tapasco;
#define T2_KID 10
#define T3_KID 9
static Tapasco Tapasco;
static tapasco::Tapasco Tapasco;
static atomic<int> runs;
typedef int run_block[SZ];
......@@ -67,7 +66,7 @@ bool test1_execute(int *arr)
for (int i = 0; i < SZ; ++i)
(*z)[i] = i;
#else
if (Tapasco.launch_no_return(T1_KID, OutOnly<run_block>{z}) != TAPASCO_SUCCESS)
if (Tapasco.launch_no_return(T1_KID, tapasco::OutOnly<run_block>{z}) != tapasco::TAPASCO_SUCCESS)
return false;
#endif
}
......@@ -111,7 +110,7 @@ int test2_execute(int *arr)
result += (*z)[i];
#else
int tr = 0;
if (Tapasco.launch(T2_KID, tr, z) != TAPASCO_SUCCESS)
if (Tapasco.launch(T2_KID, tr, z) != tapasco::TAPASCO_SUCCESS)
return -1;
else
result += tr;
......@@ -143,9 +142,9 @@ void test3_execute(int *arr)
for (int i = 0; i < SZ; ++i)
(*z)[i] += 42;
#else
tapasco_res_t res;
if ((res = Tapasco.launch_no_return(T3_KID, z)) != TAPASCO_SUCCESS)
throw Tapasco::tapasco_error(res);
tapasco::tapasco_res_t res;
if ((res = Tapasco.launch_no_return(T3_KID, z)) != tapasco::TAPASCO_SUCCESS)
throw tapasco::Tapasco::tapasco_error(res);
#endif
}
}
......
......@@ -6,7 +6,7 @@ include (../examples.cmake)
include_directories(../../kernel/warraw)
add_executable(warraw warraw-example.c ../../kernel/warraw/warraw.c)
target_link_libraries(warraw rt pthread tapasco platform-client)
target_link_libraries(warraw rt pthread tapasco platform atomic)
set_target_properties(warraw PROPERTIES COMPILE_FLAGS "-g -Wall -Werror -std=gnu99 -Wno-unused-label")
install(TARGETS warraw
......
......@@ -95,33 +95,34 @@ int main(int argc, char **argv) {
printf("Golden output for run %d: %d\n", run, golden);
// allocate mem on device and copy array part
tapasco_handle_t h = tapasco_device_alloc(dev, SZ * sizeof(int),
TAPASCO_COPY_BLOCKING);
tapasco_handle_t h;
check_tapasco(tapasco_device_alloc(dev, &h, SZ * sizeof(int),
TAPASCO_DEVICE_COPY_BLOCKING));
check(h != 0);
check_tapasco(tapasco_device_copy_to(dev, &arr[SZ * run], h,
SZ * sizeof(int), TAPASCO_COPY_BLOCKING));
SZ * sizeof(int), TAPASCO_DEVICE_COPY_BLOCKING));
// get a job id and set argument to handle
tapasco_job_id_t j_id = tapasco_device_acquire_job_id(dev, 12,
TAPASCO_ACQUIRE_JOB_ID_BLOCKING);
TAPASCO_DEVICE_ACQUIRE_JOB_ID_BLOCKING);
check(j_id > 0);
check_tapasco(tapasco_device_job_set_arg(dev, j_id, 0, sizeof(h), &h));
// shoot me to the moon!
check_tapasco(tapasco_device_job_launch(dev, j_id,
TAPASCO_JOB_LAUNCH_BLOCKING));
TAPASCO_DEVICE_JOB_LAUNCH_BLOCKING));
// get the result
int32_t r = 0;
check_tapasco(tapasco_device_job_get_return(dev, j_id, sizeof(r), &r));
check_tapasco(tapasco_device_copy_from(dev, h, &arr[SZ * run],
SZ * sizeof(int), TAPASCO_COPY_BLOCKING));
SZ * sizeof(int), TAPASCO_DEVICE_COPY_BLOCKING));
printf("TPC output for run %d: %d\n", run, r);
unsigned int errs = check_arrays(&arr[SZ * run],
&golden_arr[SZ * run], SZ);
printf("\nRUN %d %s\n", run, r == golden && errs == 0 ?
"OK" : "NOT OK");
tapasco_device_free(dev, h);
tapasco_device_free(dev, h, 0);
tapasco_device_release_job_id(dev, j_id);
}
......
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