working with mpi compile on main, initialising MPI on main and calling mpi functions on library
This commit is contained in:
parent
f391a0873f
commit
812d360e24
@ -1,4 +1,4 @@
|
|||||||
@rem @echo off
|
@echo off
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
@rem I rely on environment variables here.
|
@rem I rely on environment variables here.
|
||||||
@ -22,7 +22,7 @@ set CudaLibPaths=-L"%CUDA_PATH%\lib\x64" -L"%CUDSS_PATH%\lib\12"
|
|||||||
|
|
||||||
set LibraryLinks=-lcudss -lcudart
|
set LibraryLinks=-lcudss -lcudart
|
||||||
|
|
||||||
nvcc -v -c -o build/%commLayerSource%.obj src/%commLayerSource%.cu ^
|
nvcc -c -o build/%commLayerSource%.obj src/%commLayerSource%.cu ^
|
||||||
-arch=%nvccArch% ^
|
-arch=%nvccArch% ^
|
||||||
%CudaIncludes% %OtherIncludes% %MPIIncludes% %CudaLibPaths% %MPILibPath% ^
|
%CudaIncludes% %OtherIncludes% %MPIIncludes% %CudaLibPaths% %MPILibPath% ^
|
||||||
%LibraryLinks% ^
|
%LibraryLinks% ^
|
||||||
@ -48,8 +48,8 @@ if %ERRORLEVEL% NEQ 0 (
|
|||||||
|
|
||||||
nvcc -o build/%mainSource% src/%mainSource%.cu ^
|
nvcc -o build/%mainSource% src/%mainSource%.cu ^
|
||||||
-arch=%nvccArch% ^
|
-arch=%nvccArch% ^
|
||||||
%CudaIncludes% %OtherIncludes% %CudaLibPaths% ^
|
%CudaIncludes% %OtherIncludes% %CudaLibPaths% %MPIIncludes% %MPILibPath% ^
|
||||||
-lcudss -lcudart ^
|
-lcudss -lcudart -lmsmpi ^
|
||||||
%IgnoreWarnings% ^
|
%IgnoreWarnings% ^
|
||||||
-Xcompiler %ExeXcompilerFlags%
|
-Xcompiler %ExeXcompilerFlags%
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
|
||||||
|
#include "cudss.h"
|
||||||
|
|
||||||
#define __CSCUDSS_EXPORT extern "C" __declspec(dllexport)
|
#define __CSCUDSS_EXPORT extern "C" __declspec(dllexport)
|
||||||
|
|
||||||
|
|
||||||
@ -18,10 +20,7 @@ __CSCUDSS_EXPORT int cudssCommSize(void *comm, int *size) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
__CSCUDSS_EXPORT int libraryMain() {
|
__CSCUDSS_EXPORT int libraryMain(void) {
|
||||||
|
|
||||||
MPI_Init(0,0);
|
|
||||||
std::cout << "HELLO LIBRARY" << std::endl;
|
|
||||||
|
|
||||||
int rank;
|
int rank;
|
||||||
int size;
|
int size;
|
||||||
@ -29,9 +28,8 @@ __CSCUDSS_EXPORT int libraryMain() {
|
|||||||
cudssCommRank(&Comm, &rank);
|
cudssCommRank(&Comm, &rank);
|
||||||
cudssCommSize(&Comm, &size);
|
cudssCommSize(&Comm, &size);
|
||||||
|
|
||||||
std::cout << "Rank: " << rank << ", size: " << size << std::endl;
|
std::cout << "Entered library for Rank: " << rank << ", size: " << size << std::endl;
|
||||||
|
|
||||||
MPI_Finalize();
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
47
src/main.cu
47
src/main.cu
@ -6,13 +6,17 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <mpi.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/* ============================================================================
|
/* ============================================================================
|
||||||
* Version Information
|
* Version Information
|
||||||
* ============================================================================ */
|
* ============================================================================ */
|
||||||
|
|
||||||
void printCudaVersion(void) {
|
void printCudaVersion(int rank) {
|
||||||
|
if(rank !=0) return;
|
||||||
|
|
||||||
int runtimeVersion = 0;
|
int runtimeVersion = 0;
|
||||||
int driverVersion = 0;
|
int driverVersion = 0;
|
||||||
|
|
||||||
@ -29,7 +33,9 @@ void printCudaVersion(void) {
|
|||||||
LOG("CUDA Driver Version: %d.%d", driverMajor, driverMinor);
|
LOG("CUDA Driver Version: %d.%d", driverMajor, driverMinor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printCudssVersion(void) {
|
void printCudssVersion(int rank) {
|
||||||
|
if(rank !=0) return;
|
||||||
|
|
||||||
int major = 0;
|
int major = 0;
|
||||||
int minor = 0;
|
int minor = 0;
|
||||||
int patch = 0;
|
int patch = 0;
|
||||||
@ -41,7 +47,9 @@ void printCudssVersion(void) {
|
|||||||
LOG("cuDSS Version: %d.%d.%d", major, minor, patch);
|
LOG("cuDSS Version: %d.%d.%d", major, minor, patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printDeviceInfo(void) {
|
void printDeviceInfo(int rank) {
|
||||||
|
if(rank !=0) return;
|
||||||
|
|
||||||
int deviceCount = 0;
|
int deviceCount = 0;
|
||||||
CUDA_CHECK(cudaGetDeviceCount(&deviceCount));
|
CUDA_CHECK(cudaGetDeviceCount(&deviceCount));
|
||||||
|
|
||||||
@ -67,13 +75,22 @@ void printDeviceInfo(void) {
|
|||||||
using libraryMain = int(*)();
|
using libraryMain = int(*)();
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
LOG("cuDSS Test Program");
|
|
||||||
LOG("==================");
|
MPI_Init(0,0);
|
||||||
|
int rank;
|
||||||
|
int size;
|
||||||
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||||
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||||
|
|
||||||
|
if(rank == 0) {
|
||||||
|
LOG("cuDSS Test Program");
|
||||||
|
LOG("==================");
|
||||||
|
}
|
||||||
|
|
||||||
/* Print version information */
|
/* Print version information */
|
||||||
printCudaVersion();
|
printCudaVersion(rank);
|
||||||
printCudssVersion();
|
printCudssVersion(rank);
|
||||||
printDeviceInfo();
|
printDeviceInfo(rank);
|
||||||
|
|
||||||
HMODULE hLib = LoadLibraryA("commlayer.dll");
|
HMODULE hLib = LoadLibraryA("commlayer.dll");
|
||||||
if (!hLib) {
|
if (!hLib) {
|
||||||
@ -92,12 +109,18 @@ int main(int argc, char **argv) {
|
|||||||
/* Initialize cuDSS */
|
/* Initialize cuDSS */
|
||||||
cudssHandle_t handle = NULL;
|
cudssHandle_t handle = NULL;
|
||||||
CUDSS_CHECK(cudssCreate(&handle));
|
CUDSS_CHECK(cudssCreate(&handle));
|
||||||
LOG("cuDSS handle created successfully");
|
if(rank == 0) {
|
||||||
|
LOG("cuDSS handle created successfully");
|
||||||
|
}
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
CUDSS_CHECK(cudssDestroy(handle));
|
CUDSS_CHECK(cudssDestroy(handle));
|
||||||
LOG("cuDSS handle destroyed");
|
if(rank == 0) {
|
||||||
|
LOG("cuDSS handle destroyed");
|
||||||
|
}
|
||||||
|
|
||||||
LOG("Done.");
|
MPI_Finalize();
|
||||||
|
if(rank == 0) {
|
||||||
|
LOG("Done.");
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user