prune completed rows

This commit is contained in:
2019-12-10 11:28:26 -05:00
parent 601f863573
commit 6ec91a3b5b
2 changed files with 16 additions and 29 deletions

BIN
gpu-slo/main Executable file

Binary file not shown.

View File

@@ -52,9 +52,9 @@ struct Solver {
__device__ __device__
void operator()(Row &r) { void operator()(Row &r) {
if (r.l + 1 >= r.r) return; if (r.r - r.l <= 1) return;
while ((r.r - r.l) > 0) { while (r.r - r.l > 1) {
int gen = rels[r.rel].gens[r.l & 1]; int gen = rels[r.rel].gens[r.l & 1];
int next = cosets[r.from * ngens + gen]; int next = cosets[r.from * ngens + gen];
if (next < 0) break; if (next < 0) break;
@@ -62,7 +62,7 @@ struct Solver {
r.from = next; r.from = next;
} }
while ((r.r - r.l) > 0) { while (r.r - r.l > 1) {
int gen = rels[r.rel].gens[r.r & 1]; int gen = rels[r.rel].gens[r.r & 1];
int next = cosets[r.to * ngens + gen]; int next = cosets[r.to * ngens + gen];
if (next < 0) break; if (next < 0) break;
@@ -70,7 +70,7 @@ struct Solver {
r.to = next; r.to = next;
} }
if (r.r - r.l == 0) { if (r.r - r.l <= 1) {
int gen = rels[r.rel].gens[r.l & 1]; int gen = rels[r.rel].gens[r.l & 1];
cosets[r.from * ngens + gen] = r.to; cosets[r.from * ngens + gen] = r.to;
cosets[r.to * ngens + gen] = r.from; cosets[r.to * ngens + gen] = r.from;
@@ -106,6 +106,13 @@ struct RowGen {
} }
}; };
struct RowIncomplete {
__device__
bool operator()(Row r) {
return r.r - r.l > 1;
}
};
void add_row( void add_row(
int ngens, int ngens,
thrust::device_vector<int> &cosets) { thrust::device_vector<int> &cosets) {
@@ -173,31 +180,11 @@ thrust::device_vector<int> solve(
thrust::for_each(rows.begin(), rows.end(), solve); thrust::for_each(rows.begin(), rows.end(), solve);
} }
std::cout << thrust::host_vector<Row>(rows) << std::endl; auto cut = thrust::partition(
thrust::device,
/* rows.begin(), rows.end(),
RowIncomplete());
add_coset(ngens, &coset, &hint, cosets); rows.erase(cut, rows.end());
std::cout << coset << " " << hint << std::endl;
std::cout << rows << std::endl;
thrust::counting_iterator<int> counter(0);
thrust::device_vector<Row> new_rows(rels.size());
thrust::transform(counter, counter + rels.size(), new_rows.begin(),
RowGen(lastCoset, rels));
rows.insert(rows.begin(), new_rows.begin(), new_rows.end());
std::cout << rows << std::endl;
Solver solv(ngens, cosets, rels);
std::cout << thrust::host_vector<Row>(rows) << std::endl;
thrust::for_each(rows.begin(), rows.end(), solv);
std::cout << thrust::host_vector<Row>(rows) << std::endl;
*/
return cosets; return cosets;
} }