Skip to content

Replace parallel-hashmap with gtl #895

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

Open
wants to merge 7 commits into
base: exBuiltinArchives
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
[submodule "3rdparty/gli"]
path = 3rdparty/gli
url = [email protected]:Devsh-Graphics-Programming/gli.git
[submodule "3rdparty/parallel-hashmap"]
path = 3rdparty/parallel-hashmap
url = [email protected]:Devsh-Graphics-Programming/parallel-hashmap.git
[submodule "3rdparty/jitify"]
path = 3rdparty/jitify
url = [email protected]:Devsh-Graphics-Programming/jitify.git
Expand Down Expand Up @@ -121,3 +118,6 @@
[submodule "docker/msvc-winsdk"]
path = docker/msvc-winsdk
url = ../docker-nanoserver-msvc-winsdk
[submodule "3rdparty/gtl"]
path = 3rdparty/gtl
url = https://github.com/greg7mdp/gtl.git
2 changes: 1 addition & 1 deletion 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ add_dependencies(3rdparty ${NBL_3RDPARTY_TARGETS})

NBL_ADJUST_FOLDERS(3rdaprty)

nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/parallel-hashmap/parallel_hashmap")
nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/gtl/include")

# parent scope exports, must be at the end of the file
set(_NBL_3RDPARTY_TARGETS_
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/gtl
Submodule gtl added at 6ad66c
1 change: 0 additions & 1 deletion 3rdparty/parallel-hashmap
Submodule parallel-hashmap deleted from fd7b8f
8 changes: 4 additions & 4 deletions include/nbl/asset/utils/CDirQuantCacheBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <limits>
#include <cmath>

#include "parallel-hashmap/parallel_hashmap/phmap_dump.h"
#include "gtl/include/gtl/phmap_dump.hpp"


#include "nbl/core/declarations.h"
Expand Down Expand Up @@ -282,7 +282,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl::
backup.swap(particularCache);

CBufferPhmapInputArchive buffWrap(buffer);
bool loadingSuccess = particularCache.load(buffWrap);
bool loadingSuccess = particularCache.phmap_load(buffWrap);

if (!replaceCurrentContents || !loadingSuccess)
particularCache.merge(std::move(backup));
Expand Down Expand Up @@ -333,7 +333,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl::
return false;

CBufferPhmapOutputArchive buffWrap(buffer);
return std::get<cache_type_t<CacheFormat>>(cache).dump(buffWrap);
return std::get<cache_type_t<CacheFormat>>(cache).phmap_dump(buffWrap);
}

//!
Expand Down Expand Up @@ -488,7 +488,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl::
template<E_FORMAT CacheFormat>
static inline size_t getSerializedCacheSizeInBytes_impl(size_t capacity)
{
return 1u+sizeof(size_t)*2u+phmap::priv::Group::kWidth+(sizeof(typename cache_type_t<CacheFormat>::slot_type)+1u)*capacity;
return 1u+sizeof(size_t)*2u+gtl::priv::Group::kWidth+(sizeof(typename cache_type_t<CacheFormat>::slot_type)+1u)*capacity;
}
template<E_FORMAT CacheFormat>
static inline bool validateSerializedCache(const SBufferRange<const ICPUBuffer>& buffer)
Expand Down
9 changes: 4 additions & 5 deletions include/nbl/asset/utils/phmap_deserialization.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#ifndef __NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED__
#define __NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED__
#ifndef _NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED_
#define _NBL_ASSET_PHMAP_DESERIALIZATION_H_INCLUDED_

#include "nbl/core/declarations.h"
#include "nbl/asset/ICPUBuffer.h"
Expand All @@ -20,7 +19,7 @@ class CBufferPhmapInputArchive
}

// TODO: protect against reading out of the buffer range
bool load(char* p, size_t sz)
bool loadBinary(void* p, size_t sz)
{
memcpy(p, buffPtr, sz);
buffPtr += sz;
Expand All @@ -29,7 +28,7 @@ class CBufferPhmapInputArchive
}

template<typename V>
typename std::enable_if<phmap::type_traits_internal::IsTriviallyCopyable<V>::value,bool>::type load(V* v)
typename std::enable_if<gtl::type_traits_internal::IsTriviallyCopyable<V>::value,bool>::type loadBinary(V* v)
{
memcpy(reinterpret_cast<uint8_t*>(v), buffPtr, sizeof(V));
buffPtr += sizeof(V);
Expand Down
9 changes: 4 additions & 5 deletions include/nbl/asset/utils/phmap_serialization.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#ifndef __NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED__
#define __NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED__
#ifndef _NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED_
#define _NBL_ASSET_PHMAP_SERIALIZATION_H_INCLUDED_

#include "nbl/core/declarations.h"
#include "nbl/asset/ICPUBuffer.h"
Expand All @@ -20,7 +19,7 @@ class CBufferPhmapOutputArchive
}

// TODO: protect against writing out of bounds as defined by SBufferRange
bool dump(const char* p, size_t sz)
bool saveBinary(const void* p, size_t sz)
{
memcpy(bufferPtr, p, sz);
bufferPtr += sz;
Expand All @@ -29,7 +28,7 @@ class CBufferPhmapOutputArchive
}

template<typename V>
typename std::enable_if<phmap::type_traits_internal::IsTriviallyCopyable<V>::value,bool>::type dump(const V& v)
typename std::enable_if<gtl::type_traits_internal::IsTriviallyCopyable<V>::value,bool>::type saveBinary(const V& v)
{
memcpy(bufferPtr, reinterpret_cast<const uint8_t*>(&v), sizeof(V));
bufferPtr += sizeof(V);
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/core/decl/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <vector>
#include <utility>
#include <iterator>
#include <parallel-hashmap/parallel_hashmap/phmap.h>
#include <gtl/include/gtl/phmap.hpp>

#include "nbl/core/memory/new_delete.h"

Expand Down Expand Up @@ -62,7 +62,7 @@ template<typename K, class Compare=std::less<K>, class Allocator=allocator<K> >
using set = std::set<K,Compare,Allocator>;

template<typename K,typename T, class Hash=std::hash<K>, class KeyEqual=std::equal_to<K>, class Allocator=allocator<std::pair<const K,T> > >
using unordered_map = phmap::flat_hash_map<K,T,Hash,KeyEqual,Allocator>;
using unordered_map = gtl::flat_hash_map<K, T, Hash, KeyEqual, Allocator>;
//
template<class Key,class T,class Hash,class KeyEqual,class Alloc,class Pred>
unordered_map<Key,T,Hash,KeyEqual,Alloc>::size_type erase_if(unordered_map<Key,T,Hash,KeyEqual,Alloc>& c, Pred pred)
Expand All @@ -84,7 +84,7 @@ using unordered_multimap = std::unordered_multimap<K,T,Hash,KeyEqual,Allocator>;
template<typename K, class Hash=std::hash<K>, class KeyEqual=std::equal_to<K>, class Allocator=allocator<K> >
using unordered_multiset = std::unordered_multiset<K,Hash,KeyEqual,Allocator>;
template<typename K, class Hash=std::hash<K>, class KeyEqual=std::equal_to<K>, class Allocator=allocator<K> >
using unordered_set = phmap::flat_hash_set<K,Hash,KeyEqual,Allocator>;
using unordered_set = gtl::flat_hash_set<K,Hash,KeyEqual,Allocator>;


template<typename T, class Allocator=allocator<T> >
Expand Down
5 changes: 5 additions & 0 deletions include/nbl/video/ILogicalDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
// Create an ImageView that can actually be used by shaders (@see ICPUImageView)
inline core::smart_refctd_ptr<IGPUImageView> createImageView(IGPUImageView::SCreationParams&& params)
{
if (!params.image)
{
NBL_LOG_ERROR("The image is null");
return nullptr;
}
if (!params.image->wasCreatedBy(this))
{
NBL_LOG_ERROR("The image was not created by this device");
Expand Down
3 changes: 3 additions & 0 deletions src/nbl/video/IPhysicalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ asset::E_FORMAT IPhysicalDevice::promoteBufferFormat(const SBufferFormatPromotio

asset::E_FORMAT IPhysicalDevice::promoteImageFormat(const SImageFormatPromotionRequest req, const IGPUImage::TILING tiling) const
{
if (req.originalFormat==asset::EF_UNKNOWN)
return req.originalFormat;

format_image_cache_t& cache = tiling==IGPUImage::TILING::LINEAR
? this->m_formatPromotionCache.linearTilingImages
: this->m_formatPromotionCache.optimalTilingImages;
Expand Down
4 changes: 2 additions & 2 deletions src/nbl/video/utilities/CAssetConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3721,7 +3721,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult
auto pruneStaging = [&]<Asset AssetType>()->void
{
auto& stagingCache = std::get<SReserveResult::staging_cache_t<AssetType>>(retval.m_stagingCaches);
phmap::erase_if(stagingCache,[&retval](const auto& entry)->bool
gtl::erase_if(stagingCache,[&retval](const auto& entry)->bool
{
if (entry.first->getReferenceCount()==1)
{
Expand Down Expand Up @@ -5565,7 +5565,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
auto checkDependents = [&]<Asset AssetType>()->void
{
auto& stagingCache = std::get<SReserveResult::staging_cache_t<AssetType>>(reservations.m_stagingCaches);
phmap::erase_if(stagingCache,[&](auto& item)->bool
gtl::erase_if(stagingCache,[&](auto& item)->bool
{
auto* pGpuObj = item.first;
// rescan all the GPU objects and find out if they depend on anything that failed, if so add to failure set
Expand Down
Loading