Software Archive
Read-only legacy content
17061 Discussions

Using Offload in Dynamic Shared Library for Postgres

Timofey_R_
Beginner
500 Views

Hello!

I need to compile user defined functions in C language for Postgres. These functions may offload some work to MIC.

The problem is that Postgres drop session on any #pragma offload.

I make minimal example. I made a simple DSO library, simple direct call tester and testing with Postgres (in attachments).

I use next compilation commands:

[bash]

CC=icc
CFLAGS=-Wall -openmp
PG_PATH_BIN=/storage/home/xxx/postgresql-9.1.9-build/bin
PG_SERVER_INCLUDE_DIR_PATH=-I`$(PG_PATH_BIN)/pg_config --includedir-server`
SO_FLAG=-shared

$(CC) $(CFLAGS) $(SO_FLAG) $(PG_SERVER_INCLUDE_DIR_PATH) -fPIC pgMIC.c -o libpgMIC.so

$(CC) exec.o -L. -lpgMIC -o exec.out

[/bash]

exec.out returns: add_one1(5) = 11

Postgres psql call returns:
postgres=# CREATE FUNCTION add_one(integer) returnS integer AS 'libpgMIC', 'add_one' LANGUAGE C STRICT;
CREATE FUNCTION
postgres=# SELECT add_one(5);
The connection to the server was lost. Attempting reset: Succeeded

Postgres log shows: LOG:  server process (PID 25489) was terminated by signal 11: Segmentation fault

If I comment out #pragma offload Postgres is OK.

Can anybody give some advice what is the problem, how to get more information about segmentation fault reason? Maybe I forgot some compile options?

0 Kudos
7 Replies
TaylorIoTKidd
New Contributor I
500 Views

Hi,

Unfortunately, your post fell through the cracks.

Do you still need an answer?

Regards
--
Taylor

 

0 Kudos
Timofey_R_
Beginner
500 Views

Hi Taylor!

Happens strange thing - the problem fixed suddenly without any changes in code. Now it is not reproducable. I don't know what was the reason and what solved the problem.

So for now question is closed.

Regards

--

Timofey

0 Kudos
aazue
New Contributor I
500 Views

Hi

(I don't know what was the reason and what solved the problem.)

Probably it's only  refresh (ldconfig) when you have reboot.

Regards

0 Kudos
TaylorIoTKidd
New Contributor I
500 Views

Timofey,

If you have anything other problems or if it shows back up again, please let us know.

Regards
--
Taylor

0 Kudos
Timofey_R_
Beginner
500 Views

To bustaf:

I'm just user of cluster not sysadmin so I can't reboot node. I just can try to move to other node. Problem reproduced on all nodes which I tried to use. Possibly sysadmins made some magic so it starts work again.

Regards

0 Kudos
aazue
New Contributor I
500 Views

Hi
In system you have  (cron) that could run this task automatically without
query accord of your admin.

I think functions dissociated on each  database
 Personally I not use OpenMp directly on function database
exist several problems conflicts I use only on an backend ..
with using  (PTH) it's  better but it's also not perfect.

Regards

0 Kudos
aazue
New Contributor I
500 Views

Hi
Look  the last Babar  9.3 , I think you have  is tailor for your Phi card.
(postgres_fdw)
http://www.postgresql.org/docs/9.3/static/postgres-fdw.h.t.m.l (remove the (.) h.t.m.l)
http://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.3

It's sure that when you have the system is specifically builded to  databases
and is not  unique imposed same here, it could be more simple to manage...

About other sides  he seem improved compared the  precedent version.

Maybe, yet, two new future version, I think  that  with , all  functions are  added each
upgrade ,it will be reserved only  accessible  for Einstein.
Regards

0 Kudos
Reply