1 /*
2 * Copyright (c) 1995-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18 #include "stdioInterf.h"
19 #include "fioMacros.h"
20
21 char *__fort_getopt(char *opt);
22 long __fort_strtol(char *str, char **ptr, int base); /* atol.c */
23
24 static int tracing = 0;
25 static int call_level = 0;
26
27 /** \brief Initialization */
28 int
__fort_trac_init(void)29 __fort_trac_init(void)
30 {
31 char *p, *q;
32 int n;
33
34 p = __fort_getopt("-trace");
35 if (p) {
36 n = (int)__fort_strtol(p, &q, 0);
37 if (q == p)
38 tracing = 1;
39 else if (*q != '\0' || n < 0 || n >= GET_DIST_TCPUS)
40 __fort_abort("invalid -trace processor");
41 else
42 tracing = (n == GET_DIST_LCPU);
43 }
44 return 0;
45 }
46
47 /* function entry */
48
49 static char dots[] = "....................";
50
51 /* FIXME: still used? */
52 void
__fort_trac_function_entry(int line,int lines,int cline,char * func,char * file,__CLEN_T funcl,__CLEN_T filel)53 __fort_trac_function_entry(int line, int lines, int cline, char *func,
54 char *file, __CLEN_T funcl, __CLEN_T filel)
55 {
56 ++call_level;
57 if (tracing)
58 printf("%d: %.*s %.*s (%.*s:%d..%d) called from line %d\n", GET_DIST_LCPU,
59 call_level, dots, funcl, func, filel, file, line, line + lines - 1,
60 cline);
61 }
62
63 /* FIXME: still used? */
64 /** \brief line entry
65 * \param line - current line number
66 */
67 void
__fort_trac_line_entry(int line)68 __fort_trac_line_entry(int line)
69 {
70 }
71
72 /** \brief Update start receive message stats
73 * \param cpu: sending cpu
74 * \param len: total length in bytes
75 */
76 void
__fort_trac_recv(int cpu,long len)77 __fort_trac_recv(int cpu, long len)
78 {
79 }
80
81 /** \brief Update done receive message stats
82 * \param cpu - sending cpu
83 */
84 void
__fort_trac_recv_done(int cpu)85 __fort_trac_recv_done(int cpu)
86 {
87 }
88
89 /** \brief Update start send message stats
90 * \param cpu: sending cpu
91 * \param len: total length in bytes
92 */
93 void
__fort_trac_send(int cpu,long len)94 __fort_trac_send(int cpu, long len)
95 {
96 }
97
98 /** \brief Update done send message stats
99 * \param cpu - receiving cpu
100 */
101 void
__fort_trac_send_done(int cpu)102 __fort_trac_send_done(int cpu)
103 {
104 }
105
106 /** \brief Update start bcopy message stats
107 * \param len: total length in bytes
108 */
109 void
__fort_trac_copy(long len)110 __fort_trac_copy(long len)
111 {
112 }
113
114 /** \brief Update done bcopy message stats */
115 void
__fort_trac_copy_done(void)116 __fort_trac_copy_done(void)
117 {
118 }
119
120 /* FIXME: still used */
121 /** \brief Function exit */
122 void
__fort_trac_function_exit(void)123 __fort_trac_function_exit(void)
124 {
125 --call_level;
126 }
127
128 /** \brief Termination */
129 void
__fort_trac_term(void)130 __fort_trac_term(void)
131 {
132 }
133