Skip to content

Commit

Permalink
Add test to check for unnecessary allocation
Browse files Browse the repository at this point in the history
---
Signed-off-by: Michael Ferguson <[email protected]>
  • Loading branch information
mppf committed Sep 6, 2024
1 parent f3a1c28 commit 5c78534
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# show only lines containing "alloc int"
# show only lines after "alloc test begins"
# show only lines before "alloc test begins"
# show only lines after "alloc int test begins"
# show only lines before "alloc int test ends"
cat $2 | grep "alloc int" | grep -A 1000 "alloc int test begins" | grep -B 1000 "alloc int test ends" > $2.tmp
mv $2.tmp $2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# show only lines containing 'alloc int'
# show only lines after "alloc test begins"
# show only lines before "alloc test begins"
# show only lines after "alloc int test begins"
# show only lines before "alloc int test ends"
cat $2 | grep "alloc int" | grep -A 1000 "alloc int test begins" | grep -B 1000 "alloc int test ends" > $2.tmp
mv $2.tmp $2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// this test is intended as a reproducer for the
// problem of too much memory allocated
// shown in issue #25741

config const n = 100_000;

proc myfn(nn: int) : [0..<nn] int {
var ret: [0..<nn] int;
return ret;
}

proc main() {
writeln("alloc int test begins");
var x = myfn(n);
writeln("alloc int test ends");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--set debugDefaultDist=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alloc int test begins
*** DR alloc int(64) 100000
*** DR calling postalloc int(64) 100000
alloc int test ends
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# show only lines containing 'alloc int'
# show only lines after "alloc int test begins"
# show only lines before "alloc int test ends"
cat $2 | grep "alloc int" | grep -A 1000 "alloc int test begins" | grep -B 1000 "alloc int test ends" > $2.tmp
mv $2.tmp $2

0 comments on commit 5c78534

Please sign in to comment.