-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ParlayHash] new recipe #22638
Open
fpelliccioni
wants to merge
17
commits into
conan-io:master
Choose a base branch
from
fpelliccioni:feat/parlayhash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[ParlayHash] new recipe #22638
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6428d7d
ParlayHash: new recipe
fpelliccioni 94c8c1c
fix linting
fpelliccioni e3c96b8
Update recipes/parlay_hash/all/conanfile.py
fpelliccioni c7cacb1
fix
fpelliccioni c917d1b
Merge branch 'feat/parlayhash' of github.com-fpelliccioni:fpelliccion…
fpelliccioni a9a1a20
fix test_package
fpelliccioni 6cb2aa2
Update recipes/parlay_hash/all/test_package/test_package.cpp
AbrilRBS c154019
Update recipes/parlay_hash/all/conanfile.py
AbrilRBS 94e4195
WOrk for v0.1
AbrilRBS b61413f
Merge branch 'master' into feat/parlayhash
fpelliccioni af282aa
remove temp files
fpelliccioni 920fbae
Merge branch 'master' into feat/parlayhash
fpelliccioni 39da6c7
fix
fpelliccioni 7cf7f4b
Merge branch 'feat/parlayhash' of github.com-fpelliccioni:fpelliccion…
fpelliccioni a83bf37
Merge branch 'master' into feat/parlayhash
fpelliccioni fccfa68
Follow upstream target names
AbrilRBS bd4010e
Typo
AbrilRBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"0.1": | ||
url: "https://github.com/cmuparlay/parlayhash/archive/refs/tags/v0.1.tar.gz" | ||
sha256: "63dd2680de0291c8c4440fc3364490de0ee3cdea94b02b7449900bac18d66f2f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.files import get, copy, rm | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
from conan.tools.layout import basic_layout | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class ParlayHashConan(ConanFile): | ||
name = "parlayhash" | ||
description = "A Header-Only Scalable Concurrent Hash Map." | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/cmuparlay/parlayhash" | ||
topics = ("unordered_map", "hashmap", "header-only") | ||
package_type = "header-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
no_copy_source = True | ||
|
||
@property | ||
def _minimum_cpp_standard(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"Visual Studio": "15.7", | ||
"msvc": "191", | ||
"gcc": "7", | ||
"clang": "7", | ||
"apple-clang": "11", | ||
} | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def package_id(self): | ||
self.info.clear() | ||
|
||
def requirements(self): | ||
# TODO: Upstream mentions jemalloc in https://github.com/cmuparlay/parlayhash/blob/main/CMakeLists.txt#L45 | ||
# but it's not ported to Conan 2 yet. Add it here if needed in the future. | ||
pass | ||
|
||
def validate(self): | ||
if self.settings.get_safe("compiler.cppstd"): | ||
check_min_cppstd(self, self._minimum_cpp_standard) | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: | ||
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
rm(self, "#hash_table.h#", os.path.join(self.source_folder, "include", "parlay")) | ||
rm(self, "#primitives.h#", os.path.join(self.source_folder, "include", "parlay")) | ||
rm(self, ".#hash_table.h", os.path.join(self.source_folder, "include", "parlay")) | ||
|
||
def build(self): | ||
pass | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("pthread") | ||
|
||
# This one is a best-effort guess, as the library is header-only it does not mention a target explicitly | ||
self.cpp_info.set_property("cmake_file_name", "parlayhash") | ||
self.cpp_info.set_property("cmake_target_name", "parlay") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(parlayhash REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE parlay) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <parlay/parallel.h> | ||
#include "parlay_hash/unordered_map.h" | ||
|
||
using K = std::string; | ||
using V = unsigned long; | ||
using map_type = parlay::parlay_unordered_map<K,V>; | ||
|
||
int main() { | ||
map_type my_map(100); | ||
my_map.Insert("sue", 1); | ||
my_map.Insert("sam", 5); | ||
|
||
std::cout << "value before increment: " << *my_map.Find("sue") << std::endl; | ||
auto increment = [] (std::optional<V> v) -> V {return v.has_value() ? 1 + *v : 1;}; | ||
my_map.Upsert("sue", increment); | ||
std::cout << "value after increment: " << *my_map.Find("sue") << std::endl; | ||
|
||
std::cout << "size before remove: " << my_map.size() << std::endl; | ||
my_map.Remove("sue"); | ||
std::cout << "size after remove: " << my_map.size() << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.1": | ||
folder: all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
std::result_of
has been removed since C++20,we have to specify using C++17.
https://en.cppreference.com/w/cpp/types/result_of