Enhance ROCM-Core for Windows (#1467)
* Enhance Code for support for Windows cpp build * Updated ROCM-Core README build steps * File copyright Headers Updated
This commit is contained in:
committad av
GitHub
förälder
4f590499c6
incheckning
285061f05b
@@ -1,28 +1,5 @@
|
||||
################################################################################
|
||||
##
|
||||
## MIT License
|
||||
##
|
||||
## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved.
|
||||
##
|
||||
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
## of this software and associated documentation files (the "Software"), to deal
|
||||
## in the Software without restriction, including without limitation the rights
|
||||
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
## copies of the Software, and to permit persons to whom the Software is
|
||||
## furnished to do so, subject to the following conditions:
|
||||
##
|
||||
## The above copyright notice and this permission notice shall be included in all
|
||||
## copies or substantial portions of the Software.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
## SOFTWARE.
|
||||
##
|
||||
################################################################################
|
||||
##Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
##SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required( VERSION 3.16 )
|
||||
set( CORE_TARGET "rocm-core" )
|
||||
|
||||
@@ -14,7 +14,7 @@ module load rocm/x.y or
|
||||
module load rocm
|
||||
```
|
||||
|
||||
You can find sources and binaries in our [GitHub repository](https://github.com/ROCm/rocm-core).
|
||||
You can find sources and binaries in our [GitHub repository](https://github.com/ROCm/rocm-systems).
|
||||
|
||||
> [!NOTE]
|
||||
> As with all ROCm projects, the documentation is open source. For more information, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html).
|
||||
@@ -45,13 +45,13 @@ You can build ROCM-CORE form source
|
||||
First, get the sources from repository.
|
||||
|
||||
```shell
|
||||
git clone https://github.com/ROCm/rocm-core.git
|
||||
git clone https://github.com/ROCm/rocm-systems.git
|
||||
```
|
||||
|
||||
Go to Root Directory, create a build directory:
|
||||
|
||||
```shell
|
||||
cd rocm-core; mkdir build; cd build
|
||||
cd projects/rocm-core; mkdir build; cd build
|
||||
```
|
||||
|
||||
Next, configure CMake. Invoke cmake with the following variables define as deemed fit
|
||||
|
||||
@@ -1,46 +1,32 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2017 - 2024 Advanced Micro Devices, Inc. All rights Reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
//SPDX-License-Identifier: MIT
|
||||
|
||||
#include <cstring> /* String Operations */
|
||||
#include <cstdlib> /* Dynamic Memory Mgmt */
|
||||
#include <cstdio> /* FILENAME_MAX */
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
#include <climits> /* PATH_MAX */
|
||||
#include <link.h> /* ELF Dynamic Linking DS */
|
||||
#include <dlfcn.h> /* Dynamic linker Operations */
|
||||
#define RC_PATH_MAX (PATH_MAX+1)
|
||||
#else
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <windows.h> /* MAX_PATH */
|
||||
#define PATH_MAX MAX_PATH
|
||||
#elif !defined(PATH_MAX)
|
||||
#define PATH_MAX FILENAME_MAX
|
||||
#endif
|
||||
#define RC_PATH_MAX ((PATH_MAX > 1024 && FILENAME_MAX > 1024 ? 1024 : (PATH_MAX < FILENAME_MAX ? PATH_MAX : FILENAME_MAX))+1)
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h> /* PATH_MAX */
|
||||
#include <stdio.h>
|
||||
#include <link.h>
|
||||
#include <dlfcn.h>
|
||||
#include "rocm_getpath.h"
|
||||
|
||||
/* Macro for NULL CHECK */
|
||||
#define NULL_CHECK(ptr) if(!ptr) return PathIncorrecPararmeters;
|
||||
|
||||
|
||||
/* Target Library Install Dir */
|
||||
#define TARGET_LIB_INSTALL_DIR TARGET_LIBRARY_INSTALL_DIR
|
||||
|
||||
/* Target Library Name Buf Size */
|
||||
#define LIBRARY_FILENAME_BUFSZ (PATH_MAX+1)
|
||||
|
||||
/* Internal Function to get Base Path - Ref from Icarus Logic*/
|
||||
static int getROCmBase(char *buf);
|
||||
|
||||
@@ -66,8 +52,8 @@ PathErrors_t getROCmInstallPath( char** InstallPath, unsigned int *InstallPathLe
|
||||
char *bufPtr = (char *)NULL;
|
||||
unsigned int bufSz = 0;
|
||||
|
||||
bufPtr = (char *)malloc( LIBRARY_FILENAME_BUFSZ * sizeof(char) );
|
||||
memset( bufPtr, 0, LIBRARY_FILENAME_BUFSZ );
|
||||
bufPtr = (char *)malloc( RC_PATH_MAX * sizeof(char) );
|
||||
memset( bufPtr, 0, RC_PATH_MAX );
|
||||
*InstallPathLen = 0;
|
||||
*InstallPath = NULL;
|
||||
|
||||
@@ -96,7 +82,7 @@ static int getROCmBase(char *buf)
|
||||
{
|
||||
int len=0;
|
||||
char *envStr=NULL;
|
||||
char libFileName[LIBRARY_FILENAME_BUFSZ];
|
||||
char libFileName[RC_PATH_MAX];
|
||||
char *end=NULL;
|
||||
|
||||
// Check Environment Variable is set for ROCM
|
||||
@@ -109,7 +95,7 @@ static int getROCmBase(char *buf)
|
||||
/* Already has at least one terminating */
|
||||
len--;
|
||||
}
|
||||
if (len > PATH_MAX-1 ) {
|
||||
if (len > RC_PATH_MAX-1 ) {
|
||||
return PathValuesTooLong;
|
||||
}
|
||||
strncpy(buf, envStr, len);
|
||||
@@ -121,45 +107,53 @@ static int getROCmBase(char *buf)
|
||||
}
|
||||
}
|
||||
|
||||
// If Environment Variable is not set
|
||||
// use dl APIs to get target lib path
|
||||
// and get rocm base install path using the lib Path.
|
||||
#if BUILD_SHARED_LIBS
|
||||
sprintf(libFileName, "lib%s.so", TARGET_LIBRARY_NAME);
|
||||
void *handle=dlopen(libFileName,RTLD_NOW);
|
||||
if (!handle){
|
||||
/* We can't find the library */
|
||||
return PathLinuxRuntimeErrors;
|
||||
}
|
||||
/* Variable to hold the return value from dlinfo */
|
||||
struct link_map *map = (struct link_map*)NULL;
|
||||
/* Query the runtime linker */
|
||||
dlinfo(handle,RTLD_DI_LINKMAP,&map);
|
||||
if (map ->l_name && realpath(map ->l_name,buf)) {
|
||||
/* Get Library Directory Path */
|
||||
char *end = strrchr(buf, '/');
|
||||
if (end && end > buf) {
|
||||
*end = '\0';
|
||||
/* If Environment Variable is not set
|
||||
* use platform-specific APIs to get target lib path
|
||||
* and get rocm base install path using the lib Path. */
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
/* Limited support for Windows:
|
||||
* getROCmBase() Needs ROCM_PATH environment variable set on Windows. */
|
||||
return PathWindowsNotSet;
|
||||
#else
|
||||
#if BUILD_SHARED_LIBS
|
||||
sprintf(libFileName, "lib%s.so", TARGET_LIBRARY_NAME);
|
||||
void *handle=dlopen(libFileName,RTLD_NOW);
|
||||
if (!handle){
|
||||
/* We can't find the library */
|
||||
return PathLinuxRuntimeErrors;
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* If l_name is NULL or realpath() failed
|
||||
* Close handle before return error */
|
||||
/* Variable to hold the return value from dlinfo */
|
||||
struct link_map *map = (struct link_map*)NULL;
|
||||
/* Query the runtime linker */
|
||||
dlinfo(handle,RTLD_DI_LINKMAP,&map);
|
||||
if (map ->l_name && realpath(map ->l_name,buf)) {
|
||||
/* Get Library Directory Path */
|
||||
char *end = strrchr(buf, '/');
|
||||
if (end && end > buf) {
|
||||
*end = '\0';
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* If l_name is NULL or realpath() failed
|
||||
* Close handle before return error */
|
||||
dlclose(handle);
|
||||
return PathLinuxRuntimeErrors;
|
||||
}
|
||||
|
||||
dlclose(handle);
|
||||
/* find the start of substring TARGET_LIB_INSTALL_DIR
|
||||
* To strip down Path up to Parent Directory of TARGET_LIB_INSTALL_DIR. */
|
||||
end=strstr(buf, TARGET_LIB_INSTALL_DIR);
|
||||
if( NULL == end ){
|
||||
/* We can't find the library install directory*/
|
||||
return PathLinuxRuntimeErrors;
|
||||
}
|
||||
*end = '\0';
|
||||
#else
|
||||
// BUILD_SHARED_LIBS not defined
|
||||
return PathLinuxRuntimeErrors;
|
||||
}
|
||||
|
||||
dlclose(handle);
|
||||
/* find the start of substring TARGET_LIB_INSTALL_DIR
|
||||
* To strip down Path up to Parent Directory of TARGET_LIB_INSTALL_DIR. */
|
||||
end=strstr(buf, TARGET_LIB_INSTALL_DIR);
|
||||
if( NULL == end ){
|
||||
/* We can't find the library install directory*/
|
||||
return PathLinuxRuntimeErrors;
|
||||
}
|
||||
*end = '\0';
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Length of Path String up to Parent Directoy (ROCm Base Path)
|
||||
* with trailing '/'.*/
|
||||
len = strlen(buf);
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////
|
||||
//// MIT License
|
||||
////
|
||||
//// Copyright (c) 2017 - 2024 Advanced Micro Devices, Inc. All rights Reserved.
|
||||
////
|
||||
//// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//// of this software and associated documentation files (the "Software"), to deal
|
||||
//// in the Software without restriction, including without limitation the rights
|
||||
//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//// copies of the Software, and to permit persons to whom the Software is
|
||||
//// furnished to do so, subject to the following conditions:
|
||||
////
|
||||
//// The above copyright notice and this permission notice shall be included in all
|
||||
//// copies or substantial portions of the Software.
|
||||
////
|
||||
//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
//SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef _ROCM_GETPATH_H_
|
||||
#define _ROCM_GETPATH_H_
|
||||
@@ -32,7 +9,13 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define LIB_API_PUBLIC __attribute__ ((visibility ("default")))
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
|
||||
#define LIB_API_PUBLIC __declspec(dllexport)
|
||||
#define ATTRIBUTE_NON_NULL
|
||||
#else
|
||||
#define LIB_API_PUBLIC __attribute__((visibility("default")))
|
||||
#define ATTRIBUTE_NON_NULL __attribute__((nonnull))
|
||||
#endif
|
||||
|
||||
/* Get Library Target Build Type */
|
||||
#cmakedefine01 BUILD_SHARED_LIBS
|
||||
@@ -40,6 +23,7 @@ extern "C" {
|
||||
/* Return Status Flag Definitions*/
|
||||
typedef enum {
|
||||
PathSuccess=0,
|
||||
PathWindowsNotSet = -993,
|
||||
PathIncorrecPararmeters = -994,
|
||||
PathValuesNotDefined = -995,
|
||||
PathValuesTooLong = -996,
|
||||
@@ -62,7 +46,7 @@ typedef enum {
|
||||
// free(installPath); //caller must free allocated memory after usage.
|
||||
// ...
|
||||
// }
|
||||
LIB_API_PUBLIC PathErrors_t getROCmInstallPath(char **InstallPath, unsigned int *InstallPathLen) __attribute__((nonnull)) ;
|
||||
LIB_API_PUBLIC PathErrors_t getROCmInstallPath(char **InstallPath, unsigned int *InstallPathLen) ATTRIBUTE_NON_NULL;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end extern "C" block
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
//SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef _ROCM_VERSION_H_
|
||||
#define _ROCM_VERSION_H_
|
||||
@@ -33,8 +10,13 @@ extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#define LIB_API_PUBLIC __attribute__ ((visibility ("default")))
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define LIB_API_PUBLIC __declspec(dllexport)
|
||||
#define ATTRIBUTE_NON_NULL
|
||||
#else
|
||||
#define LIB_API_PUBLIC __attribute__((visibility("default")))
|
||||
#define ATTRIBUTE_NON_NULL __attribute__((nonnull))
|
||||
#endif
|
||||
|
||||
#define ROCM_VERSION_MAJOR @VERSION_MAJOR@
|
||||
#define ROCM_VERSION_MINOR @VERSION_MINOR@
|
||||
@@ -52,8 +34,8 @@ typedef enum {
|
||||
|
||||
|
||||
// API for getting the version
|
||||
// Return val : VerErrors : API execution status. The parameters are valid only when the exetution status is SUCCESS==0
|
||||
LIB_API_PUBLIC VerErrors getROCmVersion(unsigned int* Major, unsigned int* Minor, unsigned int* Patch) __attribute__((nonnull)) ;
|
||||
// Return val : VerErros : API execution status. The parameters are valid only when the execution status is SUCCESS==0
|
||||
LIB_API_PUBLIC VerErrors getROCmVersion(unsigned int* Major, unsigned int* Minor, unsigned int* Patch) ATTRIBUTE_NON_NULL ;
|
||||
// Usage :
|
||||
// int mj=0,mn=0,p=0,ret=0;
|
||||
// ret=getROCMVersion(&mj,&mn,&p);
|
||||
|
||||
@@ -1,29 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
################################################################################
|
||||
##
|
||||
## MIT License
|
||||
##
|
||||
## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved.
|
||||
##
|
||||
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
## of this software and associated documentation files (the "Software"), to deal
|
||||
## in the Software without restriction, including without limitation the rights
|
||||
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
## copies of the Software, and to permit persons to whom the Software is
|
||||
## furnished to do so, subject to the following conditions:
|
||||
##
|
||||
## The above copyright notice and this permission notice shall be included in all
|
||||
## copies or substantial portions of the Software.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
## SOFTWARE.
|
||||
##
|
||||
################################################################################
|
||||
|
||||
##Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
##SPDX-License-Identifier: MIT
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
################################################################################
|
||||
##
|
||||
## MIT License
|
||||
##
|
||||
## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved.
|
||||
##
|
||||
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
## of this software and associated documentation files (the "Software"), to deal
|
||||
## in the Software without restriction, including without limitation the rights
|
||||
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
## copies of the Software, and to permit persons to whom the Software is
|
||||
## furnished to do so, subject to the following conditions:
|
||||
##
|
||||
## The above copyright notice and this permission notice shall be included in all
|
||||
## copies or substantial portions of the Software.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
## SOFTWARE.
|
||||
##
|
||||
################################################################################
|
||||
##Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
||||
##SPDX-License-Identifier: MIT
|
||||
|
||||
## Parses the VERSION_STRING variable and places
|
||||
## the first, second and third number values in
|
||||
|
||||
Referens i nytt ärende
Block a user