Skip to content

Commit

Permalink
Merge pull request #281 from clEsperanto/release-0.10.0
Browse files Browse the repository at this point in the history
Release-0.10.0
  • Loading branch information
StRigaud committed Apr 17, 2024
2 parents f17d5d4 + c185459 commit 9f3aace
Show file tree
Hide file tree
Showing 280 changed files with 9,348 additions and 1,133 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)

project(CLIc VERSION 0.9.1)
project(CLIc VERSION 0.10.0)

set(BUILD_CUDA_BACKEND ON CACHE BOOL "Build CUDA backend")
set(BUILD_OPENCL_BACKEND ON CACHE BOOL "Build OpenCL backend")
Expand All @@ -24,6 +24,9 @@ configure_file(

# list project source files
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${LIBRARY_NAME_LOWERCASE}/src/*.cpp")
file(GLOB_RECURSE TIERS "${CMAKE_CURRENT_SOURCE_DIR}/${LIBRARY_NAME_LOWERCASE}/src/**/*.cpp")
list(APPEND SOURCES ${TIERS})

file(GLOB_RECURSE HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${LIBRARY_NAME_LOWERCASE}/include/*.hpp")
file(GLOB_RECURSE HEADERS_BIN "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME_LOWERCASE}/include/*.hpp")
set(HEADERS ${HEADERS_SRC})
Expand Down
37 changes: 29 additions & 8 deletions clic/include/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,20 @@ class Array
*/
Array(const Array &) = default;

/**
* @brief Check if the shared_ptr is null and throw an exception if it is
* @param ptr The shared_ptr to check
* @param errorMessage The error message to throw
*/
static inline void
check_ptr(const Array::Pointer & ptr, const char * errorMessage)
{
if (!ptr)
{
throw std::invalid_argument(errorMessage);
}
}

/**
* @brief Print the Array as a matrix for debugging
*/
Expand Down Expand Up @@ -320,23 +334,30 @@ class Array

template <typename T>
auto
print(const Array::Pointer & array) -> void
print(const Array::Pointer & array, const char * name = "Array::Pointer") -> void
{
if (array == nullptr)
{
std::cout << "Print Array::Pointer (nullptr)\n";
return;
}
std::vector<T> host_data(array->size());
array->read(host_data.data());

for (int i = 0; i < array->depth(); i++)
std::ostringstream oss;
oss << "Print (" << name << ")\n";
for (auto i = 0; i < array->depth(); ++i)
{
std::cout << "z = " << i << std::endl;
for (int j = 0; j < array->height(); j++)
oss << "z = " << i << '\n';
for (auto j = 0; j < array->height(); ++j)
{
for (int k = 0; k < array->width(); k++)
for (auto k = 0; k < array->width(); ++k)
{
std::cout << (float)host_data[i * array->height() * array->width() + j * array->width() + k] << " ";
oss << static_cast<float>(host_data[i * array->height() * array->width() + j * array->width() + k]) << ' ';
}
std::cout << std::endl;
oss << '\n';
}
}
std::cout << oss.str();
}

} // namespace cle
Expand Down
18 changes: 18 additions & 0 deletions clic/include/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ execute(const Device::Pointer & device,
const RangeArray & global_range = { 1, 1, 1 },
const ConstantList & constants = {}) -> void;


/**
* @brief Execution function for separable kernel operation
* @param device Device pointer
* @param kernel Kernel function name and code
* @param src Source array
* @param dst Destination array
* @param sigma Sigma value for the kernel
* @param radius Radius value for the kernel
*/
auto
execute_separable(const Device::Pointer & device,
const KernelInfo & kernel,
const Array::Pointer & src,
const Array::Pointer & dst,
const std::array<float, 3> & sigma,
const std::array<int, 3> & radius) -> void;

/**
* @brief Execute a kernel using native framework
* @param device Device pointer
Expand Down
6 changes: 3 additions & 3 deletions clic/include/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ create_like(const Array & arr) -> Array
static auto
create_2d_xy(const Array & arr) -> Array
{
return Array{ arr.width(), arr.height(), 1, arr.dtype(), mType::BUFFER, arr.device() };
return Array{ arr.width(), arr.height(), 1, 2, arr.dtype(), mType::BUFFER, arr.device() };
}

/**
Expand All @@ -53,7 +53,7 @@ create_2d_xy(const Array & arr) -> Array
static auto
create_2d_zy(const Array & arr) -> Array
{
return Array{ arr.depth(), arr.height(), 1, arr.dtype(), mType::BUFFER, arr.device() };
return Array{ arr.depth(), arr.height(), 1, 2, arr.dtype(), mType::BUFFER, arr.device() };
}

/**
Expand All @@ -64,7 +64,7 @@ create_2d_zy(const Array & arr) -> Array
static auto
create_2d_xz(const Array & arr) -> Array
{
return Array{ arr.width(), arr.depth(), 1, arr.dtype(), mType::BUFFER, arr.device() };
return Array{ arr.width(), arr.depth(), 1, 2, arr.dtype(), mType::BUFFER, arr.device() };
}

/**
Expand Down
17 changes: 0 additions & 17 deletions clic/include/tier0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,6 @@ create_xz(const Array::Pointer & src, Array::Pointer & dst, dType type = dType::
auto
create_zx(const Array::Pointer & src, Array::Pointer & dst, dType type = dType::UNKNOWN) -> void;

/**
* @brief Execution function for separable kernel operation
* @param device Device pointer
* @param kernel Kernel function name and code
* @param src Source array
* @param dst Destination array
* @param sigma Sigma value for the kernel
* @param radius Radius value for the kernel
*/
auto
execute_separable_func(const Device::Pointer & device,
const KernelInfo & kernel,
const Array::Pointer & src,
const Array::Pointer & dst,
const std::array<float, 3> & sigma,
const std::array<int, 3> & radius) -> void;


} // namespace cle::tier0

Expand Down

0 comments on commit 9f3aace

Please sign in to comment.