Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get compiling for CUDART 12000 #1

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/cublas/backend/CublasHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#include <string>
#include <memory>

#include <cublas.h>
// Deprecated to include both in 2.1.15.cuBLAS: Release 12.0
// #include <cublas.h>
#include "cublas_v2.h"

#include <gvirtus/backend/Handler.h>
Expand Down
16 changes: 8 additions & 8 deletions plugins/cublas/backend/CublasHandler_Level2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ CUBLAS_ROUTINE_HANDLER(Ssbmv_v2){
float * y = in->GetFromMarshal<float*>();
int incy = in->Get<int>();

cublasStatus cs = cublasSsbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
cublasStatus_t cs = cublasSsbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -874,7 +874,7 @@ CUBLAS_ROUTINE_HANDLER(Dsbmv_v2){
double * y = in->GetFromMarshal<double*>();
int incy = in->Get<int>();

cublasStatus cs = cublasDsbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
cublasStatus_t cs = cublasDsbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -896,7 +896,7 @@ CUBLAS_ROUTINE_HANDLER(Chbmv_v2){
cuComplex * y = in->GetFromMarshal<cuComplex*>();
int incy = in->Get<int>();

cublasStatus cs = cublasChbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
cublasStatus_t cs = cublasChbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -918,7 +918,7 @@ CUBLAS_ROUTINE_HANDLER(Zhbmv_v2){
cuDoubleComplex * y = in->GetFromMarshal<cuDoubleComplex*>();
int incy = in->Get<int>();

cublasStatus cs = cublasZhbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
cublasStatus_t cs = cublasZhbmv_v2(handle,uplo,n,k,alpha,A,lda,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -938,7 +938,7 @@ CUBLAS_ROUTINE_HANDLER(Sspmv_v2){
float * y = in->GetFromMarshal<float*>();
int incy = in->Get<int>();

cublasStatus cs = cublasSspmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
cublasStatus_t cs = cublasSspmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -958,7 +958,7 @@ CUBLAS_ROUTINE_HANDLER(Dspmv_v2){
double * y = in->GetFromMarshal<double*>();
int incy = in->Get<int>();

cublasStatus cs = cublasDspmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
cublasStatus_t cs = cublasDspmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -978,7 +978,7 @@ CUBLAS_ROUTINE_HANDLER(Chpmv_v2){
cuComplex * y = in->GetFromMarshal<cuComplex*>();
int incy = in->Get<int>();

cublasStatus cs = cublasChpmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
cublasStatus_t cs = cublasChpmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand All @@ -998,7 +998,7 @@ CUBLAS_ROUTINE_HANDLER(Zhpmv_v2){
cuDoubleComplex * y = in->GetFromMarshal<cuDoubleComplex*>();
int incy = in->Get<int>();

cublasStatus cs = cublasZhpmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
cublasStatus_t cs = cublasZhpmv_v2(handle,uplo,n,alpha,AP,x,incx,beta,y,incy);
return std::make_shared<Result>(cs);
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/cublas/frontend/CublasFrontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
#ifndef CUBLASFRONTEND_H
#define CUBLASFRONTEND_H

#include <cublas.h>
#include <cublas_api.h>
// Deprecated to include both in 2.1.15.cuBLAS: Release 12.0
// #include <cublas.h>
// #include <cublas_api.h>
#include "cublas_v2.h"
#include <cuda_runtime_api.h>

Expand Down
44 changes: 43 additions & 1 deletion plugins/cudart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ string(REGEX REPLACE ".*\\.so\\.([0-9]+\\.[0-9]+\\.[0-9]+)" "\\1" CUDART_VERSION

message(STATUS "Found cudaRt: ${CUDART_VERSION} (${CUDART_INCLUDE_DIRECTORY}/cuda_runtime_api.h, ${CUDART_LIBRARY})")

if (CUDART_VERSION LESS 12000)

gvirtus_add_backend(cudart ${CUDA_VERSION}
backend/CudaRtHandler_texture.cpp
backend/CudaRtHandler_event.cpp
Expand Down Expand Up @@ -66,4 +68,44 @@ gvirtus_add_frontend(cudart ${CUDA_VERSION}
frontend/CudaRt_version.cpp
util/CudaUtil.cpp)

add_subdirectory(demo)
else (CUDART_VERSION LESS 12000)

gvirtus_add_backend(cudart ${CUDA_VERSION}
# backend/CudaRtHandler_texture.cpp
backend/CudaRtHandler_event.cpp
backend/CudaRtHandler_opengl.cpp
# backend/CudaRtHandler_surface.cpp
backend/CudaRtHandler_thread.cpp
backend/CudaRtHandler_internal.cpp
backend/CudaRtHandler_occupancy.cpp
backend/CudaRtHandler_execution.cpp
backend/CudaRtHandler_device.cpp
backend/CudaRtHandler_stream.cpp
backend/CudaRtHandler_memory.cpp
backend/CudaRtHandler_version.cpp
backend/CudaRtHandler_error.cpp
backend/CudaRtHandler.cpp
util/CudaUtil.cpp)
target_link_libraries(${PROJECT_NAME} ${CUDA_CUDART_LIBRARY})

gvirtus_add_frontend(cudart ${CUDA_VERSION}
frontend/CudaRt.cpp
frontend/CudaRt_device.cpp
frontend/CudaRt_error.cpp
frontend/CudaRt_event.cpp
frontend/CudaRt_execution.cpp
frontend/CudaRtFrontend.cpp
frontend/CudaRt_internal.cpp
frontend/CudaRt_memory.cpp
frontend/CudaRt_occupancy.cpp
frontend/CudaRt_opengl.cpp
frontend/CudaRt_stream.cpp
# frontend/CudaRt_surface.cpp
# frontend/CudaRt_texture.cpp
frontend/CudaRt_thread.cpp
frontend/CudaRt_version.cpp
util/CudaUtil.cpp)

endif (CUDART_VERSION LESS 12000)

add_subdirectory(demo)
18 changes: 13 additions & 5 deletions plugins/cudart/backend/CudaRtHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ CudaRtHandler::CudaRtHandler() {
mpFatBinary = new map<string, void **>();
mpDeviceFunction = new map<string, string>();
mpVar = new map<string, string>();
#if CUDART_VERSION < 12000
mpTexture = new map<string, textureReference *>();
mpSurface = new map<string, surfaceReference *>();
#endif

mapHost2DeviceFunc = new map<const void*, std::string>();
mapDeviceFunc2InfoFunc = new map<std::string, NvInfoFunction>();
Expand Down Expand Up @@ -208,6 +210,7 @@ const char *CudaRtHandler::GetVar(const char *handler) {
return GetVar(tmp);
}

#if CUDART_VERSION < 12000
void CudaRtHandler::RegisterTexture(string &handler, textureReference *texref) {
mpTexture->insert(make_pair(handler, texref));
//#ifdef DEBUG
Expand Down Expand Up @@ -276,6 +279,7 @@ const char *CudaRtHandler::GetSurfaceHandler(surfaceReference *surfref) {
if (it->second == surfref) return it->first.c_str();
return NULL;
}
#endif

const char *CudaRtHandler::GetSymbol(std::shared_ptr<Buffer> in) {
char *symbol_handler = in->AssignString();
Expand Down Expand Up @@ -354,7 +358,7 @@ void CudaRtHandler::Initialize() {
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(SetDoubleForDevice));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(SetDoubleForHost));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(SetupArgument));
#if CUDART_VERSION >= 9020
#if (CUDART_VERSION >= 9020) && (CUDART_VERSION < 12000)
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(PushCallConfiguration));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(PopCallConfiguration));
#endif
Expand All @@ -368,8 +372,10 @@ void CudaRtHandler::Initialize() {
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(RegisterVar));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(RegisterSharedVar));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(RegisterShared));
#if CUDART_VERSION < 12000
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(RegisterTexture));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(RegisterSurface));
#endif

/* CudaRtHandler_memory */
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(Free));
Expand Down Expand Up @@ -415,31 +421,33 @@ void CudaRtHandler::Initialize() {
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(StreamWaitEvent));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(StreamCreateWithPriority));

#ifndef CUDART_VERSION
#error CUDART_VERSION not defined
#endif
#if CUDART_VERSION < 12000
/* CudaRtHandler_surface */
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(BindSurfaceToArray));

/* CudaRtHandler_texture */
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(BindTexture));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(BindTexture2D));
#ifndef CUDART_VERSION
#error CUDART_VERSION not defined
#endif
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(BindTextureToArray));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(CreateTextureObject));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(GetChannelDesc));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(GetTextureAlignmentOffset));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(GetTextureReference));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(UnbindTexture));
#endif

/* CudaRtHandler_thread */
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(ThreadExit));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(ThreadSynchronize));

/* CudaRtHandler_version */
#ifndef CUDART_VERSION
#error CUDART_VERSION not defined
#endif
#if CUDART_VERSION >= 2030
/* CudaRtHandler_version */
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(DriverGetVersion));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(RuntimeGetVersion));
mspHandlers->insert(CUDA_ROUTINE_HANDLER_PAIR(FuncSetCacheConfig));
Expand Down
16 changes: 14 additions & 2 deletions plugins/cudart/backend/CudaRtHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@
#include "../3rdparty/include/CudaRt_internal.h"

#if (CUDART_VERSION >= 9020)

#if (CUDART_VERSION >= 11000)
#define __CUDACC__
#define cudaPushCallConfiguration __cudaPushCallConfiguration
#endif

#if (CUDART_VERSION < 12000)
#include "crt/device_functions.h"
#endif

#endif

//#define DEBUG

/**
Expand Down Expand Up @@ -109,6 +114,7 @@ class CudaRtHandler : public gvirtus::backend::Handler {
const char *GetVar(std::string &handler);
const char *GetVar(const char *handler);

#if CUDART_VERSION < 12000
void RegisterTexture(std::string &handler, textureReference *texref);
void RegisterTexture(const char *handler, textureReference *texref);
void RegisterSurface(std::string &handler, surfaceReference *surref);
Expand All @@ -121,6 +127,7 @@ class CudaRtHandler : public gvirtus::backend::Handler {
surfaceReference *GetSurface(pointer_t handler);
surfaceReference *GetSurface(const char *handler);
const char *GetSurfaceHandler(surfaceReference *texref);
#endif

const char *GetSymbol(std::shared_ptr<Buffer> in);

Expand Down Expand Up @@ -168,8 +175,10 @@ class CudaRtHandler : public gvirtus::backend::Handler {
std::map<std::string, void **> *mpFatBinary;
std::map<std::string, std::string> *mpDeviceFunction;
std::map<std::string, std::string> *mpVar;
#if CUDART_VERSION < 12000
std::map<std::string, textureReference *> *mpTexture;
std::map<std::string, surfaceReference *> *mpSurface;
#endif
map<std::string, NvInfoFunction>* mapDeviceFunc2InfoFunc;
map<const void *,std::string>* mapHost2DeviceFunc;
void *mpShm;
Expand Down Expand Up @@ -229,7 +238,7 @@ CUDA_ROUTINE_HANDLER(SetDoubleForDevice);
CUDA_ROUTINE_HANDLER(SetDoubleForHost);
CUDA_ROUTINE_HANDLER(SetupArgument);

#if CUDART_VERSION >= 9020
#if (CUDART_VERSION >= 9020) && (CUDART_VERSION < 12000)
CUDA_ROUTINE_HANDLER(PushCallConfiguration);
CUDA_ROUTINE_HANDLER(PopCallConfiguration);
#endif
Expand All @@ -242,8 +251,10 @@ CUDA_ROUTINE_HANDLER(RegisterFunction);
CUDA_ROUTINE_HANDLER(RegisterVar);
CUDA_ROUTINE_HANDLER(RegisterSharedVar);
CUDA_ROUTINE_HANDLER(RegisterShared);
#if CUDART_VERSION < 12000
CUDA_ROUTINE_HANDLER(RegisterTexture);
CUDA_ROUTINE_HANDLER(RegisterSurface);
#endif
CUDA_ROUTINE_HANDLER(RegisterSharedMemory);
CUDA_ROUTINE_HANDLER(RequestSharedMemory);

Expand Down Expand Up @@ -290,6 +301,7 @@ CUDA_ROUTINE_HANDLER(StreamCreateWithFlags);
CUDA_ROUTINE_HANDLER(StreamWaitEvent);
CUDA_ROUTINE_HANDLER(StreamCreateWithPriority);

#if CUDART_VERSION < 12000
/* CudaRtHandler_texture */
CUDA_ROUTINE_HANDLER(BindTexture);
CUDA_ROUTINE_HANDLER(BindTexture2D);
Expand All @@ -302,7 +314,7 @@ CUDA_ROUTINE_HANDLER(UnbindTexture);

/* CudaRtHandler_surface */
CUDA_ROUTINE_HANDLER(BindSurfaceToArray);
// CUDA_ROUTINE_HANDLER(GetTextureReference);
#endif

/* CudaRtHandler_thread */
CUDA_ROUTINE_HANDLER(ThreadExit);
Expand Down
6 changes: 4 additions & 2 deletions plugins/cudart/backend/CudaRtHandler_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,15 @@ CUDA_ROUTINE_HANDLER(IpcOpenEventHandle) {
Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("IpcOpenEventHandler"));
CudaRtHandler::setLogLevel(&logger);

std::shared_ptr<Buffer> out = std::make_shared<Buffer>();

try {
cudaEvent_t *event = input_buffer->Assign<cudaEvent_t>();
cudaIpcEventHandle_t handle = input_buffer->Get<cudaIpcEventHandle_t>();
cudaError_t exit_code = cudaIpcOpenEventHandle(event, handle);
std::shared_ptr<Buffer> out = std::make_shared<Buffer>();

out->Add(event);
return std::make_shared<Result>(exit_code, out);

} catch (string e) {
// cerr << e << endl;
LOG4CPLUS_DEBUG(logger, e);
Expand Down
8 changes: 5 additions & 3 deletions plugins/cudart/backend/CudaRtHandler_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern void __cudaRegisterVar(void **fatCubinHandle, char *hostVar,
extern void __cudaRegisterSharedVar(void **fatCubinHandle, void **devicePtr,
size_t size, size_t alignment, int storage);
extern void __cudaRegisterShared(void **fatCubinHandle, void **devicePtr);
#if CUDART_VERSION < 12000
extern void __cudaRegisterTexture(void **fatCubinHandle,
const textureReference *hostVar,
void **deviceAddress, char *deviceName,
Expand All @@ -89,6 +90,7 @@ extern void __cudaRegisterSurface(void **fatCubinHandle,
const surfaceReference *hostVar,
void **deviceAddress, char *deviceName,
int dim, int ext);
#endif
}

static bool initialized = false;
Expand Down Expand Up @@ -421,6 +423,7 @@ CUDA_ROUTINE_HANDLER(RegisterShared) {
return std::make_shared<Result>(cudaSuccess);
}

#if CUDART_VERSION < 12000
CUDA_ROUTINE_HANDLER(RegisterTexture) {
try {
char *handler = input_buffer->AssignString();
Expand Down Expand Up @@ -504,15 +507,13 @@ CUDA_ROUTINE_HANDLER(RegisterSurface) {
return std::make_shared<Result>(cudaSuccess);
}

#if (CUDART_VERSION >= 9020)

#if (CUDART_VERSION >= 9020) && (CUDART_VERSION < 12000)

#if (CUDART_VERSION >= 11000)
#define __CUDACC__
#define cudaPushCallConfiguration __cudaPushCallConfiguration
#endif


#include "crt/device_functions.h"
#include "CudaRt_internal.h"

Expand Down Expand Up @@ -573,3 +574,4 @@ CUDA_ROUTINE_HANDLER(PopCallConfiguration) {

}
#endif
#endif
Loading