• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __VTUNE_API_H__
2 #define __VTUNE_API_H__
3 
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include "third_party/ittapi/include/ittnotify.h"
8 
9 class VTuneDomain {
10   /* factory method to create vtune domain */
11  public:
12   /* create vtune domain, domain_name should be unique, if there
13      already has a domain with same name, return false.
14    */
15   static std::shared_ptr<VTuneDomain> createDomain(const char* domain_name);
16 
17   /* destory vtune domain*/
18   static void destroyDomain(const char* domain_name);
19 
20   /* get a domain */
21   static std::shared_ptr<VTuneDomain> getDomain(const char* domain_name);
22 
23   /* domain interface */
24  public:
25   /* start a task with name, if no task name or null, use "default_task_name"*/
26   bool beginTask(const char* task_name = "default_task_name");
27 
28   /* end a task, if there is no stacked task, return false*/
29   void endTask();
30 
31  public:
~VTuneDomain()32   virtual ~VTuneDomain() {}
33 
34  protected:
35   static __itt_string_handle* getString(const char* str);
36 
37  protected:
VTuneDomain(__itt_domain * domain)38   VTuneDomain(__itt_domain* domain) { domain_ = domain; }
39 
40  private:
41   static std::map<std::string, std::shared_ptr<VTuneDomain>> domains_;
42   static std::map<std::string, __itt_string_handle*> string_handlers_;
43 
44  private:
45   __itt_domain* domain_;
46 };
47 
48 #endif
49