9. Task Overview
● Tried 4 of 5
– Bucketsort
● Faster than seq and scaled to medium input
– Unbounded Knapsack Problem
● Faster than seq and scaled to largest input
– 3-SAT
● Better than seq, but not scaled
– Mutually Friendly Number
● Slower than seq, not scaled
10. Bucketsort
● N = 10^10, #Bucket = 94
1. Putting items to local buckets
2. Sort individually
3. Merge local buckets into shared bucket
– current: non-inplace merge
● Experiment
– Medium input (10^7) tested
– Large input(10^10) not complete the test
12. ● N < 1024, M < 10^6
● Dynamic programming works
for (int i=0; i<n; ++i)
for (int j = weight[i]; j <= w; ++j)
c[j] = max(c[j], c[j - weight[i]] + cost[i]);
Unbounded Knapsack
c[j]: the max value I could have with capacity at most up to j
take item inot to take item i
// Update to c[j] is atomic
#pragma omp parallel for
14. ● V1: just parallel seq code → slower than seq
● V2: random assign variables
– #trial = 10^10, true negative = 50%
→ not acceptable at all
● V3: dfs (clause by clause) + little opt
– C = (x1 v -x1 v x2) → C is satisfied
→ faster than seq but doesn't scale
3-SAT