ryankert01 commented on code in PR #968:
URL: https://github.com/apache/mahout/pull/968#discussion_r2749668153


##########
qdp/qdp-kernels/src/amplitude.cu:
##########
@@ -617,6 +617,37 @@ int launch_l2_norm_f32(
     return (int)cudaGetLastError();
 }
 
+/// Returns the current device's max grid dimension (X), fallback to 
CUDA_MAX_GRID_DIM_1D if error.
+static size_t get_max_grid_dim_1d(void) {
+    static size_t cached_device = 0;
+    if (cached_device != 0) {

Review Comment:
   when will cached_device != 0?



##########
qdp/qdp-kernels/src/amplitude.cu:
##########
@@ -617,6 +617,37 @@ int launch_l2_norm_f32(
     return (int)cudaGetLastError();
 }
 
+/// Returns the current device's max grid dimension (X), fallback to 
CUDA_MAX_GRID_DIM_1D if error.
+static size_t get_max_grid_dim_1d(void) {
+    static size_t cached_device = 0;
+    if (cached_device != 0) {
+        return cached_device;
+    }
+
+    int device = -1;
+    // Fallback to CUDA_MAX_GRID_DIM_1D if error
+    if (cudaGetDevice(&device) != cudaSuccess || device < 0) {
+        cached_device = CUDA_MAX_GRID_DIM_1D;
+        return cached_device;
+    }
+
+    int max_x = 0;
+    cudaError_t err = cudaDeviceGetAttribute(
+        &max_x,
+        cudaDevAttrMaxGridDimX,
+        device
+    );
+
+    // Fallback to CUDA_MAX_GRID_DIM_1D if error
+    if (err != cudaSuccess || max_x <= 0) {
+        cached_device = CUDA_MAX_GRID_DIM_1D;

Review Comment:
   please change `CUDA_MAX_GRID_DIM_1D` to value I descibe.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to