From 9cf45796b082a9c7528573dec40ff23e6abd8a64 Mon Sep 17 00:00:00 2001 From: Guillaume-Helbecque Date: Fri, 23 Aug 2024 23:50:54 +0200 Subject: [PATCH] optimize integers bit-size for 0/1-KP Node --- benchmarks/Knapsack/Node_Knapsack.chpl | 4 +--- benchmarks/Knapsack/Problem_Knapsack.chpl | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/benchmarks/Knapsack/Node_Knapsack.chpl b/benchmarks/Knapsack/Node_Knapsack.chpl index 9858dbf..1425add 100644 --- a/benchmarks/Knapsack/Node_Knapsack.chpl +++ b/benchmarks/Knapsack/Node_Knapsack.chpl @@ -1,13 +1,11 @@ module Node_Knapsack { - use CTypes; - config param maxItems: int = 50; record Node_Knapsack { var depth: int; - var items: c_array(int, maxItems); + var items: maxItems*uint(32); var weight: int; var profit: int; diff --git a/benchmarks/Knapsack/Problem_Knapsack.chpl b/benchmarks/Knapsack/Problem_Knapsack.chpl index dde01a4..5ae1a3b 100644 --- a/benchmarks/Knapsack/Problem_Knapsack.chpl +++ b/benchmarks/Knapsack/Problem_Knapsack.chpl @@ -122,7 +122,7 @@ class Problem_Knapsack : Problem for i in 0..1 { var child = new Node(parent); child.depth += 1; - child.items[parent.depth] = i; + child.items[parent.depth] = i:uint(32); child.weight += i*this.weight[parent.depth]; child.profit += i*this.profit[parent.depth];