Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TensorJoseph
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Camille Coti
TensorJoseph
Commits
42445948
Commit
42445948
authored
5 years ago
by
Camille Coti
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the TAU profiling function, added rdtsc
parent
9b9420a6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/profiling.cpp
+20
-22
20 additions, 22 deletions
src/profiling.cpp
src/profiling.h
+2
-1
2 additions, 1 deletion
src/profiling.h
src/sequential.cpp
+10
-5
10 additions, 5 deletions
src/sequential.cpp
with
32 additions
and
28 deletions
src/profiling.cpp
+
20
−
22
View file @
42445948
...
...
@@ -2,6 +2,7 @@
#include
"profiling.h"
#ifdef TAUPROF
double
previous
=
0
;
double
getTimeSpent
(
const
char
*
cnt
){
const
char
**
inFuncs
;
...
...
@@ -16,17 +17,10 @@ double getTimeSpent( const char* cnt ){
int
numOfFunctions
;
const
char
**
functionList
;
int
i
;
TAU_GET_FUNC_NAMES
(
functionList
,
numOfFunctions
);
numOfFunctions
=
1
;
inFuncs
=
(
const
char
**
)
malloc
(
sizeof
(
const
char
*
)
*
numOfFunctions
);
for
(
i
=
0
;
i
<
numOfFunctions
;
i
++
)
{
inFuncs
[
i
]
=
functionList
[
i
];
}
//Just to show consistency.
TAU_DB_DUMP
();
inFuncs
[
0
]
=
cnt
;
TAU_GET_FUNC_VALS
(
inFuncs
,
numOfFunctions
,
counterExclusiveValues
,
...
...
@@ -36,25 +30,29 @@ double getTimeSpent( const char* cnt ){
counterNames
,
numOfCouns
);
TAU_DUMP_FUNC_VALS_INCR
(
inFuncs
,
numOfFunctions
);
for
(
i
=
0
;
i
<
numOfFunctions
;
i
++
)
{
if
(
0
==
strcmp
(
cnt
,
inFuncs
[
i
]
)
)
{
TAU_DB_DUMP_INCR
();
return
counterExclusiveValues
[
i
][
0
];
}
i
=
0
;
if
(
0
==
strcmp
(
cnt
,
inFuncs
[
i
]
)
)
{
free
(
inFuncs
);
/* double dur = numOfCalls[i] - previous;
previous = numOfCalls[i];*/
double
dur
=
counterExclusiveValues
[
i
][
0
]
-
previous
;
previous
=
counterExclusiveValues
[
i
][
0
];
return
dur
;
}
TAU_DB_DUMP_INCR
();
std
::
cerr
<<
"Timer "
<<
cnt
<<
" not found"
<<
std
::
endl
;
free
(
inFuncs
);
return
-
1
;
}
#else
double
getTimeSpent
(
const
char
*
cnt
){
return
0
;
}
#endif // def TAUPROF
uint64_t
rdtsc
(){
unsigned
int
lo
,
hi
;
__asm__
__volatile__
(
"rdtsc"
:
"=a"
(
lo
),
"=d"
(
hi
));
return
((
uint64_t
)
hi
<<
32
)
|
lo
;
}
This diff is collapsed.
Click to expand it.
src/profiling.h
+
2
−
1
View file @
42445948
...
...
@@ -8,6 +8,7 @@
#define TAU_STOP( a ) do { ;; } while( 0 );
#endif // TAUPROF
double
getTimeSpent
(
const
char
*
cnt
);
double
getTimeSpent
(
const
char
*
);
uint64_t
rdtsc
(
void
);
#endif // _PROFILING_H_
This diff is collapsed.
Click to expand it.
src/sequential.cpp
+
10
−
5
View file @
42445948
...
...
@@ -25,6 +25,7 @@ gi::ex multiply_seq( tensor3D_t& T, matrix_int_t& J, int size ) { // simpler: s
const
char
timerB
[]
=
"B"
;
const
char
timeradd
[]
=
"add"
;
double
timeA
,
timeB
;
uint64_t
t_start
,
t_end
;
for
(
a1
=
0
;
a1
<
size
;
a1
++
){
i
=
i
+
1
;
...
...
@@ -41,7 +42,7 @@ gi::ex multiply_seq( tensor3D_t& T, matrix_int_t& J, int size ) { // simpler: s
TAB
=
J
[
a1
][
b1
];
for
(
b2
=
0
;
b2
<
size
;
b2
++
){
for
(
b3
=
0
;
b3
<
size
;
b3
++
){
TAU_START
(
timerB
);
TAU_START
(
timerB
);
/* Beyond this point, b1 is not used anymore */
TABB
=
TAB
*
A
*
T
[
b1
][
b2
][
b3
];
for
(
c1
=
0
;
c1
<
size
;
c1
++
){
...
...
@@ -54,13 +55,17 @@ gi::ex multiply_seq( tensor3D_t& T, matrix_int_t& J, int size ) { // simpler: s
for
(
d2
=
0
;
d2
<
size
;
d2
++
){
TABCDD
=
TABCD
*
J
[
b2
][
d2
];
for
(
d3
=
0
;
d3
<
size
;
d3
++
){
TAU_START
(
timeradd
);
Tens
=
Tens
+
TABCDD
*
T
[
d1
][
d2
][
d3
]
*
J
[
a3
][
d3
];
TAU_START
(
timeradd
);
t_start
=
rdtsc
();
Tens
=
Tens
+
TABCDD
*
T
[
d1
][
d2
][
d3
]
*
J
[
a3
][
d3
];
t_end
=
rdtsc
();
TAU_STOP
(
timeradd
);
#ifdef TAUPROF
std
::
cout
<<
"add "
<<
getTimeSpent
(
timeradd
)
<<
" len "
<<
Tens
.
nops
()
<<
std
::
endl
;
// std::cout << "add " << getTimeSpent( timeradd ) << " len " << Tens.nops() << std::endl;
printf
(
"add %lf %lu len %d
\n
"
,
getTimeSpent
(
timeradd
),
t_end
-
t_start
,
Tens
.
nops
()
);
std
::
cout
<<
Tens
<<
std
::
endl
;
//
std::cout << Tens << std::endl;
#endif // TAUPROF
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment