Skip to content

Commit

Permalink
Upgrade to LLVM 15 (exaloop#56)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
arshajii and inumanag authored Oct 14, 2022
1 parent a9fdefb commit e1016f9
Show file tree
Hide file tree
Showing 74 changed files with 3,092 additions and 7,593 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ jobs:
cp build/codon codon-deploy/bin/
cp build/libcodon*.${LIBEXT} codon-deploy/lib/codon/
cp build/libomp.${LIBEXT} codon-deploy/lib/codon/
if [ -e build/libunwind.${LIBEXT} ]; then cp build/libunwind.${LIBEXT} codon-deploy/lib/codon/; fi
cp -r build/include codon-deploy/
cp -r stdlib codon-deploy/lib/codon/
cp -r extra/python/dist/*.whl codon-deploy/
Expand Down
44 changes: 30 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)
project(
Codon
VERSION "0.14.0"
VERSION "0.15.0"
HOMEPAGE_URL "https://github.com/exaloop/codon"
DESCRIPTION "high-performance, extensible Python compiler")
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
Expand All @@ -28,6 +28,11 @@ endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
include_directories(.)

set(APPLE_ARM OFF)
if (APPLE AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
set(APPLE_ARM ON)
endif()

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(LLVM REQUIRED)
Expand Down Expand Up @@ -64,6 +69,9 @@ set(CODONRT_FILES codon/runtime/lib.h codon/runtime/lib.cpp
codon/runtime/gpu.cpp)
add_library(codonrt SHARED ${CODONRT_FILES})
add_dependencies(codonrt zlibstatic gc backtrace bz2 liblzma re2)
if(APPLE AND APPLE_ARM)
add_dependencies(codonrt unwind_shared)
endif()
target_include_directories(codonrt PRIVATE ${backtrace_SOURCE_DIR}
${re2_SOURCE_DIR}
"${gc_SOURCE_DIR}/include" runtime)
Expand Down Expand Up @@ -102,6 +110,13 @@ add_custom_command(
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:omp>
${CMAKE_BINARY_DIR})
if(APPLE AND APPLE_ARM)
add_custom_command(
TARGET codonrt
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:unwind_shared>
${CMAKE_BINARY_DIR})
endif()

# Codon compiler library
include_directories(${LLVM_INCLUDE_DIRS})
Expand Down Expand Up @@ -148,13 +163,6 @@ set(CODON_HPPFILES
codon/sir/flow.h
codon/sir/func.h
codon/sir/instr.h
codon/sir/llvm/coro/CoroCleanup.h
codon/sir/llvm/coro/CoroEarly.h
codon/sir/llvm/coro/CoroElide.h
codon/sir/llvm/coro/CoroInstr.h
codon/sir/llvm/coro/CoroInternal.h
codon/sir/llvm/coro/CoroSplit.h
codon/sir/llvm/coro/Coroutines.h
codon/sir/llvm/gpu.h
codon/sir/llvm/llvisitor.h
codon/sir/llvm/llvm.h
Expand Down Expand Up @@ -298,12 +306,6 @@ set(CODON_CPPFILES
codon/sir/flow.cpp
codon/sir/func.cpp
codon/sir/instr.cpp
codon/sir/llvm/coro/CoroCleanup.cpp
codon/sir/llvm/coro/CoroEarly.cpp
codon/sir/llvm/coro/CoroElide.cpp
codon/sir/llvm/coro/CoroFrame.cpp
codon/sir/llvm/coro/CoroSplit.cpp
codon/sir/llvm/coro/Coroutines.cpp
codon/sir/llvm/gpu.cpp
codon/sir/llvm/llvisitor.cpp
codon/sir/llvm/optimize.cpp
Expand Down Expand Up @@ -426,6 +428,20 @@ add_custom_target(
"${CMAKE_BINARY_DIR}/lib/codon")
add_dependencies(libs codonrt codonc)

if(APPLE AND APPLE_ARM)
add_custom_target(
libs_apple ALL
COMMENT "Collecting Apple-specific libraries"
BYPRODUCTS "${CMAKE_BINARY_DIR}/lib"
VERBATIM
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/lib/codon"
COMMAND
${CMAKE_COMMAND} -E copy
"${CMAKE_BINARY_DIR}/libunwind${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_BINARY_DIR}/lib/codon")
add_dependencies(libs_apple codonrt)
endif()

# Codon command-line tool
add_executable(codon codon/app/main.cpp)
target_link_libraries(codon PUBLIC ${STATIC_LIBCPP} codonc Threads::Threads)
Expand Down
55 changes: 55 additions & 0 deletions bench/float/float.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from math import sin, cos, sqrt
from time import time

POINTS = 10000000


class Point:
x: float
y: float
z: float

def __init__(self, i):
self.x = x = sin(i)
self.y = cos(i) * 3
self.z = (x * x) / 2

def __repr__(self):
return f"<Point: x={self.x}, y={self.y}, z={self.z}>"

def normalize(self):
x = self.x
y = self.y
z = self.z
norm = sqrt(x * x + y * y + z * z)
self.x /= norm
self.y /= norm
self.z /= norm

def maximize(self, other):
self.x = self.x if self.x > other.x else other.x
self.y = self.y if self.y > other.y else other.y
self.z = self.z if self.z > other.z else other.z
return self


def maximize(points):
next = points[0]
for p in points[1:]:
next = next.maximize(p)
return next


def benchmark(n):
points = [None] * n
for i in range(n):
points[i] = Point(i)
for p in points:
p.normalize()
return maximize(points)


t0 = time()
print(benchmark(POINTS))
t1 = time()
print(t1 - t0)
Loading

0 comments on commit e1016f9

Please sign in to comment.