Skip to content

CPU and GPU identification data#6

Merged
Adrien-Tab merged 58 commits into
mainfrom
cpu-gpu-arch
May 11, 2026
Merged

CPU and GPU identification data#6
Adrien-Tab merged 58 commits into
mainfrom
cpu-gpu-arch

Conversation

@Adrien-Tab

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
@Adrien-Tab Adrien-Tab changed the title Initial version for CPU + OS for Unix CPU and GPU identification data Mar 4, 2026
@Adrien-Tab Adrien-Tab self-assigned this Mar 4, 2026
Comment thread archInfo/src/cexa_ArchInfo.cpp Outdated
Comment thread archInfo/src/cexa_ArchInfo.cpp Outdated
Comment thread archInfo/unit_test/TestArchInfo.cpp Outdated
Comment thread archInfo/src/cexa_ArchInfo.hpp Outdated
Comment thread archInfo/src/cexa_ArchInfo.hpp Outdated
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
@Adrien-Tab Adrien-Tab marked this pull request as draft March 5, 2026 14:45
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
@Adrien-Tab

Adrien-Tab commented Mar 6, 2026

Copy link
Copy Markdown
Member Author

@tretre91 tretre91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I added all the missing functionality, namely:

  • windows support
  • macos support
  • sycl support
  • openacc support
  • getting the cuda driver version

I also added a basic CI which runs the tests, installs the library and tries to build a cmake project using it

Comment thread archInfo/src/cexa_ArchInfo.hpp Outdated
Comment thread .github/workflows/arch-info.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I kept the tests as is (just removed the prints in the main function), we might want to do something more specific than checking if the string is non-empty. For example checking that if there is no GPU backend, the GPU functions return "N/A".

Comment on lines +90 to +99
std::string get_gpu_driver_version() {
if (NVML_SUCCESS != nvmlInit_v2()) {
std::cerr << "get_gpu_driver_version: failed to initialize nvml\n";
return "ERROR";
}
char buffer[NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE];
nvmlSystemGetDriverVersion(buffer, NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE);
nvmlShutdown();
return buffer;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

According to the documentation, nvml can be initialized/shutdown multiple times (they do a noop if the library was already initialized) so there shouldn't be any conflicts with a user code using nvml and our library.

For the error checking, nvmlSystemGetDriverVersion and nvmlShutdown cannot fail in our use case (nvml is initialized, buffer is not NULL, buffer size is sufficient), that's why I only check for errors in the call to nvmlInit_v2.
Also, I don't know if we should keep the std::cerr with the error message, as it is the only place in the code where we actually print an error message to the console.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am in favor of removing the cerr and simply returning "N/A".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would still check the return value of nvmlSystemGetDriverVersion. I trust you that with current specification we do not expect it to fail but:

  • we can't guarantee that new condition for failure won't appear in the future
  • we have no guarantee that the implementation contains no bug and doesn't throw error in other cases too

@tretre91 tretre91 self-assigned this Mar 11, 2026
@tretre91 tretre91 marked this pull request as ready for review March 11, 2026 23:35
@tretre91 tretre91 marked this pull request as draft March 12, 2026 10:57
Comment thread archInfo/src/cexa_unixArchInfo.hpp Outdated
@Adrien-Tab Adrien-Tab requested a review from PaulGannay March 13, 2026 22:27
Comment on lines +90 to +99
std::string get_gpu_driver_version() {
if (NVML_SUCCESS != nvmlInit_v2()) {
std::cerr << "get_gpu_driver_version: failed to initialize nvml\n";
return "ERROR";
}
char buffer[NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE];
nvmlSystemGetDriverVersion(buffer, NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE);
nvmlShutdown();
return buffer;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would still check the return value of nvmlSystemGetDriverVersion. I trust you that with current specification we do not expect it to fail but:

  • we can't guarantee that new condition for failure won't appear in the future
  • we have no guarantee that the implementation contains no bug and doesn't throw error in other cases too

Comment on lines +31 to +43
std::string get_gpu_name() {
hipDeviceProp_t device_prop;
int device_id = Kokkos::device_id();
KOKKOS_IMPL_HIP_SAFE_CALL(hipGetDeviceProperties(&device_prop, device_id));
return std::string{device_prop.name};
}

std::string get_gpu_arch() {
hipDeviceProp_t device_prop;
int device_id = Kokkos::device_id();
KOKKOS_IMPL_HIP_SAFE_CALL(hipGetDeviceProperties(&device_prop, device_id));
return std::string{device_prop.gcnArchName};
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would consider using a macro here to avoid code duplication (this is only a suggestion).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's fine since it's only used twice

Comment thread archInfo/src/cexa_ArchInfo.cpp Outdated
Comment thread archInfo/src/cexa_macosArchInfo.hpp Outdated
Comment thread archInfo/src/cexa_unixArchInfo.hpp Outdated

@pzehner pzehner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some remarks about the CMake files.

Comment thread archInfo/CMakeLists.txt Outdated
Comment thread archInfo/cmake/CexaArchInfoConfig.cmake.in
Adrien-Tab and others added 5 commits April 2, 2026 11:08
Co-authored-by: PaulGannay <paul.gannay@cea.fr>
Co-authored-by: Paul Zehner <paul.zehner@alumni.enseeiht.fr>
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
@tretre91 tretre91 self-requested a review April 15, 2026 09:10
Comment on lines +31 to +43
std::string get_gpu_name() {
hipDeviceProp_t device_prop;
int device_id = Kokkos::device_id();
KOKKOS_IMPL_HIP_SAFE_CALL(hipGetDeviceProperties(&device_prop, device_id));
return std::string{device_prop.name};
}

std::string get_gpu_arch() {
hipDeviceProp_t device_prop;
int device_id = Kokkos::device_id();
KOKKOS_IMPL_HIP_SAFE_CALL(hipGetDeviceProperties(&device_prop, device_id));
return std::string{device_prop.gcnArchName};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's fine since it's only used twice

Comment thread archInfo/src/cexa_ArchInfo.hpp Outdated
Comment thread archInfo/src/cexa_macosArchInfo.hpp Outdated
Adrien-Tab added 3 commits May 5, 2026 14:21
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
Signed-off-by: Adrien Taberner <adrien.taberner@cea.fr>
@Adrien-Tab Adrien-Tab merged commit ab346c3 into main May 11, 2026
6 checks passed
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.

4 participants