Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiting Zhu <[email protected]>
  • Loading branch information
photoszzt committed Jun 17, 2021
1 parent 2851555 commit c689fca
Show file tree
Hide file tree
Showing 17 changed files with 2,066 additions and 11,989 deletions.
6 changes: 2 additions & 4 deletions cava/samples/cuda_common_spec/cublas/blas1_unimplemented.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_CUBLAS1_UNIMPLEMENTED_H_
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS1_UNIMPLEMENTED_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS1_UNIMPLEMENTED_H_
#include <cublas_api.h>
#include <cublas_v2.h>

/* ---------------- CUBLAS BLAS1 functions ---------------- */
CUBLASAPI cublasStatus_t CUBLASWINAPI cublasNrm2Ex(cublasHandle_t handle, int n, const void *x, cudaDataType xType,
Expand Down Expand Up @@ -423,4 +421,4 @@ CUBLASAPI cublasStatus_t CUBLASWINAPI cublasRotmgEx(cublasHandle_t handle, void
ava_unsupported;
}

#endif // _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_CUBLAS1_UNIMPLEMENTED_H_
#endif // _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS1_UNIMPLEMENTED_H_
2 changes: 0 additions & 2 deletions cava/samples/cuda_common_spec/cublas/blas2_unimplemented.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS2_UNIMPLEMENTED_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS2_UNIMPLEMENTED_H_
#include <cublas_api.h>
#include <cublas_v2.h>

/* --------------- CUBLAS BLAS2 functions ---------------- */

Expand Down
2 changes: 0 additions & 2 deletions cava/samples/cuda_common_spec/cublas/blas3.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS3_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS3_H_
#include <cublas_api.h>
#include <cublas_v2.h>

/* --------------- CUBLAS BLAS3 functions ---------------- */
CUBLASAPI cublasStatus_t CUBLASWINAPI cublasGemmBatchedEx(cublasHandle_t handle, cublasOperation_t transa,
Expand Down
3 changes: 0 additions & 3 deletions cava/samples/cuda_common_spec/cublas/blas3_unimplemented.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS3_UNIMPLEMENTED_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS3_UNIMPLEMENTED_H_
#include <cublas_api.h>
#include <cublas_v2.h>

/* --------------- CUBLAS BLAS3 functions ---------------- */
CUBLASAPI cublasStatus_t CUBLASWINAPI cublasDgemm_v2(cublasHandle_t handle, cublasOperation_t transa,
cublasOperation_t transb, int m, int n, int k,
Expand Down
3 changes: 0 additions & 3 deletions cava/samples/cuda_common_spec/cublas/blas_like_ext.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS_LIKE_EXT_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS_LIKE_EXT_H_
#include <cublas_api.h>
#include <cublas_v2.h>

/* ---------------- CUBLAS BLAS-like extension ---------------- */
/* GEAM */
CUBLASAPI cublasStatus_t CUBLASWINAPI cublasSgeam(cublasHandle_t handle, cublasOperation_t transa,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS_LIKE_EXT_UNIMPLEMENTED_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_BLAS_LIKE_EXT_UNIMPLEMENTED_H_
#include <cublas_api.h>
#include <cublas_v2.h>
/* ---------------- CUBLAS BLAS-like extension ---------------- */

CUBLASAPI cublasStatus_t CUBLASWINAPI cublasDgeam(cublasHandle_t handle, cublasOperation_t transa,
Expand Down
19 changes: 3 additions & 16 deletions cava/samples/cuda_common_spec/cublas/cublas.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include <cublas_api.h>
#include <cublas_v2.h>

#include "common/extensions/cudnn_optimization.h"

/* CUDABLAS API */

CUBLASAPI cublasStatus_t CUBLASWINAPI cublasCreate(cublasHandle_t *handle) {
Expand Down Expand Up @@ -40,22 +43,6 @@ cublasStatus_t CUBLASWINAPI cublasGetMatrix(int rows, int cols, int elemSize, co
}
}

ava_begin_replacement;
EXPORTED CUBLASAPI cublasStatus_t CUBLASWINAPI cublasGetPointerMode_v2(cublasHandle_t handle,
cublasPointerMode_t *mode) {
/* XXX seems ok for tensorflow but might be wrong !FIXME */
*mode = CUBLAS_POINTER_MODE_HOST;
return CUBLAS_STATUS_SUCCESS;
}

EXPORTED CUBLASAPI cublasStatus_t CUBLASWINAPI cublasSetPointerMode_v2(cublasHandle_t handle,
cublasPointerMode_t mode) {
/* XXX seems ok for tensorflow but might be wrong ! FIXME */
assert(mode == CUBLAS_POINTER_MODE_HOST && "mode == CUBLAS_POINTER_MODE_HOST");
return CUBLAS_STATUS_SUCCESS;
}
ava_end_replacement;

#include "blas1_unimplemented.h"
#include "blas2_unimplemented.h"
#include "blas3.h"
Expand Down
2 changes: 0 additions & 2 deletions cava/samples/cuda_common_spec/cublas/cublas_unimplemented.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_UNIMPLEMENTED_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUBLAS_UNIMPLEMENTED_H_
#include <cublas_api.h>
#include <cublas_v2.h>
/* CUDABLAS API */

CUBLASAPI cublasStatus_t CUBLASWINAPI cublasGetAtomicsMode(cublasHandle_t handle, cublasAtomicsMode_t *mode) {
Expand Down
41 changes: 41 additions & 0 deletions cava/samples/cuda_common_spec/cudadrv_unimplemented.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUDADRV_UNIMPLEMENTED_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUDADRV_UNIMPLEMENTED_H_
#include <cuda.h>

CUresult CUDAAPI cuFuncSetCacheConfig(CUfunction hfunc, CUfunc_cache config) { ava_unsupported; }

CUresult CUDAAPI cuCtxGetSharedMemConfig(CUsharedconfig *pConfig) { ava_unsupported; }

CUresult CUDAAPI cuFuncGetAttribute(int *pi, CUfunction_attribute attrib, CUfunction hfunc) { ava_unsupported; }

CUresult CUDAAPI cuModuleLoadFatBinary(CUmodule *module, const void *fatCubin) { ava_unsupported; }

CUresult CUDAAPI cuStreamAddCallback(CUstream hStream, CUstreamCallback callback, void *userData, unsigned int flags) {
ava_unsupported;
}

CUresult CUDAAPI cuDeviceGetProperties(CUdevprop *prop, CUdevice dev) { ava_unsupported; }

CUresult cuGetExportTable(const void **ppExportTable, const CUuuid *pExportTableId) { ava_unsupported; }

CUresult CUDAAPI cuOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, CUfunction func, int blockSize,
size_t dynamicSMemSize) {
ava_argument(numBlocks) {
ava_out;
ava_buffer(1);
}

ava_unsupported;
}

CUresult CUDAAPI cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, CUfunction func, int blockSize,
size_t dynamicSMemSize, unsigned int flags) {
ava_argument(numBlocks) {
ava_out;
ava_buffer(1);
}

ava_unsupported;
}

#endif // _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUDADRV_UNIMPLEMENTED_H_
8 changes: 1 addition & 7 deletions cava/samples/cuda_common_spec/cudart_unimplemented.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,6 @@ __host__ cudaError_t CUDARTAPI cudaMemcpy2DArrayToArray(cudaArray_t dst, size_t
ava_unsupported;
}

__host__ cudaError_t CUDARTAPI cudaMemcpyFromSymbol(void *dst, const void *symbol, size_t count, size_t offset __dv(0),
enum cudaMemcpyKind kind __dv(cudaMemcpyDeviceToHost)) {
/* kind is always cudaMemcpyDeviceToHost */
ava_unsupported;
}

__host__ cudaError_t CUDARTAPI cudaMemcpyPeerAsync(void *dst, int dstDevice, const void *src, int srcDevice,
size_t count, cudaStream_t stream __dv(0)) {
ava_unsupported;
Expand Down Expand Up @@ -632,4 +626,4 @@ __host__ cudaError_t CUDARTAPI cudaGraphExecDestroy(cudaGraphExec_t graphExec) {

__host__ cudaError_t CUDARTAPI cudaGraphDestroy(cudaGraph_t graph) { ava_unsupported; }

// #endif // _AVA_SAMPLES_CUDA_COMMON_SPEC_CUDART_UNIMPLEMENTED_H_
#endif // _AVA_SAMPLES_CUDA_COMMON_SPEC_CUDART_UNIMPLEMENTED_H_
82 changes: 82 additions & 0 deletions cava/samples/cuda_common_spec/cudnn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#ifndef _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUDNN_H_
#define _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUDNN_H_
#include <cudnn.h>

/* Tensor Bias addition : C = alpha * A + beta * C */
cudnnStatus_t CUDNNWINAPI cudnnAddTensor(cudnnHandle_t handle, const void *alpha, const cudnnTensorDescriptor_t aDesc,
const void *A, const void *beta, const cudnnTensorDescriptor_t cDesc,
void *C) {
ava_async;
ava_argument(handle) ava_handle;
ava_argument(alpha) {
ava_type_cast(const double *);
ava_in;
ava_buffer(1);
}
ava_argument(aDesc) ava_handle;
ava_argument(A) ava_opaque;
ava_argument(beta) {
ava_type_cast(const double *);
ava_in;
ava_buffer(1);
}
ava_argument(cDesc) ava_handle;
ava_argument(C) ava_opaque;
}

/* Convolution functions: All of the form "output = alpha * Op(inputs) + beta * output" */

cudnnStatus_t CUDNNWINAPI cudnnFindConvolutionForwardAlgorithmEx(
cudnnHandle_t handle, const cudnnTensorDescriptor_t xDesc, const void *x, const cudnnFilterDescriptor_t wDesc,
const void *w, const cudnnConvolutionDescriptor_t convDesc, const cudnnTensorDescriptor_t yDesc, void *y,
const int requestedAlgoCount, int *returnedAlgoCount, cudnnConvolutionFwdAlgoPerf_t *perfResults, void *workSpace,
size_t workSpaceSizeInBytes) {
ava_argument(handle) ava_handle;
ava_argument(xDesc) ava_handle;
ava_argument(x) ava_opaque;
ava_argument(wDesc) ava_handle;
ava_argument(w) ava_opaque;
ava_argument(convDesc) ava_handle;
ava_argument(yDesc) ava_handle;
ava_argument(y) ava_opaque;
ava_argument(returnedAlgoCount) {
ava_out;
ava_buffer(1);
}
ava_argument(perfResults) {
ava_out;
cu_in_out_buffer(requestedAlgoCount, returnedAlgoCount);
}
ava_argument(workSpace) ava_opaque;
}

/* Helper function to return the minimum size of the workspace to be passed to the convolution given an algo*/
cudnnStatus_t CUDNNWINAPI cudnnGetConvolutionBackwardFilterWorkspaceSize(
cudnnHandle_t handle, const cudnnTensorDescriptor_t xDesc, const cudnnTensorDescriptor_t dyDesc,
const cudnnConvolutionDescriptor_t convDesc, const cudnnFilterDescriptor_t gradDesc,
cudnnConvolutionBwdFilterAlgo_t algo, size_t *sizeInBytes) {
ava_argument(handle) ava_handle;
ava_argument(xDesc) ava_handle;
ava_argument(dyDesc) ava_handle;
ava_argument(convDesc) ava_handle;
ava_argument(gradDesc) ava_handle;
ava_argument(sizeInBytes) {
ava_out;
ava_buffer(1);
}
}

/*
* Derives a tensor descriptor from layer data descriptor for BatchNormalization
* scale, invVariance, bnBias, bnScale tensors. Use this tensor desc for
* bnScaleBiasMeanVarDesc and bnScaleBiasDiffDesc in Batch Normalization forward and backward functions.
*/
cudnnStatus_t CUDNNWINAPI cudnnDeriveBNTensorDescriptor(cudnnTensorDescriptor_t derivedBnDesc,
const cudnnTensorDescriptor_t xDesc,
cudnnBatchNormMode_t mode) {
ava_async;
ava_argument(derivedBnDesc) ava_handle;
ava_argument(xDesc) ava_handle;
}

#endif // _AVA_CAVA_SAMPLES_CUDA_COMMON_SPEC_CUDNN_H_
Loading

0 comments on commit c689fca

Please sign in to comment.