Skip to content

Commit 717d3e4

Browse files
authored
[VL] Remove gpu hash shuffle writer type (#12593)
1 parent 3df21ca commit 717d3e4

14 files changed

Lines changed: 24 additions & 103 deletions

File tree

backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxMetricsApi.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.apache.gluten.backendsapi.velox
1818

1919
import org.apache.gluten.backendsapi.MetricsApi
20-
import org.apache.gluten.config.{GpuHashShuffleWriterType, HashShuffleWriterType, RssSortShuffleWriterType, ShuffleWriterType, SortShuffleWriterType}
20+
import org.apache.gluten.config.{HashShuffleWriterType, RssSortShuffleWriterType, ShuffleWriterType, SortShuffleWriterType}
2121
import org.apache.gluten.metrics._
2222
import org.apache.gluten.substrait.{AggregationParams, JoinParams}
2323

@@ -430,7 +430,7 @@ class VeloxMetricsApi extends MetricsApi with Logging {
430430
"peakBytes" -> SQLMetrics.createSizeMetric(sparkContext, "peak bytes allocated")
431431
)
432432
shuffleWriterType match {
433-
case HashShuffleWriterType | GpuHashShuffleWriterType =>
433+
case HashShuffleWriterType =>
434434
baseMetrics ++ Map(
435435
"splitTime" -> SQLMetrics.createNanoTimingMetric(sparkContext, "time to split"),
436436
"avgDictionaryFields" -> SQLMetrics

backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxSparkPlanExecApi.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,12 @@ class VeloxSparkPlanExecApi extends SparkPlanExecApi with Logging {
607607
/** Determine whether to use sort-based shuffle based on shuffle partitioning and output. */
608608
override def getShuffleWriterType(
609609
partitioning: Partitioning,
610-
output: Seq[Attribute]): ShuffleWriterType = {
610+
output: Seq[Attribute],
611+
executionMode: Option[StageExecutionMode] = None): ShuffleWriterType = {
612+
if (executionMode.contains(GPUStageMode)) {
613+
return HashShuffleWriterType
614+
}
615+
611616
val conf = GlutenConfig.get
612617
// todo: remove isUseCelebornShuffleManager here
613618
if (conf.isUseCelebornShuffleManager) {

backends-velox/src/main/scala/org/apache/spark/shuffle/ColumnarShuffleWriter.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package org.apache.spark.shuffle
1818

1919
import org.apache.gluten.backendsapi.BackendsApiManager
2020
import org.apache.gluten.columnarbatch.ColumnarBatches
21-
import org.apache.gluten.config.{GlutenConfig, GpuHashShuffleWriterType, HashShuffleWriterType, SortShuffleWriterType}
21+
import org.apache.gluten.config.{GlutenConfig, HashShuffleWriterType, SortShuffleWriterType}
2222
import org.apache.gluten.memory.memtarget.{MemoryTarget, Spiller}
2323
import org.apache.gluten.runtime.Runtimes
2424
import org.apache.gluten.vectorized._
@@ -44,7 +44,7 @@ class ColumnarShuffleWriter[K, V](
4444
private val dep = handle.dependency.asInstanceOf[ColumnarShuffleDependency[K, V, V]]
4545

4646
dep.shuffleWriterType match {
47-
case HashShuffleWriterType | SortShuffleWriterType | GpuHashShuffleWriterType =>
47+
case HashShuffleWriterType | SortShuffleWriterType =>
4848
// Valid shuffle writer types
4949
case _ =>
5050
throw new IllegalArgumentException(
@@ -174,17 +174,6 @@ class ColumnarShuffleWriter[K, V](
174174
conf.get(SHUFFLE_SORT_USE_RADIXSORT),
175175
partitionWriterHandle
176176
)
177-
} else if (dep.shuffleWriterType == GpuHashShuffleWriterType) {
178-
shuffleWriterJniWrapper.createGpuHashShuffleWriter(
179-
numPartitions,
180-
dep.nativePartitioning.getShortName,
181-
GlutenShuffleUtils.getStartPartitionId(
182-
dep.nativePartitioning,
183-
taskContext.partitionId),
184-
nativeBufferSize,
185-
reallocThreshold,
186-
partitionWriterHandle
187-
)
188177
} else {
189178
shuffleWriterJniWrapper.createHashShuffleWriter(
190179
numPartitions,

cpp/core/jni/JniWrapper.cc

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,34 +1029,6 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_ShuffleWriterJniWrappe
10291029
JNI_METHOD_END(kInvalidObjectHandle)
10301030
}
10311031

1032-
JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_ShuffleWriterJniWrapper_createGpuHashShuffleWriter(
1033-
JNIEnv* env,
1034-
jobject wrapper,
1035-
jint numPartitions,
1036-
jstring partitioningNameJstr,
1037-
jint startPartitionId,
1038-
jint splitBufferSize,
1039-
jdouble splitBufferReallocThreshold,
1040-
jlong partitionWriterHandle) {
1041-
JNI_METHOD_START
1042-
1043-
const auto ctx = getRuntime(env, wrapper);
1044-
1045-
auto partitionWriter = ObjectStore::retrieve<PartitionWriter>(partitionWriterHandle);
1046-
if (partitionWriter == nullptr) {
1047-
throw GlutenException("Partition writer handle is invalid: " + std::to_string(partitionWriterHandle));
1048-
}
1049-
ObjectStore::release(partitionWriterHandle);
1050-
1051-
auto shuffleWriterOptions = std::make_shared<HashShuffleWriterOptions>(
1052-
toPartitioning(jStringToCString(env, partitioningNameJstr)),
1053-
startPartitionId,
1054-
splitBufferSize,
1055-
splitBufferReallocThreshold);
1056-
return ctx->saveObject(ctx->createShuffleWriter(numPartitions, partitionWriter, shuffleWriterOptions));
1057-
JNI_METHOD_END(kInvalidObjectHandle)
1058-
}
1059-
10601032
JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_ShuffleWriterJniWrapper_createSortShuffleWriter(
10611033
JNIEnv* env,
10621034
jobject wrapper,

cpp/core/shuffle/Options.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static constexpr int64_t kDefaultShuffleFileBufferSize = 32 << 10;
4646
static constexpr bool kDefaultEnableDictionary = false;
4747
static constexpr bool kDefaultEnableTypeAwareCompress = false;
4848

49-
enum class ShuffleWriterType { kHashShuffle, kSortShuffle, kRssSortShuffle, kGpuHashShuffle };
49+
enum class ShuffleWriterType { kHashShuffle, kSortShuffle, kRssSortShuffle };
5050

5151
enum class PartitionWriterType { kLocal, kRss };
5252

@@ -161,25 +161,6 @@ struct RssSortShuffleWriterOptions : ShuffleWriterOptions {
161161
compressionType(compressionType) {}
162162
};
163163

164-
struct GpuHashShuffleWriterOptions : HashShuffleWriterOptions {
165-
int32_t splitBufferSize = kDefaultShuffleWriterBufferSize;
166-
double splitBufferReallocThreshold = kDefaultSplitBufferReallocThreshold;
167-
168-
GpuHashShuffleWriterOptions() : HashShuffleWriterOptions(ShuffleWriterType::kGpuHashShuffle) {}
169-
170-
GpuHashShuffleWriterOptions(
171-
Partitioning partitioning,
172-
int32_t startPartitionId,
173-
int32_t partitionBufferSize,
174-
double partitionBufferReallocThreshold)
175-
: HashShuffleWriterOptions(
176-
ShuffleWriterType::kGpuHashShuffle,
177-
partitioning,
178-
startPartitionId,
179-
partitionBufferSize,
180-
partitionBufferReallocThreshold) {}
181-
};
182-
183164
struct LocalPartitionWriterOptions {
184165
int64_t shuffleFileBufferSize = kDefaultShuffleFileBufferSize; // spark.shuffle.file.buffer
185166
int32_t compressionBufferSize =

cpp/core/shuffle/ShuffleWriter.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace {
2424
const std::string kHashShuffleName = "hash";
2525
const std::string kSortShuffleName = "sort";
2626
const std::string kRssSortShuffleName = "rss_sort";
27-
const std::string kGpuHashShuffleName = "gpu_hash";
2827
} // namespace
2928

3029
ShuffleWriterType ShuffleWriter::stringToType(const std::string& typeString) {
@@ -37,9 +36,6 @@ ShuffleWriterType ShuffleWriter::stringToType(const std::string& typeString) {
3736
if (typeString == kRssSortShuffleName) {
3837
return ShuffleWriterType::kRssSortShuffle;
3938
}
40-
if (typeString == kGpuHashShuffleName) {
41-
return ShuffleWriterType::kGpuHashShuffle;
42-
}
4339
throw GlutenException("Unrecognized shuffle writer type: " + typeString);
4440
}
4541

@@ -51,8 +47,6 @@ std::string ShuffleWriter::typeToString(ShuffleWriterType type) {
5147
return kSortShuffleName;
5248
case ShuffleWriterType::kRssSortShuffle:
5349
return kRssSortShuffleName;
54-
case ShuffleWriterType::kGpuHashShuffle:
55-
return kGpuHashShuffleName;
5650
}
5751
GLUTEN_UNREACHABLE();
5852
}

cpp/velox/shuffle/VeloxShuffleReader.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,7 @@ void VeloxShuffleReader::createDeserializer(
967967
const std::shared_ptr<StreamReader>& streamReader,
968968
const OutputType& outputType) {
969969
switch (options_->shuffleWriterType) {
970-
case ShuffleWriterType::kHashShuffle:
971-
case ShuffleWriterType::kGpuHashShuffle: {
970+
case ShuffleWriterType::kHashShuffle: {
972971
if (outputType == OutputType::kCudfTable) {
973972
#ifdef GLUTEN_ENABLE_GPU
974973
VELOX_CHECK(!hasComplexType_);

cpp/velox/shuffle/VeloxShuffleWriter.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ arrow::Result<std::shared_ptr<VeloxShuffleWriter>> VeloxShuffleWriter::create(
3131
std::shared_ptr<VeloxShuffleWriter> shuffleWriter;
3232
switch (type) {
3333
case ShuffleWriterType::kHashShuffle:
34-
case ShuffleWriterType::kGpuHashShuffle:
3534
return VeloxHashShuffleWriter::create(numPartitions, std::move(partitionWriter), options, memoryManager);
3635
case ShuffleWriterType::kSortShuffle:
3736
return VeloxSortShuffleWriter::create(numPartitions, std::move(partitionWriter), options, memoryManager);

cpp/velox/tests/VeloxGpuShuffleWriterTest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ std::vector<GpuShuffleTestParams> getTestParams() {
152152
for (const auto mergeBufferSize : mergeBufferSizes) {
153153
for (const auto enableGpuAsyncReader : {false, true}) {
154154
params.push_back(GpuShuffleTestParams{
155-
.shuffleWriterType = ShuffleWriterType::kGpuHashShuffle,
155+
.shuffleWriterType = ShuffleWriterType::kHashShuffle,
156156
.partitionWriterType = PartitionWriterType::kLocal,
157157
.compressionType = compression,
158158
.compressionThreshold = compressionThreshold,
@@ -163,7 +163,7 @@ std::vector<GpuShuffleTestParams> getTestParams() {
163163

164164
// Rss.
165165
params.push_back(GpuShuffleTestParams{
166-
.shuffleWriterType = ShuffleWriterType::kGpuHashShuffle,
166+
.shuffleWriterType = ShuffleWriterType::kHashShuffle,
167167
.partitionWriterType = PartitionWriterType::kRss,
168168
.compressionType = compression,
169169
.compressionThreshold = compressionThreshold});
@@ -225,7 +225,7 @@ class GpuVeloxShuffleWriterTest : public ::testing::TestWithParam<GpuShuffleTest
225225
std::shared_ptr<ShuffleWriterOptions> options;
226226
const auto& params = GetParam();
227227
switch (params.shuffleWriterType) {
228-
case ShuffleWriterType::kGpuHashShuffle: {
228+
case ShuffleWriterType::kHashShuffle: {
229229
auto hashOptions = std::make_shared<HashShuffleWriterOptions>();
230230
hashOptions->splitBufferSize = splitBufferSize;
231231
options = hashOptions;

gluten-arrow/src/main/java/org/apache/gluten/vectorized/ShuffleWriterJniWrapper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ public native long createRssSortShuffleWriter(
6565
String codec,
6666
long partitionWriterHandle);
6767

68-
public native long createGpuHashShuffleWriter(
69-
int numPartitions,
70-
String partitioningName,
71-
int startPartitionId,
72-
int splitBufferSize,
73-
double splitBufferReallocThreshold,
74-
long partitionWriterHandle);
75-
7668
/**
7769
* Reclaim memory from the shuffle writer instance. It will first try to shrink allocated memory,
7870
* and may trigger a spill if needed.

0 commit comments

Comments
 (0)