Commit 38d22d97 authored by danfis's avatar danfis

op-mutex-sym-redundant: Speed up by more clever reading of op-mutexes.

parent e24ac41f
...@@ -20,19 +20,12 @@ ...@@ -20,19 +20,12 @@
#include "plan/op_mutex_sym_redundant.h" #include "plan/op_mutex_sym_redundant.h"
#include "assert.h" #include "assert.h"
struct reduce_gen_op {
int op_id;
int irrelevant;
bor_iset_t mutex_with;
};
typedef struct reduce_gen_op reduce_gen_op_t;
struct reduce_gen { struct reduce_gen {
int gen_id; int gen_id;
int is_destroyed; int is_destroyed;
const plan_sym_gen_t *gen; const plan_sym_gen_t *gen;
bor_iset_t relevant_op; bor_iset_t relevant_op;
reduce_gen_op_t *op; bor_iset_t *op_mutex_with;
int op_size; int op_size;
bor_iset_t redundant_set; bor_iset_t redundant_set;
...@@ -41,6 +34,8 @@ struct reduce_gen { ...@@ -41,6 +34,8 @@ struct reduce_gen {
typedef struct reduce_gen reduce_gen_t; typedef struct reduce_gen reduce_gen_t;
struct reduce { struct reduce {
bor_iset_t *op_mutex_with;
int op_size;
reduce_gen_t *gen; reduce_gen_t *gen;
int gen_size; int gen_size;
bor_iset_t pruned_ops; bor_iset_t pruned_ops;
...@@ -50,6 +45,7 @@ typedef struct reduce reduce_t; ...@@ -50,6 +45,7 @@ typedef struct reduce reduce_t;
static void reduceGenInit(reduce_gen_t *rgen, static void reduceGenInit(reduce_gen_t *rgen,
int gen_id, int gen_id,
const reduce_t *red,
const plan_sym_gen_t *gen, const plan_sym_gen_t *gen,
const plan_sym_t *sym, const plan_sym_t *sym,
const plan_strips_t *strips, const plan_strips_t *strips,
...@@ -67,18 +63,13 @@ static void reduceGenInit(reduce_gen_t *rgen, ...@@ -67,18 +63,13 @@ static void reduceGenInit(reduce_gen_t *rgen,
} }
rgen->op_size = planStripsOpsSize(&strips->op); rgen->op_size = planStripsOpsSize(&strips->op);
rgen->op = BOR_CALLOC_ARR(reduce_gen_op_t, rgen->op_size); rgen->op_mutex_with = BOR_CALLOC_ARR(bor_iset_t, rgen->op_size);
for (int i = 0; i < rgen->op_size; ++i){
rgen->op[i].op_id = i;
rgen->op[i].irrelevant = 1;
}
int op_id; int op_id;
BOR_ISET_FOR_EACH(&rgen->relevant_op, op_id){ BOR_ISET_FOR_EACH(&rgen->relevant_op, op_id){
reduce_gen_op_t *rop = rgen->op + op_id; borISetIntersect2(rgen->op_mutex_with + op_id,
rop->irrelevant = 0; red->op_mutex_with + op_id,
planOpMutexPairsMutexWith(op_mutex, op_id, &rop->mutex_with); &rgen->relevant_op);
borISetIntersect(&rop->mutex_with, &rgen->relevant_op);
} }
} }
...@@ -87,10 +78,10 @@ static void reduceGenFree(reduce_gen_t *rgen) ...@@ -87,10 +78,10 @@ static void reduceGenFree(reduce_gen_t *rgen)
borISetFree(&rgen->relevant_op); borISetFree(&rgen->relevant_op);
for (int i = 0; i < rgen->op_size; ++i){ for (int i = 0; i < rgen->op_size; ++i){
borISetFree(&rgen->op[i].mutex_with); borISetFree(rgen->op_mutex_with + i);
} }
if (rgen->op != NULL) if (rgen->op_mutex_with != NULL)
BOR_FREE(rgen->op); BOR_FREE(rgen->op_mutex_with);
} }
static void reduceInit(reduce_t *red, static void reduceInit(reduce_t *red,
...@@ -99,10 +90,20 @@ static void reduceInit(reduce_t *red, ...@@ -99,10 +90,20 @@ static void reduceInit(reduce_t *red,
const plan_op_mutex_pairs_t *op_mutex) const plan_op_mutex_pairs_t *op_mutex)
{ {
bzero(red, sizeof(*red)); bzero(red, sizeof(*red));
red->op_size = planStripsOpsSize(&strips->op);
red->op_mutex_with = BOR_CALLOC_ARR(bor_iset_t, red->op_size);
const plan_strips_op_t *op;
PLAN_STRIPS_OPS_FOR_EACH(&strips->op, op){
planOpMutexPairsMutexWith(op_mutex, op->id,
red->op_mutex_with + op->id);
}
red->gen_size = sym->gen_size; red->gen_size = sym->gen_size;
red->gen = BOR_CALLOC_ARR(reduce_gen_t, sym->gen_size); red->gen = BOR_CALLOC_ARR(reduce_gen_t, sym->gen_size);
for (int i = 0; i < sym->gen_size; ++i) for (int i = 0; i < sym->gen_size; ++i){
reduceGenInit(red->gen + i, i, sym->gen + i, sym, strips, op_mutex); reduceGenInit(red->gen + i, i, red,
sym->gen + i, sym, strips, op_mutex);
}
} }
static void reduceFree(reduce_t *red) static void reduceFree(reduce_t *red)
...@@ -178,7 +179,7 @@ static int selectCandidate(reduce_gen_t *rgen, ...@@ -178,7 +179,7 @@ static int selectCandidate(reduce_gen_t *rgen,
BOR_ISET_FOR_EACH(cand, op){ BOR_ISET_FOR_EACH(cand, op){
destroyedSymmetries(rgen, red, op); destroyedSymmetries(rgen, red, op);
int dest = borISetSize(&rgen->destroyed_syms); int dest = borISetSize(&rgen->destroyed_syms);
int siz = borISetSize(&rgen->op[op].mutex_with); int siz = borISetSize(&rgen->op_mutex_with[op]);
if (dest < destroy || (dest == destroy && siz > size)){ if (dest < destroy || (dest == destroy && siz > size)){
//if (siz > size){ //if (siz > size){
...@@ -202,7 +203,7 @@ static void findRedundantSet(reduce_gen_t *rgen, const reduce_t *red) ...@@ -202,7 +203,7 @@ static void findRedundantSet(reduce_gen_t *rgen, const reduce_t *red)
int keep_op = rgen->gen->op[prune_op]; int keep_op = rgen->gen->op[prune_op];
borISetAdd(&rgen->redundant_set, prune_op); borISetAdd(&rgen->redundant_set, prune_op);
borISetRm(&cand, prune_op); borISetRm(&cand, prune_op);
borISetIntersect(&cand, &rgen->op[keep_op].mutex_with); borISetIntersect(&cand, &rgen->op_mutex_with[keep_op]);
} }
destroyedSymmetries(rgen, red, -1); destroyedSymmetries(rgen, red, -1);
...@@ -217,7 +218,7 @@ static void pruneRedundantSet(reduce_t *red, const bor_iset_t *redundant) ...@@ -217,7 +218,7 @@ static void pruneRedundantSet(reduce_t *red, const bor_iset_t *redundant)
reduce_gen_t *rgen = red->gen + gi; reduce_gen_t *rgen = red->gen + gi;
borISetMinus(&rgen->relevant_op, redundant); borISetMinus(&rgen->relevant_op, redundant);
for (int oi = 0; oi < rgen->op_size; ++oi) for (int oi = 0; oi < rgen->op_size; ++oi)
borISetMinus(&rgen->op[oi].mutex_with, redundant); borISetMinus(&rgen->op_mutex_with[oi], redundant);
rgen->is_destroyed = isDestroyed(rgen, &red->pruned_ops); rgen->is_destroyed = isDestroyed(rgen, &red->pruned_ops);
destroyedSymmetries(rgen, red, -1); destroyedSymmetries(rgen, red, -1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment