Skip to content

Commit

Permalink
Merge pull request #324 from clEsperanto/rename-read/write/copy-funct…
Browse files Browse the repository at this point in the history
…ions

Rename-read/write/copy-functions
  • Loading branch information
StRigaud authored Jul 15, 2024
2 parents 89bd7e2 + 4bc296e commit b1d6029
Show file tree
Hide file tree
Showing 187 changed files with 666 additions and 666 deletions.
32 changes: 16 additions & 16 deletions clic/include/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Array
* @param host_data pointer to the host data
*/
auto
write(const void * host_data) -> void;
writeFrom(const void * host_data) -> void;

/**
* @brief Write host data into the Array region
Expand All @@ -112,9 +112,9 @@ class Array
* @param buffer_origin origin of the buffer to write
*/
auto
write(const void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) -> void;
writeFrom(const void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) -> void;

/**
* @brief Write host data into the Array at a specific position (x, y, z)
Expand All @@ -124,14 +124,14 @@ class Array
* @param z_coord z coordinate
*/
auto
write(const void * host_data, size_t x_coord, size_t y_coord, size_t z_coord) -> void;
writeFrom(const void * host_data, size_t x_coord, size_t y_coord, size_t z_coord) -> void;

/**
* @brief Read the Array data into host memory
* @param host_data pointer to the host data
*/
auto
read(void * host_data) const -> void;
readTo(void * host_data) const -> void;

/**
* @brief Read the Array region data into host memory
Expand All @@ -140,9 +140,9 @@ class Array
* @param buffer_origin origin of the buffer to read
*/
auto
read(void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) const -> void;
readTo(void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) const -> void;

/**
* @brief Read the Array data at a specific position (x, y, z) into host memory
Expand All @@ -152,14 +152,14 @@ class Array
* @param z_coord z coordinate
*/
auto
read(void * host_data, size_t x_coord, size_t y_coord, size_t z_coord) const -> void;
readTo(void * host_data, size_t x_coord, size_t y_coord, size_t z_coord) const -> void;

/**
* @brief Copy the Array data into another Array
* @param dst destination Array::Pointer
*/
auto
copy(const Array::Pointer & dst) const -> void;
copyTo(const Array::Pointer & dst) const -> void;

/**
* @brief Copy the Array region data into another Array
Expand All @@ -169,10 +169,10 @@ class Array
* @param dst_origin origin of the destination buffer
*/
auto
copy(const Array::Pointer & dst,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & src_origin,
const std::array<size_t, 3> & dst_origin) const -> void;
copyTo(const Array::Pointer & dst,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & src_origin,
const std::array<size_t, 3> & dst_origin) const -> void;

/**
* @brief Fill the Array with a specific value
Expand Down Expand Up @@ -337,7 +337,7 @@ print(const Array::Pointer & array, const char * name = "Array::Pointer") -> voi
return;
}
std::vector<T> host_data(array->size());
array->read(host_data.data());
array->readTo(host_data.data());
std::ostringstream oss;
oss << name << ":\n";
for (auto i = 0; i < array->depth(); ++i)
Expand Down
50 changes: 25 additions & 25 deletions clic/src/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Array::create(const size_t width,
const Device::Pointer & device_ptr) -> Array::Pointer
{
auto ptr = create(width, height, depth, dimension, data_type, mem_type, device_ptr);
ptr->write(host_data);
ptr->writeFrom(host_data);
return ptr;
}

Expand Down Expand Up @@ -97,7 +97,7 @@ Array::allocate() -> void
}

auto
Array::write(const void * host_data) -> void
Array::writeFrom(const void * host_data) -> void
{
if (host_data == nullptr)
{
Expand All @@ -110,9 +110,9 @@ Array::write(const void * host_data) -> void
}

auto
Array::write(const void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) -> void
Array::writeFrom(const void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) -> void
{
if (host_data == nullptr)
{
Expand All @@ -125,13 +125,13 @@ Array::write(const void * host_data,
}

auto
Array::write(const void * host_data, const size_t x_coord, const size_t y_coord, const size_t z_coord) -> void
Array::writeFrom(const void * host_data, const size_t x_coord, const size_t y_coord, const size_t z_coord) -> void
{
write(host_data, { 1, 1, 1 }, { x_coord, y_coord, z_coord });
writeFrom(host_data, { 1, 1, 1 }, { x_coord, y_coord, z_coord });
}

auto
Array::read(void * host_data) const -> void
Array::readTo(void * host_data) const -> void
{
if (host_data == nullptr)
{
Expand All @@ -144,9 +144,9 @@ Array::read(void * host_data) const -> void
}

auto
Array::read(void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) const -> void
Array::readTo(void * host_data,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & buffer_origin) const -> void
{
if (host_data == nullptr)
{
Expand All @@ -159,13 +159,13 @@ Array::read(void * host_data,
}

auto
Array::read(void * host_data, const size_t x_coord, const size_t y_coord, const size_t z_coord) const -> void
Array::readTo(void * host_data, const size_t x_coord, const size_t y_coord, const size_t z_coord) const -> void
{
read(host_data, { 1, 1, 1 }, { x_coord, y_coord, z_coord });
readTo(host_data, { 1, 1, 1 }, { x_coord, y_coord, z_coord });
}

auto
Array::copy(const Array::Pointer & dst) const -> void
Array::copyTo(const Array::Pointer & dst) const -> void
{
check_ptr(dst, "Error: Destination Array is null");
if (device() != dst->device())
Expand Down Expand Up @@ -208,10 +208,10 @@ Array::copy(const Array::Pointer & dst) const -> void
}

auto
Array::copy(const Array::Pointer & dst,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & src_origin,
const std::array<size_t, 3> & dst_origin) const -> void
Array::copyTo(const Array::Pointer & dst,
const std::array<size_t, 3> & region,
const std::array<size_t, 3> & src_origin,
const std::array<size_t, 3> & dst_origin) const -> void
{
check_ptr(dst, "Error: Destination Array is null");
if (device() != dst->device())
Expand Down Expand Up @@ -259,37 +259,37 @@ Array::fill(const float value) -> void
{
case dType::FLOAT: {
std::vector<float> data(this->size(), value);
write(data.data());
writeFrom(data.data());
return;
}
case dType::INT8: {
std::vector<int8_t> data(this->size(), static_cast<int8_t>(value));
write(data.data());
writeFrom(data.data());
return;
}
case dType::INT16: {
std::vector<int16_t> data(this->size(), static_cast<int16_t>(value));
write(data.data());
writeFrom(data.data());
return;
}
case dType::INT32: {
std::vector<int32_t> data(this->size(), static_cast<int32_t>(value));
write(data.data());
writeFrom(data.data());
return;
}
case dType::UINT8: {
std::vector<uint8_t> data(this->size(), static_cast<uint8_t>(value));
write(data.data());
writeFrom(data.data());
return;
}
case dType::UINT16: {
std::vector<uint16_t> data(this->size(), static_cast<uint16_t>(value));
write(data.data());
writeFrom(data.data());
return;
}
case dType::UINT32: {
std::vector<uint32_t> data(this->size(), static_cast<uint32_t>(value));
write(data.data());
writeFrom(data.data());
return;
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion clic/src/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ execute_separable(const Device::Pointer & device,
}
else
{
input->copy(output);
input->copyTo(output);
}
};

Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier1/write_values_to_positions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ write_values_to_positions_func(const Device::Pointer & device,
auto temp = Array::create(1, list->height(), 1, 2, dType::INT32, list->mtype(), list->device());
maximum_x_projection_func(device, list, temp);
std::vector<int> max_position(temp->size());
temp->read(max_position.data());
temp->readTo(max_position.data());
size_t max_pos_x = max_position[0] + 1;
size_t max_pos_y = (list->height() > 2) ? max_position[1] + 1 : 1;
size_t max_pos_z = (list->height() > 3) ? max_position[2] + 1 : 1;
Expand Down
6 changes: 3 additions & 3 deletions clic/src/tier2/extend_labeling_via_voronoi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ extend_labeling_via_voronoi_func(const Device::Pointer & device,
{
tier1::onlyzero_overwrite_maximum_func(device, flop, flag, flip, "box");
}
flag->read(&flag_value);
flag->readTo(&flag_value);
flag->fill(0);
iteration_count++;
}
if (iteration_count % 2 == 0)
{
flip->copy(dst);
flip->copyTo(dst);
}
else
{
flop->copy(dst);
flop->copyTo(dst);
}
return dst;
}
Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier2/maximum_of_all_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ maximum_of_all_pixels_func(const Device::Pointer & device, const Array::Pointer
tier1::maximum_x_projection_func(device, tmp, dst);

float res;
dst->read(&res);
dst->readTo(&res);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier2/minimum_of_all_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ minimum_of_all_pixels_func(const Device::Pointer & device, const Array::Pointer
tier1::minimum_x_projection_func(device, tmp, dst);

float res;
dst->read(&res);
dst->readTo(&res);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier2/minimum_of_masked_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ minimum_of_masked_pixels_func(const Device::Pointer & device,
tier1::minimum_of_masked_pixels_reduction_func(device, tmp_src, tmp_mask, dst_src, dst_mask);

float res;
dst_src->read(&res);
dst_src->readTo(&res);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier2/sum_of_all_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sum_of_all_pixels_func(const Device::Pointer & device, const Array::Pointer & sr
tier1::sum_x_projection_func(device, tmp, dst);

float res;
dst->read(&res);
dst->readTo(&res);
return res;
}

Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier3/exclude_labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exclude_labels_func(const Device::Pointer & device,
throw std::runtime_error("exclude_labels: label list must be of type uint32");
}
std::vector<uint32_t> labels_list(list->size());
list->read(labels_list.data());
list->readTo(labels_list.data());

labels_list.front() = 0;
uint32_t count = 1;
Expand All @@ -38,7 +38,7 @@ exclude_labels_func(const Device::Pointer & device,
}

auto index_list = Array::create(list->size(), 1, 1, 1, dType::LABEL, mType::BUFFER, src->device());
index_list->write(labels_list.data());
index_list->writeFrom(labels_list.data());
tier1::replace_values_func(device, src, index_list, dst);
return dst;
}
Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier3/exclude_labels_on_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exclude_labels_on_edges_func(const Device::Pointer & device,
execute_if_needed(exclude_z, src->depth(), "exclude_on_edges_z");

std::vector<uint32_t> label_map_vector(label_map->size());
label_map->read(label_map_vector.data());
label_map->readTo(label_map_vector.data());
int32_t count = 1;
for (auto & i : label_map_vector)
{
Expand All @@ -51,7 +51,7 @@ exclude_labels_on_edges_func(const Device::Pointer & device,
count++;
}
}
label_map->write(label_map_vector.data());
label_map->writeFrom(label_map_vector.data());
return tier1::replace_values_func(device, src, label_map, dst);
}

Expand Down
6 changes: 3 additions & 3 deletions clic/src/tier3/maximum_position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ maximum_position_func(const Device::Pointer & device, const Array::Pointer & src

if (pos_x != nullptr)
{
pos_x->read(&x_coord, { 1, 1, 1 }, { 0, 0, 0 });
pos_x->readTo(&x_coord, { 1, 1, 1 }, { 0, 0, 0 });
coord[0] = x_coord;
}
if (pos_y != nullptr)
{
pos_y->read(&y_coord, { 1, 1, 1 }, { x_coord, 0, 0 });
pos_y->readTo(&y_coord, { 1, 1, 1 }, { x_coord, 0, 0 });
coord[1] = y_coord;
}
if (pos_z != nullptr)
{
pos_z->read(&z_coord, { 1, 1, 1 }, { x_coord, y_coord, 0 });
pos_z->readTo(&z_coord, { 1, 1, 1 }, { x_coord, y_coord, 0 });
coord[2] = z_coord;
}
return coord;
Expand Down
6 changes: 3 additions & 3 deletions clic/src/tier3/minimum_position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ minimum_position_func(const Device::Pointer & device, const Array::Pointer & src

if (pos_x != nullptr)
{
pos_x->read(&x_coord, { 1, 1, 1 }, { 0, 0, 0 });
pos_x->readTo(&x_coord, { 1, 1, 1 }, { 0, 0, 0 });
coord[0] = x_coord;
}
if (pos_y != nullptr)
{
pos_y->read(&y_coord, { 1, 1, 1 }, { x_coord, 0, 0 });
pos_y->readTo(&y_coord, { 1, 1, 1 }, { x_coord, 0, 0 });
coord[1] = y_coord;
}
if (pos_z != nullptr)
{
pos_z->read(&z_coord, { 1, 1, 1 }, { x_coord, y_coord, 0 });
pos_z->readTo(&z_coord, { 1, 1, 1 }, { x_coord, y_coord, 0 });
coord[2] = z_coord;
}
return coord;
Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier3/morphological_chan_vese.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ create_checkerboard_init(const Array::Pointer & src, Array::Pointer dst, int squ
}
}
}
dst->write(checkerboard.data());
dst->writeFrom(checkerboard.data());
}


Expand Down
Loading

0 comments on commit b1d6029

Please sign in to comment.