Skip to content

Commit

Permalink
Merge pull request #52 from fixstars/feature/remove-deprecated-unary_…
Browse files Browse the repository at this point in the history
…function

Stop to use unary_function
  • Loading branch information
iitaku authored Feb 8, 2021
2 parents e584eb8 + a56724c commit 3dbc92e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ if (UNIX)
else()
install(FILES ${CMAKE_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/ion-core.dll DESTINATION bin)
install(FILES ${CMAKE_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/ion-core.lib DESTINATION lib)
# These lines is for backward compatibility.

# These lines is for backward compatibility.
# TODO: Deprecate old name of dll/lib.
install(FILES ${CMAKE_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/ion-core.dll DESTINATION bin RENAME ion.dll)
install(FILES ${CMAKE_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/ion-core.lib DESTINATION lib RENAME ion.lib)
Expand Down Expand Up @@ -152,7 +152,7 @@ endif()
# Packaging
#
if (UNIX)
set(CPACK_GENERATOR "DEB")
set(CPACK_GENERATOR "TGZ" "DEB")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Fixstars Corporation Inc.")
configure_file(${CMAKE_SOURCE_DIR}/ion-kit.pc.in ${CMAKE_BINARY_DIR}/ion-kit.pc @ONLY)
Expand All @@ -167,4 +167,4 @@ message(STATUS "Version: ${GIT_DESCRIBE_RESULT}")
string(STRIP "${GIT_DESCRIBE_RESULT}" ION_KIT_VERSION_S)
string(REPLACE "v" "" ION_KIT_VERSION ${ION_KIT_VERSION_S})
set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION})
include(CPack)
include(CPack)
47 changes: 27 additions & 20 deletions include/ion/port_map.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
#ifndef ION_PORT_MAP_H
#define ION_PORT_MAP_H

#include <functional>
#include <string>
#include <tuple>

#include <Halide.h>

#include "ion/util.h"

namespace std
{

template<>
struct hash<tuple<string, string>>
{
std::size_t operator()(const tuple<string, string>& k) const noexcept
{
return std::hash<std::string>{}(std::get<0>(k)) ^ std::hash<std::string>{}(std::get<1>(k));
}
};

template<>
struct equal_to<tuple<string, string>>
{
bool operator()(const tuple<string, string>& v0, const tuple<string, string>& v1) const
{
return (std::get<0>(v0) == std::get<0>(v1) && std::get<1>(v0) == std::get<1>(v1));
}
};

} // std

namespace ion {

/**
* PortMap is used to assign actual value to the port input.
*/
class PortMap {

using key_t = std::tuple<std::string, std::string>;

struct key_hash : public std::unary_function<key_t, std::size_t>
{
std::size_t operator()(const key_t& k) const
{
return std::hash<std::string>{}(std::get<0>(k)) ^ std::hash<std::string>{}(std::get<1>(k));
}
};

struct key_equal : public std::binary_function<key_t, key_t, bool>
{
bool operator()(const key_t& v0, const key_t& v1) const
{
return (std::get<0>(v0) == std::get<0>(v1) && std::get<1>(v0) == std::get<1>(v1));
}
};

public:

template<typename T>
Expand Down Expand Up @@ -142,7 +149,7 @@ class PortMap {
return param_func_.at(k);
}

std::unordered_map<key_t, std::vector<Halide::Buffer<>>, key_hash, key_equal> get_output_buffer() const {
std::unordered_map<std::tuple<std::string, std::string>, std::vector<Halide::Buffer<>>> get_output_buffer() const {
return output_buffer_;
}

Expand All @@ -154,7 +161,7 @@ class PortMap {

std::unordered_map<std::string, Halide::Expr> param_expr_;
std::unordered_map<std::string, Halide::Func> param_func_;
std::unordered_map<key_t, std::vector<Halide::Buffer<>>, key_hash, key_equal> output_buffer_;
std::unordered_map<std::tuple<std::string, std::string>, std::vector<Halide::Buffer<>>> output_buffer_;
Halide::ParamMap param_map_;
};

Expand Down

0 comments on commit 3dbc92e

Please sign in to comment.