Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin/Native and C/C++ support #68

Open
wants to merge 76 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
f5251e3
Just rename java files to kt
Krock21 Dec 21, 2020
07a056d
Apply java -> kt transformations
Krock21 Dec 21, 2020
ec0217d
Remove CachedVerifier and DummeSequentialSpecification kt files
Krock21 Dec 21, 2020
672bff0
Move some parts to common
Krock21 Dec 22, 2020
ff4da1d
Merge remote-tracking branch 'origin/develop' into move-to-common
Krock21 Dec 22, 2020
5f1b013
Add Boolean default gen to defaultGens
Krock21 Dec 22, 2020
ec07ae3
Move some parts to common
Krock21 Jan 8, 2021
de4f0dd
Move some parts(#2) to common
Krock21 Jan 9, 2021
39c055e
Move some parts to common(3), change sequentialSpecification internal…
Krock21 Jan 9, 2021
c60f93c
Fix tests, KClass<out Any> -> KClass<*>
Krock21 Jan 9, 2021
1a11040
move ValueResult and ExceptionResult in common
Krock21 Jan 19, 2021
1f0f968
Move LincheckFailure, InvocationResult, and Reporter to common
Krock21 Feb 1, 2021
945cc27
abstract SequentialSpecification, move LTS
Krock21 Feb 6, 2021
ac46f5b
move verifiers to common
Krock21 Feb 10, 2021
0c2b606
replace testClass: Class<*> by TestClass abstraction
Krock21 Feb 10, 2021
ec80ba5
Move Options to common, strange fixes for SequentialSpecification, Ve…
Krock21 Feb 11, 2021
069c0ba
move annotation to jvm, fix some unused expect-actual
Krock21 Feb 16, 2021
f6825ab
Get rid of WeakHashMap in CachedVerifier
ndkoval Feb 16, 2021
362e152
Get rid of WeakHashMap in QuiescentConsistencyVerifier
ndkoval Feb 16, 2021
cf0bd5f
Meeting changes
ndkoval Feb 16, 2021
5c1a4ef
fix last commit, break java api
Krock21 Feb 22, 2021
1ff8375
Move Runner and StressStrategy to common, make ParallelThreadsRunner …
Krock21 Feb 22, 2021
fb45647
Merge remote-tracking branch 'origin/develop' into java-to-kotlin
Krock21 Feb 22, 2021
a72dcef
add native platform, fix stable state
Krock21 Mar 16, 2021
71fce28
another stable state
Krock21 Mar 16, 2021
e723229
fix bug with many iterations
Krock21 Mar 16, 2021
1b4b001
change model, make it work
Krock21 Mar 28, 2021
78f60cf
Add native API, fix bugs, copy runner on every new iteration
Krock21 Mar 31, 2021
ac517e1
update gradle version to fix atomicFu problems, separate StressStrate…
Krock21 Mar 31, 2021
664e12c
add some tests
Krock21 Apr 13, 2021
43e8c0f
fix some tests
Krock21 Apr 13, 2021
0bdfbd7
update performance
Krock21 Apr 13, 2021
9eec6e4
reset runner on every invocation
Krock21 Apr 13, 2021
f4a7020
stable state with bug
Krock21 Apr 13, 2021
d99a355
Add more tests. Add exception handling. Improve code structure
Krock21 Apr 14, 2021
7b52e46
Add 2 simple tests
Krock21 Apr 14, 2021
563d50f
Add more tests. Reduce invocationsPerIteration to 500
Krock21 Apr 16, 2021
37d4951
change debug output. Add test names
Krock21 Apr 17, 2021
0d32c51
Change gradle version, add sharedLib to native project
Krock21 Apr 19, 2021
0c712f7
Add simple API for native
Krock21 Apr 19, 2021
310c889
Add simple c++ example
Krock21 Apr 19, 2021
44991e1
Improve API for native, add lincheck.h wrapper
Krock21 Apr 22, 2021
c421521
Update gradle wrapper version because of problems with atomicfu
Krock21 Apr 22, 2021
d39eed6
Add cppTest gradle task. Add GTEST tests. Improve C++ API. Fix toStri…
Krock21 Apr 23, 2021
7686f24
Add init and finish thread functions
Krock21 Apr 24, 2021
0c59a61
Add libcds msqueue test
Krock21 Apr 24, 2021
bd71267
useless commit
ndkoval Apr 26, 2021
a1d7f64
minor fixes
Krock21 Apr 28, 2021
41e24e7
Merge remote-tracking branch 'origin/java-to-kotlin' into java-to-kotlin
Krock21 Apr 28, 2021
ba00819
Add junction and torf cpp example
Krock21 Apr 28, 2021
fd32a2b
Add libcuckoo test, some fixes in lincheck
Krock21 Apr 28, 2021
53edf81
Add folly ConcurrentHashMap test
Krock21 Apr 28, 2021
a96b940
Add boost::lockfree::queue test, fix bugs in Lincheck
Krock21 Apr 29, 2021
c5163ab
enable libcuckoo_test
Krock21 Apr 29, 2021
962fb29
Fix memory issue
Krock21 Apr 30, 2021
027abc3
Fix git submodules, add progress debug output
Krock21 May 3, 2021
a50b8f7
switch from debugShared to releaseShared
Krock21 May 3, 2021
74d164e
fix test_failing test
Krock21 May 3, 2021
949eb7f
increase iterations count in AbstractLincheckStressTest
Krock21 May 3, 2021
e3350e9
set up parameters for tests
Krock21 May 3, 2021
a90e7e8
Add more c++ tests
Krock21 May 5, 2021
97650e8
Add operation groups to native, add NonParallelOpGroupTest, add boost…
Krock21 May 6, 2021
b5c5f46
Improve tests stability
Krock21 May 6, 2021
f41271e
Improve NonParallelOpGroupTest stability
Krock21 May 6, 2021
8dc92a5
Fix UnexpecedExceptionTest
Krock21 May 6, 2021
2029c5f
Fix UnexpecedExceptionTest with atomic
Krock21 May 6, 2021
ce7560b
Fix HashMapTest possible IllegalStateException
Krock21 May 6, 2021
db71d4a
Fix HashMapTest possible UnexpectedExceptionFailure(IllegalStateExcep…
Krock21 May 6, 2021
d30852b
Attempt to fix UnexpectedExceptionTest
Krock21 May 6, 2021
e71ad98
Add ValidationTest
Krock21 May 8, 2021
4a27867
Add EpsilonVerifierTest
Krock21 May 8, 2021
bba9648
add scenario finalization, minor fixes
Krock21 May 12, 2021
d8993d4
Add import
Krock21 May 12, 2021
b8bcfee
Fix OpGroupTests
Krock21 May 12, 2021
faed7ed
improve cpp tests and fix some bugs
Krock21 May 30, 2021
65d46c7
Merge develop into java-to-kotlin
Krock21 Jul 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cpp/libcuckoo/libcuckoo"]
path = cpp/libcuckoo/libcuckoo
url = https://github.com/efficient/libcuckoo
65 changes: 64 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import org.gradle.jvm.tasks.Jar

allprojects {
ext {
set("hostManager", org.jetbrains.kotlin.konan.target.HostManager())
}
}

// atomicfu
buildscript {
val atomicfuVersion: String by project
Expand All @@ -9,6 +15,8 @@ buildscript {
}
apply(plugin = "kotlinx-atomicfu")

apply(from = rootProject.file("gradle/native-targets.gradle"))

plugins {
java
kotlin("multiplatform")
Expand Down Expand Up @@ -36,6 +44,34 @@ kotlin {
}

sourceSets {
val commonMain by getting {
kotlin.srcDir("src/common/main")

val kotlinVersion: String by project
val kotlinxCoroutinesVersion: String by project
val asmVersion: String by project
val reflectionsVersion: String by project
dependencies {
api("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
api("org.ow2.asm:asm-commons:$asmVersion")
api("org.ow2.asm:asm-util:$asmVersion")
api("org.reflections:reflections:$reflectionsVersion")
}
}

val commonTest by getting {
kotlin.srcDir("src/common/test")

val kotlinVersion: String by project
dependencies {
implementation(kotlin("test-common", kotlinVersion))
implementation(kotlin("test-annotations-common", kotlinVersion))
}
}

val jvmMain by getting {
kotlin.srcDir("src/jvm/main")

Expand Down Expand Up @@ -80,6 +116,11 @@ sourceSets.test {
java.srcDirs("src/jvm/test")
}

tasks.wrapper {
gradleVersion = "6.7.1"
distributionType = Wrapper.DistributionType.ALL
}

tasks {
// empty xxx-javadoc.jar
register<Jar>("javadocJar") {
Expand All @@ -89,7 +130,7 @@ tasks {
withType<Test> {
maxParallelForks = 1
jvmArgs("--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports", "java.base/jdk.internal.util=ALL-UNNAMED")
"--add-exports", "java.base/jdk.internal.util=ALL-UNNAMED")
}

withType<Jar> {
Expand All @@ -104,6 +145,28 @@ tasks {
}
}

tasks.register("cppTest") {
dependsOn("linkNative")
doLast {
exec {
workingDir("cpp")
commandLine("mkdir", "-p", "build")
}
exec {
workingDir("cpp/build")
commandLine("cmake", "..")
}
exec {
workingDir("cpp/build")
commandLine("make")
}
exec {
workingDir("cpp/build")
commandLine("ctest", "--output-on-failure")
}
}
}

publishing {
publications.withType<MavenPublication> {
// add empty javadoc
Expand Down
97 changes: 97 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
cmake_minimum_required(VERSION 3.16)
project(lincheck_test)

set(CMAKE_CXX_STANDARD 17)

# add lincheck shared library
add_library(lincheck_library SHARED IMPORTED GLOBAL)
if(EXISTS "${PROJECT_SOURCE_DIR}/../build/bin/native/releaseShared/libnative.so") #linux .so
set_target_properties(lincheck_library PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../build/bin/native/releaseShared/libnative.so")
else() # mac .dylib
set_target_properties(lincheck_library PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/../build/bin/native/releaseShared/libnative.dylib")
endif()

# add gtest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# add libcds
FetchContent_Declare(
libcds
GIT_REPOSITORY https://github.com/khizmax/libcds
GIT_TAG master
GIT_SHALLOW TRUE
)

FetchContent_GetProperties(libcds)
if (NOT libcds_POPULATED)
FetchContent_Populate(libcds)
add_subdirectory(${libcds_SOURCE_DIR} ${libcds_BINARY_DIR})
endif ()

# add folly
FetchContent_Declare(
folly
GIT_REPOSITORY https://github.com/facebook/folly
GIT_TAG master
GIT_SHALLOW TRUE
)

FetchContent_GetProperties(folly)
if (NOT folly_POPULATED)
FetchContent_Populate(folly)
add_subdirectory(${folly_SOURCE_DIR} ${folly_BINARY_DIR})
endif ()

# add libcuckoo
FetchContent_Declare(
libcuckoo
GIT_REPOSITORY https://github.com/efficient/libcuckoo
GIT_TAG master
GIT_SHALLOW TRUE
)

FetchContent_GetProperties(libcuckoo)
if (NOT libcuckoo_POPULATED)
FetchContent_Populate(libcuckoo)
add_subdirectory(${libcuckoo_SOURCE_DIR} ${libcuckoo_BINARY_DIR})
include_directories(${libcuckoo_SOURCE_DIR})
endif ()

# add boost
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED COMPONENTS thread program_options)

add_executable(
tests
counter_test.cpp
libcds_test.cpp
libcuckoo_test.cpp
folly_test.cpp
boost_lockfree_test.cpp
)

enable_testing()

target_link_libraries(tests gtest_main)
target_link_libraries(tests gmock_main)
target_link_libraries(tests lincheck_library)
target_link_libraries(tests cds)
target_link_libraries(tests libcuckoo)
target_link_libraries(tests folly)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
include_directories(${Boost_INCLUDE_DIR} ${BOOST_LOCKFREE_DIR})
target_link_libraries(tests ${Boost_LIBRARIES})

include(GoogleTest)
gtest_discover_tests(tests)
8 changes: 8 additions & 0 deletions cpp/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
In the kotlinx-lincheck directory run `./gradlew linkNative`. It generates `build/bin/native/debugShared` and `build/bin/native/releaseShared`

Run this as a CMake application
1. `mkdir build`
2. `cd build`
3. `cmake ..`
4. `make`
5. `./lincheck_test`
Loading