[x265] [PATCH 1 of 2] cmake: add support for finding Intel PCM on Windows

deepthi at multicorewareinc.com deepthi at multicorewareinc.com
Fri May 8 12:05:34 CEST 2015


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1431064348 -19800
#      Fri May 08 11:22:28 2015 +0530
# Node ID 4203e7ac7d784a307d6d7174f69d96a86bc576c8
# Parent  7a1fd70739410f874f8ccd51ad688a29364d5e72
cmake: add support for finding Intel PCM on Windows

diff -r 7a1fd7073941 -r 4203e7ac7d78 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Tue May 05 14:44:19 2015 -0700
+++ b/source/CMakeLists.txt	Fri May 08 11:22:28 2015 +0530
@@ -296,7 +296,7 @@
     endif()
 endif(WARNINGS_AS_ERRORS)
 
-if (WIN32)
+if(WIN32)
     # Visual leak detector
     find_package(VLD QUIET)
     if(VLD_FOUND)
@@ -314,7 +314,20 @@
         # default to targeting Windows 7 for the NUMA APIs
         add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_WIN7)
     endif(WINXP_SUPPORT)
-endif()
+endif(WIN32)
+
+if(WIN32)
+   option(ENABLE_PCM "Enable profiling using Intel Performance Counter Monitor" OFF)
+    if(ENABLE_PCM)
+        find_package(PCM)
+        if(PCM_FOUND)
+            add_definitions(-DENABLE_PCM)
+            list(APPEND PLATFORM_LIBS PCM)
+            include_directories(${PCM_ROOT_DIR})
+            add_subdirectory(profile/PCM)
+        endif(PCM_FOUND)        
+    endif(ENABLE_PCM)
+endif(WIN32)
 
 include(version) # determine X265_VERSION and X265_LATEST_TAG
 include_directories(. common encoder "${PROJECT_BINARY_DIR}")
@@ -478,7 +491,6 @@
     source_group(input FILES ${InputFiles})
     source_group(output FILES ${OutputFiles})
     source_group(filters FILES ${FilterFiles})
-
     check_include_files(getopt.h HAVE_GETOPT_H)
     if(NOT HAVE_GETOPT_H)
         if(MSVC)
diff -r 7a1fd7073941 -r 4203e7ac7d78 source/cmake/FindPCM.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/cmake/FindPCM.cmake	Fri May 08 11:22:28 2015 +0530
@@ -0,0 +1,25 @@
+include(FindPackageHandleStandardArgs)
+SET(PCM_ROOT_DIR "C:/Program Files/Intel/IntelPerformanceCounterMonitorV2.8" CACHE PATH "Location of Intel PCM Root Directory")
+
+find_path(PCM_ROOT_DIR
+  NAMES cpucounters.h
+  HINTS ${PCM_ROOT_DIR}
+  DOC "PCM root directory")
+
+if(X64)
+    find_path(PCM_OBJ_DIR
+      NAMES cpucounters.obj
+      HINTS ${PCM_ROOT_DIR}
+      PATH_SUFFIXES PCM_Win/x64/Release PCM_Win/x64/Debug
+      DOC "PCM Object files")
+else()
+    find_path(PCM_OBJ_DIR
+      NAMES cpucounters.obj
+      HINTS ${PCM_ROOT_DIR}
+      PATH_SUFFIXES PCM_Win/Release PCM_Win/Debug
+      DOC "PCM Object files")
+endif(X64)
+
+mark_as_advanced(PCM_ROOT_DIR PCM_OBJ_DIR)
+
+find_package_handle_standard_args(PCM REQUIRED_VARS PCM_ROOT_DIR PCM_OBJ_DIR)
diff -r 7a1fd7073941 -r 4203e7ac7d78 source/profile/CMakeLists.txt
--- a/source/profile/CMakeLists.txt	Tue May 05 14:44:19 2015 -0700
+++ b/source/profile/CMakeLists.txt	Fri May 08 11:22:28 2015 +0530
@@ -23,3 +23,16 @@
         list(APPEND PLATFORM_LIBS libittnotify.a dl)
     endif()
 endif(ENABLE_VTUNE)
+
+if(WIN32)
+   option(ENABLE_PCM "Enable profiling using Intel Performance Counter Monitor" OFF)
+    if(ENABLE_PCM)
+        find_package(PCM)
+        if(PCM_FOUND)
+            add_definitions(-DENABLE_PCM)
+            add_subdirectory(PCM)
+            list(APPEND PLATFORM_LIBS pcm)
+            include_directories(${PCM_ROOT_DIR})
+        endif(PCM_FOUND)
+    endif(ENABLE_PCM)
+endif(WIN32)
\ No newline at end of file
diff -r 7a1fd7073941 -r 4203e7ac7d78 source/profile/PCM/CMakeLists.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/profile/PCM/CMakeLists.txt	Fri May 08 11:22:28 2015 +0530
@@ -0,0 +1,5 @@
+include_directories(${PCM_ROOT_DIR})
+file(GLOB PCMFiles ${PCM_OBJ_DIR}/cpucounters.obj ${PCM_OBJ_DIR}/client_bw.obj ${PCM_OBJ_DIR}/msr.obj 
+                       ${PCM_OBJ_DIR}/pci.obj ${PCM_OBJ_DIR}/winpmem.obj ${PCM_OBJ_DIR}/utils.obj)
+source_group(ObjFiles FILES ${PCMFiles}) 
+add_library(PCM ${PCMFiles} pcm.h pcm.cpp)
diff -r 7a1fd7073941 -r 4203e7ac7d78 source/profile/PCM/pcm.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/profile/PCM/pcm.cpp	Fri May 08 11:22:28 2015 +0530
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Copyright (C) 2015 x265 project
+ *
+ * Authors: Deepthi Nandakumar <deepthi at multicorewareinc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at license @ x265.com.
+ *****************************************************************************/
\ No newline at end of file
diff -r 7a1fd7073941 -r 4203e7ac7d78 source/profile/PCM/pcm.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/profile/PCM/pcm.h	Fri May 08 11:22:28 2015 +0530
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (C) 2015 x265 project
+ *
+ * Authors: Deepthi Nandakumar <deepthi at multicorewareinc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at license @ x265.com.
+ *****************************************************************************/
+
+#ifndef PCM_H
+#define PCM_H
+
+#include "cpucounters.h"
+
+#endif
\ No newline at end of file


More information about the x265-devel mailing list