small fixes

This commit is contained in:
Vítor Santos Costa 2013-10-07 18:34:29 +01:00
parent fbf6648433
commit 490b7cd40a
3 changed files with 22 additions and 6 deletions

View File

@ -97,6 +97,15 @@ int32_t Cuda_NewRule(predicate *pe)
int32_t Cuda_Erase(predicate *pe)
{
int i = 0;
while ( rules[i] != pe )
i++;
while (i < cr-1) {
rules[i] = rules[i+1];
i++;
}
rules[i] = NULL;
cr--;
if (pe->address_host_table)
free( pe->address_host_table );
free( pe );
@ -240,7 +249,6 @@ cuda_eval( void )
int32_t *mat;
predicate *ptr = (predicate *)YAP_IntOfTerm(YAP_ARG1);
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;
YAP_Term out = YAP_TermNil();
YAP_Functor f = YAP_MkFunctor(YAP_IntToAtom(ptr->name), ncols);

View File

@ -594,7 +594,6 @@ void cargareglas(vector<rulenode> *rules, int name, list<rulenode> *res) /*This
actual++;
}
numrules = rules->size();
start = res->begin();
while(res->size() < numrules && start != res->end())
{
@ -789,7 +788,7 @@ extern "C"
int Cuda_Eval(predicate **inpfacts, int ninpf, predicate **inprules, int ninpr, predicate *inpquery, int **result)
{
vector<gpunode> L;
int showr = 1; /*1 show results; 0 don't show results*/
int showr = 0; /*1 show results; 0 don't show results*/
int x, y;
int qsize, *query, qname;
@ -858,7 +857,7 @@ int Cuda_Eval(predicate **inpfacts, int ninpf, predicate **inprules, int ninpr,
while(rul_act != reglas.end()) /*Here's the loop that evaluates each rule*/
{
tipo = rul_act->referencias[0];
if(tipo < 0)
if(tipo)
{
tmpfact = L.at(-tipo - 1);
name1 = tmpfact.name;
@ -1197,8 +1196,8 @@ int Cuda_Eval(predicate **inpfacts, int ninpf, predicate **inprules, int ninpr,
//free(hres);
cout << "Elapsed = " << time << endl;
cout << "tamanio = " << res_rows << endl;
cout << "iteraciones = " << itr << endl;
cout << "Size = " << res_rows << endl;
cout << "Iterations = " << itr << endl;
*result = hres;

View File

@ -12,6 +12,15 @@ main :-
cuda_erase( Q ),
writeln(L).
main2 :-
Rule = ( db(Y, Z), db(X, Z), db(1, Z), X \= Y ),
setof(a(X,Y), Z^Rule, L0), reverse(L0, RL0), writeln(RL0),
cuda_rule((a(X, Y) :- Rule ), Q),
cuda_eval(Q, L),
cuda_erase( Q ),
writeln(L).
db(1,a).
db(2,a).
db(5,b).