From 4f75b93394cea1e079788a62d5badd8d945599eb Mon Sep 17 00:00:00 2001 From: Jared Casper Date: Mon, 31 Oct 2016 10:32:23 -0700 Subject: [PATCH 1/2] Add an API version function. --- include/ctc.h | 3 +++ src/ctc_entrypoint.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/ctc.h b/include/ctc.h index 6023336..8402796 100644 --- a/include/ctc.h +++ b/include/ctc.h @@ -21,6 +21,9 @@ typedef enum { CTC_STATUS_UNKNOWN_ERROR = 4 } ctcStatus_t; +/** Returns a single integer which specifies the API version of the warpctc library */ +int get_warpctc_version(); + /** Returns a string containing a description of status that was passed in * \param[in] status identifies which string should be returned * \return C style string containing the text description diff --git a/src/ctc_entrypoint.cpp b/src/ctc_entrypoint.cpp index 4522bb6..ea789e5 100644 --- a/src/ctc_entrypoint.cpp +++ b/src/ctc_entrypoint.cpp @@ -12,6 +12,10 @@ extern "C" { +int get_warpctc_version() { + return 1; +} + const char* ctcGetStatusString(ctcStatus_t status) { switch (status) { case CTC_STATUS_SUCCESS: From b3e398a6e750e583a708f62fae89e7314369ea69 Mon Sep 17 00:00:00 2001 From: Jared Casper Date: Mon, 31 Oct 2016 11:03:02 -0700 Subject: [PATCH 2/2] Check API version in tests and return a value from main. --- tests/test_cpu.cpp | 12 ++++++++++-- tests/test_gpu.cu | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/test_cpu.cpp b/tests/test_cpu.cpp index 6a65644..251c70f 100644 --- a/tests/test_cpu.cpp +++ b/tests/test_cpu.cpp @@ -242,6 +242,11 @@ bool run_tests() { } int main(void) { + if (get_warpctc_version() != 1) { + std::cerr << "Invalid WarpCTC version." << std::endl; + return 1; + } + std::cout << "Running CPU tests" << std::endl; bool status = true; @@ -249,8 +254,11 @@ int main(void) { status &= inf_test(); status &= run_tests(); - if (status) + if (status) { std::cout << "Tests pass" << std::endl; - else + return 0; + } else { std::cout << "Some or all tests fail" << std::endl; + return 1; + } } diff --git a/tests/test_gpu.cu b/tests/test_gpu.cu index 803dfde..89d9f8c 100644 --- a/tests/test_gpu.cu +++ b/tests/test_gpu.cu @@ -326,6 +326,11 @@ bool run_tests() { } int main(void) { + if (get_warpctc_version() != 1) { + std::cerr << "Invalid WarpCTC version." << std::endl; + return 1; + } + std::cout << "Running GPU tests" << std::endl; throw_on_error(cudaSetDevice(0), "cudaSetDevice"); @@ -334,8 +339,11 @@ int main(void) { status &= inf_test(); status &= run_tests(); - if (status) + if (status) { std::cout << "Tests pass" << std::endl; - else + return 0; + } else { std::cout << "Some or all tests fail" << std::endl; + return 1; + } }