summaryrefslogtreecommitdiff
path: root/libcuda
diff options
context:
space:
mode:
authorMengchi Zhang <[email protected]>2017-10-03 11:36:52 -0400
committertgrogers <[email protected]>2018-03-25 15:22:41 -0400
commitb4cf66026f66291293c6e11e9c07976f773732fa (patch)
treec705af9d06eeef14a19719c4c6c4c7f16957b1e4 /libcuda
parent82a62207406739bc8597326aa473a99007029d75 (diff)
Add lonestar tick support
Signed-off-by: Mengchi Zhang <[email protected]>
Diffstat (limited to 'libcuda')
-rw-r--r--libcuda/cuda_runtime_api.cc49
1 files changed, 31 insertions, 18 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index d8e7832..4f5e0fb 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -336,23 +336,19 @@ class _cuda_device_id *GPGPUSim_Init()
prop->minor = 2;
prop->totalGlobalMem = 0x80000000 /* 2 GB */;
prop->memPitch = 0;
+ if(prop->major >= 2) {
+ prop->maxThreadsPerBlock = 1024;
+ prop->maxThreadsDim[0] = 1024;
+ prop->maxThreadsDim[1] = 1024;
+ }
+ else
+ {
+ prop->maxThreadsPerBlock = 512;
+ prop->maxThreadsDim[0] = 512;
+ prop->maxThreadsDim[1] = 512;
+ }
- if(prop->major >= 2) {
- prop->maxThreadsPerBlock = 1024;
- prop->maxThreadsDim[0] = 1024;
- prop->maxThreadsDim[1] = 1024;
- }
- else
- {
- prop->maxThreadsPerBlock = 512;
- prop->maxThreadsDim[0] = 512;
- prop->maxThreadsDim[1] = 512;
- }
-
- prop->maxThreadsDim[2] = 64;
- prop->maxGridSize[0] = 0x40000000;
- prop->maxGridSize[1] = 0x40000000;
- prop->maxGridSize[2] = 0x40000000;
+ prop->maxThreadsDim[2] = 64;
prop->maxGridSize[0] = 0x40000000;
prop->maxGridSize[1] = 0x40000000;
prop->maxGridSize[2] = 0x40000000;
@@ -366,7 +362,7 @@ class _cuda_device_id *GPGPUSim_Init()
prop->multiProcessorCount = the_gpu->get_config().num_shader();
#endif
#if (CUDART_VERSION >= 4000)
- prop->maxThreadsPerMultiProcessor = the_gpu->threads_per_core();
+ prop->maxThreadsPerMultiProcessor = the_gpu->threads_per_core();
#endif
the_gpu->set_prop(prop);
the_device = new _cuda_device_id(the_gpu);
@@ -2112,6 +2108,20 @@ cudaError_t CUDARTAPI cudaSetDeviceFlags( int flags )
return g_last_cudaError = cudaErrorUnknown;
}
+size_t getMaxThreadsPerBlock(struct cudaFuncAttributes *attr) {
+ _cuda_device_id *dev = GPGPUSim_Init();
+ struct cudaDeviceProp prop;
+
+ prop = *dev->get_prop();
+
+ size_t max = prop.maxThreadsPerBlock;
+
+ if ((prop.regsPerBlock / attr->numRegs) < max)
+ max = prop.regsPerBlock / attr->numRegs;
+
+ return max;
+}
+
cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const char *hostFun )
{
CUctx_st *context = GPGPUSim_Context();
@@ -2122,7 +2132,10 @@ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, con
attr->constSizeBytes = kinfo->cmem;
attr->localSizeBytes = kinfo->lmem;
attr->numRegs = kinfo->regs;
- attr->maxThreadsPerBlock = 0; // from pragmas?
+ if(kinfo->maxthreads > 0)
+ attr->maxThreadsPerBlock = kinfo->maxthreads;
+ else
+ attr->maxThreadsPerBlock = getMaxThreadsPerBlock(attr);
#if CUDART_VERSION >= 3000
attr->ptxVersion = kinfo->ptx_version;
attr->binaryVersion = kinfo->sm_target;