Commit 304ce17e authored by Kim, Jungwon's avatar Kim, Jungwon

Merge branch 'develop' into 'master'

Add Fortran 90 Binding

See merge request !2
parents 30ee861f b425f34f
......@@ -6,17 +6,28 @@ set(PAPYRUS_VERSION_MAJOR 1)
set(PAPYRUS_VERSION_MINOR 0)
set(PAPYRUS_VERSION_PATCH 0)
set(PAPYRUS_USE_FORTRAN OFF CACHE BOOL "Enable support for Fortran 90")
option(PAPYRUS_BUILD_WITH_SPACK "Bulid with Spack" OFF)
if(PAPYRUS_USE_FORTRAN)
enable_language(Fortran)
endif()
find_package(MPI REQUIRED)
MESSAGE (STATUS "MPI_CXX_COMPILER ${MPI_CXX_COMPILER}")
MESSAGE (STATUS "MPI_C_COMPILER ${MPI_C_COMPILER}")
if ("${MPI_C_COMPILER}" STREQUAL "MPI_C_COMPILER-NOTFOUND")
else()
MESSAGE (STATUS "MPI_Fortran_COMPILER ${MPI_Fortran_COMPILER}")
if (NOT "${MPI_C_COMPILER}" STREQUAL "MPI_C_COMPILER-NOTFOUND")
set(CMAKE_C_COMPILER "${MPI_C_COMPILER}")
endif()
if ("${MPI_CXX_COMPILER}" STREQUAL "MPI_CXX_COMPILER-NOTFOUND")
else()
if (NOT "${MPI_CXX_COMPILER}" STREQUAL "MPI_CXX_COMPILER-NOTFOUND")
set(CMAKE_CXX_COMPILER "${MPI_CXX_COMPILER}")
endif()
if (NOT "${MPI_Fortran_COMPILER}" STREQUAL "MPI_Fortran_COMPILER-NOTFOUND")
set(CMAKE_Fortran_COMPILER "${MPI_Fortran_COMPILER}")
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
......
......@@ -2,5 +2,6 @@
rm -rf build install
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../install -DMPIEXEC="/opt/intel/compilers_and_libraries_2017.4.196/linux/mpi/intel64/bin/mpirun" -DMPIEXEC_NUMPROC_FLAG="-n"
#cmake .. -DCMAKE_INSTALL_PREFIX=../install -DMPIEXEC="/opt/intel/compilers_and_libraries_2017.4.196/linux/mpi/intel64/bin/mpirun" -DMPIEXEC_NUMPROC_FLAG="-n" # Stampede2
cmake .. -DCMAKE_INSTALL_PREFIX=../install -DMPIEXEC="/opt/slurm/default/bin/srun" -DMPIEXEC_NUMPROC_FLAG="-n" -DPAPYRUS_USE_FORTRAN=ON #Grand Tave
make -j install
......@@ -53,7 +53,7 @@ extern int papyruskv_put(int db, const char* key, size_t keylen, const char* val
extern int papyruskv_get(int db, const char* key, size_t keylen, char** val, size_t* vallen);
extern int papyruskv_get_pos(int db, const char* key, size_t keylen, char** val, size_t* vallen, papyruskv_pos_t* pos);
extern int papyruskv_delete(int db, const char* key, size_t keylen);
extern int papyruskv_free(void* val);
extern int papyruskv_free(char** val);
extern int papyruskv_fence(int db, int level);
extern int papyruskv_barrier(int db, int level);
extern int papyruskv_signal_notify(int signum, int* ranks, int count);
......
add_subdirectory(src)
if(NOT PAPYRUS_BUILD_WITH_SPACK)
add_subdirectory(tests)
endif()
add_subdirectory(bin)
......@@ -36,7 +36,7 @@ int papyruskv_delete(int db, const char* key, size_t keylen) {
return Platform::GetPlatform()->Delete(db, key, keylen);
}
int papyruskv_free(void* val) {
int papyruskv_free(char** val) {
return Platform::GetPlatform()->Free(val);
}
......
include_directories(${PROJECT_SOURCE_DIR}/include)
add_library(papyruskv
set(PAPYRUSKV_SOURCES
Bloom.cpp
CAPI.cpp
Cache.cpp
......@@ -22,4 +22,17 @@ add_library(papyruskv
Timer.cpp
)
if(PAPYRUS_USE_FORTRAN)
set(PAPYRUSKV_SOURCES ${PAPYRUSKV_SOURCES}
C_Binding.f90
)
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include)
endif()
add_library(papyruskv ${PAPYRUSKV_SOURCES})
install(TARGETS papyruskv DESTINATION lib)
if(PAPYRUS_USE_FORTRAN)
install(FILES ${PROJECT_BINARY_DIR}/include/papyrus.mod DESTINATION include)
endif()
This diff is collapsed.
......@@ -156,7 +156,7 @@ int Platform::Delete(int dbid, const char* key, size_t keylen) {
return GetDB(dbid)->Delete(key, keylen);
}
int Platform::Free(void* val) {
int Platform::Free(char** val) {
pool_->FreeVal(val);
return PAPYRUSKV_OK;
}
......
......@@ -26,7 +26,7 @@ public:
int Put(int dbid, const char* key, size_t keylen, const char* val, size_t vallen);
int Get(int dbid, const char* key, size_t keylen, char** val, size_t* vallen, papyruskv_pos_t* pos);
int Delete(int dbid, const char* key, size_t keylen);
int Free(void* val);
int Free(char** val);
int Fence(int dbid, int level);
int Barrier(int dbid, int level);
int SignalNotify(int signum, int* ranks, int count);
......
......@@ -14,8 +14,9 @@ char* Pool::AllocVal(size_t vallen) {
return new char[vallen];
}
void Pool::FreeVal(void* val) {
delete[] reinterpret_cast<char *>(val);
void Pool::FreeVal(char** val) {
delete[] *val;
*val = NULL;
}
} /* namespace papyruskv */
......@@ -13,7 +13,7 @@ public:
~Pool();
char* AllocVal(size_t vallen);
void FreeVal(void* val);
void FreeVal(char** val);
private:
Platform* platform_;
......
......@@ -49,7 +49,7 @@ int main(int argc, char** argv) {
else printf("[%s:%d] GET:rank[%d] peer[%d] key[%s] value[%s] vallen[%lu]\n", __FILE__, __LINE__, rank, peer, k[peer], val, vallen);
}
if (val) ret = papyruskv_free(val);
if (val) ret = papyruskv_free(&val);
if (ret != PAPYRUSKV_OK) printf("[%s:%d] ERROR:ret[%d] val[%p]\n", __FILE__, __LINE__, ret, val);
ret = papyruskv_close(db);
......
papyruskv_test_fortran(test14_fortran)
PROGRAM TEST14_FORTRAN
USE MPI
USE PAPYRUS
IMPLICIT NONE
INTEGER :: RANK, NRANKS, IERROR, PROVIDED, PEER, DB
CHARACTER, DIMENSION(4) :: KEY * 32
CHARACTER, DIMENSION(4) :: VAL * 256
CHARACTER, POINTER :: VAL1(:)
CHARACTER, POINTER :: VAL2(:)
INTEGER(KIND=8) :: KEYLEN, VALLEN
CALL MPI_INIT_THREAD(MPI_THREAD_MULTIPLE, PROVIDED, IERROR)
CALL PAPYRUSKV_INIT('./pkv_repo', IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
CALL MPI_COMM_RANK(MPI_COMM_WORLD, RANK, IERROR)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, NRANKS, IERROR)
KEY(1) = 'GOOGLE'
KEY(2) = 'FACEBOOK'
KEY(3) = 'TWITTER'
KEY(4) = 'PAPYRUS'
VAL(1) = 'https://google.com'
VAL(2) = 'https://facebook.com'
VAL(3) = 'https://twitter.com'
VAL(4) = 'https://code.ornl.gov/eck/papyrus'
ALLOCATE(VAL1(256))
NULLIFY(VAL2)
IF (RANK == NRANKS - 1) THEN
PEER = 0
ELSE
PEER = RANK + 1
ENDIF
CALL PAPYRUSKV_OPEN('TEST_DB', PAPYRUSKV_CREATE .OR. PAPYRUSKV_RDWR, DB, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
IF (RANK < SIZE(KEY)) THEN
PRINT*, 'PUT --> RANK', RANK, 'KEY:', TRIM(KEY(RANK + 1)), ' VAL:', TRIM(VAL(RANK + 1))
KEYLEN = LEN(TRIM(KEY(RANK + 1)), KIND = 8)
VALLEN = LEN(TRIM(VAL(RANK + 1)), KIND = 8)
CALL PAPYRUSKV_PUT(DB, TRIM(KEY(RANK + 1)), KEYLEN, TRIM(VAL(RANK + 1)), VALLEN, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
END IF
CALL PAPYRUSKV_BARRIER(DB, PAPYRUSKV_MEMTABLE, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
IF (RANK < SIZE(KEY)) THEN
CALL PAPYRUSKV_GET(DB, TRIM(KEY(RANK + 1)), KEYLEN, VAL1, VALLEN, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
PRINT*, 'GET--> RANK', RANK, 'KEY:', TRIM(KEY(RANK + 1)), ' VAL:', VAL1(1: VALLEN)
CALL PAPYRUSKV_GET(DB, TRIM(KEY(RANK + 1)), KEYLEN, VAL2, VALLEN, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
PRINT*, 'GET--> RANK', RANK, 'KEY:', TRIM(KEY(RANK + 1)), ' VAL:', VAL2(1: VALLEN)
CALL PAPYRUSKV_FREE(VAL2, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
KEYLEN = LEN(TRIM(KEY(PEER + 1)), KIND = 8)
CALL PAPYRUSKV_GET(DB, TRIM(KEY(PEER + 1)), KEYLEN, VAL1, VALLEN, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
PRINT*, 'GET--> RANK', RANK, 'KEY:', TRIM(KEY(PEER + 1)), ' VAL:', VAL1(1: VALLEN)
KEYLEN = LEN(TRIM(KEY(PEER + 1)), KIND = 8)
CALL PAPYRUSKV_GET(DB, TRIM(KEY(PEER + 1)), KEYLEN, VAL2, VALLEN, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
PRINT*, 'GET--> RANK', RANK, 'KEY:', TRIM(KEY(PEER + 1)), ' VAL:', VAL2(1: VALLEN)
CALL PAPYRUSKV_FREE(VAL2, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
END IF
CALL PAPYRUSKV_CLOSE(DB, IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
DEALLOCATE(VAL1)
CALL PAPYRUSKV_FINALIZE(IERROR)
IF (IERROR /= PAPYRUSKV_OK) THEN
PRINT*, 'FAILED'
ENDIF
CALL MPI_FINALIZE(IERROR)
END PROGRAM TEST14_FORTRAN
......@@ -7,6 +7,14 @@ macro(papyruskv_test arg)
set_tests_properties(kv.${arg} PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endmacro(papyruskv_test)
macro(papyruskv_test_fortran arg)
include_directories(${PROJECT_BINARY_DIR}/include)
add_executable(kv.${arg} ${arg}.f90)
target_link_libraries(kv.${arg} papyruskv pthread stdc++)
add_test(kv.${arg} ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./kv.${arg})
set_tests_properties(kv.${arg} PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endmacro(papyruskv_test_fortran)
add_subdirectory(01_open_close)
add_subdirectory(02_put_get)
add_subdirectory(03_barrier)
......@@ -20,3 +28,6 @@ add_subdirectory(10_checkpoint)
add_subdirectory(11_restart)
add_subdirectory(12_free)
#add_subdirectory(13_upc)
if(PAPYRUS_USE_FORTRAN)
add_subdirectory(14_fortran)
endif()
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