Skip to content
Merged
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
5 changes: 4 additions & 1 deletion tools/library/include/cutlass/library/handle.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -338,6 +338,9 @@ using HandlePtr = std::unique_ptr<Handle>;
/// Finds conv2d operation instances with Conv2d::ElementC = Reduction::ElementWorkspace
Operation const* find_conv_operation_for_parallel_reduction(Operation const *operation);
/////////////////////////////////////////////////////////////////////////////////////////////////
/// Finds gemm operation instances with ElementC = Reduction::ElementWorkspace
Operation const* find_gemm_operation_for_parallel_reduction(Operation const *operation);
/////////////////////////////////////////////////////////////////////////////////////////////////

} // namespace library
} // namespace cutlass
Expand Down
3 changes: 2 additions & 1 deletion tools/library/include/cutlass/library/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ class Operation {
void const *configuration) const = 0;

virtual uint64_t get_device_workspace_size(
void const *configuration) const = 0;
void const *configuration,
void const *arguments = nullptr) const = 0;

virtual Status initialize(
void const *configuration,
Expand Down
5 changes: 3 additions & 2 deletions tools/library/src/conv2d_operation.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -272,7 +272,8 @@ class Conv2dOperation : public Conv2dOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down
5 changes: 3 additions & 2 deletions tools/library/src/conv3d_operation.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -266,7 +266,8 @@ class Conv3dOperation : public Conv3dOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down
27 changes: 20 additions & 7 deletions tools/library/src/gemm_operation.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -242,7 +242,8 @@ class GemmOperation : public GemmOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down Expand Up @@ -443,7 +444,8 @@ class GemmSparseOperation : public GemmOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down Expand Up @@ -569,7 +571,7 @@ class GemmUniversalOperation : public GemmOperationBase<Operator_> {
operator_args.ldb = (configuration->ldb);
operator_args.ldc = (configuration->ldc);
operator_args.ldd = (configuration->ldd);

return Status::kSuccess;
}

Expand Down Expand Up @@ -649,7 +651,8 @@ class GemmUniversalOperation : public GemmOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr) const {

OperatorArguments args;

Expand All @@ -661,6 +664,14 @@ class GemmUniversalOperation : public GemmOperationBase<Operator_> {
return 0;
}

status = update_arguments_(
args,
static_cast<GemmUniversalArguments const *>(arguments_ptr));

if (status != Status::kSuccess) {
return 0;
}

uint64_t size = Operator::get_workspace_size(args);

return size;
Expand Down Expand Up @@ -855,7 +866,8 @@ class GemmPlanarComplexOperation : public GemmOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down Expand Up @@ -1055,7 +1067,8 @@ class GemmPlanarComplexArrayOperation : public GemmOperationBase<Operator_> {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down
55 changes: 54 additions & 1 deletion tools/library/src/handle.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -1098,6 +1098,59 @@ Operation const* find_conv_operation_for_parallel_reduction(Operation const *ope

return nullptr;
}

/////////////////////////////////////////////////////////////////////////////////////////////////

/// Finds gemm operation instances with Gemm::ElementC = Reduction::ElementWorkspace
Operation const* find_gemm_operation_for_parallel_reduction(Operation const *operation) {

GemmDescription const &gemm_desc =
static_cast<GemmDescription const &>(operation->description());

// if the curren gemm operation accumulator and output data type match return operation
if(gemm_desc.tile_description.math_instruction.element_accumulator == gemm_desc.C.element) {
return operation;
}

// find gemm operation to match gemm output and reduction workspace data type
GemmFunctionalKey key(
library::Provider::kCUTLASS,
gemm_desc.gemm_kind,
gemm_desc.tile_description.math_instruction.element_accumulator,
gemm_desc.element_epilogue,
gemm_desc.A.element,
gemm_desc.A.layout,
gemm_desc.transform_A,
gemm_desc.B.element,
gemm_desc.B.layout,
gemm_desc.transform_B,
gemm_desc.tile_description.math_instruction.element_accumulator);

// gemm operation table
auto gemm_operations = Singleton::get().operation_table.gemm_operations;

// find ConvFunctionalKey in gemm operation table
auto operators_it = gemm_operations.find(key);

if (operators_it == gemm_operations.end()) {
return nullptr;
}

if (operators_it->second.empty()) {
return nullptr;
}

// A and B uses the same alignment in the generator.py
int alignment = gemm_desc.A.alignment;

// gemm operation for same compute capability and iterator algorithm
GemmPreferenceKey preference_key(
gemm_desc.tile_description.minimum_compute_capability,
alignment);

return find_gemm_operation(operators_it, preference_key);
}

/////////////////////////////////////////////////////////////////////////////////////////////////

} // namespace library
Expand Down
2 changes: 1 addition & 1 deletion tools/library/src/reduction/init_reduction_operations.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down
9 changes: 4 additions & 5 deletions tools/library/src/reduction/reduction_device.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -46,7 +46,7 @@ void initialize_reduce_add_linear_combination_f32_f32_f16(Manifest &manifest) {

using EpilogueOutputOp = cutlass::epilogue::thread::LinearCombination<
ElementOutput,
128 / cutlass::sizeof_bits<ElementOutput>::value,
128 / cutlass::sizeof_bits<ElementWorkspace>::value,
ElementAccumulator,
ElementCompute
>;
Expand Down Expand Up @@ -81,7 +81,7 @@ void initialize_reduce_add_linear_combination_f32_f32_f32(Manifest &manifest) {

using EpilogueOutputOp = cutlass::epilogue::thread::LinearCombination<
ElementOutput,
128 / cutlass::sizeof_bits<ElementOutput>::value,
128 / cutlass::sizeof_bits<ElementWorkspace>::value,
ElementAccumulator,
ElementCompute
>;
Expand Down Expand Up @@ -115,7 +115,7 @@ void initialize_reduce_add_linear_combination_cf32_cf32_cf32(Manifest &manifest)

using EpilogueOutputOp = cutlass::epilogue::thread::LinearCombination<
ElementOutput,
128 / cutlass::sizeof_bits<ElementOutput>::value,
128 / cutlass::sizeof_bits<ElementWorkspace>::value,
ElementAccumulator,
ElementCompute
>;
Expand All @@ -140,6 +140,5 @@ void initialize_reduce_add_linear_combination_cf32_cf32_cf32(Manifest &manifest)
));
}


}
}
4 changes: 3 additions & 1 deletion tools/library/src/reduction/reduction_operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <iostream>
#include "cutlass/cutlass.h"
#include "cutlass/epilogue/thread/linear_combination.h"
#include "cutlass/epilogue/thread/linear_combination_clamp.h"
#include "cutlass/reduction/thread/reduction_operators.h"
#include "cutlass/reduction/device/reduce_split_k.h"

Expand Down Expand Up @@ -180,7 +181,8 @@ class ReductionOperation : public Operation {

/// Gets the device-side workspace
virtual uint64_t get_device_workspace_size(
void const *configuration_ptr) const {
void const *configuration_ptr,
void const *arguments_ptr = nullptr) const {

OperatorArguments args;

Expand Down
5 changes: 3 additions & 2 deletions tools/library/src/reference/conv_reference_operation.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -403,7 +403,8 @@ class ConvReferenceOperation : public Operation {
}

virtual uint64_t get_device_workspace_size(
void const *configuration) const {
void const *configuration,
void const *arguments = nullptr) const {

return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions tools/library/src/reference/gemm_reference_operation.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************************************
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -161,7 +161,8 @@ class GemmReferenceOperation : public Operation {
}

virtual uint64_t get_device_workspace_size(
void const *configuration) const {
void const *configuration,
void const *arguments = nullptr) const {

return 0;
}
Expand Down
Loading