Skip to content

Commit e1016f9

Browse files
arshajiiinumanag
andauthored
Upgrade to LLVM 15 (exaloop#56)
* Upgrade to LLVM 15 (WIP) * Call `setPresplitCoroutine()` on coro LLVM funcs * Use new pass manager * Update deps * Update docs * Fix exceptions on M1 * Add libunwind * Use Orc and JITLink for "codon run" * JITLink integration * Fix callback * Fix strbuf, fix GC root registration * Fix test init * Fix llvm function * Fix pickle, float atomics * Add TargetLibraryAnalysis * Use new LLVM pass manager in GPU codegen * Fix libunwind linking * Fix libunwind * Fix GPU passes * Don't link libunwind explicitly * Bump version * Update plugins for new pass manager * Fix bash error * Fix GPU GV extraction * Move simd module to experimental folder * Update file read * Add benchmark programs * Add dynamic tuple * Fix parser tuple slicing bug * Make DynamicTuple interoperable with Tuple * Fix DynamicTuple GPU interop * Dockerize builds * Simplify CMake * Revert "Simplify CMake" This reverts commit 08d2920. Co-authored-by: Ibrahim Numanagić <[email protected]>
1 parent a9fdefb commit e1016f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3092
-7593
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ jobs:
196196
cp build/codon codon-deploy/bin/
197197
cp build/libcodon*.${LIBEXT} codon-deploy/lib/codon/
198198
cp build/libomp.${LIBEXT} codon-deploy/lib/codon/
199+
if [ -e build/libunwind.${LIBEXT} ]; then cp build/libunwind.${LIBEXT} codon-deploy/lib/codon/; fi
199200
cp -r build/include codon-deploy/
200201
cp -r stdlib codon-deploy/lib/codon/
201202
cp -r extra/python/dist/*.whl codon-deploy/

CMakeLists.txt

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.14)
22
project(
33
Codon
4-
VERSION "0.14.0"
4+
VERSION "0.15.0"
55
HOMEPAGE_URL "https://github.com/exaloop/codon"
66
DESCRIPTION "high-performance, extensible Python compiler")
77
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
@@ -28,6 +28,11 @@ endif()
2828
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
2929
include_directories(.)
3030

31+
set(APPLE_ARM OFF)
32+
if (APPLE AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
33+
set(APPLE_ARM ON)
34+
endif()
35+
3136
set(THREADS_PREFER_PTHREAD_FLAG ON)
3237
find_package(Threads REQUIRED)
3338
find_package(LLVM REQUIRED)
@@ -64,6 +69,9 @@ set(CODONRT_FILES codon/runtime/lib.h codon/runtime/lib.cpp
6469
codon/runtime/gpu.cpp)
6570
add_library(codonrt SHARED ${CODONRT_FILES})
6671
add_dependencies(codonrt zlibstatic gc backtrace bz2 liblzma re2)
72+
if(APPLE AND APPLE_ARM)
73+
add_dependencies(codonrt unwind_shared)
74+
endif()
6775
target_include_directories(codonrt PRIVATE ${backtrace_SOURCE_DIR}
6876
${re2_SOURCE_DIR}
6977
"${gc_SOURCE_DIR}/include" runtime)
@@ -102,6 +110,13 @@ add_custom_command(
102110
POST_BUILD
103111
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:omp>
104112
${CMAKE_BINARY_DIR})
113+
if(APPLE AND APPLE_ARM)
114+
add_custom_command(
115+
TARGET codonrt
116+
POST_BUILD
117+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:unwind_shared>
118+
${CMAKE_BINARY_DIR})
119+
endif()
105120

106121
# Codon compiler library
107122
include_directories(${LLVM_INCLUDE_DIRS})
@@ -148,13 +163,6 @@ set(CODON_HPPFILES
148163
codon/sir/flow.h
149164
codon/sir/func.h
150165
codon/sir/instr.h
151-
codon/sir/llvm/coro/CoroCleanup.h
152-
codon/sir/llvm/coro/CoroEarly.h
153-
codon/sir/llvm/coro/CoroElide.h
154-
codon/sir/llvm/coro/CoroInstr.h
155-
codon/sir/llvm/coro/CoroInternal.h
156-
codon/sir/llvm/coro/CoroSplit.h
157-
codon/sir/llvm/coro/Coroutines.h
158166
codon/sir/llvm/gpu.h
159167
codon/sir/llvm/llvisitor.h
160168
codon/sir/llvm/llvm.h
@@ -298,12 +306,6 @@ set(CODON_CPPFILES
298306
codon/sir/flow.cpp
299307
codon/sir/func.cpp
300308
codon/sir/instr.cpp
301-
codon/sir/llvm/coro/CoroCleanup.cpp
302-
codon/sir/llvm/coro/CoroEarly.cpp
303-
codon/sir/llvm/coro/CoroElide.cpp
304-
codon/sir/llvm/coro/CoroFrame.cpp
305-
codon/sir/llvm/coro/CoroSplit.cpp
306-
codon/sir/llvm/coro/Coroutines.cpp
307309
codon/sir/llvm/gpu.cpp
308310
codon/sir/llvm/llvisitor.cpp
309311
codon/sir/llvm/optimize.cpp
@@ -426,6 +428,20 @@ add_custom_target(
426428
"${CMAKE_BINARY_DIR}/lib/codon")
427429
add_dependencies(libs codonrt codonc)
428430

431+
if(APPLE AND APPLE_ARM)
432+
add_custom_target(
433+
libs_apple ALL
434+
COMMENT "Collecting Apple-specific libraries"
435+
BYPRODUCTS "${CMAKE_BINARY_DIR}/lib"
436+
VERBATIM
437+
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/lib/codon"
438+
COMMAND
439+
${CMAKE_COMMAND} -E copy
440+
"${CMAKE_BINARY_DIR}/libunwind${CMAKE_SHARED_LIBRARY_SUFFIX}"
441+
"${CMAKE_BINARY_DIR}/lib/codon")
442+
add_dependencies(libs_apple codonrt)
443+
endif()
444+
429445
# Codon command-line tool
430446
add_executable(codon codon/app/main.cpp)
431447
target_link_libraries(codon PUBLIC ${STATIC_LIBCPP} codonc Threads::Threads)

bench/float/float.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from math import sin, cos, sqrt
2+
from time import time
3+
4+
POINTS = 10000000
5+
6+
7+
class Point:
8+
x: float
9+
y: float
10+
z: float
11+
12+
def __init__(self, i):
13+
self.x = x = sin(i)
14+
self.y = cos(i) * 3
15+
self.z = (x * x) / 2
16+
17+
def __repr__(self):
18+
return f"<Point: x={self.x}, y={self.y}, z={self.z}>"
19+
20+
def normalize(self):
21+
x = self.x
22+
y = self.y
23+
z = self.z
24+
norm = sqrt(x * x + y * y + z * z)
25+
self.x /= norm
26+
self.y /= norm
27+
self.z /= norm
28+
29+
def maximize(self, other):
30+
self.x = self.x if self.x > other.x else other.x
31+
self.y = self.y if self.y > other.y else other.y
32+
self.z = self.z if self.z > other.z else other.z
33+
return self
34+
35+
36+
def maximize(points):
37+
next = points[0]
38+
for p in points[1:]:
39+
next = next.maximize(p)
40+
return next
41+
42+
43+
def benchmark(n):
44+
points = [None] * n
45+
for i in range(n):
46+
points[i] = Point(i)
47+
for p in points:
48+
p.normalize()
49+
return maximize(points)
50+
51+
52+
t0 = time()
53+
print(benchmark(POINTS))
54+
t1 = time()
55+
print(t1 - t0)

0 commit comments

Comments
 (0)