small fixes
This commit is contained in:
parent
fbf6648433
commit
490b7cd40a
@ -97,6 +97,15 @@ int32_t Cuda_NewRule(predicate *pe)
|
|||||||
|
|
||||||
int32_t Cuda_Erase(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)
|
if (pe->address_host_table)
|
||||||
free( pe->address_host_table );
|
free( pe->address_host_table );
|
||||||
free( pe );
|
free( pe );
|
||||||
@ -240,7 +249,6 @@ 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);
|
||||||
|
@ -594,7 +594,6 @@ void cargareglas(vector<rulenode> *rules, int name, list<rulenode> *res) /*This
|
|||||||
actual++;
|
actual++;
|
||||||
}
|
}
|
||||||
numrules = rules->size();
|
numrules = rules->size();
|
||||||
|
|
||||||
start = res->begin();
|
start = res->begin();
|
||||||
while(res->size() < numrules && start != res->end())
|
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)
|
int Cuda_Eval(predicate **inpfacts, int ninpf, predicate **inprules, int ninpr, predicate *inpquery, int **result)
|
||||||
{
|
{
|
||||||
vector<gpunode> L;
|
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 x, y;
|
||||||
int qsize, *query, qname;
|
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*/
|
while(rul_act != reglas.end()) /*Here's the loop that evaluates each rule*/
|
||||||
{
|
{
|
||||||
tipo = rul_act->referencias[0];
|
tipo = rul_act->referencias[0];
|
||||||
if(tipo < 0)
|
if(tipo)
|
||||||
{
|
{
|
||||||
tmpfact = L.at(-tipo - 1);
|
tmpfact = L.at(-tipo - 1);
|
||||||
name1 = tmpfact.name;
|
name1 = tmpfact.name;
|
||||||
@ -1197,8 +1196,8 @@ int Cuda_Eval(predicate **inpfacts, int ninpf, predicate **inprules, int ninpr,
|
|||||||
//free(hres);
|
//free(hres);
|
||||||
|
|
||||||
cout << "Elapsed = " << time << endl;
|
cout << "Elapsed = " << time << endl;
|
||||||
cout << "tamanio = " << res_rows << endl;
|
cout << "Size = " << res_rows << endl;
|
||||||
cout << "iteraciones = " << itr << endl;
|
cout << "Iterations = " << itr << endl;
|
||||||
|
|
||||||
*result = hres;
|
*result = hres;
|
||||||
|
|
||||||
|
@ -12,6 +12,15 @@ main :-
|
|||||||
cuda_erase( Q ),
|
cuda_erase( Q ),
|
||||||
writeln(L).
|
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(1,a).
|
||||||
db(2,a).
|
db(2,a).
|
||||||
db(5,b).
|
db(5,b).
|
||||||
|
Reference in New Issue
Block a user