Skip to content
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

Lums/sc 19399/specialnode #3453

Merged
merged 4 commits into from Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions cmake/TileDB-Superbuild.cmake
Expand Up @@ -193,12 +193,10 @@ if (${CLANG_FORMAT_FOUND})
message(STATUS "clang hunt, found ${CLANG_FORMAT_BIN}")
# runs clang format and updates files in place.

add_custom_target(format ${SCRIPTS_DIR}/run-clang-format.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CLANG_FORMAT_BIN} 1
${CLANG_FORMAT_FIND_FILES})
add_custom_target(format ${SCRIPTS_DIR}/run-clang-format.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CLANG_FORMAT_BIN} 1)

# runs clang format and exits with a non-zero exit code if any files need to be reformatted
add_custom_target(check-format ${SCRIPTS_DIR}/run-clang-format.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CLANG_FORMAT_BIN} 0
${CLANG_FORMAT_FIND_FILES})
add_custom_target(check-format ${SCRIPTS_DIR}/run-clang-format.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CLANG_FORMAT_BIN} 0)
else()
message(STATUS "was unable to find clang-format")
endif()
Expand Down
4 changes: 4 additions & 0 deletions experimental/CMakeLists.txt
Expand Up @@ -25,10 +25,14 @@
# THE SOFTWARE.
#

message(STATUS "+++++++ in experimental")

if(NOT TILEDB_EXPERIMENTAL_FEATURES)
return()
endif()

message(STATUS "+++++++ past experimental")

include(common NO_POLICY_SCOPE)

add_subdirectory(tiledb)
Expand Down
2 changes: 2 additions & 0 deletions experimental/tiledb/common/CMakeLists.txt
Expand Up @@ -24,6 +24,8 @@
# THE SOFTWARE.
#

message(STATUS "+++++++ in common")

include(common-root)
include(common)

Expand Down
13 changes: 8 additions & 5 deletions experimental/tiledb/common/dag/CMakeLists.txt
Expand Up @@ -25,10 +25,13 @@
# THE SOFTWARE.
#

add_subdirectory(data_block)
# add_subdirectory(edge)
message(STATUS "+++++++ in dag")

add_subdirectory(utils)
add_subdirectory(execution)
# add_subdirectory(graph)
# add_subdirectory(node)
add_subdirectory(state_machine)
add_subdirectory(ports)
add_subdirectory(utils)
add_subdirectory(data_block)
add_subdirectory(edge)
add_subdirectory(nodes)
# add_subdirectory(graph)
41 changes: 41 additions & 0 deletions experimental/tiledb/common/dag/data_block/CMakeLists.txt
Expand Up @@ -111,3 +111,44 @@ if (TILEDB_TESTS)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()

# list(APPEND SOURCES
# )
# gather_sources(${SOURCES})

#
# Object library for other units to depend upon
#
# add_library(blocks_and_ports OBJECT ${SOURCES})
# target_link_libraries(blocks_and_ports PUBLIC baseline $<TARGET_OBJECTS:baseline>)

#
# Test-compile of object library ensures link-completeness
#
# add_executable(compile_blocks_and_ports EXCLUDE_FROM_ALL)
# target_link_libraries(compile_blocks_and_ports PRIVATE blocks_and_ports)
# target_sources(compile_blocks_and_ports PRIVATE test/compile_blocks_and_ports_main.cc)

if (TILEDB_TESTS)
add_executable(unit_blocks_and_ports EXCLUDE_FROM_ALL)
# target_link_libraries(unit_blocks_and_ports PUBLIC blocks_and_ports)
find_package(Catch_EP REQUIRED)
target_link_libraries(unit_blocks_and_ports PUBLIC Catch2::Catch2)
# target_link_libraries(unit_blocks_and_ports PUBLIC $<TARGET_OBJECTS:thread_pool>)

# Sources for code elsewhere required for tests
target_sources(unit_blocks_and_ports PUBLIC ${DEPENDENT_SOURCES})

# Sources for tests
target_sources(unit_blocks_and_ports PUBLIC
test/main.cc
test/unit_blocks_and_ports.cc
)

add_test(
NAME "unit_blocks_and_ports"
COMMAND $<TARGET_FILE:unit_blocks_and_ports> --durations=yes
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()

55 changes: 49 additions & 6 deletions experimental/tiledb/common/dag/data_block/data_block.h
Expand Up @@ -28,6 +28,12 @@
* @section DESCRIPTION
*
* This file declares the DataBlock class for dag.
*
* A `DataBlock` is a managed fixed-size container of `std::byte`. The actual
* data is a fixed-size "chunk" of bytes, which are managed by a shared pointer.
* As a result (and by design), copy and assignment semantics are shallow.
*
* @todo For hygiene, might want to clean up a moved-from `DataBlock`.
*/

#ifndef TILEDB_DAG_DATA_BLOCK_H
Expand Down Expand Up @@ -88,22 +94,22 @@ class DataBlockImpl {
* as well as the total capacity of the underlying data chunk. Both size and
* capacity are in units of bytes.
*/
size_t capacity_;
size_t size_;
size_t capacity_{0};
size_t size_{0};

/**
* The actual stored chunk. The `storage_` is the `shared_ptr` to the chunk,
* while `data_` is a pointer to the actual bytes.
*/
storage_t storage_;
pointer_t data_;
pointer_t data_{nullptr};

public:
/**
* Constructor used if the `Allocator` is `std::allocator` of `std::byte`.
*/
template <class R = Allocator>
DataBlockImpl(
explicit DataBlockImpl(
size_t init_size = 0UL,
typename std::enable_if<
std::is_same_v<R, std::allocator<std::byte>>>::type* = 0)
Expand All @@ -121,7 +127,7 @@ class DataBlockImpl {
* return the chunk to the pool. See pool_allocator.h for details.
*/
template <class R = Allocator>
DataBlockImpl(
explicit DataBlockImpl(
size_t init_size = 0UL,
typename std::enable_if<
std::is_same_v<R, PoolAllocator<chunk_size_>>>::type* = 0)
Expand All @@ -132,7 +138,23 @@ class DataBlockImpl {
, data_{storage_.get()} {
}

/*
/**
* Copy constructors and assignment operators.
* NOTE: Copies are shallow.
*/
DataBlockImpl(const DataBlockImpl&) = default;
DataBlockImpl(DataBlockImpl&&) = default;
// DataBlockImpl(DataBlockImpl&& rhs) {
// if (storage_.use_count() == 0) {
// rhs.size_ = 0;
// rhs.capacity_ = 0;
// rhs.data_ = nullptr;
// }
// }
DataBlockImpl& operator=(const DataBlockImpl&) = default;
DataBlockImpl& operator=(DataBlockImpl&&) = default;

/**
* Various type aliases expected for a random-access range.
*/
using DataBlockIterator = span_t::iterator;
Expand Down Expand Up @@ -241,6 +263,20 @@ class DataBlockImpl {
size_t capacity() const {
return capacity_;
}

/**
* Class variable to access max possible size of the `DataBlock`
*/
constexpr static inline size_t max_size() {
return chunk_size_;
}

/**
* Get shared pointer use count -- needed for diagnostics / testing
*/
size_t use_count() const noexcept {
return storage_.use_count();
}
};

template <class Allocator>
Expand All @@ -252,6 +288,13 @@ Allocator DataBlockImpl<Allocator>::allocator_;
*/
using DataBlock = DataBlockImpl<PoolAllocator<chunk_size_>>;

/**
* Function for getting new `DataBlock`s
*/
[[maybe_unused]] static DataBlock make_data_block(size_t init_size) {
return DataBlock{init_size};
}

} // namespace tiledb::common

#endif // TILEDB_DAG_DATA_BLOCK_H
@@ -0,0 +1,34 @@
/**
* @file compile_data_block_main.cc
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2022 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/

#include "../data_block.h"

int main() {
}
@@ -0,0 +1,39 @@
/**
* @file compile_pool_allocator_main.cc
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2022 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/

#include "../pool_allocator.h"

using namespace tiledb::common;

int main() {
(void)sizeof(PoolAllocator<sizeof(size_t)>);
(void)sizeof(PoolAllocator<1024>);
(void)sizeof(PoolAllocator<1024 * 1024>);
}