CUTLASS 3.8 Release (#2059)
* CUTLASS 3.8 Release * update * Update README.md * Revert "Update README.md" This reverts commit b353e36fe83e0815f99b44e46c0c95494c44726b. * update * update --------- Co-authored-by: Haicheng Wu <57973641+hwu36@users.noreply.github.com> Co-authored-by: Haicheng Wu <haichengw@nvidia.com>
This commit is contained in:
co-authored by
Haicheng Wu
Haicheng Wu
parent
9eb01fa0b0
commit
389e493055
@@ -38,6 +38,8 @@
|
||||
#include <cuda_runtime_api.h>
|
||||
#include "cutlass/cutlass.h"
|
||||
#include "cutlass/trace.h"
|
||||
#include <cute/arch/cluster_sm100.hpp>
|
||||
|
||||
#if defined(__CUDACC_RTC__)
|
||||
#include <cuda/std/type_traits>
|
||||
#else
|
||||
@@ -49,6 +51,11 @@
|
||||
# define CUTLASS_SM90_CLUSTER_LAUNCH_ENABLED
|
||||
#endif
|
||||
|
||||
#ifndef CUDA_ENABLE_PREFERRED_CLUSTER
|
||||
#if (__CUDACC_VER_MAJOR__ > 12 || (__CUDACC_VER_MAJOR__ == 12 && __CUDACC_VER_MINOR__ >= 8))
|
||||
# define CUDA_ENABLE_PREFERRED_CLUSTER
|
||||
#endif
|
||||
#endif
|
||||
namespace cutlass {
|
||||
|
||||
#ifndef NDEBUG
|
||||
@@ -78,7 +85,13 @@ struct ClusterLauncher {
|
||||
struct LaunchConfig {
|
||||
#if defined(CUTLASS_SM90_CLUSTER_LAUNCH_ENABLED)
|
||||
cudaLaunchConfig_t launch_config;
|
||||
|
||||
#if defined(CUDA_ENABLE_PREFERRED_CLUSTER)
|
||||
constexpr static int numAttrs = 3;
|
||||
#else
|
||||
|
||||
constexpr static int numAttrs = 2;
|
||||
#endif
|
||||
cudaLaunchAttribute launch_attribute[numAttrs];
|
||||
// Commonly used utility functions
|
||||
dim3 gridDim() { return launch_config.gridDim; }
|
||||
@@ -143,6 +156,7 @@ struct ClusterLauncher {
|
||||
size_t const smem_size = 0,
|
||||
cudaStream_t cuda_stream = 0,
|
||||
bool launch_with_pdl = false
|
||||
, dim3 const fallback_cluster_dims = {0, 0, 0}
|
||||
) {
|
||||
LaunchConfig cluster_launch_config;
|
||||
#if defined(CUTLASS_SM90_CLUSTER_LAUNCH_ENABLED)
|
||||
@@ -151,9 +165,37 @@ struct ClusterLauncher {
|
||||
auto numAttrs = cluster_launch_config.numAttrs;
|
||||
|
||||
launch_attribute[0].id = cudaLaunchAttributeClusterDimension;
|
||||
|
||||
bool have_fallback = fallback_cluster_dims.x * fallback_cluster_dims.y * fallback_cluster_dims.z > 0;
|
||||
|
||||
if (have_fallback) {
|
||||
launch_attribute[0].val.clusterDim = {fallback_cluster_dims.x, fallback_cluster_dims.y, fallback_cluster_dims.z};
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: Setting fallback ClusterDims = "
|
||||
"(" << fallback_cluster_dims.x << ", " << fallback_cluster_dims.y << ", " << fallback_cluster_dims.z << ")\n");
|
||||
}
|
||||
else {
|
||||
|
||||
launch_attribute[0].val.clusterDim = {cluster_dims.x, cluster_dims.y, cluster_dims.z};
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: Setting ClusterDims = "
|
||||
"(" << cluster_dims.x << ", " << cluster_dims.y << ", " << cluster_dims.z << ")\n");
|
||||
|
||||
}
|
||||
|
||||
#if defined(CUDA_ENABLE_PREFERRED_CLUSTER)
|
||||
if (have_fallback) {
|
||||
if (cute::initialize_preferred_cluster_launch(nullptr, grid_dims, cluster_dims, fallback_cluster_dims)) {
|
||||
launch_attribute[1].id = cudaLaunchAttributePreferredClusterDimension;
|
||||
launch_attribute[1].val.preferredClusterDim = {cluster_dims.x, cluster_dims.y, cluster_dims.z};
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: Setting preferred ClusterDims = "
|
||||
"(" << cluster_dims.x << ", " << cluster_dims.y << ", " << cluster_dims.z << ")\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
numAttrs--;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// PDL attributes
|
||||
launch_attribute[numAttrs - 1].id = cudaLaunchAttributeProgrammaticStreamSerialization;
|
||||
launch_attribute[numAttrs - 1].val.programmaticStreamSerializationAllowed = 1;
|
||||
@@ -198,7 +240,7 @@ struct ClusterLauncher {
|
||||
return Status::kInvalid;
|
||||
}
|
||||
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: Launching GPC_CLUSTER_GRID GridDims = "
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: Launching GridDims = "
|
||||
"(" << launch_grid_dims.x << ", " << launch_grid_dims.y << ", " << launch_grid_dims.z << "), "
|
||||
"And ClusterDims = "
|
||||
"(" << cluster_dims.x << ", " << cluster_dims.y << ", " << cluster_dims.z << ")\n");
|
||||
@@ -212,6 +254,53 @@ struct ClusterLauncher {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// This is the method we expect to use going forward
|
||||
// Launch a preferred cluster grid
|
||||
static inline CUTLASS_HOST
|
||||
Status launch_with_fallback_cluster(
|
||||
dim3 const grid_dims,
|
||||
dim3 const preferred_cluster_dims,
|
||||
dim3 const fallback_cluster_dims,
|
||||
dim3 const block_dims,
|
||||
size_t const smem_size,
|
||||
cudaStream_t cuda_stream,
|
||||
void const* kernel,
|
||||
void** kernel_params,
|
||||
bool launch_with_pdl = false) {
|
||||
#if defined(CUTLASS_SM90_CLUSTER_LAUNCH_ENABLED)
|
||||
LaunchConfig cluster_launch_config = make_cluster_launch_config(grid_dims, preferred_cluster_dims,
|
||||
block_dims, smem_size, cuda_stream, launch_with_pdl, fallback_cluster_dims);
|
||||
|
||||
auto launch_grid_dims = cluster_launch_config.gridDim();
|
||||
if (check_cluster_dims(launch_grid_dims, preferred_cluster_dims) != Status::kSuccess) {
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: check_cluster_dims() failed. Aborting.");
|
||||
return Status::kInvalid;
|
||||
}
|
||||
|
||||
auto init_status = init(kernel);
|
||||
if (init_status != Status::kSuccess) {
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: init(kernel) failed with status " << int(init_status) << ". Aborting.");
|
||||
return Status::kInvalid;
|
||||
}
|
||||
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: Launching \n\tGridDims = "
|
||||
"(" << launch_grid_dims.x << ", " << launch_grid_dims.y << ", " << launch_grid_dims.z << "), "
|
||||
"\n\tPreferred ClusterDims = "
|
||||
"(" << preferred_cluster_dims.x << ", " << preferred_cluster_dims.y << ", " << preferred_cluster_dims.z << "),"
|
||||
"\n\tFallback ClusterDims = "
|
||||
"(" << fallback_cluster_dims.x << ", " << fallback_cluster_dims.y << ", " << fallback_cluster_dims.z << ")\n");
|
||||
|
||||
cutlass::arch::synclog_setup();
|
||||
cudaError_t status = cudaLaunchKernelExC(&cluster_launch_config.launch_config, kernel, kernel_params);
|
||||
Return_Status(status);
|
||||
#else
|
||||
CUTLASS_TRACE_HOST("ClusterLauncher: CUTLASS_SM90_CLUSTER_LAUNCH_ENABLED not defined! Aborting cluster launch.");
|
||||
return Status::kInvalid;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
Reference in New Issue
Block a user