Change compiler for certain files in the project

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Change compiler for certain files in the project

Aaron Boxer
Hello,

I have a cmake project on linux, and I would like to change the compiler
for certain files from g++ to  another, llvm-based compiler called hcc.
(hcc is AMDs HIP compiler for GPGPU)


Is there a way of doing this in my cmake file ?

Thanks,
Aaron

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Change compiler for certain files in the project

CMake mailing list

> On Oct 28, 2017, at 9:50 AM, Aaron Boxer <[hidden email]> wrote:
>
> Hello,
>
> I have a cmake project on linux, and I would like to change the compiler
> for certain files from g++ to  another, llvm-based compiler called hcc.
> (hcc is AMDs HIP compiler for GPGPU)
>
>
> Is there a way of doing this in my cmake file ?

There isn’t a simple way to do that. The FindCUDA and FindHIP cmake modules do that, but its not at all easy to follow, and brings its own set of issues.

Of course, why do you need to use g++ to compile host code? Being clang-based hcc should be able to compile any g++ code. So you can just use hcc as the compiler for everything and then link with the `hccrt` cmake target(provided by `find_package(hcc)`) which will enable GPU compiling when you want to compile code for the device.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Change compiler for certain files in the project

Thompson, KT
Aaron,

Another way to do this is by using external project, but it is very 'hacky'.  A good place to look for examples is CMake's own AddCMakeFortranSubdirectory features.  This is designed to allow Fortran to be compiled with MinGW when the main project uses a VisualStudio generator. The same general logic would work to allow you to process a subdirectory with a different toolchain.

-kt

-----Original Message-----
From: CMake [mailto:[hidden email]] On Behalf Of P F via CMake
Sent: Saturday, October 28, 2017 9:22 AM
To: Aaron Boxer <[hidden email]>
Cc: cmake <[hidden email]>
Subject: Re: [CMake] Change compiler for certain files in the project


> On Oct 28, 2017, at 9:50 AM, Aaron Boxer <[hidden email]> wrote:
>
> Hello,
>
> I have a cmake project on linux, and I would like to change the compiler
> for certain files from g++ to  another, llvm-based compiler called hcc.
> (hcc is AMDs HIP compiler for GPGPU)
>
>
> Is there a way of doing this in my cmake file ?

There isn’t a simple way to do that. The FindCUDA and FindHIP cmake modules do that, but its not at all easy to follow, and brings its own set of issues.

Of course, why do you need to use g++ to compile host code? Being clang-based hcc should be able to compile any g++ code. So you can just use hcc as the compiler for everything and then link with the `hccrt` cmake target(provided by `find_package(hcc)`) which will enable GPU compiling when you want to compile code for the device.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Change compiler for certain files in the project

Aaron Boxer
In reply to this post by CMake mailing list


On Sat, Oct 28, 2017 at 11:22 AM, P F <[hidden email]> wrote:

> On Oct 28, 2017, at 9:50 AM, Aaron Boxer <[hidden email]> wrote:
>
> Hello,
>
> I have a cmake project on linux, and I would like to change the compiler
> for certain files from g++ to  another, llvm-based compiler called hcc.
> (hcc is AMDs HIP compiler for GPGPU)
>
>
> Is there a way of doing this in my cmake file ?

There isn’t a simple way to do that. The FindCUDA and FindHIP cmake modules do that, but its not at all easy to follow, and brings its own set of issues.

Of course, why do you need to use g++ to compile host code? Being clang-based hcc should be able to compile any g++ code. So you can just use hcc as the compiler for everything and then link with the `hccrt` cmake target(provided by `find_package(hcc)`) which will enable GPU compiling when you want to compile code for the device.

Yes, I just might do that. I didn't realize there was a find_package for hcc.  So, how would I set hcc as the compiler for everything ?



 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Change compiler for certain files in the project

Aaron Boxer
In reply to this post by Thompson, KT


On Mon, Oct 30, 2017 at 11:18 AM, Thompson, KT <[hidden email]> wrote:
Aaron,

Another way to do this is by using external project, but it is very 'hacky'.  A good place to look for examples is CMake's own AddCMakeFortranSubdirectory features.  This is designed to allow Fortran to be compiled with MinGW when the main project uses a VisualStudio generator. The same general logic would work to allow you to process a subdirectory with a different toolchain.

Thanks, I will look into this as one option.
Aaron


-----Original Message-----
From: CMake [mailto:[hidden email]] On Behalf Of P F via CMake
Sent: Saturday, October 28, 2017 9:22 AM
To: Aaron Boxer <[hidden email]>
Cc: cmake <[hidden email]>
Subject: Re: [CMake] Change compiler for certain files in the project


> On Oct 28, 2017, at 9:50 AM, Aaron Boxer <[hidden email]> wrote:
>
> Hello,
>
> I have a cmake project on linux, and I would like to change the compiler
> for certain files from g++ to  another, llvm-based compiler called hcc.
> (hcc is AMDs HIP compiler for GPGPU)
>
>
> Is there a way of doing this in my cmake file ?

There isn’t a simple way to do that. The FindCUDA and FindHIP cmake modules do that, but its not at all easy to follow, and brings its own set of issues.

Of course, why do you need to use g++ to compile host code? Being clang-based hcc should be able to compile any g++ code. So you can just use hcc as the compiler for everything and then link with the `hccrt` cmake target(provided by `find_package(hcc)`) which will enable GPU compiling when you want to compile code for the device.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Change compiler for certain files in the project

CMake mailing list
In reply to this post by Aaron Boxer
On Mon, 2017-10-30 at 21:34 -0400, Aaron Boxer wrote:

>
>
> On Sat, Oct 28, 2017 at 11:22 AM, P F <[hidden email]> wrote:
> >
> > > On Oct 28, 2017, at 9:50 AM, Aaron Boxer <[hidden email]> wrote:
> > >
> > > Hello,
> > >
> > > I have a cmake project on linux, and I would like to change the compiler
> > > for certain files from g++ to  another, llvm-based compiler called hcc.
> > > (hcc is AMDs HIP compiler for GPGPU)
> > >
> > >
> > > Is there a way of doing this in my cmake file ?
> >
> > There isn’t a simple way to do that. The FindCUDA and FindHIP cmake
> > modules do that, but its not at all easy to follow, and brings its own set
> > of issues.
> >
> > Of course, why do you need to use g++ to compile host code? Being clang-
> > based hcc should be able to compile any g++ code. So you can just use hcc
> > as the compiler for everything and then link with the `hccrt` cmake
> > target(provided by `find_package(hcc)`) which will enable GPU compiling
> > when you want to compile code for the device.
> Yes, I just might do that. I didn't realize there was a find_package for
> hcc. 

Yes there is. If you are using AMD's repo from repo.radeon.com, then you will
need to call it with: `find_package(hcc PATHS /opt/rocm/hcc)` as its not
installed in the standard /usr location.

>  So, how would I set hcc as the compiler for everything ?

I usually set it like this when I first run cmake:

CXX=hcc cmake ..


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake