Skip to content

Commit

Permalink
(#3794) coz: Causal profiler
Browse files Browse the repository at this point in the history
* coz: Causal profiler

Coz is a new kind of profiler that unlocks optimization opportunities
missed by traditional profilers. Coz employs a novel technique we call
causal profiling that measures optimization potential. This measurement
matches developers' assumptions about profilers: that optimizing
highly-ranked code will have the greatest impact on performance. Causal
profiling measures optimization potential for serial, parallel, and
asynchronous programs without instrumentation of special handling for
library calls and concurrency primitives. Instead, a causal profiler
uses performance experiments to predict the effect of optimizations.
This allows the profiler to establish causality: "optimizing function X
will have effect Y," exactly the measurement developers had assumed they
were getting all along.

https://github.com/plasma-umass/coz

* Cleanup config_options, since options.fPIC does not exist

* Patch Python version

* Disable incompatible Macos builds

* Build test_package files with debug info

* Implement code-review fixes

* Use CMake from the package sources

* Do not package lib/cmake

* Pushed patch to upstream

* Do not build for GCC version <5.0

* Require C++11 to match parent

* Update recipes/coz/all/test_package/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/coz/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Apply suggestions from code review

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/coz/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/coz/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/coz/all/test_package/CMakeLists.txt

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Minor cleanup

* Update recipes/coz/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/coz/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/coz/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/coz/all/CMakeLists.txt

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Use cmake template similar to other recipes

* Remove private system_libs dependencies since building always shared

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
4 people committed Jun 10, 2021
1 parent 140964e commit 1be2afb
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/coz/all/CMakeLists.txt
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/coz/all/conandata.yml
@@ -0,0 +1,4 @@
sources:
"cci.20210322":
url: "https://github.com/plasma-umass/coz/archive/6dd3c3f9cdce5094024aab49aeb1b6b44c73b220.zip"
sha256: "f6b8332df45190d300a9d7a9049e9817729080dbd099af3b02ea4ea6977f24dd"
62 changes: 62 additions & 0 deletions recipes/coz/all/conanfile.py
@@ -0,0 +1,62 @@
import os
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration

required_conan_version = ">=1.33.0"


class CozConan(ConanFile):
name = "coz"
description = """Causal profiler, uses performance experiments
to predict the effect of optimizations"""
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://coz-profiler.org"
license = "BSD-2-Clause"
topics = ("conan", "coz", "profiler", "causal")

settings = "os", "arch", "compiler", "build_type"

requires = "libelfin/0.3"
exports_sources = "CMakeLists.txt"
generators = "cmake", "cmake_find_package"

_source_subfolder = "source_subfolder"

def validate(self):
compiler = self.settings.compiler
compiler_version = tools.Version(self.settings.compiler.version)
if self.settings.os == "Macos" or compiler == "Visual Studio" or (
compiler == "gcc" and compiler_version < "5.0"):
raise ConanInvalidConfiguration(
"coz doesn't support compiler: {} on OS: {}.".format(
self.settings.compiler, self.settings.os))
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, "11")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

_cmake = None

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure()
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.filenames["cmake_find_package"] = "coz-profiler"
self.cpp_info.filenames["cmake_find_package_multi"] = "coz-profiler"
self.cpp_info.names["cmake_find_package"] = "coz"
self.cpp_info.names["cmake_find_package_multi"] = "coz"
8 changes: 8 additions & 0 deletions recipes/coz/all/test_package/CMakeLists.txt
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
19 changes: 19 additions & 0 deletions recipes/coz/all/test_package/conanfile.py
@@ -0,0 +1,19 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self, build_type="RelWithDebInfo") # To work properly Coz tool requires debug information https://github.com/plasma-umass/coz
cmake.configure()
cmake.build()

def test(self):
if tools.cross_building(self.settings):
return
bin_path = os.path.join("bin", "test_package")
self.run("coz run --- " + bin_path, run_environment=True)
print(open("profile.coz").read())
11 changes: 11 additions & 0 deletions recipes/coz/all/test_package/test_package.c
@@ -0,0 +1,11 @@
#include <coz.h>
#include <stdio.h>

int
main(int argc, char **argv)
{
COZ_PROGRESS_NAMED("something");
printf("Hello, Coz!\n");

return 0;
}
3 changes: 3 additions & 0 deletions recipes/coz/config.yml
@@ -0,0 +1,3 @@
versions:
"cci.20210322":
folder: "all"

0 comments on commit 1be2afb

Please sign in to comment.