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

taskvine: add example for building and testing C api #25

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ jobs:
- name: Test Vine Serverless Mode
run: ./test-vine-serverless.sh

vine-throughput-capi-job:
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test Vine Throughput Test C API
run: ./test-vine-task-throughput-capi.sh

parrot-cvmfs-job:
runs-on: ubuntu-20.04
timeout-minutes: 10
Expand Down
11 changes: 11 additions & 0 deletions test-vine-task-throughput-capi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# Build the sources from github
. ./install-github.sh

# Compile C API test using environment
gcc test-vine-task-throughput.c -o test-vine-task-throughput -I $PREFIX/include/cctools/ -L $PREFIX/lib -ltaskvine -ldttools -lm -lcrypto -lssl -lz

./test-vine-task-throughput &

vine_worker localhost 9123 --single-shot
50 changes: 50 additions & 0 deletions test-vine-task-throughput.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "taskvine.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>

int main(int argc, char *argv[])
{
struct vine_manager *m;
struct vine_task *t;
int i;
int tasksC = 5000;

//Create the manager. All tasks and files will be declared with respect to
m = vine_create(9123);
if(!m) {
printf("couldn't create manager: %s\n", strerror(errno));
return 1;
}
printf("TaskVine listening on %d\n", vine_port(m));
printf("Declaring tasks...");

for(i=0;i<tasksC;i++) {
struct vine_task *t = vine_task_create(":");
vine_task_set_cores(t, 1);
int task_id = vine_submit(m, t);
}

printf("waiting for tasks to complete...\n");
clock_t start = clock();
while(!vine_empty(m)) {
t = vine_wait(m, 5);
if(t) {
vine_task_delete(t);
}
}
clock_t end = clock();
double time = ((double)(end - start)) / CLOCKS_PER_SEC;
double throughput = tasksC / time;
printf("all tasks complete!\n");
printf("Time was %f seconds\n", time);
printf("Throughput was %f tasks per second\n", throughput);
//Free the manager structure, and release all the workers.
vine_delete(m);

return 0;
}
Loading