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

Add missing includes #775

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

thilinarmtb
Copy link
Collaborator

@thilinarmtb thilinarmtb commented Nov 20, 2024

Description

Currently, when we run OCCA tests, they use the automatically generated *_codegen
files from the build directory. This is because, we do the following two things:

  • -I${OCCA_INSTALL_DIR} is added to the compile command in device::buildKernel()
    methods.
  • If OCCA_INSTALL_DIR is not defined, it defaults to OCCA_BUILD_DIR.

Since we never set OCCA_INSTALL_DIR, we have always been using *_codegen files from
the build directory. When I tried running the tests by setting OCCA_INSTALL_DIR, I get
compilation errors since we don't have the required *_codegen files at the correct places
in the install directory. This PR fixes this issue.

PS: I only tested the CMake build for now. May need fixes for the GNU Make build.

Todo

  • Run the GitHub CI tests with OCCA_INSTALL_DIR set.

@thilinarmtb
Copy link
Collaborator Author

thilinarmtb commented Feb 26, 2025

I tested this on both Polaris and Aurora with the following changes.

On Aurora:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51597010..4efe545b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,7 @@ option(OCCA_ENABLE_METAL  "Build with Metal if available" ON)
 option(OCCA_ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON)

 option(OCCA_ENABLE_TESTS    "Build tests"               OFF)
-option(OCCA_ENABLE_EXAMPLES "Build simple examples"     OFF)
+option(OCCA_ENABLE_EXAMPLES "Build simple examples"     ON)
 option(OCCA_ENABLE_FORTRAN  "Enable Fortran interface"  OFF)
 option(OCCA_CLANG_BASED_TRANSPILER      "Build with occa-transpiler dependecy" OFF)

diff --git a/examples/cpp/01_add_vectors/main.cpp b/examples/cpp/01_add_vectors/main.cpp
index 66e449bb..bf46c38c 100644
--- a/examples/cpp/01_add_vectors/main.cpp
+++ b/examples/cpp/01_add_vectors/main.cpp
@@ -31,6 +31,11 @@ int main(int argc, const char **argv) {

   //---[ Device Setup ]-------------------------------------
   device.setup((std::string) args["options/device"]);
+  device.setup({
+    {"mode"     , "DPCPP"},
+    {"platform_id", 0},
+    {"device_id", 0},
+  });

   /*
    * Examples of setting up a device in other backend modes:

On Polaris:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51597010..4efe545b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,7 @@ option(OCCA_ENABLE_METAL  "Build with Metal if available" ON)
 option(OCCA_ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON)

 option(OCCA_ENABLE_TESTS    "Build tests"               OFF)
-option(OCCA_ENABLE_EXAMPLES "Build simple examples"     OFF)
+option(OCCA_ENABLE_EXAMPLES "Build simple examples"     ON)
 option(OCCA_ENABLE_FORTRAN  "Enable Fortran interface"  OFF)
 option(OCCA_CLANG_BASED_TRANSPILER      "Build with occa-transpiler dependecy" OFF)

diff --git a/examples/cpp/01_add_vectors/main.cpp b/examples/cpp/01_add_vectors/main.cpp
index 66e449bb..b37ff8d8 100644
--- a/examples/cpp/01_add_vectors/main.cpp
+++ b/examples/cpp/01_add_vectors/main.cpp
@@ -31,6 +31,10 @@ int main(int argc, const char **argv) {

   //---[ Device Setup ]-------------------------------------
   device.setup((std::string) args["options/device"]);
+  device.setup({
+    {"mode"     , "CUDA"},
+    {"device_id", 0},
+  });

Then run the 01_add_vectors example using the following environment:

export OCCA_INSTALL_DIR=<occa_install_dir>
./examples_cpp_add_vectors

The development branch fails in this case and this PR works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant