fix interface

This commit is contained in:
Vítor Santos Costa 2013-10-07 12:38:08 +01:00
parent 9800753a1b
commit 1593ee4918
3 changed files with 12 additions and 3 deletions

View File

@ -30,6 +30,7 @@ int32_t Cuda_Erase(predicate *pred);
void init_cuda( void ); void init_cuda( void );
#if DEBUG_INTERFACE
static void static void
dump_mat(int32_t mat[], int32_t nrows, int32_t ncols) dump_mat(int32_t mat[], int32_t nrows, int32_t ncols)
{ {
@ -58,6 +59,8 @@ dump_vec(int32_t vec[], int32_t rows)
} }
printf("\n"); printf("\n");
} }
#endif /* DEBUG_INTERFACE */
// stubs, will point at Carlos code. // stubs, will point at Carlos code.
@ -67,7 +70,9 @@ void Cuda_Initialize( void )
int32_t Cuda_NewFacts(predicate *pe) int32_t Cuda_NewFacts(predicate *pe)
{ {
#if DEBUG_INTERFACE
dump_mat( pe->address_host_table, pe->num_rows, pe->num_columns ); dump_mat( pe->address_host_table, pe->num_rows, pe->num_columns );
#endif
facts[cf] = pe; facts[cf] = pe;
cf++; cf++;
return TRUE; return TRUE;
@ -75,7 +80,9 @@ int32_t Cuda_NewFacts(predicate *pe)
int32_t Cuda_NewRule(predicate *pe) int32_t Cuda_NewRule(predicate *pe)
{ {
#if DEBUG_INTERFACE
dump_vec( pe->address_host_table, pe->num_rows); dump_vec( pe->address_host_table, pe->num_rows);
#endif
rules[cr] = pe; rules[cr] = pe;
cr++; cr++;
return TRUE; return TRUE;
@ -212,6 +219,7 @@ cuda_eval( void )
int32_t *mat; int32_t *mat;
predicate *ptr = (predicate *)YAP_IntOfTerm(YAP_ARG1); predicate *ptr = (predicate *)YAP_IntOfTerm(YAP_ARG1);
int32_t n = Cuda_Eval(facts, cf, rules, cr, ptr, & mat); int32_t n = Cuda_Eval(facts, cf, rules, cr, ptr, & mat);
printf("n = %d, mat = %p\n", n, mat);
int32_t ncols = ptr->num_columns; int32_t ncols = ptr->num_columns;
YAP_Term out = YAP_TermNil(); YAP_Term out = YAP_TermNil();
YAP_Functor f = YAP_MkFunctor(YAP_IntToAtom(ptr->name), ncols); YAP_Functor f = YAP_MkFunctor(YAP_IntToAtom(ptr->name), ncols);
@ -223,7 +231,7 @@ cuda_eval( void )
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
int32_t ni = ((n-1)-i)*ncols, j; int32_t ni = ((n-1)-i)*ncols, j;
for (j=0; j<ncols; j++) { for (j=0; j<ncols; j++) {
vec[i] = YAP_MkIntTerm(mat[ni+j]); vec[j] = YAP_MkIntTerm(mat[ni+j]);
} }
out = YAP_MkPairTerm(YAP_MkApplTerm( f, ncols, vec ), out); out = YAP_MkPairTerm(YAP_MkApplTerm( f, ncols, vec ), out);
} }

View File

@ -1200,7 +1200,7 @@ int Cuda_Eval(predicate **inpfacts, int ninpf, predicate **inprules, int ninpr,
cout << "tamanio = " << res_rows << endl; cout << "tamanio = " << res_rows << endl;
cout << "iteraciones = " << itr << endl; cout << "iteraciones = " << itr << endl;
result = &hres; *result = hres;
return res_rows; return res_rows;
} }

View File

@ -6,7 +6,8 @@
main :- main :-
cuda_extensional(db/2, _X), cuda_extensional(db/2, _X),
cuda_rule((a(X, Y) :- db(Y, Z), db(X, Z), db(1, Z) ), Q), cuda_rule((a(X, Y) :- db(Y, Z), db(X, Z), db(1, Z) ), Q),
cuda_eval(Q, _). cuda_eval(Q, L), writeln(here),
writeln(L).
db(1,a). db(1,a).
db(2,a). db(2,a).