forked from halide/Halide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc42da9
commit c45be97
Showing
9 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## | ||
# Load Julia dependencies, including external JlCxx | ||
## | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(libhalide-julia) | ||
|
||
set(JLCXX_VER 0.8.2) | ||
find_package(jlcxx ${JLCXX_VER} QUIET) | ||
if (NOT jlcxx_FOUND) | ||
include(FetchContent) | ||
FetchContent_Declare(jlcxx | ||
GIT_REPOSITORY https://github.com/JuliaInterop/libcxxwrap-julia.git | ||
GIT_TAG v${JLCXX_VER}) | ||
FetchContent_MakeAvailable(jlcxx) | ||
endif () | ||
|
||
# ## | ||
# # Add our sources to this sub-tree. | ||
# ## | ||
|
||
add_subdirectory(src) | ||
|
||
option(WITH_TEST_JULIA "Build Julia tests" ON) | ||
if (WITH_TESTS AND WITH_TEST_JULIA) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = "Halide" | ||
uuid = "26cb47bb-16f4-45b8-86ca-ecaeb6ea8cd7" | ||
authors = ["Johnny Chen <johnnychen94@hotmail.com>"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Halide | ||
|
||
using CxxWrap | ||
# TODO: wrap this with jll package provided by BinaryBuilder to avoid hardcoded path | ||
artifacts_root = joinpath(@__DIR__, "../../../build/julia_bindings/src") | ||
@wrapmodule(joinpath(artifacts_root, "libhalide"), :define_func) | ||
|
||
|
||
function __init__() | ||
@initcxx | ||
end | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
set(SOURCES | ||
JlHalide.cpp | ||
JlFunc.cpp | ||
) | ||
|
||
# CxxWrap requires this to be built as shared library | ||
add_library(Halide_Julia SHARED ${SOURCES}) | ||
add_library(Halide::Julia ALIAS Halide_Julia) | ||
set_target_properties(Halide_Julia | ||
PROPERTIES | ||
LIBRARY_OUTPUT_NAME halide | ||
EXPORT_NAME Julia) | ||
|
||
target_include_directories(Halide_Julia PRIVATE ${jlcxx_SOURCE_DIR}/include) | ||
target_link_libraries(Halide_Julia PRIVATE Halide::Halide) | ||
target_link_libraries(Halide_Julia PUBLIC cxxwrap_julia) | ||
|
||
install(TARGETS | ||
Halide_Julia | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
RUNTIME DESTINATION lib | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "JlFunc.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace Halide { | ||
namespace JuliaBindings { | ||
|
||
|
||
JLCXX_MODULE define_func(jlcxx::Module& m) { | ||
m.add_type<Func>("Func") | ||
.constructor<const std::string&>() | ||
.constructor<>() | ||
.method("name", &Func::name); | ||
} | ||
|
||
} // namespace JuliaBindings | ||
} // namespace Halide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef HALIDE_JULIA_BINDINGS_JLFUNC_H | ||
#define HALIDE_JULIA_BINDINGS_JLFUNC_H | ||
|
||
#include "JlHalide.h" | ||
|
||
namespace Halide { | ||
namespace JuliaBindings { | ||
|
||
JLCXX_MODULE define_func(jlcxx::Module& m); | ||
|
||
} // namespace JuliaBindings | ||
} // namespace Halide | ||
|
||
#endif // HALIDE_JULIA_BINDINGS_JLFUNC_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "JlHalide.h" | ||
|
||
static_assert(JLCXX_VERSION_MAJOR == 0 && JLCXX_VERSION_MINOR == 8 && JLCXX_VERSION_PATCH >= 2, | ||
"Halide requires JlCxx 0.8.2+"); | ||
|
||
namespace Halide { | ||
namespace JuliaBindings { | ||
|
||
|
||
} // namespace JuliaBindings | ||
} // namespace Halide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef HALIDE_JULIA_BINDINGS_JLHALIDE_H | ||
#define HALIDE_JULIA_BINDINGS_JLHALIDE_H | ||
|
||
#include <jlcxx/jlcxx_config.hpp> // For compatibility check | ||
#include <jlcxx/jlcxx.hpp> | ||
|
||
// Everyone needs Halide.h | ||
#include "Halide.h" | ||
|
||
#endif // HALIDE_JULIA_BINDINGS_JLHALIDE_H |