clSPARSE  v0.10.0.0
a software library containing Sparse functions written in OpenCL
clsparseTimer.hpp
Go to the documentation of this file.
1 /* ************************************************************************
2  * Copyright 2015 Advanced Micro Devices, Inc.
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 
25 #pragma once
26 #ifndef _STATISTICALTIMER_H_
27 #define _STATISTICALTIMER_H_
28 
29 #include <vector>
30 #include <functional>
31 #include <string>
32 #include <stdexcept>
33 
34 #if defined(__APPLE__) || defined(__MACOSX)
35 # include <OpenCL/cl.h>
36 #else
37 # include <CL/cl.h>
38 #endif
39 
40 #include "clSPARSE-error.h"
41 
47 {
48 protected:
49 
53  virtual ~clsparseTimer( )
54  {
55  };
56 
57 public:
61  virtual void Start( size_t id ) = 0;
62 
66  virtual void Stop( size_t id ) = 0;
67 
71  virtual void Clear( ) = 0;
72 
77  virtual void Reset( ) = 0;
78 
88  virtual void Reserve( size_t nEvents, size_t nSamples ) = 0;
89 
96  virtual size_t getUniqueID( const std::string& label, cl_uint groupID ) = 0;
97 
103  virtual void setNormalize( bool norm ) = 0;
104 
111  virtual void Print( cl_ulong flopCount, std::string unit ) = 0;
112 
119  virtual size_t pruneOutliers( cl_double multiple ) = 0;
120 };
121 
122 #endif // _STATISTICALTIMER_H_
virtual size_t getUniqueID(const std::string &label, cl_uint groupID)=0
Provide a mapping from a 'friendly' human readable text string to an index into internal data structu...
virtual ~clsparseTimer()
Destructor for StatisticalTimer that cleans up the class.
Definition: clsparseTimer.hpp:53
defines 'C' compatible macros and inline functions to help pretty print error messages from clSPARSE ...
virtual void Reserve(size_t nEvents, size_t nSamples)=0
The implementation of the timing class may contains data structures that need to grow as more samples...
virtual void Print(cl_ulong flopCount, std::string unit)=0
Print the output of the timing information to the console. This includes information specific to the ...
virtual void Clear()=0
Clear all internal data structures, deallocate all memory.
virtual size_t pruneOutliers(cl_double multiple)=0
Using the stdDev of the entire population (of an id), eliminate those samples that fall outside some ...
Counter that provides a fairly accurate timing mechanism for both windows and linux. This timer is used extensively in all the samples.
Definition: clsparseTimer.hpp:46
virtual void Reset()=0
Clear all internal data structures, freeing all memory, then reallocate the same amount of memory req...
virtual void setNormalize(bool norm)=0
Request that the timer divides total samples collected by sample frequency, converting tick counts in...
virtual void Stop(size_t id)=0
Stop a timing sample.
virtual void Start(size_t id)=0
Start a timing sample.