From 3015fd9792d27d8d3c90db28c79446d8875819ef Mon Sep 17 00:00:00 2001 From: Nicolas Bock Date: Tue, 25 Jan 2022 15:55:35 -0700 Subject: [PATCH] Add first basic test --- cpp_prototype/CMakeLists.txt | 4 +++- cpp_prototype/src/bml.h | 3 +++ cpp_prototype/src/bml_allocate.cc | 4 +++- cpp_prototype/src/bml_allocate.h | 14 ++++++++++++++ cpp_prototype/src/bml_types.h | 19 +++++++++++++++++++ cpp_prototype/tests/CMakeLists.txt | 7 ++++--- cpp_prototype/tests/bml-test.cc | 2 +- 7 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 cpp_prototype/src/bml_allocate.h diff --git a/cpp_prototype/CMakeLists.txt b/cpp_prototype/CMakeLists.txt index 58cbc4b90..40a3a6b0c 100644 --- a/cpp_prototype/CMakeLists.txt +++ b/cpp_prototype/CMakeLists.txt @@ -12,7 +12,9 @@ endif() set(BML_BUILD_PYTHON_INTERFACE TRUE CACHE BOOL "Build the Python API (requires Python dev package)") -project(bml ${LANGUAGES}) # don't move this line as it changes PROJECT_SOURCE_DIR +project(bml ${LANGUAGES}) add_subdirectory(src) + +enable_testing() add_subdirectory(tests) diff --git a/cpp_prototype/src/bml.h b/cpp_prototype/src/bml.h index eee51cece..cb32cfbf4 100644 --- a/cpp_prototype/src/bml.h +++ b/cpp_prototype/src/bml.h @@ -1,4 +1,7 @@ #ifndef __BML_H #define __BML_H +#include "bml_types.h" +#include "bml_allocate.h" + #endif diff --git a/cpp_prototype/src/bml_allocate.cc b/cpp_prototype/src/bml_allocate.cc index 50b339b28..0a4235f43 100644 --- a/cpp_prototype/src/bml_allocate.cc +++ b/cpp_prototype/src/bml_allocate.cc @@ -24,5 +24,7 @@ bml_identity_matrix( int M, bml_distribution_mode_t distrib_mode) { - return NULL; + BMLMatrix * A = new BMLMatrix(); + + return A; } diff --git a/cpp_prototype/src/bml_allocate.h b/cpp_prototype/src/bml_allocate.h new file mode 100644 index 000000000..a2aad7277 --- /dev/null +++ b/cpp_prototype/src/bml_allocate.h @@ -0,0 +1,14 @@ +#ifndef __BML_ALLOCATE_H +#define __BML_ALLOCATE_H + +#include "bml_types.h" + +BMLMatrix * +bml_identity_matrix( + bml_matrix_type_t matrix_type, + bml_matrix_precision_t matrix_precision, + int N, + int M, + bml_distribution_mode_t distrib_mode); + +#endif diff --git a/cpp_prototype/src/bml_types.h b/cpp_prototype/src/bml_types.h index 463ff6380..df2cfa01a 100644 --- a/cpp_prototype/src/bml_types.h +++ b/cpp_prototype/src/bml_types.h @@ -8,6 +8,25 @@ class BMLMatrix int N; }; +/** The supported matrix types. */ +typedef enum +{ + /** The matrix is not initialized. */ + type_uninitialized, + /** Dense matrix. */ + dense, + /** ELLPACK matrix. */ + ellpack, + /** BLOCK ELLPACK matrix. */ + ellblock, + /** ELLSORT matrix. */ + ellsort, + /** CSR matrix. */ + csr, + /** distributed matrix. */ + distributed2d +} bml_matrix_type_t; + /** The supported real precisions. */ typedef enum { diff --git a/cpp_prototype/tests/CMakeLists.txt b/cpp_prototype/tests/CMakeLists.txt index 5a50e421b..78c4111b5 100644 --- a/cpp_prototype/tests/CMakeLists.txt +++ b/cpp_prototype/tests/CMakeLists.txt @@ -1,5 +1,6 @@ -include_directories(${CMAKE_SOURCE_DIR}/src) +include_directories(${PROJECT_SOURCE_DIR}/src) add_executable(bml-test bml-test.cc) - -add_test(NAME allocate COMMAND bml-test) +target_link_libraries(bml-test bml) +add_test(NAME allocate + COMMAND bml-test) diff --git a/cpp_prototype/tests/bml-test.cc b/cpp_prototype/tests/bml-test.cc index 100a986af..352c78665 100644 --- a/cpp_prototype/tests/bml-test.cc +++ b/cpp_prototype/tests/bml-test.cc @@ -4,5 +4,5 @@ int main() { printf("starting tests\n"); - return 1; + BMLMatrix * A = bml_identity_matrix(dense, double_real, 10, 10, sequential); }