philip-davis / dataspaces

Git Home of the RDI2 DataSpaces Project
BSD 2-Clause "Simplified" License
4 stars 1 forks source link

add python client example #45

Open wangzhezhe opened 6 years ago

wangzhezhe commented 6 years ago

add python wrapper based put.c and get.c. The detail is described in readme.md

dataspaces.conf

## Config file for DataSpaces
ndim = 1
dims = 128

max_versions = 10
lock_type = 1

test output:

(testPython3) [zw241@e3c-070 Python]$ make
[ -f ./numpy.i ] && echo "numpy.i already here, good" || wget https://raw.githubusercontent.com/numpy/numpy/master/tools/swig/numpy.i
numpy.i already here, good
swig -python -I/home1/zw241/testPython3/lib/python3.6/site-packages/mpi4py/include -I/home1/zw241/testPython3/lib/python3.6/site-packages/numpy/core/include -I/home1/zw241/dataspaces/include -o putdata_wrap.c putdata.i
mpicc -fPIC -I/software/python/3.6.3/include/python3.6m -I/home1/zw241/testPython3/lib/python3.6/site-packages/mpi4py/include -I/home1/zw241/testPython3/lib/python3.6/site-packages/numpy/core/include -I/home1/zw241/dataspaces/include ../C/common.o -L/home1/zw241/dataspaces/install/lib -ldspaces -ldart -ldscommon -ldspacesf -lpthread -lm -lrt -libverbs -lrdmacm -o _putdata.cpython-36m-x86_64-linux-gnu.so putdata_wrap.c -shared -lpthread -ldl -lutil -lm
[ -f ./numpy.i ] && echo "numpy.i already here, good" || wget https://raw.githubusercontent.com/numpy/numpy/master/tools/swig/numpy.i
numpy.i already here, good
swig -python -I/home1/zw241/testPython3/lib/python3.6/site-packages/mpi4py/include -I/home1/zw241/testPython3/lib/python3.6/site-packages/numpy/core/include -I/home1/zw241/dataspaces/include -o getdata_wrap.c getdata.i
mpicc -fPIC -I/software/python/3.6.3/include/python3.6m -I/home1/zw241/testPython3/lib/python3.6/site-packages/mpi4py/include -I/home1/zw241/testPython3/lib/python3.6/site-packages/numpy/core/include -I/home1/zw241/dataspaces/include ../C/common.o -L/home1/zw241/dataspaces/install/lib -ldspaces -ldart -ldscommon -ldspacesf -lpthread -lm -lrt -libverbs -lrdmacm -o _getdata.cpython-36m-x86_64-linux-gnu.so getdata_wrap.c -shared -lpthread -ldl -lutil -lm
/bin/bash ./run.sh
array len 3
index 0 value 1.100000
index 0 value 2.200000
index 0 value 3.300000
array len 3
index 0 value 1.100000
index 0 value 2.200000
index 0 value 3.300000
in c file nprocs 2 rank 0
curr ndim is 1
in c file nprocs 2 rank 1
curr ndim is 1

Timestep 0: put data 1.100000 2.200000 3.300000
Timestep 0: put data 1.100000 2.200000 3.300000
'dcg_unlock_on_write()': Rank 1572864: 'dcg_unlock_on_write()':getting lock my_test_lock
'dcg_unlock_on_write()': Rank 1572864: 'dcg_unlock_on_write()':got lock successfully my_test_lock
'dcg_unlock_on_write()': Rank 1572864: 'dcg_unlock_on_write()':getting lock my_test_lock
'dcg_unlock_on_write()': Rank 1572864: 'dcg_unlock_on_write()':got lock successfully my_test_lock
'dcg_unlock_on_write()': Rank 0: 'dcg_unlock_on_write()':requesting unlock my_test_lock
'dcg_free()': num pending = 1.
'dcg_unlock_on_write()': Rank 0: 'dcg_unlock_on_write()':request for unlock my_test_lock sent
'dcg_free()': num pending = 0.
free_gdim_list(): number of user-defined global dimension is 0
free_gdim_list(): number of user-defined global dimension is 0
in c file nprocs 2 rank 0
curr ndim is 1
in c file nprocs 2 rank 1
curr ndim is 1
Timestep 0: get data 1.100000 2.200000 3.300000
'dcg_unlock_on_read()': Rank 0: 'dcg_unlock_on_read()':getting lock my_test_lock
'dcg_unlock_on_read()': Rank 0: 'dcg_unlock_on_read()':got lock successfully my_test_lock
Timestep 0: get data 1.100000 2.200000 3.300000
'dcg_unlock_on_read()': Rank 0: 'dcg_unlock_on_read()':requesting unlock my_test_lock
'dcg_unlock_on_read()': Rank 1: 'dcg_unlock_on_read()':getting lock my_test_lock
'dcg_unlock_on_read()': Rank 1: 'dcg_unlock_on_read()':got lock successfully my_test_lock
'dcg_free()': num pending = 0.
'dcg_unlock_on_read()': Rank 0: 'dcg_unlock_on_read()':request for unlock my_test_lock sent
'dcg_free()': num pending = 0.
free_gdim_list(): number of user-defined global dimension is 0
free_gdim_list(): number of user-defined global dimension is 0
get return data:
[1.1 2.2 3.3]
get return data:
[1.1 2.2 3.3]