Files
TheRock/rocm-systems/projects/rocm-core/rocm_version.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

86 lines
2.4 KiB
C++

//Copyright © Advanced Micro Devices, Inc., or its affiliates.
//SPDX-License-Identifier: MIT
#include "rocm_version.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define NULL_CHECK(ptr) if(!ptr) return VerIncorrectParameters;
#define CHECK_AND_REPORT_API_RESULT(val) do { \
if(VerSuccess != val) { \
const char *ErrStrings[VerErrorMAX]= { \
"VerSuccess", \
"VerIncorrectParameters", \
"VerMemoryAllocationFailed", \
"VerValuesNotDefined" \
}; \
fprintf(stderr, " API returned : %s \n", ErrStrings[val]); \
fflush(stderr); \
return val; \
} \
}while(0);
VerErrors getROCmVersion(unsigned int* Major, unsigned int* Minor, unsigned int* Patch) {
NULL_CHECK(Major)
NULL_CHECK(Minor)
NULL_CHECK(Patch)
*Major=ROCM_VERSION_MAJOR;
*Minor=ROCM_VERSION_MINOR;
*Patch=ROCM_VERSION_PATCH;
return VerSuccess;
}
static VerErrors getBuildInfo( char* InfoString, int length_of_the_buffer ) {
NULL_CHECK(InfoString);
#if defined(ROCM_BUILD_INFO)
if(length_of_the_buffer<=strlen(ROCM_BUILD_INFO)){
fprintf(stderr, "\n Error :: Buffer is less than adequate size required\n");
fflush(stderr);
return VerIncorrectParameters;
}
snprintf(InfoString, length_of_the_buffer, "%s", ROCM_BUILD_INFO);
return VerSuccess;
#else
return VerValuesNotDefined;
#endif //end definition checker
}
VerErrors printBuildInfo() {
int len_of_buffer_to_be_created = 0;
VerErrors apiret=VerSuccess;
#if defined(ROCM_BUILD_INFO)
len_of_buffer_to_be_created = 1 + strlen(ROCM_BUILD_INFO);//additional char for null termination
#else
return VerValuesNotDefined;
#endif //end definition checker
// len_of_buffer_to_be_created is now strlen(ROCM_BUILD_INFO) + 1
char* cstr=(char*) malloc(len_of_buffer_to_be_created);
if(cstr){
apiret=getBuildInfo(cstr,len_of_buffer_to_be_created);
if(VerSuccess != apiret) {
free(cstr);
}
CHECK_AND_REPORT_API_RESULT(apiret);
printf("\n Build Info of lib = [%s] \n",cstr);
//All good lets free
free(cstr);
return VerSuccess;
}
fprintf(stderr, "\n malloc failed for length [%d] \n",len_of_buffer_to_be_created);
fflush(stderr);
return VerMemoryAllocationFailed;
}