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

Failed to 'make install' in macbook pro m1 : #1433

Closed
adi-lb-phoenix opened this issue Apr 7, 2024 · 9 comments
Closed

Failed to 'make install' in macbook pro m1 : #1433

adi-lb-phoenix opened this issue Apr 7, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@adi-lb-phoenix
Copy link

adi-lb-phoenix commented Apr 7, 2024

Thanks for the amazing repo , it has been a great learning experience trying to build software's such as adaptive cpp , it introduced me to LLVM JIT compiler , building LLVM from source , made me curious about sycl from its mentions in documentation .
So I have a macbook pro m1 , following are the steps I followed in trying to build adaptiveCpp .

Following the installation guide on https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/doc/installing.md and trying to build on an macbook pro m1 with
Chip : Apple M1
macOS : Ventura 13.1
Memory : 16GB
.

git clone https://github.com/AdaptiveCpp/AdaptiveCpp
cd AdaptiveCpp
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/build ..
make install
The following was the error output of make install .

  109 | HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN(exp10)
      | ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:36:12: note: expanded from macro 'HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN'
   36 |     return name##f(x);                                                 \
      |            ^
<scratch space>:267:1: note: expanded from here
  267 | exp10f
      | ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:109:37: error: use of undeclared identifier 'exp10'
  109 | HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN(exp10)
      |                                     ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:199:10: error: use of undeclared identifier 'lgammaf_r'
  199 |   return lgammaf_r(x,y);
      |          ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:204:14: error: use of undeclared identifier 'lgamma_r'
  204 |   auto res = lgamma_r(x,&w);
      |              ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:216:50: error: use of undeclared identifier 'fmaxmagf'
  216 | HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN2_NAME(maxmag,fmaxmagf,fmaxmag)
      |                                                  ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:216:59: error: use of undeclared identifier 'fmaxmag'
  216 | HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN2_NAME(maxmag,fmaxmagf,fmaxmag)
      |                                                           ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:217:50: error: use of undeclared identifier 'fmaxmagf'
  217 | HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN2_NAME(minmag,fmaxmagf,fmaxmag)
      |                                                  ^
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/src/libkernel/sscp/host/math.cpp:217:59: error: use of undeclared identifier 'fmaxmag'
  217 | HIPSYCL_SSCP_MAP_HOST_FLOAT_BUILTIN2_NAME(minmag,fmaxmagf,fmaxmag)
      |                                                           ^
8 errors generated.
make[2]: *** [src/libkernel/sscp/host/libkernel-sscp-host-math.bc] Error 1
make[1]: *** [src/libkernel/sscp/host/CMakeFiles/libkernel-sscp-host.dir/all] Error 2
make: *** [all] Error 2

I inspected the file AdaptiveCpp/src/libkernel/sscp/host/math.cpp .

#include <math.h>

#include "hipSYCL/sycl/libkernel/sscp/builtins/builtin_config.hpp"
#include "hipSYCL/sycl/libkernel/sscp/builtins/math.hpp"

The error seems to be happening from the last 2 lines of the above code .

Packages were installed using : brew install [package name]
packages were :
opencl-headers
libomp
boost
ninja
opencl-clhpp-headers
ocl-icd

Some information about my system

uname -a
Darwin Adithyas-MacBook-Pro.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64 

Additionally I would like to contribute to the official docs to document the steps for mac in official docs

@adi-lb-phoenix adi-lb-phoenix added the bug Something isn't working label Apr 7, 2024
@adi-lb-phoenix adi-lb-phoenix changed the title Fail's to run the cmake command in macbook pro m1 : Fail's to run the cmake command in macbook pro m1 : CMake Error at CMakeLists.txt:151 (message): OpenCL was not found Apr 7, 2024
@adi-lb-phoenix adi-lb-phoenix changed the title Fail's to run the cmake command in macbook pro m1 : CMake Error at CMakeLists.txt:151 (message): OpenCL was not found Failed to 'make install' in macbook pro m1 : Apr 7, 2024
@badumbatish
Copy link
Contributor

hi adi-bhatl, can you try out the build again with the same steps as .github/workflows/macos.yml, currently the build on Mac are a bit messy due to the newer versions of Clang not supporting OpenMP.

This is being worked on in #1427

@adi-lb-phoenix
Copy link
Author

adi-lb-phoenix commented Apr 9, 2024

hello @badumbatish , Thanks for the reply .
so I am manually trying to execute the given commands in the file https://github.com/AdaptiveCpp/AdaptiveCpp/blob/b61a18683cb66734b3d6a1d02ab3e3cb6f1d7d8d/.github/workflows/macos.yml .
I have few questions
1 . How do i proceed with the .github/workflows/macos.yml file ? is there way to execute them ? or its just a set of instructions that i have to manually execute them ?
2. what does $GITHUB_ENV mean here ? I see no definition of $GITHUB_ENV in .yml file

@adi-lb-phoenix
Copy link
Author

adi-lb-phoenix commented Apr 9, 2024

- name: build
      run: |
        OMP_ROOT=`brew list libomp | grep libomp.a | sed -E "s/\/lib\/.*//"`
        echo "OMP_ROOT=${OMP_ROOT}" >> $GITHUB_ENV
        mkdir build && cd build
        cmake .. \
        -DOpenMP_ROOT=$OMP_ROOT \
        -DWITH_OPENCL_BACKEND=OFF \
        -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/build/install
        make -j 2 install VERBOSE=ON

the output of the above is in this file
build_1.txt

- name: build CPU tests
      run: |
        mkdir build/tests-cpu && cd build/tests-cpu
        cmake \
        -DACPP_TARGETS=omp.library-only \
        -DCMAKE_CXX_FLAGS=-I$OMP_ROOT/include \
        -DAdaptiveCpp_DIR=${GITHUB_WORKSPACE}/build/install/lib/cmake/AdaptiveCpp \
        ${GITHUB_WORKSPACE}/tests
        make -j 2 VERBOSE=ON

the out put of the above is in below file
build_test_cpu.txt

- name: run CPU tests
      run: |
        cd ${GITHUB_WORKSPACE}/build/tests-cpu
        LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/build/install/lib ./sycl_tests

the out put of the above is the below file
run_cpu_test.txt


adithyalbhat@Adithyas-MacBook-Pro build % /Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/build/install/bin/acpp-info
=================Backend information===================
Loaded backend 0: OpenMP
  Found device: hipSYCL OpenMP host device

=================Device information===================
***************** Devices for backend OpenMP *****************
Device 0:
 General device information:
  Name: hipSYCL OpenMP host device
  Backend: OpenMP
  Vendor: the hipSYCL project
  Arch: <native-cpu>
  Driver version: 1.2
  Is CPU: 1
  Is GPU: 0
 Default executor information:
  Is in-order queue: 0
  Is out-of-order queue: 1
  Is task graph: 0
 Device support queries:
  images: 0
  error_correction: 0
  host_unified_memory: 1
  little_endian: 1
  global_mem_cache: 1
  global_mem_cache_read_only: 0
  global_mem_cache_read_write: 1
  emulated_local_memory: 1
  sub_group_independent_forward_progress: 0
  usm_device_allocations: 1
  usm_host_allocations: 1
  usm_atomic_host_allocations: 1
  usm_shared_allocations: 1
  usm_atomic_shared_allocations: 1
  usm_system_allocations: 1
  execution_timestamps: 1
  sscp_kernels: 0
 Device properties:
  max_compute_units: 8
  max_global_size0: 18446744073709551615
  max_global_size1: 18446744073709551615
  max_global_size2: 18446744073709551615
  max_group_size: 1024
  max_num_sub_groups: 18446744073709551615
  preferred_vector_width_char: 4
  preferred_vector_width_double: 1
  preferred_vector_width_float: 1
  preferred_vector_width_half: 2
  preferred_vector_width_int: 1
  preferred_vector_width_long: 1
  preferred_vector_width_short: 2
  native_vector_width_char: 4
  native_vector_width_double: 1
  native_vector_width_float: 1
  native_vector_width_half: 2
  native_vector_width_int: 1
  native_vector_width_long: 1
  native_vector_width_short: 2
  max_clock_speed: 0
  max_malloc_size: 18446744073709551615
  address_bits: 64
  max_read_image_args: 0
  max_write_image_args: 0
  image2d_max_width: 0
  image2d_max_height: 0
  image3d_max_width: 0
  image3d_max_height: 0
  image3d_max_depth: 0
  image_max_buffer_size: 0
  image_max_array_size: 0
  max_samplers: 0
  max_parameter_size: 18446744073709551615
  mem_base_addr_align: 8
  global_mem_cache_line_size: 64
  global_mem_cache_size: 1
  global_mem_size: 18446744073709551615
  max_constant_buffer_size: 18446744073709551615
  max_constant_args: 18446744073709551615
  local_mem_size: 18446744073709551615
  printf_buffer_size: 18446744073709551615
  partition_max_sub_devices: 0
  vendor_id: 18446744073709551615
  sub_group_sizes: 1 
  
  
adithyalbhat@Adithyas-MacBook-Pro build % acpp --help
zsh: command not found: acpp

adithyalbhat@Adithyas-MacBook-Pro build % acpp-info -l
zsh: command not found: acpp-info

@fodinabor
Copy link
Collaborator

fodinabor commented Apr 9, 2024

  1. what does $GITHUB_ENV mean here ? I see no definition of $GITHUB_ENV in .yml file

Storing variables in there persists them as environment variables in the next steps, so you should be able to ignore that, for a shell session in which you executed:

export OMP_ROOT=`brew list libomp | grep libomp.a | sed -E "s/\/lib\/.*//"`

Also, nice seems to have worked! :)
acpp is probably not in your PATH variable, so it's not found without giving the full path..

@adi-lb-phoenix
Copy link
Author

adi-lb-phoenix commented Apr 9, 2024

hello @fodinabor , thank you for your insights and taking the time to solve this .

I do have few follow up questions .

  1. How can I test if the adaptivecpp is working as expected ?

  2. if acpp is probably not in my PATH variable, so it's not found without giving the full path. which path should I run to see if the adaptiveCPP actually works on my system

  3. how can i get something like this


acpp [AdaptiveCpp compilation driver], Copyright (C) 2018-2023 Aksel Alpay and the AdaptiveCpp project
  AdaptiveCpp version: 23.10.0+git.2d0c6b6f.20240226.branch.develop
  Installation root: /install/path
  Plugin LLVM version: <version>, can accelerate CPU: <bool>
  Available runtime backends:
     librt-backend-<name>.so
     librt-backend-<name>.so
     librt-backend-<name>.so
     librt-backend-<name>.so
     librt-backend-<name>.so

@chsasank
Copy link
Contributor

How can I test if the adaptivecpp is working as expected ?

I recommend running vector-add program from here. Something like this:

$ acpp vector-add.cpp driver.c
$ ./a.out

@adi-lb-phoenix
Copy link
Author

adi-lb-phoenix commented Apr 10, 2024

Hello @chsasank , I did download the files from the repo you gave the link to .

pwd
/Users/adithyalbhat/github/adaptive_cpp
(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro adaptive_cpp % ls
AdaptiveCpp        driver.c        vector-add.c    vector-add.cpp  vector-add.ll
(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro adaptive_cpp % ./AdaptiveCpp/bin/acpp --acpp-targets=generic --acpp-platform=cpu --acpp-clang=/opt/homebrew/opt/llvm/bin/clang  vector-add.cpp driver.c
acpp warning: No optimization flag was given, optimizations are disabled by default. Performance may be degraded. Compile with e.g. -O2/-O3 to enable optimizations.
clang: error: no such file or directory: '/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/bin/../lib/'
(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro adaptive_cpp % which clang
/opt/homebrew/opt/llvm/bin/clang

used clang ++ in the below

adithyalbhat@Adithyas-MacBook-Pro adaptive_cpp % ./AdaptiveCpp/bin/acpp --acpp-targets=generic --acpp-platform=cpu --acpp-clang=/opt/homebrew/opt/llvm/bin/clang++  vector-add.cpp driver.c
acpp warning: No optimization flag was given, optimizations are disabled by default. Performance may be degraded. Compile with e.g. -O2/-O3 to enable optimizations.
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang++: error: no such file or directory: '/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/bin/../lib/'

It gives me an error : clang: error: no such file or directory: '/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/bin/../lib/'
but when I check for location of clang using

adithyalbhat@Adithyas-MacBook-Pro adaptive_cpp % which clang
/opt/homebrew/opt/llvm/bin/clang

Also I have provided this location to the flag --acpp-clang .
What am i missing ?

@illuhad
Copy link
Collaborator

illuhad commented Apr 11, 2024

adithyalbhat@Adithyas-MacBook-Pro build % acpp --help
zsh: command not found: acpp

based on your CMAKE_INSTALL_PREFIX, you have installed to the build directory as installation root, so therefore, the executables will be in the bin subdirectory. So it needs to be bin/acpp.

(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro adaptive_cpp % ./AdaptiveCpp/bin/acpp --acpp-targets=generic --acpp-platform=cpu --acpp-clang=/opt/homebrew/opt/llvm/bin/clang vector-add.cpp driver.c
acpp warning: No optimization flag was given, optimizations are disabled by default. Performance may be degraded. Compile with e.g. -O2/-O3 to enable optimizations.
clang: error: no such file or directory: '/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/bin/../lib/'

Probably you are not invoking the acpp from your install tree. Based on your cmake invocation, that would be in build.

Do NOT use --acpp-platform=cpu, especially when also using --acpp-targets. --acpp-platform is deprecated and will be ignored if --acpp-targets is present.
Do NOT use --acpp-clang unless you really, really know what you are doing. The AdaptiveCpp compiler plugin must exactly match the clang that it is loaded into, so this must be the clang/LLVM that AdaptiveCpp was built against. It will automatically be configured correctly when building and installing AdaptiveCpp.

@adi-lb-phoenix
Copy link
Author

adi-lb-phoenix commented Apr 13, 2024

@illuhad Thank you for the idea about the location of acpp . Initially I was running acpp from the directory /AdaptiveCpp/bin as ./AdaptiveCpp/bin/acpp . But what actually worked is running acpp from directory AdaptiveCpp/build/install/bin as ./AdaptiveCpp/build/install/bin/acpp


pwd
/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/build/install/bin
(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro bin % ./acpp
acpp [AdaptiveCpp compilation driver], Copyright (C) 2018-2023 Aksel Alpay and the AdaptiveCpp project
  AdaptiveCpp version: 24.02.0+git.b61a1868.20240408.branch.develop
  Installation root: /Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/build/install
  Available runtime backends:
     librt-backend-omp.dylib
Usage: acpp <options>

Hello @chsasank as recommended I used the programs in the link and this is the output I received .

(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro bin % ./acpp /Users/adithyalbhat/github/adaptive_cpp/vector-add.cpp  
 /Users/adithyalbhat/github/adaptive_cpp/driver.c
acpp warning: No optimization flag was given, optimizations are disabled by default. Performance may be degraded. Compile with e.g. -O2/-O3 to enable optimizations.
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
ld: warning: dylib (/Users/adithyalbhat/github/adaptive_cpp/AdaptiveCpp/build/install/lib/libacpp-rt.dylib) was built for newer macOS version (13.1) than being linked (13.0)
(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro bin % ls
a.out           acpp            acpp-hcf-tool   acpp-info       syclcc          syclcc-clang
(ada_c_pp) adithyalbhat@Adithyas-MacBook-Pro bin % ./a.out 
sum of element of C is: 135.000000

seems like it worked .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants