Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add prototype using C++ #571

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cpp_prototype/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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})

add_subdirectory(src)

enable_testing()
add_subdirectory(tests)
2 changes: 2 additions & 0 deletions cpp_prototype/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_library(bml
bml_allocate.cc)
7 changes: 7 additions & 0 deletions cpp_prototype/src/bml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __BML_H
#define __BML_H

#include "bml_types.h"
#include "bml_allocate.h"

#endif
30 changes: 30 additions & 0 deletions cpp_prototype/src/bml_allocate.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "bml_types.h"

#include <stdlib.h>

/** Allocate the identity matrix.
*
* Note that the matrix \f$ A \f$ will be newly allocated. The
* function does not check whether the matrix is already allocated.
*
* \ingroup allocate_group_C
*
* \param matrix_type The matrix type.
* \param matrix_precision The precision of the matrix.
* \param N The matrix size.
* \param M The number of non-zeroes per row.
* \param distrib_mode The distribution mode.
* \return The matrix.
*/
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)
{
BMLMatrix * A = new BMLMatrix();

return A;
}
14 changes: 14 additions & 0 deletions cpp_prototype/src/bml_allocate.h
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions cpp_prototype/src/bml_types.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "bml_types.h"
98 changes: 98 additions & 0 deletions cpp_prototype/src/bml_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#ifndef __BML_TYPES_H
#define __BML_TYPES_H

/** The BML matrix type. */
class BMLMatrix
{
/** The number of rows/columns. */
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
{
/** The matrix is not initialized. */
precision_uninitialized,
/** Matrix data is stored in single precision (float). */
single_real,
/** Matrix data is stored in double precision (double). */
double_real,
/** Matrix data is stored in single-complex precision (float). */
single_complex,
/** Matrix data is stored in double-complex precision (double). */
double_complex
} bml_matrix_precision_t;

/** The supported dense matrix elements orderings. */
typedef enum
{
/** row-major order. */
dense_row_major,
/** column-major order. */
dense_column_major
} bml_dense_order_t;

/** The supported distribution modes. */
typedef enum
{
/** Each rank works on the full matrix. */
sequential,
/** Each rank works on its part of the matrix. */
distributed,
/** Each rank works on its set of graph partitions. */
graph_distributed
} bml_distribution_mode_t;

/** Decomposition for working in parallel. */
struct bml_domain_t
{
/** number of processors */
int totalProcs;
/** total number of rows */
int totalRows;
/** total number of columns */
int totalCols;

/** global minimum row number */
int globalRowMin;
/** global maximum row number */
int globalRowMax;
/** global total rows */
int globalRowExtent;

/** maximum extent for most processors */
int maxLocalExtent;
/** minimum extent for last processors */
int minLocalExtent;
/** minimum row per rank */
int *localRowMin;
/** maximum row per rank */
int *localRowMax;
/** extent of rows per rank, localRowMax - localRowMin */
int *localRowExtent;
/** local number of elements per rank */
int *localElements;
/** local displacements per rank for 2D */
int *localDispl;
};

#endif
6 changes: 6 additions & 0 deletions cpp_prototype/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include_directories(${PROJECT_SOURCE_DIR}/src)
add_executable(bml-test
bml-test.cc)
target_link_libraries(bml-test bml)
add_test(NAME allocate
COMMAND bml-test)
8 changes: 8 additions & 0 deletions cpp_prototype/tests/bml-test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <bml.h>
#include <stdlib.h>
#include <stdio.h>

int main() {
printf("starting tests\n");
BMLMatrix * A = bml_identity_matrix(dense, double_real, 10, 10, sequential);
}