forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PaddlePaddle#24 from mthreads/support_dynload
Support dynload module for MUSA
- Loading branch information
Showing
27 changed files
with
895 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include "paddle/fluid/platform/dynload/mccl.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
#define DEFINE_WRAP(__name) DynLoad__##__name __name | ||
|
||
MCCL_RAND_ROUTINE_EACH(DEFINE_WRAP); | ||
|
||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
#pragma once | ||
|
||
#include <mccl.h> | ||
|
||
#include <mutex> // NOLINT | ||
|
||
#include "paddle/phi/backends/dynload/mccl.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
#define PLATFORM_DECLARE_DYNAMIC_LOAD_MCCL_WRAP(__name) \ | ||
using DynLoad__##__name = phi::dynload::DynLoad__##__name; \ | ||
extern DynLoad__##__name __name | ||
|
||
#define MCCL_RAND_ROUTINE_EACH(__macro) \ | ||
__macro(mcclCommInitAll); \ | ||
__macro(mcclGetUniqueId); \ | ||
__macro(mcclCommInitRank); \ | ||
__macro(mcclCommDestroy); \ | ||
__macro(mcclCommCount); \ | ||
__macro(mcclCommCuDevice); \ | ||
__macro(mcclCommUserRank); \ | ||
__macro(mcclAllReduce); \ | ||
__macro(mcclBcast); \ | ||
__macro(mcclAllGather); \ | ||
__macro(mcclGroupStart); \ | ||
__macro(mcclGroupEnd); \ | ||
__macro(mcclReduce); \ | ||
__macro(mcclReduceScatter); \ | ||
__macro(mcclGetErrorString); \ | ||
__macro(mcclBroadcast); \ | ||
__macro(mcclGetVersion); \ | ||
__macro(mcclSend); \ | ||
__macro(mcclRecv); \ | ||
__macro(mcclRedOpCreatePreMulSum); \ | ||
__macro(mcclRedOpDestroy); | ||
|
||
MCCL_RAND_ROUTINE_EACH(PLATFORM_DECLARE_DYNAMIC_LOAD_MCCL_WRAP) | ||
|
||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include "paddle/fluid/platform/dynload/mublas.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
#define DEFINE_WRAP(__name) DynLoad__##__name __name | ||
|
||
MUBLAS_BLAS_ROUTINE_EACH(DEFINE_WRAP); | ||
|
||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#pragma once | ||
|
||
#include <mublas.h> | ||
#include <musa.h> | ||
|
||
#include <mutex> // NOLINT | ||
#include <type_traits> | ||
|
||
#include "paddle/phi/backends/dynload/mublas.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
/** | ||
* The following macro definition can generate structs | ||
* (for each function) to dynamic load mublas routine | ||
* via operator overloading. | ||
* | ||
* note: default dynamic linked libs | ||
*/ | ||
#define PLATFORM_DECLARE_DYNAMIC_LOAD_MUBLAS_WRAP(__name) \ | ||
using DynLoad__##__name = phi::dynload::DynLoad__##__name; \ | ||
extern DynLoad__##__name __name | ||
|
||
#define MUBLAS_BLAS_ROUTINE_EACH(__macro) \ | ||
__macro(mublasSaxpy); \ | ||
__macro(mublasDaxpy); \ | ||
__macro(mublasCaxpy); \ | ||
__macro(mublasZaxpy); \ | ||
__macro(mublasSscal); \ | ||
__macro(mublasDscal); \ | ||
__macro(mublasScopy); \ | ||
__macro(mublasDcopy); \ | ||
__macro(mublasSgemv); \ | ||
__macro(mublasDgemv); \ | ||
__macro(mublasCgemv); \ | ||
__macro(mublasZgemv); \ | ||
__macro(mublasSgemm); \ | ||
__macro(mublasDgemm); \ | ||
__macro(mublasCgemm); \ | ||
__macro(mublasZgemm); \ | ||
__macro(mublasHgemm); \ | ||
__macro(mublasSgeam); \ | ||
__macro(mublasDgeam); \ | ||
__macro(mublasDtrsm); \ | ||
__macro(mublasCtrsm); \ | ||
__macro(mublasZtrsm); \ | ||
__macro(mublasCreate); \ | ||
__macro(mublasDestroy); \ | ||
__macro(mublasSetStream); \ | ||
__macro(mublasSetPointerMode); \ | ||
__macro(mublasGetPointerMode); \ | ||
__macro(mublasSgemmBatched); \ | ||
__macro(mublasDgemmBatched); \ | ||
__macro(mublasCgemmBatched); \ | ||
__macro(mublasZgemmBatched); | ||
|
||
MUBLAS_BLAS_ROUTINE_EACH(PLATFORM_DECLARE_DYNAMIC_LOAD_MUBLAS_WRAP) | ||
|
||
#undef PLATFORM_DECLARE_DYNAMIC_LOAD_MUBLAS_WRAP | ||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include "paddle/fluid/platform/dynload/murand.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
#define DEFINE_WRAP(__name) DynLoad__##__name __name | ||
|
||
MURAND_RAND_ROUTINE_EACH(DEFINE_WRAP); | ||
|
||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
#pragma once | ||
|
||
#include <murand.h> | ||
|
||
#include <mutex> // NOLINT | ||
|
||
#include "paddle/phi/backends/dynload/murand.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
#define PLATFORM_DECLARE_DYNAMIC_LOAD_MURAND_WRAP(__name) \ | ||
using DynLoad__##__name = phi::dynload::DynLoad__##__name; \ | ||
extern DynLoad__##__name __name | ||
|
||
#define MURAND_RAND_ROUTINE_EACH(__macro) \ | ||
__macro(murandCreateGenerator); \ | ||
__macro(murandSetStream); \ | ||
__macro(murandSetPseudoRandomGeneratorSeed); \ | ||
__macro(murandGenerateUniform); \ | ||
__macro(murandGenerateUniformDouble); \ | ||
__macro(murandGenerateNormal); \ | ||
__macro(murandDestroyGenerator); | ||
|
||
MURAND_RAND_ROUTINE_EACH(PLATFORM_DECLARE_DYNAMIC_LOAD_MURAND_WRAP); | ||
|
||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include "paddle/fluid/platform/dynload/musparse.h" | ||
|
||
namespace paddle { | ||
namespace platform { | ||
namespace dynload { | ||
|
||
#define DEFINE_WRAP(__name) DynLoad__##__name __name | ||
|
||
#ifdef MUSPARSE_ROUTINE_EACH | ||
MUSPARSE_ROUTINE_EACH(DEFINE_WRAP); | ||
#endif | ||
|
||
} // namespace dynload | ||
} // namespace platform | ||
} // namespace paddle |
Oops, something went wrong.