Skip to content

Commit 5ffbc57

Browse files
committed
adding everything new now
1 parent d37ea2a commit 5ffbc57

18 files changed

+461
-380
lines changed

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ If your application uses multiple threads (e.g., with Pthreads), see `pthread_ex
88
- `pthread_example.cpp`: Similar to `thread_markers.cpp`, but runs across multiple threads using Pthreads.
99
In this case, threads must be explicitly initialized.
1010

11-
- `vmarkers_push_pop.cpp`: Equivalent to `thread_markers.cpp`, but uses VMARKERS (short for vanilla markers).
11+
- `vmarkers_push_pop.cpp`: Equivalent to `thread_markers.cpp`, but uses VMARKS (short for vanilla markers).
1212
These are lightweight markers that are pushed using a color ID instead of a marker ID. Useful when working with many different markers.
1313

14-
- `vmarkers_set.cpp`: Another VMARKERS example, this time using the SET method instead of PUSH/POP.
14+
- `vmarkers_set.cpp`: Another VMARKS example, this time using the SET method instead of PUSH/POP.
1515
The PUSH/POP method relies on each marker being explicitly pushed and later popped, whereas the SET method simply sets the marker without requiring an end point (i.e. a pop).

examples/pthread_example.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <unistd.h> // For getpid()
2121
#include <vector>
2222

23-
#include <tracr.hpp>
23+
#include <tracr/tracr.hpp>
2424

2525
#define NRANKS 4 // number of threads
2626
#define NTASKS 3 // number of tasks per thread
@@ -40,7 +40,7 @@ void *threadFunction(void *arg) {
4040
// TraCR init thread
4141
INSTRUMENTATION_THREAD_INIT();
4242

43-
INSTRUMENTATION_THREAD_MARK_SET(thrd_running_id);
43+
INSTRUMENTATION_MARK_SET(thrd_running_id);
4444

4545
// Get the process ID (PID) and thread ID (TID)
4646
pid_t pid = getpid(); // Process ID
@@ -60,11 +60,11 @@ void *threadFunction(void *arg) {
6060
std::cout << "Thread " << id << " is running task: " << taskid << std::endl;
6161
}
6262

63-
INSTRUMENTATION_THREAD_MARK_SET(thrd_finished_id);
63+
INSTRUMENTATION_MARK_SET(thrd_finished_id);
6464

6565
// Optional: This marker pushes the int64_t max value. Can be used to indicate
6666
// the ending.
67-
INSTRUMENTATION_VMARKER_RESET();
67+
INSTRUMENTATION_MARK_RESET();
6868

6969
// TraCR free thread
7070
INSTRUMENTATION_THREAD_END();
@@ -83,18 +83,18 @@ int main() {
8383
INSTRUMENTATION_START(externally_init);
8484

8585
// 0 == Set and 1 == Push/Pop
86-
INSTRUMENTATION_THREAD_MARK_INIT(0);
86+
INSTRUMENTATION_MARK_INIT(0);
8787

8888
// Each Label creation costs around (~3us)
8989
// Should be done at the beginning or at the ending of the code
9090
thrd_running_id =
91-
INSTRUMENTATION_THREAD_MARK_ADD(MARK_COLOR_MINT, "thread running");
91+
INSTRUMENTATION_MARK_ADD(MARK_COLOR_MINT, "thread running");
9292
thrd_finished_id =
93-
INSTRUMENTATION_THREAD_MARK_ADD(MARK_COLOR_GREEN, "thread finished");
93+
INSTRUMENTATION_MARK_ADD(MARK_COLOR_GREEN, "thread finished");
9494
const size_t thrd_join_id =
95-
INSTRUMENTATION_THREAD_MARK_ADD(MARK_COLOR_BROWN, "join threads");
95+
INSTRUMENTATION_MARK_ADD(MARK_COLOR_BROWN, "join threads");
9696
const size_t thrds_end_id =
97-
INSTRUMENTATION_THREAD_MARK_ADD(MARK_COLOR_RED, "threads end");
97+
INSTRUMENTATION_MARK_ADD(MARK_COLOR_RED, "threads end");
9898

9999
std::vector<pthread_t> threads(NRANKS); // Vector to hold pthreads
100100
std::vector<int> threadIds(NRANKS); // Vector to hold thread IDs
@@ -108,14 +108,14 @@ int main() {
108108
pthread_create(&threads[i], nullptr, threadFunction, &threadIds[i]);
109109
}
110110

111-
INSTRUMENTATION_THREAD_MARK_SET(thrd_join_id);
111+
INSTRUMENTATION_MARK_SET(thrd_join_id);
112112

113113
// Wait for all threads to finish
114114
for (int i = 0; i < NRANKS; ++i) {
115115
pthread_join(threads[i], nullptr);
116116
}
117117

118-
INSTRUMENTATION_THREAD_MARK_SET(thrds_end_id);
118+
INSTRUMENTATION_MARK_SET(thrds_end_id);
119119

120120
std::cout << "All threads have finished." << std::endl;
121121

examples/pytracr/pthread_example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def threadFunction(lock, id, thrd_running_id, thrd_finished_id):
3636
# TraCR init thread
3737
INSTRUMENTATION_THREAD_INIT()
3838

39-
INSTRUMENTATION_THREAD_MARK_SET(thrd_running_id)
39+
INSTRUMENTATION_MARK_SET(thrd_running_id)
4040

4141
# Get the process ID (PID) and thread ID (TID)
4242
pid = os.getpid() # Process ID
@@ -53,7 +53,7 @@ def threadFunction(lock, id, thrd_running_id, thrd_finished_id):
5353

5454
print(f"Thread {id} is running task: {taskid}")
5555

56-
INSTRUMENTATION_THREAD_MARK_SET(thrd_finished_id)
56+
INSTRUMENTATION_MARK_SET(thrd_finished_id)
5757

5858
# TraCR free thread
5959
INSTRUMENTATION_THREAD_END()
@@ -67,14 +67,14 @@ def main():
6767
INSTRUMENTATION_START()
6868

6969
# 0 == Set and 1 == Push/Pop
70-
INSTRUMENTATION_THREAD_MARK_INIT(0)
70+
INSTRUMENTATION_MARK_INIT(0)
7171

7272
# Each Label creation costs around (~3us)
7373
# Should be done at the beginning or at the ending of the code
74-
thrd_running_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_MINT, "thread running")
75-
thrd_finished_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_GREEN, "thread finished")
76-
thrd_join_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_BROWN, "join threads")
77-
thrds_end_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_RED, "threads end")
74+
thrd_running_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_MINT, "thread running")
75+
thrd_finished_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_GREEN, "thread finished")
76+
thrd_join_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_BROWN, "join threads")
77+
thrds_end_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_RED, "threads end")
7878

7979
threads = [None] * NRANKS # Vector to hold pthreads
8080
threadIds = [None] * NRANKS # Vector to hold thread IDs
@@ -90,13 +90,13 @@ def main():
9090

9191
threads[i].start()
9292

93-
INSTRUMENTATION_THREAD_MARK_SET(thrd_join_id)
93+
INSTRUMENTATION_MARK_SET(thrd_join_id)
9494

9595
# Wait for all threads to finish
9696
for thread in threads:
9797
thread.join()
9898

99-
INSTRUMENTATION_THREAD_MARK_SET(thrds_end_id)
99+
INSTRUMENTATION_MARK_SET(thrds_end_id)
100100

101101
print("All threads have finished.")
102102

examples/pytracr/thread_markers.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,49 +30,49 @@ def main():
3030
INSTRUMENTATION_START()
3131

3232
# 0 == Set and 1 == Push/Pop
33-
INSTRUMENTATION_THREAD_MARK_INIT(1)
33+
INSTRUMENTATION_MARK_INIT(1)
3434

35-
# Each INSTRUMENTATION_THREAD_MARK_ADD costs around (~3us)
35+
# Each INSTRUMENTATION_MARK_ADD costs around (~3us)
3636
# Should be done at the beginning or at the ending of the code
37-
alloc_mem_label_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_TEAL, "Allocate Memory")
38-
fill_mat_label_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_LAVENDER, "Fill matrices with values")
39-
prt_mat_label_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_RED, "Print all matrices")
40-
mmm_label_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_PEACH, "MMM")
41-
prt_A_label_id = INSTRUMENTATION_THREAD_MARK_ADD(mark_color.MARK_COLOR_LIGHT_GRAY, "Print solution of matrix A")
37+
alloc_mem_label_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_TEAL, "Allocate Memory")
38+
fill_mat_label_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_LAVENDER, "Fill matrices with values")
39+
prt_mat_label_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_RED, "Print all matrices")
40+
mmm_label_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_PEACH, "MMM")
41+
prt_A_label_id = INSTRUMENTATION_MARK_ADD(mark_color.MARK_COLOR_LIGHT_GRAY, "Print solution of matrix A")
4242

4343
t_after_label_set = time.time()
4444

4545
# allocate memory
46-
INSTRUMENTATION_THREAD_MARK_PUSH(alloc_mem_label_id)
46+
INSTRUMENTATION_MARK_PUSH(alloc_mem_label_id)
4747
A = np.empty((N,N))
4848
B = np.empty((N,N))
4949
C = np.empty((N,N))
5050

5151
# fill matrices
52-
INSTRUMENTATION_THREAD_MARK_PUSH(fill_mat_label_id)
52+
INSTRUMENTATION_MARK_PUSH(fill_mat_label_id)
5353
for i in range(N):
5454
for j in range(N):
5555
B[i,j] = i
5656
C[i,j] = j
57-
INSTRUMENTATION_THREAD_MARK_POP(fill_mat_label_id)
58-
INSTRUMENTATION_THREAD_MARK_POP(alloc_mem_label_id)
57+
INSTRUMENTATION_MARK_POP(fill_mat_label_id)
58+
INSTRUMENTATION_MARK_POP(alloc_mem_label_id)
5959

6060
# print matrices
61-
INSTRUMENTATION_THREAD_MARK_PUSH(prt_mat_label_id)
61+
INSTRUMENTATION_MARK_PUSH(prt_mat_label_id)
6262
print(f"A: {A}")
6363
print(f"B: {B}")
6464
print(f"C: {C}")
65-
INSTRUMENTATION_THREAD_MARK_POP(prt_mat_label_id)
65+
INSTRUMENTATION_MARK_POP(prt_mat_label_id)
6666

6767
# mmm
68-
INSTRUMENTATION_THREAD_MARK_PUSH(mmm_label_id)
68+
INSTRUMENTATION_MARK_PUSH(mmm_label_id)
6969
A = B @ C
70-
INSTRUMENTATION_THREAD_MARK_POP(mmm_label_id)
70+
INSTRUMENTATION_MARK_POP(mmm_label_id)
7171

7272
# last print
73-
INSTRUMENTATION_THREAD_MARK_PUSH(prt_A_label_id)
73+
INSTRUMENTATION_MARK_PUSH(prt_A_label_id)
7474
print(f"A: {A}")
75-
INSTRUMENTATION_THREAD_MARK_POP(prt_A_label_id)
75+
INSTRUMENTATION_MARK_POP(prt_A_label_id)
7676

7777
# TraCR finished
7878
INSTRUMENTATION_END()

examples/pytracr/vmarkers_push_pop.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
VMakers (Vanilla Markers) are the type of markers pushing the color ID
2424
directly.
2525
26-
This example is the same as the thread_markers.cpp but with VMARKERS
26+
This example is the same as the thread_markers.cpp but with VMARKS
2727
They are useful if you don't wanna have labels and wanna keep track the
2828
number.
2929
30-
Still, one can use INSTRUMENTATION_VMARKER_LABEL() if labels are of need.
30+
Still, one can use INSTRUMENTATION_VMARK_LABEL() if labels are of need.
3131
But then you need to remember which color id corresponds to which label.
3232
"""
3333
def main():
@@ -40,50 +40,50 @@ def main():
4040

4141
# 0 == Set and 1 == Push/Pop
4242
flag = 1
43-
INSTRUMENTATION_VMARKER_TYPE(flag, "Simple Marker Example")
43+
INSTRUMENTATION_VMARK_TYPE(flag, "Simple Marker Example")
4444

45-
# Each INSTRUMENTATION_THREAD_MARK_ADD costs around (~3us)
45+
# Each INSTRUMENTATION_MARK_ADD costs around (~3us)
4646
# Should be done at the beginning or at the ending of the code
47-
INSTRUMENTATION_VMARKER_LABEL(MARK_COLOR_LIGHT_GREEN, "Allocate Memory")
48-
INSTRUMENTATION_VMARKER_LABEL(MARK_COLOR_LAVENDER,
47+
INSTRUMENTATION_VMARK_LABEL(MARK_COLOR_LIGHT_GREEN, "Allocate Memory")
48+
INSTRUMENTATION_VMARK_LABEL(MARK_COLOR_LAVENDER,
4949
"Fill matrices with values")
50-
INSTRUMENTATION_VMARKER_LABEL(MARK_COLOR_MAROON, "Print all matrices")
51-
INSTRUMENTATION_VMARKER_LABEL(MARK_COLOR_OLIVE, "MMM")
52-
INSTRUMENTATION_VMARKER_LABEL(MARK_COLOR_NAVY, "Print solution of matrix A")
50+
INSTRUMENTATION_VMARK_LABEL(MARK_COLOR_MAROON, "Print all matrices")
51+
INSTRUMENTATION_VMARK_LABEL(MARK_COLOR_OLIVE, "MMM")
52+
INSTRUMENTATION_VMARK_LABEL(MARK_COLOR_NAVY, "Print solution of matrix A")
5353

5454
t_after_label_set = time.time()
5555

5656
# allocate memory
57-
INSTRUMENTATION_VMARKER_PUSH(MARK_COLOR_LIGHT_GREEN)
57+
INSTRUMENTATION_VMARK_PUSH(MARK_COLOR_LIGHT_GREEN)
5858
A = np.empty((N,N))
5959
B = np.empty((N,N))
6060
C = np.empty((N,N))
6161

6262
# fill matrices
63-
INSTRUMENTATION_VMARKER_PUSH(MARK_COLOR_LAVENDER)
63+
INSTRUMENTATION_VMARK_PUSH(MARK_COLOR_LAVENDER)
6464
for i in range(N):
6565
for j in range(N):
6666
B[i, j] = i
6767
C[i, j] = j
68-
INSTRUMENTATION_VMARKER_POP(MARK_COLOR_LAVENDER)
69-
INSTRUMENTATION_VMARKER_POP(MARK_COLOR_LIGHT_GREEN)
68+
INSTRUMENTATION_VMARK_POP(MARK_COLOR_LAVENDER)
69+
INSTRUMENTATION_VMARK_POP(MARK_COLOR_LIGHT_GREEN)
7070

7171
# print matrices
72-
INSTRUMENTATION_VMARKER_PUSH(MARK_COLOR_MAROON)
72+
INSTRUMENTATION_VMARK_PUSH(MARK_COLOR_MAROON)
7373
print(f"A: {A}")
7474
print(f"B: {B}")
7575
print(f"C: {C}")
76-
INSTRUMENTATION_VMARKER_POP(MARK_COLOR_MAROON)
76+
INSTRUMENTATION_VMARK_POP(MARK_COLOR_MAROON)
7777

7878
# mmm
79-
INSTRUMENTATION_VMARKER_PUSH(MARK_COLOR_OLIVE)
79+
INSTRUMENTATION_VMARK_PUSH(MARK_COLOR_OLIVE)
8080
A = B @ C
81-
INSTRUMENTATION_VMARKER_POP(MARK_COLOR_OLIVE)
81+
INSTRUMENTATION_VMARK_POP(MARK_COLOR_OLIVE)
8282

8383
# last print
84-
INSTRUMENTATION_VMARKER_PUSH(MARK_COLOR_NAVY)
84+
INSTRUMENTATION_VMARK_PUSH(MARK_COLOR_NAVY)
8585
print(f"A: {A}")
86-
INSTRUMENTATION_VMARKER_POP(MARK_COLOR_NAVY)
86+
INSTRUMENTATION_VMARK_POP(MARK_COLOR_NAVY)
8787

8888
# TraCR finished
8989
INSTRUMENTATION_END()

examples/pytracr/vmarkers_set.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
"""
2020
Basic c code to demonstrate TraCR's VMAKERS
21-
This example uses the VMARKER SET method
21+
This example uses the VMARK SET method
2222
you can create a nice gradient plot in Paraver with it
2323
"""
2424
def main():
@@ -27,11 +27,11 @@ def main():
2727

2828
# use flag == 1 for push/pop and flag == 0 for the set method
2929
flag = 0
30-
INSTRUMENTATION_VMARKER_TYPE(flag, "Simple VMarker Example")
30+
INSTRUMENTATION_VMARK_TYPE(flag, "Simple VMarker Example")
3131

3232
n = 150
3333
for i in range(1, n+1):
34-
INSTRUMENTATION_VMARKER_SET(i)
34+
INSTRUMENTATION_VMARK_SET(i)
3535
print(i, end=' ')
3636

3737
# TraCR finished

0 commit comments

Comments
 (0)