SQL Objects

This chapter introduces SQL objects additionally provided by PG-Strom.

Device Information

Function Result Description
gpu_device_name(int = 0) text It tells name of the specified GPU device.
gpu_global_memsize(int = 0) bigint It tells amount of the specified GPU device in bytes.
gpu_max_blocksize(int = 0) int It tells maximum block-size on the specified GPU device. 1024, in the currently supported GPU models.
gpu_warp_size(int = 0) int It tells warp-size on the specified GPU device. 32, in the currently supported GPU models.
gpu_max_shared_memory_perblock(int = 0) int It tells maximum shared memory size per block on the specified GPU device.
gpu_num_registers_perblock(int = 0) int It tells total number of registers per block on the specified GPU device.
gpu_num_multiptocessors(int = 0) int It tells number of SM(Streaming Multiprocessor) units on the specified GPU device.
gpu_num_cuda_cores(int = 0) int It tells number of CUDA cores on the specified GPU device.
gpu_cc_major(int = 0) int It tells major CC(Compute Capability) version of the specified GPU device.
gpu_cc_minor(int = 0) int It tells minor CC(Compute Capability) version of the specified GPU device.
gpu_pci_id(int = 0) int It tells PCI bus-id of the specified GPU device.

Arrow_Fdw Supports

Function Result Description
pgstrom.arrow_fdw_truncate(regclass) bool It truncates contents of the specified Arrow_Fdw foreign table. Arrow_Fdw foreign table must be writable.

GPU Data Frame Functions

Function Result Description
pgstrom.arrow_fdw_export_cupy(regclass, text[], int) text It exports the specified columns of Arrow_Fdw foreign table as cuPy's data frame(cupy.ndarray). GPU buffer shall be released automatically on session closed.
pgstrom.arrow_fdw_export_cupy_pinned(regclass, text[], int) text It exports the specified columns of Arrow_Fdw foreign table as cuPy's data frame(cupy.ndarray), as pinned GPU buffer; that is available after the session closed.
pgstrom.arrow_fdw_put_gpu_buffer(text) bool It unreference the GPU buffer that is exported with the above functions.
pgstrom.arrow_fdw_unpin_gpu_buffer(text) bool It unpin the GPU buffer that is exported with the above functions.

Test Data Generation

Function Result Description
pgstrom.random_setseed(int) void It initializes the random seed.
pgstrom.random_int(float=0.0, bigint=0, bigint=INT_MAX) bigint It generates random data in bigint type within the range.
pgstrom.random_float(float=0.0, float=0.0, float=1.0) float It generates random data in float type within the range.
pgstrom.random_date(float=0.0, date='2015-01-01', date='2025-12-31') date It generates random data in date type within the range.
pgstrom.random_time(float=0.0, time='00:00:00', time='23:59:59') time It generates random data in time type within the range.
pgstrom.random_timetz(float=0.0, time='00:00:00', time='23:59:59') timetz It generates random data in timetz type within the range.
pgstrom.random_timestamp(float=0.0, timestamp='2015-01-01', timestamp='2025-01-01') timestamp It generates random data in timestamp type within the range.
pgstrom.random_macaddr(float=0.0, macaddr='ab:cd:00:00:00', macaddr='ab:cd:ff:ff:ff:ff') macaddr It generates random data in macaddr type within the range.
pgstrom.random_inet(float=0.0, inet='192.168.0.1/16') inet It generates random data in inet type within the range.
pgstrom.random_text(float=0.0, text='test_**') text It generates random data in text type. The '*' characters in 2nd argument shall be replaced randomly.
pgstrom.random_text_len(float=0.0, int=10) text It generates random data in text type within the specified length.
pgstrom.random_int4range(float=0.0, bigint=0, bigint=INT_MAX) int4range It generates random data in int4range type within the range.
pgstrom.random_int8range(float=0.0, bigint=0, bigint=LONG_MAX) int8range It generates random data in int8range type within the range.
pgstrom.random_tsrange(float=0.0, timestamp='2015-01-01', timestamp='2025-01-01') tsrange It generates random data in tsrange type within the range.
pgstrom.random_tstzrange(float=0.0, timestamptz='2015-01-01', timestamptz='2025-01-01') tstzrange It generates random data in tstzrange type within the range.
pgstrom.random_daterange(float=0.0, date='2015-01-01', date='2025-12-31') daterange It generates random data in daterange type within the range.

Other Functions

Function Result Description
pgstrom.license_query() text It shows the active commercial subscription.

System View

PG-Strom provides several system view to export its internal state for users or applications. The future version may add extra fields here. So, it is not recommended to reference these information schemas using SELECT * FROM ....

pgstrom.device_info

pgstrom.device_into system view exports device attributes of the GPUs recognized by PG-Strom. GPU has different specification for each model, like number of cores, capacity of global memory, maximum number of threads and etc, user's software should be optimized according to the information if you try raw GPU programming with PL/CUDA functions.

Name Data Type Description
device_nr int GPU device number
aindex int Attribute index
attribute text Attribute name
value text Value of the attribute

pgstrom.device_preserved_meminfo

pgstrom.device_preserved_meminfo system view exports information of the preserved device memory; which can be shared multiple PostgreSQL backend. Right now, only Python collaboration of Arrow_Fdw uses this feature.

Name Data Type Description
device_nr int GPU device number
handle bytea IPC handle of the preserved device memory
owner regrole Owner of the preserved device memory
length bigint Length of the preserved device memory in bytes
ctime timestamp with time zone Timestamp when the preserved device memory is created