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

Unable to run autoscheduler program in Windows using Visual Studio #4893

Closed
anjugopinath opened this issue May 3, 2020 · 9 comments · Fixed by #4644
Closed

Unable to run autoscheduler program in Windows using Visual Studio #4893

anjugopinath opened this issue May 3, 2020 · 9 comments · Fixed by #4644

Comments

@anjugopinath
Copy link

The following program
https://halide-lang.org/tutorials/tutorial_lesson_21_auto_scheduler_generate.html

is compiled on Linux with the following command:
g++ lesson_21_auto_scheduler_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_21_generate

No instructions are given to compile it in Windows.

@alexreinking
Copy link
Member

You should use CMake with Halide on Windows, for which more robust support is forthcoming. See #4644

MinGW was deprecated in #4601 . See also #4593

@alexreinking
Copy link
Member

I'm adding "Add CMake tutorial" to the TODOs in #4644

@abadams
Copy link
Member

abadams commented May 4, 2020

The tutorials intentionally do not use a build system. The intent is to minimize the number of layers of abstraction to begin with and force people to understand the raw compiler invocations. This is especially important for the generator tutorial because it uses staged compilation. Unfortunately this is all at odds with how people build things on Windows.

So I guess we need a later tutorial that's a Hello World for Halide in Visual Studio. Or maybe it could be an explanatory comment in a Halide CMake tutorial? I'm not sure what else you need to do in visual studio once you have a minimal cmake project.

@alexreinking
Copy link
Member

So I guess we need a later tutorial that's a Hello World for Halide in Visual Studio. Or maybe it could be an explanatory comment in a Halide CMake tutorial? I'm not sure what else you need to do in visual studio once you have a minimal cmake project.

This is the plan. VS2017+ has native support for CMake projects, so a tutorial that introduces how to build Halide with CMake suffices for all platforms.

@anjugopinath
Copy link
Author

anjugopinath commented May 4, 2020

Can I use Cmake with the Halide binaries for Windows?
I have downloaded the binaries for Windows halide-win-64-distro-800-65c26cba6a3eca2d08a0bccf113ca28746012cc3.zip from this link https://github.com/halide/Halide/releases.

@alexreinking
Copy link
Member

You can and should use CMake, but note that the support will not be as robust as in #4644

See README_cmake.md for details on how to use it.

@anjugopinath
Copy link
Author

anjugopinath commented May 4, 2020

  1. In the README_cmake.md file, it is mentioned that a ".a" file will be generated. I need a ".lib" file for Windows. Is there a workaround?

@alexreinking
Copy link
Member

It should generate a .lib regardless. I'm guessing it says ".a" simply because that's the convention on Linux.

@anjugopinath
Copy link
Author

anjugopinath commented May 6, 2020

Inside the root directory of halide binaries for windows, I created a folder called autoschedule.
Inside this folder ,

  1. I added files lesson_21_auto_scheduler_generate.cpp and lesson_21_auto_scheduler_run.cpp.
  2. I created a CMakeLists.txt file . The contents are:
    ***
    project(autoschedule)
    cmake_minimum_required(VERSION 3.1.3)

set(HALIDE_DISTRIB_DIR "${CMAKE_CURRENT_LIST_DIR}/../../distrib")

include("${HALIDE_DISTRIB_DIR}/halide.cmake")

add_executable(autoschedule "${CMAKE_CURRENT_SOURCE_DIR}/lesson_21_auto_scheduler_run.cpp")
set_target_properties(autoschedule PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
target_include_directories(autoschedule PRIVATE "${HALIDE_INCLUDE_DIR}" "${HALIDE_TOOLS_DIR}")
halide_use_image_io(autoschedule)

file(GLOB GENS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*_generator.cpp")
foreach(GEN_SRC ${GENS})
string(REPLACE "_generator.cpp" "" GEN_NAME "${GEN_SRC}")
halide_library("${GEN_NAME}" SRCS ${GEN_SRC})
target_link_libraries(autoschedule PUBLIC "${GEN_NAME}")
endforeach()
***
I am getting errors:
CMake Error at CMakeLists.txt:7 (include):
include could not find load file:

C:/Users/<username>/Downloads/halide-win-64-distro-800-65c26cba6a3eca2d08a0bccf113ca28746012cc3/halide/autoschedule/../../distrib/halide.cmake

CMake Error at CMakeLists.txt:13 (halide_use_image_io):
Unknown CMake command "halide_use_image_io".

-- Configuring incomplete, errors occurred!

alexreinking added a commit that referenced this issue May 12, 2020
Fixes #870
Fixes #2643
Fixes #2821
Fixes #2852
Fixes #2942
Fixes #3658
Fixes #4009
Fixes #4284
Fixes #4476
Fixes #4581
Fixes #4893
Fixes #4895
alexreinking added a commit that referenced this issue May 12, 2020
Fixes #870
Fixes #2643
Fixes #2821
Fixes #2852
Fixes #2942
Fixes #3658
Fixes #4009
Fixes #4284
Fixes #4476
Fixes #4581
Fixes #4893
Fixes #4895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants