Changeset 6ff08d8 for doc/theses
- Timestamp:
- Jul 12, 2021, 1:44:35 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 605673f, 9345684
- Parents:
- cf444b6 (diff), a953c2e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- doc/theses
- Files:
-
- 1 added
- 21 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/CondCatch.java
rcf444b6 r6ff08d8 3 3 class EmptyException extends Exception {} 4 4 5 public class Cond Match {5 public class CondCatch { 6 6 static boolean should_catch = false; 7 7 … … 20 20 } 21 21 22 public static void main(String[] args) { 23 int times = 1; 24 int total_frames = 1; 25 if (0 < args.length) { 26 times = Integer.parseInt(args[0]); 27 } 28 if (1 < args.length) { 29 total_frames = Integer.parseInt(args[1]); 30 } 31 22 private static long loop(int times) { 23 long startTime = System.nanoTime(); 32 24 for (int count = 0 ; count < times ; ++count) { 33 25 try { … … 37 29 } 38 30 } 31 long endTime = System.nanoTime(); 32 return endTime - startTime; 33 } 34 35 public static void main(String[] args) { 36 int times = 1; 37 if (0 < args.length) { 38 times = Integer.parseInt(args[0]); 39 } 40 if (1 < args.length) { 41 should_catch = 0 != Integer.parseInt(args[1]); 42 } 43 44 // Warm-Up: 45 loop(1000); 46 47 long time = loop(times); 48 System.out.println("Run-Time (ns): " + time); 39 49 } 40 50 } -
doc/theses/andrew_beach_MMath/code/CrossCatch.java
rcf444b6 r6ff08d8 4 4 5 5 public class CrossCatch { 6 public static void main(String[] args) { 7 int times = 1; 8 boolean shouldThrow = false; 9 if (0 < args.length) { 10 times = Integer.parseInt(args[0]); 11 } 6 private static boolean shouldThrow = false; 12 7 8 private static long loop(int times) { 9 long startTime = System.nanoTime(); 13 10 for (int count = 0 ; count < times ; ++count) { 14 11 try { … … 20 17 } 21 18 } 19 long endTime = System.nanoTime(); 20 return endTime - startTime; 21 } 22 23 public static void main(String[] args) { 24 int times = 1; 25 if (0 < args.length) { 26 times = Integer.parseInt(args[0]); 27 } 28 29 // Warm-Up: 30 loop(1000); 31 32 long time = loop(times); 33 System.out.println("Run-Time (ns): " + time); 22 34 } 23 35 } -
doc/theses/andrew_beach_MMath/code/CrossFinally.java
rcf444b6 r6ff08d8 2 2 3 3 public class CrossFinally { 4 public static void main(String[] args) { 5 int times = 1; 6 boolean shouldThrow = false; 7 if (0 < args.length) { 8 times = Integer.parseInt(args[0]); 9 } 4 private static boolean shouldThrow = false; 10 5 6 private static long loop(int times) { 7 long startTime = System.nanoTime(); 11 8 for (int count = 0 ; count < times ; ++count) { 12 9 try { … … 16 13 } 17 14 } 15 long endTime = System.nanoTime(); 16 return endTime - startTime; 17 } 18 19 public static void main(String[] args) { 20 int times = 1; 21 if (0 < args.length) { 22 times = Integer.parseInt(args[0]); 23 } 24 25 // Warm-Up: 26 loop(1000); 27 28 long time = loop(times); 29 System.out.println("Run-Time (ns): " + time); 18 30 } 19 31 } -
doc/theses/andrew_beach_MMath/code/ThrowEmpty.java
rcf444b6 r6ff08d8 12 12 } 13 13 14 private static long loop(int times, int total_frames) { 15 long startTime = System.nanoTime(); 16 for (int count = 0 ; count < times ; ++count) { 17 try { 18 unwind_empty(total_frames); 19 } catch (EmptyException e) { 20 // ... 21 } 22 } 23 long endTime = System.nanoTime(); 24 return endTime - startTime; 25 } 26 14 27 public static void main(String[] args) { 15 28 int times = 1; … … 22 35 } 23 36 24 for (int count = 0 ; count < times ; ++count) { 25 try { 26 unwind_empty(total_frames); 27 } catch (EmptyException e) { 28 // ... 29 } 30 } 37 // Warm-Up: 38 loop(1000, total_frames); 39 40 long time = loop(times, total_frames); 41 System.out.println("Run-Time (ns): " + time); 31 42 } 32 43 } -
doc/theses/andrew_beach_MMath/code/ThrowFinally.java
rcf444b6 r6ff08d8 13 13 } 14 14 15 private static long loop(int times, int total_frames) { 16 long startTime = System.nanoTime(); 17 for (int count = 0 ; count < times ; ++count) { 18 try { 19 unwind_finally(total_frames); 20 } catch (EmptyException e) { 21 // ... 22 } 23 } 24 long endTime = System.nanoTime(); 25 return endTime - startTime; 26 } 27 15 28 public static void main(String[] args) { 16 29 int times = 1; … … 23 36 } 24 37 25 for (int count = 0 ; count < times ; ++count) { 26 try { 27 unwind_finally(total_frames); 28 } catch (EmptyException e) { 29 // ... 30 } 31 } 38 // Warm-Up: 39 loop(1000, total_frames); 40 41 long time = loop(times, total_frames); 42 System.out.println("Run-Time (ns): " + time); 32 43 } 33 44 } -
doc/theses/andrew_beach_MMath/code/ThrowOther.java
rcf444b6 r6ff08d8 24 24 } 25 25 26 private static long loop(int times, int total_frames) { 27 long startTime = System.nanoTime(); 28 for (int count = 0 ; count < times ; ++count) { 29 try { 30 unwind_other(total_frames); 31 } catch (EmptyException e) { 32 // ... 33 } catch (NotRaisedException e) { 34 // ... 35 } 36 } 37 long endTime = System.nanoTime(); 38 return endTime - startTime; 39 } 40 26 41 public static void main(String[] args) { 27 42 int times = 1; … … 34 49 } 35 50 36 for (int count = 0 ; count < times ; ++count) { 37 try { 38 unwind_other(total_frames); 39 } catch (EmptyException e) { 40 // ... 41 } catch (NotRaisedException e) { 42 // ... 43 } 44 } 51 // Warm-Up: 52 loop(1000, total_frames); 53 54 long time = loop(times, total_frames); 55 System.out.println("Run-Time (ns): " + time); 45 56 } 46 57 } -
doc/theses/andrew_beach_MMath/code/cond-catch.cfa
rcf444b6 r6ff08d8 1 1 // Conditional Match (or Re-Raise) 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.h> 4 6 … … 23 25 int main(int argc, char * argv[]) { 24 26 unsigned int times = 1; 25 if ( 2< argc) {27 if (1 < argc) { 26 28 times = strtol(argv[1], 0p, 10); 27 29 } 30 if (2 < argc) { 31 should_catch = strtol(argv[2], 0p, 10); 32 } 28 33 34 Time start_time = timeHiRes(); 29 35 for (unsigned int count = 0 ; count < times ; ++count) { 30 36 try { … … 34 40 } 35 41 } 42 Time end_time = timeHiRes(); 43 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 36 44 } -
doc/theses/andrew_beach_MMath/code/cond-catch.cpp
rcf444b6 r6ff08d8 1 1 // Conditional Match (or Re-Raise) 2 #include <chrono> 3 #include <cstdlib> 2 4 #include <exception> 3 #include <cstdlib> 5 #include <iostream> 6 7 using namespace std::chrono; 4 8 5 9 struct EmptyException : public std::exception {}; … … 23 27 int main(int argc, char * argv[]) { 24 28 unsigned int times = 1; 25 unsigned int total_frames = 1; 26 if (2 < argc) { 29 if (1 < argc) { 27 30 times = strtol(argv[1], nullptr, 10); 28 31 } 29 if ( 3< argc) {30 total_frames= strtol(argv[2], nullptr, 10);32 if (2 < argc) { 33 should_catch = strtol(argv[2], nullptr, 10); 31 34 } 32 35 36 time_point<steady_clock> start_time = steady_clock::now(); 33 37 for (unsigned int count = 0 ; count < times ; ++count) { 34 38 try { … … 38 42 } 39 43 } 44 time_point<steady_clock> end_time = steady_clock::now(); 45 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 46 std::cout << "Run-Time (ns): " << duration.count() << std::endl; 40 47 } -
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa
rcf444b6 r6ff08d8 1 1 // Conditional Match (or Re-Raise) 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 23 25 int main(int argc, char * argv[]) { 24 26 unsigned int times = 1; 25 unsigned int total_frames = 1; 26 if (2 < argc) { 27 if (1 < argc) { 27 28 times = strtol(argv[1], 0p, 10); 28 29 } 29 if ( 3< argc) {30 total_frames= strtol(argv[2], 0p, 10);30 if (2 < argc) { 31 should_catch = strtol(argv[2], 0p, 10); 31 32 } 32 33 34 Time start_time = timeHiRes(); 33 35 for (unsigned int count = 0 ; count < times ; ++count) { 34 36 try { … … 38 40 } 39 41 } 42 Time end_time = timeHiRes(); 43 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 40 44 } -
doc/theses/andrew_beach_MMath/code/cross-catch.cfa
rcf444b6 r6ff08d8 1 1 // Cross a Try Statement with a Termination Handler 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 8 10 unsigned int times = 1; 9 11 unsigned int total_frames = 1; 10 if ( 2< argc) {12 if (1 < argc) { 11 13 times = strtol(argv[1], 0p, 10); 12 14 } 13 if ( 3< argc) {15 if (2 < argc) { 14 16 total_frames = strtol(argv[2], 0p, 10); 15 17 } 16 18 19 Time start_time = timeHiRes(); 17 20 for (unsigned int count = 0 ; count < times ; ++count) { 18 21 try { … … 22 25 } 23 26 } 27 Time end_time = timeHiRes(); 28 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 24 29 } -
doc/theses/andrew_beach_MMath/code/cross-catch.cpp
rcf444b6 r6ff08d8 1 1 // Cross a Try Statement with a Termination Handler 2 #include <chrono> 3 #include <cstdlib> 2 4 #include <exception> 3 #include <cstdlib> 5 #include <iostream> 6 7 using namespace std::chrono; 4 8 5 9 struct NotRaisedException : public std::exception {}; … … 7 11 int main(int argc, char * argv[]) { 8 12 unsigned int times = 1; 9 if ( 2< argc) {13 if (1 < argc) { 10 14 times = strtol(argv[1], nullptr, 10); 11 15 } 12 16 17 time_point<steady_clock> start_time = steady_clock::now(); 13 18 for (unsigned int count = 0 ; count < times ; ++count) { 14 19 try { … … 18 23 } 19 24 } 25 time_point<steady_clock> end_time = steady_clock::now(); 26 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 27 std::cout << "Run-Time (ns): " << duration.count() << std::endl; 20 28 } -
doc/theses/andrew_beach_MMath/code/cross-finally.cfa
rcf444b6 r6ff08d8 1 1 // Cross a Try Statement With Finally Clause 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 6 8 unsigned int times = 1; 7 9 unsigned int total_frames = 1; 8 if ( 2< argc) {10 if (1 < argc) { 9 11 times = strtol(argv[1], 0p, 10); 10 12 } 11 if ( 3< argc) {13 if (2 < argc) { 12 14 total_frames = strtol(argv[2], 0p, 10); 13 15 } 14 16 17 Time start_time = timeHiRes(); 15 18 for (unsigned int count = 0 ; count < times ; ++count) { 16 19 try { … … 20 23 } 21 24 } 25 Time end_time = timeHiRes(); 26 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 22 27 } -
doc/theses/andrew_beach_MMath/code/cross-resume.cfa
rcf444b6 r6ff08d8 1 1 // Cross a Try Statement With Finally Clause 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 8 10 unsigned int times = 1; 9 11 unsigned int total_frames = 1; 10 if ( 2< argc) {12 if (1 < argc) { 11 13 times = strtol(argv[1], 0p, 10); 12 14 } 13 if ( 3< argc) {15 if (2 < argc) { 14 16 total_frames = strtol(argv[2], 0p, 10); 15 17 } 16 18 19 Time start_time = timeHiRes(); 17 20 for (unsigned int count = 0 ; count < times ; ++count) { 18 21 try { … … 22 25 } 23 26 } 27 Time end_time = timeHiRes(); 28 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 24 29 } -
doc/theses/andrew_beach_MMath/code/resume-detor.cfa
rcf444b6 r6ff08d8 1 1 // Throw Across Destructor 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 26 28 unsigned int times = 1; 27 29 unsigned int total_frames = 1; 28 if ( 2< argc) {30 if (1 < argc) { 29 31 times = strtol(argv[1], 0p, 10); 30 32 } 31 if ( 3< argc) {33 if (2 < argc) { 32 34 total_frames = strtol(argv[2], 0p, 10); 33 35 } 34 36 37 Time start_time = timeHiRes(); 35 38 for (int count = 0 ; count < times ; ++count) { 36 39 try { … … 40 43 } 41 44 } 45 Time end_time = timeHiRes(); 46 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 42 47 } -
doc/theses/andrew_beach_MMath/code/resume-empty.cfa
rcf444b6 r6ff08d8 1 1 // Resume Across Empty Function 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 9 11 void unwind_empty(unsigned int frames) { 10 12 if (frames) { 11 12 13 unwind_empty(frames - 1); 13 14 } else { … … 19 20 unsigned int times = 1; 20 21 unsigned int total_frames = 1; 21 if ( 2< argc) {22 if (1 < argc) { 22 23 times = strtol(argv[1], 0p, 10); 23 24 } 24 if ( 3< argc) {25 if (2 < argc) { 25 26 total_frames = strtol(argv[2], 0p, 10); 26 27 } 27 28 29 Time start_time = timeHiRes(); 28 30 for (int count = 0 ; count < times ; ++count) { 29 31 try { … … 33 35 } 34 36 } 37 Time end_time = timeHiRes(); 38 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 35 39 } -
doc/theses/andrew_beach_MMath/code/resume-finally.cfa
rcf444b6 r6ff08d8 1 1 // Throw Across Finally 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 22 24 unsigned int times = 1; 23 25 unsigned int total_frames = 1; 24 if ( 2< argc) {26 if (1 < argc) { 25 27 times = strtol(argv[1], 0p, 10); 26 28 } 27 if ( 3< argc) {29 if (2 < argc) { 28 30 total_frames = strtol(argv[2], 0p, 10); 29 31 } 30 32 33 Time start_time = timeHiRes(); 31 34 for (int count = 0 ; count < times ; ++count) { 32 35 try { … … 36 39 } 37 40 } 41 Time end_time = timeHiRes(); 42 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 38 43 } -
doc/theses/andrew_beach_MMath/code/resume-other.cfa
rcf444b6 r6ff08d8 1 1 // Resume Across Other Handler 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 24 26 unsigned int times = 1; 25 27 unsigned int total_frames = 1; 26 if ( 2< argc) {28 if (1 < argc) { 27 29 times = strtol(argv[1], 0p, 10); 28 30 } 29 if ( 3< argc) {31 if (2 < argc) { 30 32 total_frames = strtol(argv[2], 0p, 10); 31 33 } 32 34 35 Time start_time = timeHiRes(); 33 36 for (int count = 0 ; count < times ; ++count) { 34 37 try { … … 38 41 } 39 42 } 43 Time end_time = timeHiRes(); 44 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 40 45 } -
doc/theses/andrew_beach_MMath/code/throw-detor.cfa
rcf444b6 r6ff08d8 1 1 // Throw Across Destructor 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 25 27 unsigned int times = 1; 26 28 unsigned int total_frames = 1; 27 if ( 2< argc) {29 if (1 < argc) { 28 30 times = strtol(argv[1], 0p, 10); 29 31 } 30 if ( 3< argc) {32 if (2 < argc) { 31 33 total_frames = strtol(argv[2], 0p, 10); 32 34 } 33 35 36 Time start_time = timeHiRes(); 34 37 for (int count = 0 ; count < times ; ++count) { 35 38 try { … … 39 42 } 40 43 } 44 Time end_time = timeHiRes(); 45 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 41 46 } -
doc/theses/andrew_beach_MMath/code/throw-detor.cpp
rcf444b6 r6ff08d8 1 1 // Throw Across Destructor 2 #include <chrono> 3 #include <cstdlib> 2 4 #include <exception> 3 #include <cstdlib> 5 #include <iostream> 6 7 using namespace std::chrono; 4 8 5 9 struct EmptyException : public std::exception {}; … … 21 25 unsigned int times = 1; 22 26 unsigned int total_frames = 1; 23 if ( 2< argc) {27 if (1 < argc) { 24 28 times = strtol(argv[1], nullptr, 10); 25 29 } 26 if ( 3< argc) {30 if (2 < argc) { 27 31 total_frames = strtol(argv[2], nullptr, 10); 28 32 } 29 33 34 time_point<steady_clock> start_time = steady_clock::now(); 30 35 for (int count = 0 ; count < times ; ++count) { 31 36 try { … … 35 40 } 36 41 } 42 time_point<steady_clock> end_time = steady_clock::now(); 43 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 44 std::cout << "Run-Time (ns): " << duration.count() << std::endl; 37 45 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cfa
rcf444b6 r6ff08d8 1 1 // Throw Across Empty Function 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 18 20 unsigned int times = 1; 19 21 unsigned int total_frames = 1; 20 if ( 2< argc) {22 if (1 < argc) { 21 23 times = strtol(argv[1], 0p, 10); 22 24 } 23 if ( 3< argc) {25 if (2 < argc) { 24 26 total_frames = strtol(argv[2], 0p, 10); 25 27 } 26 28 29 Time start_time = timeHiRes(); 27 30 for (unsigned int count = 0 ; count < times ; ++count) { 28 31 try { … … 32 35 } 33 36 } 37 Time end_time = timeHiRes(); 38 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 34 39 } -
doc/theses/andrew_beach_MMath/code/throw-empty.cpp
rcf444b6 r6ff08d8 1 1 // Throw Across Empty Function 2 #include <chrono> 3 #include <cstdlib> 2 4 #include <exception> 3 #include <cstdlib> 5 #include <iostream> 6 7 using namespace std::chrono; 4 8 5 9 struct EmptyException : public std::exception {}; … … 16 20 unsigned int times = 1; 17 21 unsigned int total_frames = 1; 18 if ( 2< argc) {22 if (1 < argc) { 19 23 times = strtol(argv[1], nullptr, 10); 20 24 } 21 if ( 3< argc) {25 if (2 < argc) { 22 26 total_frames = strtol(argv[2], nullptr, 10); 23 27 } 24 28 29 time_point<steady_clock> start_time = steady_clock::now(); 25 30 for (unsigned int count = 0 ; count < times ; ++count) { 26 31 try { … … 30 35 } 31 36 } 37 time_point<steady_clock> end_time = steady_clock::now(); 38 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 39 std::cout << "Run-Time (ns): " << duration.count() << std::endl; 32 40 } -
doc/theses/andrew_beach_MMath/code/throw-finally.cfa
rcf444b6 r6ff08d8 1 1 // Throw Across Finally 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 22 24 unsigned int times = 1; 23 25 unsigned int total_frames = 1; 24 if ( 2< argc) {26 if (1 < argc) { 25 27 times = strtol(argv[1], 0p, 10); 26 28 } 27 if ( 3< argc) {29 if (2 < argc) { 28 30 total_frames = strtol(argv[2], 0p, 10); 29 31 } 30 32 33 Time start_time = timeHiRes(); 31 34 for (int count = 0 ; count < times ; ++count) { 32 35 try { … … 36 39 } 37 40 } 41 Time end_time = timeHiRes(); 42 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 38 43 } -
doc/theses/andrew_beach_MMath/code/throw-other.cfa
rcf444b6 r6ff08d8 1 1 // Throw Across Other Handler 2 #include <clock.hfa> 2 3 #include <exception.hfa> 4 #include <fstream.hfa> 3 5 #include <stdlib.hfa> 4 6 … … 24 26 unsigned int times = 1; 25 27 unsigned int total_frames = 1; 26 if ( 2< argc) {28 if (1 < argc) { 27 29 times = strtol(argv[1], 0p, 10); 28 30 } 29 if ( 3< argc) {31 if (2 < argc) { 30 32 total_frames = strtol(argv[2], 0p, 10); 31 33 } 32 34 35 Time start_time = timeHiRes(); 33 36 for (int count = 0 ; count < times ; ++count) { 34 37 try { … … 38 41 } 39 42 } 43 Time end_time = timeHiRes(); 44 sout | "Run-Time (ns): " | (end_time - start_time)`ns; 40 45 } -
doc/theses/andrew_beach_MMath/code/throw-other.cpp
rcf444b6 r6ff08d8 1 1 // Throw Across Other Handler 2 #include <chrono> 3 #include <cstdlib> 2 4 #include <exception> 3 #include <cstdlib> 5 #include <iostream> 6 7 using namespace std::chrono; 4 8 5 9 struct EmptyException : public std::exception {}; … … 22 26 unsigned int times = 1; 23 27 unsigned int total_frames = 1; 24 if ( 2< argc) {28 if (1 < argc) { 25 29 times = strtol(argv[1], nullptr, 10); 26 30 } 27 if ( 3< argc) {31 if (2 < argc) { 28 32 total_frames = strtol(argv[2], nullptr, 10); 29 33 } 30 34 35 time_point<steady_clock> start_time = steady_clock::now(); 31 36 for (int count = 0 ; count < times ; ++count) { 32 37 try { … … 36 41 } 37 42 } 43 time_point<steady_clock> end_time = steady_clock::now(); 44 nanoseconds duration = duration_cast<nanoseconds>(end_time - start_time); 45 std::cout << "Run-Time (ns): " << duration.count() << std::endl; 38 46 } -
doc/theses/mubeen_zulfiqar_MMath/allocator.tex
rcf444b6 r6ff08d8 44 44 45 45 \subsection{Design philosophy} 46 46 The objective of uHeapLmmm's new design was to fulfill following requirements: 47 \begin{itemize} 48 \item It should be concurrent to be used in multi-threaded programs. 49 \item It should avoid global locks, on resources shared across all threads, as much as possible. 50 \item It's performance (FIX ME: cite performance benchmarks) should be comparable to the commonly used allocators (FIX ME: cite common allocators). 51 \item It should be a lightweight memory allocator. 52 \end{itemize} 47 53 48 54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 49 55 50 56 \section{Background and previous design of uHeapLmmm} 51 57 uHeapLmmm was originally designed by X in X (FIX ME: add original author after confirming with Peter). 58 (FIX ME: make and add figure of previous design with description) 52 59 53 60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54 61 55 62 \section{Distributed design of uHeapLmmm} 63 uHeapLmmm's design was reviewed and changed to fulfill new requirements (FIX ME: cite allocator philosophy). For this purpose, following two designs of uHeapLmm were proposed: 56 64 65 \paragraph{Design 1: Decentralized} 66 Fixed number of heaps: shard the heap into N heaps each with a bump-area allocated from the @sbrk@ area. 67 Kernel threads (KT) are assigned to the N heaps. 68 When KTs $\le$ N, the heaps are uncontented. 69 When KTs $>$ N, the heaps are contented. 70 By adjusting N, this approach reduces storage at the cost of speed due to contention. 71 In all cases, a thread acquires/releases a lock, contented or uncontented. 72 \begin{cquote} 73 \centering 74 \input{AllocDS1} 75 \end{cquote} 76 Problems: need to know when a KT is created and destroyed to know when to assign/un-assign a heap to the KT. 77 78 \paragraph{Design 2: Centralized} 79 One heap, but lower bucket sizes are N-shared across KTs. 80 This design leverages the fact that 95\% of allocation requests are less than 512 bytes and there are only 3--5 different request sizes. 81 When KTs $\le$ N, the important bucket sizes are uncontented. 82 When KTs $>$ N, the free buckets are contented. 83 Therefore, threads are only contending for a small number of buckets, which are distributed among them to reduce contention. 84 \begin{cquote} 85 \centering 86 \input{AllocDS2} 87 \end{cquote} 88 Problems: need to know when a kernel thread (KT) is created and destroyed to know when to assign a shared bucket-number. 89 When no thread is assigned a bucket number, its free storage is unavailable. All KTs will be contended for one lock on sbrk for their initial allocations (before free-lists gets populated). 90 91 Out of the two designs, Design 1 was chosen because it's concurrency is better across all bucket-sizes as design-2 shards a few buckets of selected sizes while design-1 shards all the buckets. Design-2 shards the whole heap which has all the buckets with the addition of sharding sbrk area. 57 92 58 93 \subsection{Advantages of distributed design} 94 The distributed design of uHeapLmmm is concurrent to work in multi-threaded applications. 59 95 96 Some key benefits of the distributed design of uHeapLmmm are as follows: 97 98 \begin{itemize} 99 \item 100 The bump allocation is concurrent as memory taken from sbrk is sharded across all heaps as bump allocation reserve. The lock on bump allocation (on memory taken from sbrk) will only be contended if KTs > N. The contention on sbrk area is less likely as it will only happen in the case if heaps assigned to two KTs get short of bump allocation reserve simultanously. 101 \item 102 N heaps are created at the start of the program and destroyed at the end of program. When a KT is created, we only assign it to one of the heaps. When a KT is destroyed, we only dissociate it from the assigned heap but we do not destroy that heap. That heap will go back to our pool-of-heaps, ready to be used by some new KT. And if that heap was shared among multiple KTs (like the case of KTs > N) then, on deletion of one KT, that heap will be still in-use of the other KTs. This will prevent creation and deletion of heaps during run-time as heaps are re-usable which helps in keeping low-memory footprint. 103 \item 104 It is possible to use sharing and stealing techniques to share/find unused storage, when a free list is unused or empty. 105 \item 106 Distributed design avoids unnecassry locks on resources shared across all KTs. 107 \end{itemize} 108 109 FIX ME: Cite performance comparison of the two heap designs if required 60 110 61 111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 72 122 Why did we need it? 73 123 The added benefits. 74 75 76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%77 % Following is added by Peter78 79 \noindent80 ====================81 82 \newpage83 \paragraph{Design 1: Decentralized}84 Fixed number of heaps: shard the heap into N heaps each with a bump-area allocated from the @sbrk@ area.85 Kernel threads (KT) are assigned to the N heaps.86 When KTs $\le$ N, the heaps are uncontented.87 When KTs $>$ N, the heaps are contented.88 By adjusting N, this approach reduces storage at the cost of speed due to contention.89 In all cases, a thread acquires/releases a lock, contented or uncontented.90 \begin{cquote}91 \centering92 \input{AllocDS1}93 \end{cquote}94 Problems: need to know when a KT is created and destroyed to know when to create/delete the KT's heap.95 On KT deletion, its heap freed-storage needs to be distributed somewhere.96 97 \paragraph{Design 2: Centralized}98 99 One heap, but lower bucket sizes are N-shared across KTs.100 This design leverages the fact that 95\% of allocation requests are less than 512 bytes and there are only 3--5 different request sizes.101 When KTs $\le$ N, the important bucket sizes are uncontented.102 When KTs $>$ N, the free buckets are contented.103 Therefore, threads are only contending for a small number of buckets, which are distributed among them to reduce contention.104 \begin{cquote}105 \centering106 \input{AllocDS2}107 \end{cquote}108 Problems: need to know when a kernel thread (KT) is created and destroyed to know when to assign a shared bucket-number.109 When no thread is assigned a bucket number, its free storage is unavailable.110 It is possible to use sharing and stealing techniques to share/find unused storage, when a free list is unused or empty.
Note:
See TracChangeset
for help on using the changeset viewer.