/**
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
:- ensure_loaded(library(misc/brainfog)).
/**
* expedite(G):
* expedite(G, N):
* The predicate succeeds. As a side effect it runs G on a
* GPU backend for π-WAM. The only side effects consumed or
* produced by the π-WAM is their input and output. The binary
* predicate allows specifying hack options.
*/
% expedite(+Goal)
expedite(GOAL) :-
expedite(GOAL, []).
% expedite(+Goal, +List)
expedite(GOAL, OPTS) :-
sys_hack_opts(OPTS, v(1,0rNone,0rNone), v(NUM,_,_)),
sys_comp_goal(GOAL, _, BUFFER, [], CODE, []),
sys_close_list(BUFFER),
term_variables(BUFFER-CODE, LIST),
(sys_number_list(LIST, 0, 1),
length(LIST, LEN),
LEN3 is 3+LEN,
LEN2 is LEN3*NUM,
length(STATE, LEN2),
sys_number_list(STATE, 0, 0),
maplist(sys_pack_instr, CODE, CODE2),
% write('CODE2='), write(CODE2), write(', LEN='), write(LEN), nl,
gpu_data_new(CODE2, BUF),
gpu_data_new(STATE, BUF2),
length(OFFSETS, NUM),
sys_number_list(OFFSETS, 3, LEN3),
gpu_data_new(OFFSETS, BUF3),
sys_expedite(BUF, BUF2, BUF3, NUM);
true).
% sys_expedite(+Buffer, +Buffer, +Buffer, +Integer)
sys_expedite(BUF, BUF2, BUF3, NUM) :-
gpu_comp_new(BUF, BUF3, BUF2, PIWAM),
gpu_comp_work(PIWAM, WORK),
NUM2 is (NUM + WORK - 1) // WORK,
gpu_comp_submit(PIWAM, NUM2),
gpu_comp_done(PIWAM, PROM),
'$YIELD'(PROM), fail.
/****************************************************************/
/* Error Texts */
/****************************************************************/
% strings(+Atom, +Atom, -Atom)
:- multifile(strings/3).
strings('resource_error.gpu_abort', de, 'GPU Ausführung abgebrochen').
strings('resource_error.gpu_abort', '', 'GPU execution aborted').
/*******************************************************************/
/* Foreign Predicates */
/*******************************************************************/
% gpu_data_new(A, B):
% defined in foreign(edge/cmdlib)
% gpu_comp_new(C, S, O, M):
% defined in foreign(edge/cmdlib)
% gpu_comp_work(M, W):
% defined in foreign(edge/cmdlib)
% gpu_comp_submit(M, K):
% defined in foreign(edge/cmdlib)
% gpu_comp_done(M, P):
% defined in foreign(edge/cmdlib)
:- ensure_loaded(foreign(edge/cmdlib)).