-
Notifications
You must be signed in to change notification settings - Fork 82
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
[Windows] Build applications tests and benchmarks on Windows [Include #2924 changes] #2952
base: main
Are you sure you want to change the base?
Conversation
You could make two PRs if you had two features. That would help others review. Just let this as it is for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1db2541
to
17aaadc
Compare
I originally make this changes in 2 PRs but first one is in review for more than week (see #2924) |
17aaadc
to
64aa7cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! can't wait to dive into benchmarking on Windows :)
third_party/benchmark.wrap
Outdated
@@ -0,0 +1,4 @@ | |||
[wrap-git] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move *wrap
files under the subprojects directory. (#2917)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move
*wrap
files under the subprojects directory. (#2917)
Ok
64aa7cd
to
88ca77f
Compare
For the case, please mention the dependency between PRs in your title. This will be helpful for reviewers! |
|
||
nntr_alex_resdir = nntr_app_resdir / 'AlexNet' | ||
run_command('cp', '-lr', res_path, nntr_alex_resdir) | ||
if host_machine.system() == 'windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need that, it can be done in native file.
Please see https://mesonbuild.com/Machine-files.html#binaries
and also my POC
[binaries]
#mkdir = ['mkdir']
mkdir = ['wine', 'cmd.exe', '/c','mkdir']
nproc = ['wine', 'cmd', '/c', '@echo', '%NUMBER_OF_PROCESSORS%']
touch = ['@DIRNAME@'/'touch.bat']
It'll require find_program('cp')
add_project_arguments(['-mavx2'], language: ['c','cpp']) | ||
message('-march=native added for AVX hardware acceleration.') | ||
if host_machine.system() == 'windows' | ||
add_project_arguments(['/arch:AVX2'], language: ['c','cpp']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also possible in native-file
cpp_args=...
cpp_link_args=...
we still need if !=
windows`
meson.build
Outdated
run_command('mkdir', '-p', nntrainer_resdir) | ||
|
||
if host_machine.system() == 'windows' | ||
nntrainer_resdir_win = nntrainer_resdir.replace('/', '\\') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we construct it correctly using '/'?
Couldn't test with wine since Z:\
is required for abs path.
blas_options.add_cmake_defines({'BUILD_TESTING': false}) | ||
blas_options.add_cmake_defines({'BUILD_BENCHMARKS': false}) | ||
blas_options.add_cmake_defines({'BUILD_SHARED_LIBS': false}) | ||
blas_options.add_cmake_defines({'BUILD_WITHOUT_LAPACK': true}) | ||
blas_subproject = cmake.subproject('openblas', options: blas_options, required: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't ever test it but worth checking if defining those in native [cmake] section works
if not benchmark_dep.found() | ||
benchmark_options = cmake.subproject_options() | ||
if host_machine.system() == 'windows' | ||
benchmark_options.append_compile_args('c', windows_compile_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again native file
meson.build
Outdated
libm_dep = cxx.find_library('m') # cmath library | ||
libdl_dep = cxx.find_library('dl') # DL library | ||
if host_machine.system() != 'windows' | ||
libm_dep = cxx.find_library('m') # cmath library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false
should do
meson.build
Outdated
libdl_dep = cxx.find_library('dl') # DL library | ||
if host_machine.system() != 'windows' | ||
libm_dep = cxx.find_library('m') # cmath library | ||
libdl_dep = cxx.find_library('dl') # DL library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
if get_option('platform') == 'android' | ||
iniparser_root = meson.source_root() / 'third_party' / 'iniparser' | ||
iniparser_root = meson.source_root() / 'subprojects' / 'iniparser' | ||
iniparser_dep = declare_dependency() | ||
else | ||
iniparser_dep = dependency('iniparser', required : false, version : '>=3.2') # iniparser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use `dependency(..., fallback='iniparse')
libcurl_dep = dependency('libcurl') | ||
if not tflite_dep.found() | ||
error('Tensorflow-Lite dependency not found') | ||
if host_machine.system() != 'windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to make it optional for all platforms in 'Applications', I already do to some degree for openvino.
Warn that something-something is unsupported
meson.build
Outdated
endif | ||
subdir('Applications') | ||
endif | ||
endif | ||
|
||
if get_option('platform') != 'android' | ||
if get_option('platform') != 'android' and host_machine.system() != 'windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use get_option() here really, since it's already optional by meson.options
@@ -207,15 +207,17 @@ std::vector<std::string> getPluginPaths() { | |||
const std::string getFullPath(const std::string &path, | |||
const std::string &base) { | |||
/// if path is absolute, return path | |||
if (path[0] == '/') { | |||
if (std::filesystem::path(path).is_absolute()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe global alias since it is *.cpp
namespace fs = std::filesystem;
What I already do.
nntrainer/cl_context.cpp
Outdated
@@ -231,12 +231,12 @@ bool ClContext::clCreateKernel(std::string &kernel_string, | |||
size_t binary_size = fs.tellg(); | |||
fs.seekg(0, std::ios::beg); | |||
|
|||
unsigned char chunk[binary_size]; | |||
fs.read((char *)chunk, binary_size); | |||
std::vector<unsigned char> chunk(binary_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brace constructor? Nitpick
@@ -163,6 +163,7 @@ void ReshapeLayerCl::ReshapeProcess(Tensor const &input, Tensor &output) { | |||
} | |||
} | |||
|
|||
#ifdef ENABLE_FP16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool
thread_dep, | ||
openmp_dep | ||
] | ||
|
||
if host_machine.system() != 'windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required:false
should do it
nntrainer/meson.build
Outdated
@@ -101,9 +105,13 @@ else | |||
install_dir: nntrainer_libdir | |||
) | |||
|
|||
nntrainer_lib = nntrainer_shared | |||
if get_option('default_library') == 'static' | |||
if host_machine.system() == 'windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment? What is going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should ban default_library=shared
build on windows, or override it in native file and warn/error at toplevel
#if defined(_WIN32) | ||
__m256 temp = _mm256_loadu_ps(&X[i]); | ||
_mm256_storeu_ps(&Y[i], temp); | ||
#else | ||
__asm__ __volatile__("vmovups (%1), %%ymm0\n\t" | ||
"vmovups %%ymm0, (%0)\n\t" | ||
: | ||
: "r"(&Y[i]), "r"(&X[i]) | ||
: "ymm0", "memory"); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if we really wan't inline asm here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be same modulo forcing ymm0 here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current nntrainer is undergoing major refactor process on blas-level codes, so it is highly recommended to remove any fixes at tensor/blas_* files if not super urgent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't finish this review, but looks good, probably will rebase my changes.
@@ -1,8 +1,15 @@ | |||
build_root = meson.build_root() | |||
res_path = meson.current_source_dir() / '..' / 'res' | |||
fs = import('fs') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move closer to begin of file, it'll be useful
It's include/import as in other language.
I'll add proposed modifications in next PR |
@gkisalapl fine by me, thanks |
88ca77f
to
51e9c8a
Compare
This PR add possibility to run soma applications, tests and benchmarks on windows It aslo fix support for blas and avx on windows **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Grzegorz Kisala <[email protected]>
51e9c8a
to
4dcf0a2
Compare
This PR add possibility to run soma applications, tests and benchmarks on windows
It also fix support for blas and avx on windows
Self-evaluation: