From ab01dfb31fc55da9f216a0f71688982d1383bfa1 Mon Sep 17 00:00:00 2001 From: Nicolas Bock Date: Tue, 25 Jan 2022 11:47:17 -0700 Subject: [PATCH] Add prototype using C++ Issue: lanl/bml#570 Signed-off-by: Nicolas Bock --- cpp_prototype/CMakeLists.txt | 18 ++++++++++++++++++ cpp_prototype/src/CMakeLists.txt | 2 ++ cpp_prototype/src/bml.h | 4 ++++ cpp_prototype/src/bml_allocate.cc | 8 ++++++++ cpp_prototype/src/bml_types.h | 6 ++++++ cpp_prototype/tests/CMakeLists.txt | 3 +++ cpp_prototype/tests/bml-test.cc | 7 +++++++ 7 files changed, 48 insertions(+) create mode 100644 cpp_prototype/CMakeLists.txt create mode 100644 cpp_prototype/src/CMakeLists.txt create mode 100644 cpp_prototype/src/bml.h create mode 100644 cpp_prototype/src/bml_allocate.cc create mode 100644 cpp_prototype/src/bml_types.h create mode 100644 cpp_prototype/tests/CMakeLists.txt create mode 100644 cpp_prototype/tests/bml-test.cc diff --git a/cpp_prototype/CMakeLists.txt b/cpp_prototype/CMakeLists.txt new file mode 100644 index 000000000..58cbc4b90 --- /dev/null +++ b/cpp_prototype/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.10) + +message(STATUS "CMake version ${CMAKE_VERSION}") + +set(LANGUAGES C CXX) +set(BML_BUILD_FORTRAN_INTERFACE TRUE CACHE BOOL + "Build the Fortran API (requires a Fortran compiler)") +if(BML_BUILD_FORTRAN_INTERFACE) + list(APPEND LANGUAGES Fortran) +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 + +add_subdirectory(src) +add_subdirectory(tests) diff --git a/cpp_prototype/src/CMakeLists.txt b/cpp_prototype/src/CMakeLists.txt new file mode 100644 index 000000000..61cd4f200 --- /dev/null +++ b/cpp_prototype/src/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(bml + bml_allocate.cc) diff --git a/cpp_prototype/src/bml.h b/cpp_prototype/src/bml.h new file mode 100644 index 000000000..eee51cece --- /dev/null +++ b/cpp_prototype/src/bml.h @@ -0,0 +1,4 @@ +#ifndef __BML_H +#define __BML_H + +#endif diff --git a/cpp_prototype/src/bml_allocate.cc b/cpp_prototype/src/bml_allocate.cc new file mode 100644 index 000000000..abc445674 --- /dev/null +++ b/cpp_prototype/src/bml_allocate.cc @@ -0,0 +1,8 @@ +#include "bml_types.h" + +#include + +void * bml_allocate(int rows) +{ + return malloc(10); +} diff --git a/cpp_prototype/src/bml_types.h b/cpp_prototype/src/bml_types.h new file mode 100644 index 000000000..acf4f47fb --- /dev/null +++ b/cpp_prototype/src/bml_types.h @@ -0,0 +1,6 @@ +#ifndef __BML_TYPES_H +#define __BML_TYPES_H + +typedef void * BML_MATRIX_DENSE_T; + +#endif diff --git a/cpp_prototype/tests/CMakeLists.txt b/cpp_prototype/tests/CMakeLists.txt new file mode 100644 index 000000000..f997753d7 --- /dev/null +++ b/cpp_prototype/tests/CMakeLists.txt @@ -0,0 +1,3 @@ +include_directories(${CMAKE_SOURCE_DIR}/src) +add_executable(bml-test + bml-test.cc) diff --git a/cpp_prototype/tests/bml-test.cc b/cpp_prototype/tests/bml-test.cc new file mode 100644 index 000000000..2fbdc929a --- /dev/null +++ b/cpp_prototype/tests/bml-test.cc @@ -0,0 +1,7 @@ +#include +#include +#include + +int main() { + printf("starting tests\n"); +}