Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Simple python experiment * Moved python lib * Added pyfaasm submodule * Added divide and conquer checker * More work on python bindings * Python benchmarks * Strict compilation errors * Pyfaasm * pyfaasm * Python input/output * Fiddling with numpy * numpy redis bytes * Updated pyfaasm * e2e python state * Test cases for python state * Updated pyfaasm * Python matrix multiplication function * More python chaining * Test for python chaining
- Loading branch information
Showing
87 changed files
with
464 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
LOG_LEVEL=debug | ||
CGROUP_MODE=off | ||
NETNS_MODE=off | ||
FS_MODE=on | ||
IBM_API_KEY= | ||
|
||
# Redis | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from pyfaasm.core import getFunctionIdx, getInput, chainThisWithInput, registerFunction, IS_NATIVE_PYTHON, awaitCall | ||
|
||
idx = getFunctionIdx() | ||
print("Got function index {}".format(idx)) | ||
|
||
|
||
def chainOne(input_bytes): | ||
expected = b'1234' | ||
print("Chained 1: {} {}".format(input_bytes, expected)) | ||
if input_bytes != expected: | ||
exit(1) | ||
|
||
|
||
def chainTwo(input_bytes): | ||
expected = b'5678' | ||
print("Chained 2: {} {}".format(input_bytes, expected)) | ||
if input_bytes != expected: | ||
exit(1) | ||
|
||
|
||
if IS_NATIVE_PYTHON: | ||
print("Running native python") | ||
registerFunction(1, chainOne) | ||
registerFunction(2, chainTwo) | ||
else: | ||
print("Not running native python") | ||
|
||
if idx == 0: | ||
print("Main chaining entry point") | ||
call_a = chainThisWithInput(1, b'1234') | ||
call_b = chainThisWithInput(2, b'5678') | ||
|
||
print("Awaiting calls {} and {}".format(call_a, call_b)) | ||
|
||
res_a = awaitCall(call_a) | ||
res_b = awaitCall(call_b) | ||
|
||
if res_a != 0 or res_b != 0: | ||
print("Chained functions failed: {} {}".format(res_a, res_b)) | ||
exit(1) | ||
|
||
elif idx == 1: | ||
chainOne(getInput()) | ||
|
||
elif idx == 2: | ||
chainTwo(getInput()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from pyfaasm.core import getInput, setOutput | ||
|
||
i = getInput() | ||
|
||
print("Got input {}".format(i)) | ||
|
||
setOutput(bytes(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
|
||
from pyfaasm.core import getFunctionIdx, getInput | ||
from pyfaasm.matrix import divide_and_conquer, distributed_divide_and_conquer, MATRIX_SIZE | ||
|
||
# This is the Faasm entry point. If we've been chained, | ||
# we need to invoke the worker, otherwise run the main function | ||
print("Getting function index for matrix multiplication") | ||
idx = getFunctionIdx() | ||
|
||
if idx == 0: | ||
print("Setting up matrix multiplication problem") | ||
# Set up the problem | ||
mat_a = np.random.rand(MATRIX_SIZE, MATRIX_SIZE) | ||
mat_b = np.random.rand(MATRIX_SIZE, MATRIX_SIZE) | ||
|
||
divide_and_conquer() | ||
else: | ||
# Run the worker | ||
print("Running matrix multiplication worker") | ||
input_bytes = getInput() | ||
print("Got input bytes: {}".format(input_bytes)) | ||
distributed_divide_and_conquer(input_bytes) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from pyfaasm.core import getState, getStateOffset | ||
|
||
key = "pyStateTest" | ||
valueLen = 10 | ||
expected = b'0199956789' | ||
|
||
# Check the full value | ||
actual = getState(key, valueLen) | ||
if actual != expected: | ||
msg = "Mismatch: actual {}, expected {})".format(actual, expected) | ||
print(msg) | ||
exit(1) | ||
|
||
# Check a couple of segments | ||
actualSegmentA = getStateOffset(key, valueLen, 0, 3) | ||
expectedA = b'019' | ||
if actualSegmentA != expectedA: | ||
msg = "Mismatched segment: actual {}, expected {})".format(actualSegmentA, expectedA) | ||
print(msg) | ||
exit(1) | ||
|
||
actualSegmentB = getStateOffset(key, valueLen, 4, 4) | ||
expectedB = b'9567' | ||
if actualSegmentB != expectedB: | ||
msg = "Mismatched segment: actual {}, expected {})".format(actualSegmentB, expectedB) | ||
print(msg) | ||
exit(1) | ||
|
||
print("Successful Python state reading check") |
Oops, something went wrong.