libsysve
3.1.0
|
VH call is a mechanism to append functions in shared libraries on Vector Host (VH) as system calls on Vector Engine (VE).
SX-Aurora TSUBASA provides VH call for invoking functions in shared libraries on VH from a VE program as system calls. VH call enables to develop a program using both VE and VH computing resources. It would be useful for offloading I/O and procedures not well-vectorized.
To develop VE programs using VH call, please install libsysve-devel package, which has libvhcall.h header declaring VH call API functions.
For example, execute the following command as root. On ve1
On ve3
If you are using musl-libc as C library, APIs introduced here are not supported.
If you execute a program using VH call only, no extra packages are required.
To develop VH library invoked by VH Call, veos-devel package is available.
For example, execute the following command as root.
A VE program using VH Call needs to include "libvhcall.h"
. In the header, the following API functions are declared.
vhcall_install()
loads a VH shared library.vhcall_find()
searches an address of a symbol a function in the VH library.vhcall_args_alloc()
allocates VHCall arguments object (vhcall_args).vhcall_args_set_i8()
sets a 8-bit signed integer argument.vhcall_args_set_u8()
sets a 8-bit unsigned integer argument.vhcall_args_set_i16()
sets a 16-bit signed integer argument.vhcall_args_set_u16()
sets a 16-bit unsigned integer argument.vhcall_args_set_i32()
sets a 32-bit signed integer argument.vhcall_args_set_u32()
sets a 32-bit unsigned integer argument.vhcall_args_set_i64()
sets a 64-bit signed integer argument.vhcall_args_set_u64()
sets a 64-bit unsigned integer argument.vhcall_args_set_float()
sets a single precision floating point number argument.vhcall_args_set_double()
sets a double precision floating point number argument.vhcall_args_set_complex_float()
sets a single precision floating point complex object argument.vhcall_args_set_complex_double()
sets a double precision floating point complex object argument.vhcall_args_set_pointer()
sets VH function argument of pointer type.vhcall_args_set_veoshandle()
sets VH function argument of pointer to VEOS handle.vhcall_args_clear()
clears arguments set in VHCall arguments object.vhcall_args_free()
frees VHCall arguments object.vhcall_invoke_with_args()
invokes a function on VH side with passing arguments.vhcall_uninstall()
unloads a VH shared library.For VE side, sending data to VH is implemented as API of passing arguments. Receiving data from VH is also implemented as return value or pointer type argument which INTENT is OUT or INOUT. Please see VH Call for more detail.
Any arguments passed to VH Fortran program is set by only using vhcall_args_set_pointer(), i.e. they are passed by reference.
A VH library invoked by VH Call can include "libvepseudo.h"
. In the header, the following API functions are declared.
int ve_send_data()
send data from VH to VE memory.int ve_recv_data()
receive data from VE memory.int ve_send_data_tid()
send data from VH to VE memory.int ve_recv_data_tid()
receive data from VE memory.veos_handle *veos_handle_copy()
copy VEOS handlervoid veos_handle_free()
free VEOS handler.ve_send_data(veos_handle *handle, uint64_t dst, size_t size, void *src)
ve_recv_data(veos_handle *handle, uint64_t src, size_t size, void *dst)
The first argument handle is an opaque VE OS handle passed as a library function argument by calling vhcall_args_set_veoshandle()
on VE side. The second is address of VE virtual memory space.
VH call can call a function on VH with the following prototype:
Argument type <T> is allowed to be following variation:
This is a simple program invoking VH shared library functions with passing arguments.
Program invokes VH C library function which has three types arguments, pointer type, int type and float type. The pointer one is used as input and output.
Steps of programs are below.
vhcall_install()
, which returns a VH call handle, an identifier to specify the VH library loaded.vhcall_find()
with the name of a function and a VH call handle.vhcall_args_alloc()
and vhcall_args_set_<T>()
vhcall_invoke_with_args()
.vhcall_args_free()
.vhcall_uninstall()
.This invokes VH Fortran library function and subroutine. For Fortran, all arguments are treated as pointer type.
All arguments of VH Fortran function requires to be set by vhcall_args_set_pointer from VE C program.
vhcall_args_alloc()
and vhcall_args_set_pointer()
.vhcall_args_set_pointer()
.vhcall_args_free()
.This is simple program using ve_recv_data()
and ve_send_data()
. Steps of programs are below.
vhcall_args_set_veoshandle()
vhcall_args_set_u64()
Put all files of this sample in the same directory. Confirm indented lines in Makefile start with a tab. If they start with 8 spaces, replace them to tabs.
Build the programs.
For first example
For second example
For third example
One way to implement asynchronous VH Call, callee VH library function creates worker threads and these threads do their works with transferring data with caller VE thread. But such VH threads don't have their VEOS handle. So they have to copy VEOS handle from parent's to transfer data with VE.
veos_handle_copy(veos_handler *handle)
veos_handle_free(veos_handler *handle)
Normally, caller VE thread and callee VH library function have same thread ID and data transfer APIs don't have to take care of them. But VH thread created by callee VH library function gets different thread ID, and data transfer APIs have to take care of them to find caller VE thread.
ve_send_data_tid(veos_handle *handle, uint64_t dst, size_t size, void *src, pid_t tid)
ve_recv_data_tid(veos_handle *handle, uint64_t src, size_t size, void *dst, pid_t tid)
The third argument tid is VE thread ID which has invoked VH Call. Then, these APIs can be used from worker thread created by VH library function of VH Call.