-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
blasfeo: add package #15643
blasfeo: add package #15643
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Thank you for your contribution, I'm curious why don't you use the cmake support from the project instead of parsing manually all thos options https://github.com/giaf/blasfeo/blob/0.1.3/CMakeLists.txt
recipes/blasfeo/all/conanfile.py
Outdated
options = { | ||
"library_type": ["static_library", "shared_library"], | ||
"fPIC": [True, False], | ||
"target": [ |
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.
It seems part of target architecture, so it's part of settings, not an option.
printf("Testing processor\n"); | ||
|
||
char supportString[50]; | ||
blasfeo_processor_library_string(supportString); | ||
printf("Library requires processor features:%s\n", supportString); | ||
|
||
int features = 0; | ||
int procCheckSucceed = blasfeo_processor_cpu_features(&features); | ||
blasfeo_processor_feature_string(features, supportString); | ||
printf("Processor supports features:%s\n", supportString); | ||
|
||
if (!procCheckSucceed) | ||
{ | ||
printf("Current processor does not support the current compiled BLASFEO library.\n"); | ||
printf("Please get a BLASFEO library compatible with this processor.\n"); | ||
exit(3); | ||
} | ||
|
||
int ii; // loop index | ||
|
||
int n = 12; // matrix size | ||
|
||
// A | ||
struct blasfeo_dmat sA; // matrix structure | ||
blasfeo_allocate_dmat(n, n, &sA); // allocate and assign memory needed by A | ||
|
||
// B | ||
struct blasfeo_dmat sB; // matrix structure | ||
int B_size = blasfeo_memsize_dmat(n, n); // size of memory needed by B | ||
void *B_mem_align; | ||
v_zeros_align(&B_mem_align, B_size); // allocate memory needed by B | ||
blasfeo_create_dmat(n, n, &sB, B_mem_align); // assign aligned memory to struct | ||
|
||
// C | ||
struct blasfeo_dmat sC; // matrix structure | ||
int C_size = blasfeo_memsize_dmat(n, n); // size of memory needed by C | ||
C_size += 64; // 64-bytes alignment | ||
void *C_mem = malloc(C_size); | ||
void *C_mem_align = (void *)((((unsigned long long)C_mem) + 63) / 64 * 64); // align memory pointer | ||
blasfeo_create_dmat(n, n, &sC, C_mem_align); // assign aligned memory to struct | ||
|
||
// A | ||
double *A = malloc(n * n * sizeof(double)); | ||
for (ii = 0; ii < n * n; ii++) | ||
{ | ||
A[ii] = ii; | ||
} | ||
int lda = n; | ||
blasfeo_pack_dmat(n, n, A, lda, &sA, 0, 0); // convert from column-major to BLASFEO dmat | ||
free(A); | ||
|
||
// B | ||
blasfeo_dgese(n, n, 0.0, &sB, 0, 0); // set B to zero | ||
for (ii = 0; ii < n; ii++) | ||
{ | ||
BLASFEO_DMATEL(&sB, ii, ii) = 1.0; // set B diagonal to 1.0 accessing dmat elements | ||
} | ||
|
||
// C | ||
blasfeo_dgese(n, n, -1.0, &sC, 0, 0); // set C to -1.0 | ||
|
||
blasfeo_dgemm_nt(n, n, n, 1.0, &sA, 0, 0, &sB, 0, 0, 0.0, &sC, 0, 0, &sC, 0, 0); | ||
|
||
printf("\nC = \n"); | ||
blasfeo_print_dmat(n, n, &sC, 0, 0); | ||
|
||
blasfeo_free_dmat(&sA); | ||
v_free_align(B_mem_align); | ||
free(C_mem); | ||
|
||
return 0; |
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.
printf("Testing processor\n"); | |
char supportString[50]; | |
blasfeo_processor_library_string(supportString); | |
printf("Library requires processor features:%s\n", supportString); | |
int features = 0; | |
int procCheckSucceed = blasfeo_processor_cpu_features(&features); | |
blasfeo_processor_feature_string(features, supportString); | |
printf("Processor supports features:%s\n", supportString); | |
if (!procCheckSucceed) | |
{ | |
printf("Current processor does not support the current compiled BLASFEO library.\n"); | |
printf("Please get a BLASFEO library compatible with this processor.\n"); | |
exit(3); | |
} | |
int ii; // loop index | |
int n = 12; // matrix size | |
// A | |
struct blasfeo_dmat sA; // matrix structure | |
blasfeo_allocate_dmat(n, n, &sA); // allocate and assign memory needed by A | |
// B | |
struct blasfeo_dmat sB; // matrix structure | |
int B_size = blasfeo_memsize_dmat(n, n); // size of memory needed by B | |
void *B_mem_align; | |
v_zeros_align(&B_mem_align, B_size); // allocate memory needed by B | |
blasfeo_create_dmat(n, n, &sB, B_mem_align); // assign aligned memory to struct | |
// C | |
struct blasfeo_dmat sC; // matrix structure | |
int C_size = blasfeo_memsize_dmat(n, n); // size of memory needed by C | |
C_size += 64; // 64-bytes alignment | |
void *C_mem = malloc(C_size); | |
void *C_mem_align = (void *)((((unsigned long long)C_mem) + 63) / 64 * 64); // align memory pointer | |
blasfeo_create_dmat(n, n, &sC, C_mem_align); // assign aligned memory to struct | |
// A | |
double *A = malloc(n * n * sizeof(double)); | |
for (ii = 0; ii < n * n; ii++) | |
{ | |
A[ii] = ii; | |
} | |
int lda = n; | |
blasfeo_pack_dmat(n, n, A, lda, &sA, 0, 0); // convert from column-major to BLASFEO dmat | |
free(A); | |
// B | |
blasfeo_dgese(n, n, 0.0, &sB, 0, 0); // set B to zero | |
for (ii = 0; ii < n; ii++) | |
{ | |
BLASFEO_DMATEL(&sB, ii, ii) = 1.0; // set B diagonal to 1.0 accessing dmat elements | |
} | |
// C | |
blasfeo_dgese(n, n, -1.0, &sC, 0, 0); // set C to -1.0 | |
blasfeo_dgemm_nt(n, n, n, 1.0, &sA, 0, 0, &sB, 0, 0, 0.0, &sC, 0, 0, &sC, 0, 0); | |
printf("\nC = \n"); | |
blasfeo_print_dmat(n, n, &sC, 0, 0); | |
blasfeo_free_dmat(&sA); | |
v_free_align(B_mem_align); | |
free(C_mem); | |
return 0; | |
char supportString[50]; | |
blasfeo_processor_library_string(supportString); | |
printf("Library requires processor features:%s\n", supportString); | |
return 0; |
Please, use something smaller: https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/test_packages.md#minimalist-source-code
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.
I though of just instantiating some objects, but I am not sure if it would be 100% reliable.
E.g. when I used only code before the line int ii; // loop index
, everything compiled and linked ok in test, but in fact there was linker errors after using other methods (which was solved by adding self.cpp_info.system_libs = ["m"]
).
This example is the one from the package and actually runs matrix computation and outputs the result.
This comment has been minimized.
This comment has been minimized.
@lukaumi Those configurations listed as options, are actually part of settings, because you are cross-building. So, you can not use options for that, otherwise, who consumes this package, would have a configuration mismatch, as Conan uses settings.arch to validate the architecture and match the package ID. It's not only a profile matter, but also how Conan works. What you can do is using self.settings to translate the current More about custom settings: https://docs.conan.io/en/latest/extending/custom_settings.html Of course, your case is not the first, so you can borrow some idea from OpenSSL recipe: https://github.com/conan-io/conan-center-index/blob/master/recipes/openssl/1.x.x/conanfile.py#L336 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- version 0.1.3
This comment has been minimized.
This comment has been minimized.
While I agree that the I've found the issue #13478 which aligns with what I am trying to do here. |
Also, this PR is not picked-up by the bot for review list after all reopening/errors/changes? How can I re-trigger that @prince-chrismc? |
- required as a dependency for hpipm 0.1.3 version to be added later
It can be added to configuration file (which is supported by profile too): https://docs.conan.io/en/latest/reference/config_files/global_conf.html Which means, you can create a specific profile, aligned to your target, and customize any compiler flag that you need. For instance: [settings]
os=Linux
os_build=Linux
arch=armv8
arch.cpu=a76
arch_build=x86_64
compiler=apple-clang
compiler.version=14
compiler.libcxx=libc++
build_type=Release
[options]
[conf]
tools.build:cflags=-march=armv8-a,-mtune=cortex-a76
tools.build:cxxflags=-march=armv8-a,-mtune=cortex-a76
[build_requires]
[env]
CC=/path/to/my/cross/compiler/gcc
CXX=/path/to/my/cross/compiler/g++
Indeed, but need to consider new features maturated since there and we are even closer to Conan v2, which will enforce configuration file even more. |
Conan v1 pipeline ❌Failure in build 17 (
Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability. Conan v2 pipeline (informative, not required for merge) ❌
The v2 pipeline failed. Please, review the errors and note this will be required for pull requests to be merged in the near future. See details:Failure in build 16 ( An unexpected error happened and has been reported. Help is on its way! 🏇 |
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.
This is very odd but thats upstreams fault I think thisnis fine 🙂
"0.1.3": | ||
url: "https://github.com/giaf/blasfeo/archive/refs/tags/0.1.3.tar.gz" | ||
sha256: "c33eb6467a90d6075a8db34e5ab239ecdda38c5261ae096def122fe7a0f98780" | ||
"0.1.2": |
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.
Unless you specifically need this version we generally don't add older versions (you can check the FAQ for more info)
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.
This library blasfeo
is a main dependency of another one hpipm
which I plan to add later.
I tried building locally hpipm
with blasfeo
0.1.3 version as a dependency, but apparently they are not compatible, which is not documented anywhere in either library.
Latest hpipm
release works only with blasfeo
0.1.2 so I've added it here also.
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.
Plus, apparently tests are not compatible with older version so I have to fix that also.
options = { | ||
"fPIC": [True, False], | ||
"shared": [True, False], | ||
"target": [x for list in [i for i in _blasfeo_arch_targets.values()] for x in list], |
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.
This is a very awkward way of packing softwarehttps://github.com/giaf/blasfeo#supported-computer-architectures
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.
Yes, it is. I will try to add something according to @uilianries suggestion.
and I've tracked the issue in the source. This library turns out to be too much of a mess to migrate, and I don't have time to continue playing with this. If anyone wants to continue with this, feel free to use my progress. |
Library name and version: blasfeo/0.1.3
https://github.com/giaf/blasfeo
Additional install documentation: https://blasfeo.syscop.de/docs/install/
Built with
make
as it is primary build system for the libraryPython code formatted with
black
C code formatted with
clang-format