1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Value-Profiling Utility.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
23 * Mohammad R. Haghighat [mohammad.r.haghighat@intel.com]
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
45 static void cProbe (void* vprofID
)
47 if (_VAL
== _IVAR1
) _I64VAR1
++;
50 if (_VAL
== _IVAR0
) _I64VAR0
++;
53 _DVAR0
= ((double)_I64VAR0
) / _COUNT
;
54 _DVAR1
= ((double)_I64VAR1
) / _COUNT
;
57 //__declspec (thread) boolean cv;
58 //#define if(c) cv = (c); _vprof (cv); if (cv)
59 //#define if(c) cv = (c); _vprof (cv, cProbe); if (cv)
65 static int64_t evens
= 0;
66 static int64_t odds
= 0;
72 for (i
= 0; i
< COUNT
; i
++) {
73 //_nvprof ("Iteration", 1);
74 //_nvprof ("Iteration", 1);
77 //_hprof(i, 3, (int64_t) 1000, (int64_t)2000, (int64_t)3000);
78 //_hprof(i, 3, 10000, 10001, 3000000);
79 //_nhprof("Event", i, 3, 10000, 10001, 3000000);
80 //_nhprof("Event", i, 3, 10000, 10001, 3000000);
84 ////_hprof(i, 3, 10000, 10001, 3000000);
85 //_nvprof ("Iteration", i);
92 //_nvprof ("Iterate", 1);
94 //printf("sub %d done.\n", val);
97 HANDLE array
[THREADS
];
103 time_t start_time
= time(0);
105 for (i
= 0; i
< THREADS
; i
++) {
106 array
[i
] = CreateThread(0, 0, (LPTHREAD_START_ROUTINE
)sub
, (LPVOID
)i
, 0, 0);
109 for (i
= 0; i
< THREADS
; i
++) {
110 WaitForSingleObject(array
[i
], INFINITE
);
120 start
= GetTickCount ();
122 end
= GetTickCount ();
124 printf ("\nRun took %d msecs\n\n", end
-start
);