8000
Skip to content

Conversation

@noelchalmers
Copy link
Contributor

Description

This PR does some clean up of the cmake build system to align more closely with OCCA's standard make build behaviors, as well as keep things like libraries, defines, includes, and flags private to the libocca target to avoid them bleeding out to other projects which include libocca as a dependency.

The new behaviors of the cmake build are:

  • The build by default searches for all supported backends. The user can explicitly disable a backend by adding a toggle to the cmake line, e.g. -DENABLE_CUDA=OFF
  • Examples and unit tests are not built by default. They can be built by adding -DENABLE_EXAMPLES=ON and -DENABLE_TESTS=ON
  • The occa cli binary is built by default, but can be disabled by -DENABLE_UTILITY=OFF. This is useful for GPU-less headnodes where invoking the CUDA/HIP/OpenCL runtime can errors in the default make system after running occa info
  • The occa info command is run after making the occa binary, emulating the GNU make system.
  • Much of the cmake files in cmake/ were removed since they were small. The functionality of finding different backends and adding library/include dependencies to the libocca target is now in the main CMakeLists.txt for compactness.

The majority of these changes in this PR are restricted only to OCCA's cmake files, save for two exceptions:

  • The MPI example had to be patched (was segfaulting)
  • The serial & CUDA kernel builds were explicitly assuming the lib/libocca.so and include/ folder were located at the same root OCCA_DIR. This is typically not true for cmake builds in folders like build/. Rather than linking the entire include/ folder into the cmake build folder, I've added an OCCA_SOURCE_DIR to the compiledDefines header for the cmake build. I'm open to other suggestions on how to fix that.

@codecov
Copy link
codecov bot commented Jun 3, 2020

Codecov Report

Merging #357 into master will decrease coverage by 0.24%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #357      +/-   ##
==========================================
- Coverage   76.07%   75.83%   -0.25%     
==========================================
  Files         246      241       -5     
  Lines       17973    18255     +282     
==========================================
+ Hits        13673    13843     +170     
- Misses       4300     4412     +112     
Impacted Files Coverage Δ
include/occa/tools/env.hpp 80.00% <ø> (ø)
src/modes/serial/device.cpp 91.93% <ø> (ø)
src/tools/env.cpp 87.35% <100.00%> (+0.60%) ⬆️
include/occa/tools/cli.tpp 0.00% <0.00%> (-95.66%) ⬇️
include/occa/lang/type/type.hpp 0.00% <0.00%> (-75.00%) ⬇️
include/occa/tools/json.tpp 26.19% <0.00%> (-73.81%) ⬇️
include/occa/io/output.tpp 0.00% <0.00%> (-50.00%) ⬇️
include/occa/lang/statement/statement.hpp 0.00% <0.00%> (-50.00%) ⬇️
include/occa/tools/vector.hpp 80.00% <0.00%> (-20.00%) ⬇️
include/occa/core/kernelArg.hpp 80.00% <0.00%> (-20.00%) ⬇️
... and 26 more

Copy link
Member
@dmed256 dmed256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for adding these changes!

I have 2 questions regarding the OCCA_SOURCE_DIR / OCCA_BUILD_DIR usage below

@dmed256 dmed256 added the feature Use this label to request a new feature! label Jun 4, 2020
if (OCCA_DIR.size() == 0) {
#ifdef USE_CMAKE
OCCA_DIR = OCCA_SOURCE_DIR;
#else
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmed256 The behavior here is different for the cmake build. We could add an OCCA_SOURCE_DIR to the compiledDefines for the GNU make system build to align the behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use an ifdef like you had before or is this always defined for cmake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely always defined fr the cmake build. But I suppose in theory you could use OCCA_SOURCE_DIR define in the other build as well in the case you wanted to move the lib and include locations for some reason. I'll revert back to the original way.

@dmed256
Copy link
Member
dmed256 commented Jun 5, 2020

Looks good, I'm ready to merge if we want to use USE_CMAKE vs OCCA_BUILD_DIR on the check. Thanks @noelchalmers !

@noelchalmers
Copy link
Contributor Author

Ready to go

@dmed256
Copy link
Member
dmed256 commented Jun 5, 2020

@noelchalmers Thanks for the PR + making the changes!

@dmed256 dmed256 merged commit a4473bb into libocca:master Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Use this label to request a new feature!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0