Skip to content

Commit

Permalink
Breeze fixes (#11537)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #11537

Reviewed By: xiaoxmeng

Differential Revision: D66022781

Pulled By: Yuhta

fbshipit-source-id: 2ac480e11fd1e75374f0252e0f3d1fe6acfaa296
  • Loading branch information
David Reveman authored and facebook-github-bot committed Nov 15, 2024
1 parent c21020c commit 31ae379
Show file tree
Hide file tree
Showing 31 changed files with 143 additions and 86 deletions.
2 changes: 1 addition & 1 deletion velox/experimental/breeze/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ endif()

if(NOT DISABLE_GOOGLETEST)
set(GTest_SOURCE AUTO)
resolve_dependency(GTest)
velox_resolve_dependency(GTest)
endif()

if(BUILD_TESTING)
Expand Down
18 changes: 13 additions & 5 deletions velox/experimental/breeze/breeze/platforms/openmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ struct supported_type<float> {
static float min() { return __FLT_MIN__; }
static float max() { return __FLT_MAX__; }
static float atomic_load(float *address) {
unsigned value = __atomic_load_n(reinterpret_cast<unsigned *>(address),
__ATOMIC_RELAXED);
return *reinterpret_cast<float *>(&value);
union {
float value;
unsigned raw;
} content;
content.raw = __atomic_load_n(reinterpret_cast<unsigned *>(address),
__ATOMIC_RELAXED);
return content.value;
}
static void atomic_store(float *address, float value) {
__atomic_store_n(reinterpret_cast<unsigned *>(address),
Expand All @@ -166,9 +170,13 @@ struct supported_type<double> {
static double min() { return __DBL_MIN__; }
static double max() { return __DBL_MAX__; }
static double atomic_load(double *address) {
unsigned long long value = __atomic_load_n(
union {
double value;
unsigned long long raw;
} content;
content.raw = __atomic_load_n(
reinterpret_cast<unsigned long long *>(address), __ATOMIC_RELAXED);
return *reinterpret_cast<double *>(&value);
return content.value;
}
static void atomic_store(double *address, double value) {
__atomic_store_n(reinterpret_cast<unsigned long long *>(address),
Expand Down
6 changes: 6 additions & 0 deletions velox/experimental/breeze/breeze/utils/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

#if TRACING

// Workaround for CUDA/HIP PERFETTO_NO_INLINE conflict
#ifdef __noinline__
#undef __noinline__
#define __noinline__ noinline
#endif

#include <perfetto.h>

#include <condition_variable>
Expand Down
10 changes: 3 additions & 7 deletions velox/experimental/breeze/cmake/cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if(NOT DEFINED CMAKE_NVCC_FLAGS)
set(CMAKE_NVCC_FLAGS
"$ENV{NVCCFLAGS}"
CACHE STRING "NVCC flags")
else()
set(CMAKE_NVCC_FLAGS
"-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_90,code=sm_90"
CACHE STRING "NVCC flags")
endif()
endif()
if(BREEZE_BUILD_TYPE MATCHES Debug)
Expand Down Expand Up @@ -54,7 +50,7 @@ endif()
# use PTX specialization by default for CUDA
if(NOT DEFINED CUDA_PLATFORM_SPECIALIZATION_HEADER)
set(CUDA_PLATFORM_SPECIALIZATION_HEADER
platforms/specialization/cuda-ptx.cuh
breeze/platforms/specialization/cuda-ptx.cuh
CACHE STRING "CUDA platform specialization header")
endif()

Expand Down Expand Up @@ -87,8 +83,8 @@ function(breeze_add_cuda_test target source)
"FLAGS;LIBS;DEPENDS"
${ARGN})
list(APPEND arg_FLAGS -I${gtest_SOURCE_DIR}/googletest/include)
list(APPEND arg_FLAGS -I${CMAKE_SOURCE_DIR}/test)
list(APPEND arg_FLAGS -I${CMAKE_CURRENT_BINARY_DIR})
list(APPEND arg_FLAGS -I${CMAKE_SOURCE_DIR})
list(APPEND arg_FLAGS -I${CMAKE_BINARY_DIR})
breeze_add_cuda_object(
${target}
${source}
Expand Down
7 changes: 3 additions & 4 deletions velox/experimental/breeze/cmake/hip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ function(breeze_add_hip_test target source)
OUTPUT ${target}.o
COMMAND
${HIPCC_EXECUTABLE} ${HIP_HIPCC_FLAGS} ${NDEBUG_DEFINE} -DPLATFORM_HIP
-I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/test
-I${gtest_SOURCE_DIR}/googletest/include -I${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CXX_FLAGS} ${COMPILER_WARN_FLAGS} ${OPT_FLAGS} -std=c++17 -c
${source} -MD -MF ${target}.o.d -o ${target}.o
-I${CMAKE_SOURCE_DIR} -I${gtest_SOURCE_DIR}/googletest/include
-I${CMAKE_BINARY_DIR} ${CMAKE_CXX_FLAGS} ${COMPILER_WARN_FLAGS}
${OPT_FLAGS} -std=c++17 -c ${source} -MD -MF ${target}.o.d -o ${target}.o
DEPFILE ${target}.o.d
DEPENDS ${arg_DEPENDS}
COMMENT "Building HIP object ${target}.o")
Expand Down
7 changes: 3 additions & 4 deletions velox/experimental/breeze/cmake/metal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ function(breeze_add_metal_test_kernels target source)
OUTPUT ${target}.air
COMMAND
xcrun -sdk macosx metal -DPLATFORM_METAL -I${CMAKE_SOURCE_DIR}
-I${CMAKE_CURRENT_BINARY_DIR} ${WARN_FLAGS} ${OPT_FLAGS}
-Wno-c++17-extensions -std=metal3.0 -c ${source} -MD -MF ${target}.air.d
-o ${target}.air
-I${CMAKE_BINARY_DIR} ${WARN_FLAGS} ${OPT_FLAGS} -Wno-c++17-extensions
-std=metal3.0 -c ${source} -MD -MF ${target}.air.d -o ${target}.air
COMMENT "Compile ${source} --> ${target}.air"
DEPENDS ${arg_DEPENDS}
DEPFILE ${target}.air.d)
Expand All @@ -44,7 +43,7 @@ endfunction()
function(breeze_add_metal_test target source shaderlib)
add_executable(${target} ${source} platforms/metal_test.mm)
target_compile_features(${target} PRIVATE cxx_std_17)
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${target} PRIVATE ${CMAKE_BINARY_DIR})
target_compile_definitions(${target} PUBLIC PLATFORM_METAL=1
SHADER_LIB=\"${shaderlib}\")
target_compile_options(
Expand Down
4 changes: 2 additions & 2 deletions velox/experimental/breeze/cmake/opencl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function(breeze_add_opencl_test_kernels target source)
OUTPUT ${target}.so
COMMAND
${CLCC_EXECUTABLE} -o ${target}.so ${source} -MD -MF ${target}.clcpp.d
-DPLATFORM_OPENCL -I${CMAKE_SOURCE_DIR} -I${CMAKE_CURRENT_BINARY_DIR}
-DPLATFORM_OPENCL -I${CMAKE_SOURCE_DIR} -I${CMAKE_BINARY_DIR}
${COMPILER_WARN_FLAGS} ${OPT_FLAGS}
COMMENT "Building OpenCL kernels ${source} --> ${target}.so"
DEPENDS ${arg_DEPENDS}
Expand All @@ -41,7 +41,7 @@ function(breeze_add_opencl_test target source shaderlib)
add_executable(${target} ${source})
target_compile_features(${target} PRIVATE cxx_std_17)
target_include_directories(${target} PRIVATE ${CMAKE_OPENCL_INCLUDE}
${CMAKE_CURRENT_BINARY_DIR})
${CMAKE_BINARY_DIR})
target_compile_definitions(${target} PUBLIC PLATFORM_OPENCL=1
SHADER_LIB=\"${shaderlib}\")
target_compile_options(${target} PRIVATE ${WARN_FLAGS} ${OPT_FLAGS}
Expand Down
8 changes: 4 additions & 4 deletions velox/experimental/breeze/cmake/sycl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ function(breeze_add_sycl_test target source)
OUTPUT ${target}.o
COMMAND
${SYCLCC_EXECUTABLE} ${NDEBUG_DEFINE} -DPLATFORM_SYCL
-I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/test
-I${gtest_SOURCE_DIR}/googletest/include -I${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CXX_FLAGS} ${OPT_FLAGS} ${SANITIZE_COMPILE_FLAGS} -std=c++17 -c
${source} -MD -MF ${target}.o.d -o ${target}.o
-I${CMAKE_SOURCE_DIR} -I${gtest_SOURCE_DIR}/googletest/include
-I${CMAKE_BINARY_DIR} ${CMAKE_CXX_FLAGS} ${OPT_FLAGS}
${SANITIZE_COMPILE_FLAGS} -std=c++17 -c ${source} -MD -MF ${target}.o.d -o
${target}.o
DEPFILE ${target}.o.d
DEPENDS ${arg_DEPENDS}
COMMENT "Building SYCL object ${target}.o")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#include <limits>
#include <vector>

#include "algorithms/reduce.h"
#include "breeze/algorithms/reduce.h"
#include "breeze/platforms/platform.h"
#include "breeze/utils/device_vector.h"
#include "perftest/perftest.h"
#include "platforms/platform.h"
#include "utils/device_vector.h"

namespace breeze {

Expand Down
14 changes: 7 additions & 7 deletions velox/experimental/breeze/perftest/algorithms/scan_perftest.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

#include <vector>

#include "algorithms/scan.h"
#include "functions/load.h"
#include "functions/scan.h"
#include "functions/store.h"
#include "breeze/algorithms/scan.h"
#include "breeze/functions/load.h"
#include "breeze/functions/scan.h"
#include "breeze/functions/store.h"
#include "breeze/platforms/platform.h"
#include "breeze/utils/block_details.h"
#include "breeze/utils/device_vector.h"
#include "perftest/perftest.h"
#include "platforms/platform.h"
#include "utils/block_details.h"
#include "utils/device_vector.h"

namespace breeze {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include <climits>
#include <vector>

#include "algorithms/sort.h"
#include "breeze/algorithms/sort.h"
#include "breeze/platforms/platform.h"
#include "breeze/utils/block_details.h"
#include "breeze/utils/device_vector.h"
#include "perftest/perftest.h"
#include "platforms/platform.h"
#include "utils/block_details.h"
#include "utils/device_vector.h"

namespace breeze {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

#include <vector>

#include "functions/reduce.h"
#include "breeze/functions/reduce.h"
#include "breeze/platforms/platform.h"
#include "breeze/utils/device_vector.h"
#include "perftest/perftest.h"
#include "platforms/platform.h"
#include "utils/device_vector.h"

namespace breeze {

Expand Down
6 changes: 3 additions & 3 deletions velox/experimental/breeze/perftest/functions/scan_perftest.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

#include <vector>

#include "functions/scan.h"
#include "breeze/functions/scan.h"
#include "breeze/platforms/platform.h"
#include "breeze/utils/device_vector.h"
#include "perftest/perftest.h"
#include "platforms/platform.h"
#include "utils/device_vector.h"

namespace breeze {

Expand Down
8 changes: 4 additions & 4 deletions velox/experimental/breeze/perftest/functions/sort_perftest.cu
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include <limits>
#include <vector>

#include "functions/sort.h"
#include "breeze/functions/sort.h"
#include "breeze/platforms/platform.h"
#include "breeze/utils/device_vector.h"
#include "breeze/utils/types.h"
#include "perftest/perftest.h"
#include "platforms/platform.h"
#include "utils/device_vector.h"
#include "utils/types.h"

namespace breeze {

Expand Down
4 changes: 2 additions & 2 deletions velox/experimental/breeze/perftest/perftest-cuda.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <regex>
#include <string>

#include "platforms/cuda.cuh"
#include "utils/trace.h"
#include "breeze/platforms/cuda.cuh"
#include "breeze/utils/trace.h"

namespace breeze {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
#include <memory>

#ifdef __EXCEPTIONS
#include "utils/types.h"
#include "breeze/utils/types.h"
#else
#include <iostream>
#endif

#include "platforms/cuda.cuh"
#include "breeze/platforms/cuda.cuh"

// caching device allocator that can be used to eliminate
// allocation cost from benchmarks by handling all neccessary
Expand Down
4 changes: 2 additions & 2 deletions velox/experimental/breeze/perftest/queries/device_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#pragma once

#include "utils/device_allocator.h"
#include "utils/device_vector.h"
#include "breeze/utils/device_allocator.h"
#include "breeze/utils/device_vector.h"

namespace breeze {

Expand Down
16 changes: 8 additions & 8 deletions velox/experimental/breeze/perftest/queries/order_by_perftest.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
#include <string>
#include <vector>

#include "algorithms/sort.h"
#include "functions/load.h"
#include "functions/reduce.h"
#include "functions/scan.h"
#include "functions/store.h"
#include "breeze/algorithms/sort.h"
#include "breeze/functions/load.h"
#include "breeze/functions/reduce.h"
#include "breeze/functions/scan.h"
#include "breeze/functions/store.h"
#include "breeze/platforms/cuda.cuh"
#include "breeze/utils/device_vector.h"
#include "breeze/utils/types.h"
#include "perftest/perftest.h"
#include "perftest/queries/caching_device_allocator.cuh"
#include "perftest/queries/device_column.h"
#include "platforms/cuda.cuh"
#include "utils/device_vector.h"
#include "utils/types.h"

namespace breeze {
namespace test {
Expand Down
2 changes: 2 additions & 0 deletions velox/experimental/breeze/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

include_directories(${CMAKE_SOURCE_DIR})

cxx_library(test_main "${cxx_strict}" test_main.cpp)
target_link_libraries(
test_main
Expand Down
2 changes: 1 addition & 1 deletion velox/experimental/breeze/test/algorithms/kernels.clcpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

enum { OPENCL_WARP_THREADS = 32 };

#include "generated/algorithms/kernels-opencl.h"
#include "test/generated/algorithms/kernels-opencl.h"

// kernel specializations

Expand Down
2 changes: 1 addition & 1 deletion velox/experimental/breeze/test/algorithms/kernels.metal
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "generated/algorithms/kernels-metal.h"
#include "test/generated/algorithms/kernels-metal.h"

// kernel specializations

Expand Down
2 changes: 1 addition & 1 deletion velox/experimental/breeze/test/functions/kernels.clcpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "generated/functions/kernels-opencl.h"
#include "test/generated/functions/kernels-opencl.h"

// kernel specializations

Expand Down
2 changes: 1 addition & 1 deletion velox/experimental/breeze/test/functions/kernels.metal
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "generated/functions/kernels-metal.h"
#include "test/generated/functions/kernels-metal.h"

// kernel specializations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <gtest/gtest.h>

#include <algorithm>
#include <numeric>

#include "function_test.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
* limitations under the License.
*/

// Copyright (c) 2024 by Rivos Inc.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2024 by Rivos Inc.
* Licensed under the Apache License, Version 2.0, see LICENSE for details.
* SPDX-License-Identifier: Apache-2.0
*/

/*
* This file is auto-generated from test_fixture_generator.py
* DO NOT EDIT!
*/

#include <gtest/gtest.h>
#include <omp.h>
Expand Down
Loading

0 comments on commit 31ae379

Please sign in to comment.