Skip to content

Commit 12ef6d7

Browse files
committed
highway support attempt
1 parent c5d3cb5 commit 12ef6d7

File tree

11 files changed

+632013
-631911
lines changed

11 files changed

+632013
-631911
lines changed

CMakeLists.txt

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
88
set(CMAKE_CXX_EXTENSIONS ON)
99
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
1010
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
11+
set(CMAKE_COLOR_DIAGNOSTICS ON)
1112

1213

1314

1415
# Make the default build type Release. If user or another
1516
# project sets a different value than use that
1617
if(NOT CMAKE_BUILD_TYPE)
17-
message(STATUS "Setting build type to default -- Release")
18-
set(CMAKE_BUILD_TYPE "Release" CACHE
18+
message(STATUS "Setting build type to default -- Debug")
19+
set(CMAKE_BUILD_TYPE "Debug" CACHE
1920
STRING "Choose the type of build." FORCE)
2021
endif()
2122
message(STATUS "GraphZeppelin Build Type: ${CMAKE_BUILD_TYPE}")
@@ -51,6 +52,7 @@ else()
5152
message (STATUS "GraphZeppelin building executables")
5253
endif()
5354

55+
5456
# Get GutterTree Project
5557
FetchContent_Declare(
5658
GutterTree
@@ -67,6 +69,22 @@ FetchContent_Declare(
6769
GIT_TAG main
6870
)
6971

72+
FetchContent_Declare(
73+
highway
74+
75+
GIT_REPOSITORY https://github.com/google/highway.git
76+
GIT_TAG 1.2.0
77+
)
78+
79+
set(HWY_ENABLE_EXAMPLES OFF CACHE INTERNAL "Disable highway examples")
80+
set(HWY_ENABLE_TESTS OFF CACHE INTERNAL "Disable highway tests")
81+
82+
# Get google highway
83+
FetchContent_MakeAvailable(highway)
84+
85+
# Ensure highway target is explicitly added
86+
add_library(highway INTERFACE IMPORTED)
87+
7088
if (BUILD_BENCH)
7189
# Get Google Benchmark
7290
FetchContent_Declare(
@@ -81,7 +99,7 @@ if (BUILD_BENCH)
8199
endif()
82100

83101

84-
FetchContent_MakeAvailable(GutterTree StreamingUtilities )
102+
FetchContent_MakeAvailable(GutterTree StreamingUtilities)
85103

86104
# AVAILABLE COMPILATION DEFINITIONS:
87105
# VERIFY_SAMPLES_F Use a deterministic connected-components
@@ -103,8 +121,8 @@ add_library(GraphZeppelin
103121
src/sketch.cpp
104122
src/recovery.cpp
105123
src/util.cpp)
106-
add_dependencies(GraphZeppelin GutterTree StreamingUtilities)
107-
target_link_libraries(GraphZeppelin PUBLIC xxhash GutterTree StreamingUtilities )
124+
add_dependencies(GraphZeppelin GutterTree StreamingUtilities highway)
125+
target_link_libraries(GraphZeppelin PUBLIC xxhash GutterTree StreamingUtilities highway)
108126
target_include_directories(GraphZeppelin PUBLIC include/)
109127
target_compile_options(GraphZeppelin PUBLIC -fopenmp)
110128
target_link_options(GraphZeppelin PUBLIC -fopenmp)
@@ -119,8 +137,8 @@ add_library(GraphZeppelinVerifyCC
119137
src/recovery.cpp
120138
src/util.cpp
121139
test/util/graph_verifier.cpp)
122-
add_dependencies(GraphZeppelinVerifyCC GutterTree StreamingUtilities)
123-
target_link_libraries(GraphZeppelinVerifyCC PUBLIC xxhash GutterTree StreamingUtilities )
140+
add_dependencies(GraphZeppelinVerifyCC GutterTree StreamingUtilities highway)
141+
target_link_libraries(GraphZeppelinVerifyCC PUBLIC xxhash GutterTree StreamingUtilities highway )
124142
target_include_directories(GraphZeppelinVerifyCC PUBLIC include/ include/test/)
125143
target_compile_options(GraphZeppelinVerifyCC PUBLIC -fopenmp)
126144
target_link_options(GraphZeppelinVerifyCC PUBLIC -fopenmp)

include/sketch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
#include <cmath>
99
#include <mutex>
1010

11+
#include <hwy/highway.h>
12+
#include <hwy/aligned_allocator.h>
13+
1114
#include "util.h"
1215
#include "bucket.h"
1316

1417
#include "bucket_buffer.h"
1518

19+
20+
// FOR VECTORIZING CONTIGUOUS XOR
21+
1622
// enum SerialType {
1723
// FULL,
1824
// RANGE,

include/util.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
#pragma once
22
#include <string>
33
#include <tuple>
4+
#include <iostream>
45

56
#include "types.h"
67

8+
#include <hwy/highway.h>
9+
10+
11+
HWY_BEFORE_NAMESPACE();
12+
namespace hwy {
13+
namespace HWY_NAMESPACE {
14+
static inline void simd_xor(uint32_t* dst, const uint32_t* src, size_t count) {
15+
using namespace hwy;
16+
const ScalableTag<uint32_t> d;
17+
for (size_t i = 0; i < count; i += Lanes(d)) {
18+
auto v_dst = LoadU(d, dst + i);
19+
auto v_src = LoadU(d, src + i);
20+
auto v_xor = Xor(v_dst, v_src);
21+
StoreU(v_xor, d, dst + i);
22+
}
23+
}
24+
static inline void simd_xor_aligned(uint32_t* dst, const uint32_t* src, size_t count) {
25+
using namespace hwy;
26+
const ScalableTag<uint32_t> d;
27+
for (size_t i = 0; i < count; i += Lanes(d)) {
28+
auto v_dst = Load(d, dst + i);
29+
auto v_src = Load(d, src + i);
30+
auto v_xor = Xor(v_dst, v_src);
31+
Store(v_xor, d, dst + i);
32+
}
33+
}
34+
} // namespace HWY_NAMESPACE
35+
} // namespace hwy
36+
HWY_AFTER_NAMESPACE();
37+
38+
739
/**
840
* Cast a double to unsigned long long with epsilon adjustment.
941
* @param d the double to cast.

0 commit comments

Comments
 (0)