-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
from jwt import JWT, jwk_from_pem | ||
import time | ||
import requests | ||
|
||
pem = "aalp-self-hosted-runner.2024-06-21.private-key.pem" | ||
client_id = "Iv23lixzRYO8eKFZQCxt" | ||
installation_id = "52081584" # Replace with your actual installation ID | ||
|
||
# Open PEM | ||
with open(pem, 'rb') as pem_file: | ||
signing_key = jwk_from_pem(pem_file.read()) | ||
|
||
payload = { | ||
# Issued at time | ||
'iat': int(time.time()), | ||
# JWT expiration time (in sec, 10 minutes maximum) | ||
'exp': int(time.time()) + 60, | ||
# GitHub App's client ID | ||
'iss': client_id | ||
} | ||
|
||
# Create JWT | ||
jwt_instance = JWT() | ||
jwt = jwt_instance.encode(payload, signing_key, alg='RS256') | ||
|
||
# Set the URL for the request | ||
url = f"https://api.github.com/app/installations/{installation_id}/access_tokens" | ||
|
||
# Set the headers | ||
headers = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": f"Bearer {jwt}", | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
|
||
# Send the POST request | ||
response = requests.post(url, headers=headers) | ||
|
||
# Get the "token" field from the response | ||
token = response.json().get("token") | ||
|
||
# get token for creating the runners | ||
org = "accel-sim" # Replace with your organization name | ||
|
||
# Set the URL for the request | ||
url = f"https://api.github.com/orgs/{org}/actions/runners/registration-token" | ||
|
||
# Set the headers | ||
headers = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": f"Bearer {token}", | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
} | ||
|
||
# Send the POST request | ||
response = requests.post(url, headers=headers) | ||
|
||
token = response.json().get("token") | ||
print(token) |
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,52 @@ | ||
#include <iostream> | ||
#include <cuda_runtime.h> | ||
|
||
__global__ void testDependency(int *start, int *results, int n) | ||
{ | ||
int index = threadIdx.x + blockIdx.x * blockDim.x; | ||
|
||
int dependency_var = 0; | ||
|
||
// # pragma unroll | ||
for (int i = index; i < n; ++i) | ||
{ | ||
// if (start[i] < n && i == start[i]) | ||
// { | ||
dependency_var = start[i]; | ||
// } | ||
} | ||
results[index] = dependency_var; | ||
} | ||
|
||
int main() | ||
{ | ||
unsigned n = 1024*1024; | ||
int results[n]; | ||
|
||
int *d_results; | ||
cudaMalloc(&d_results, n * sizeof(int)); | ||
|
||
int *start, *d_start; | ||
cudaMalloc(&d_start, n * sizeof(int)); | ||
cudaMallocHost(&start, n * sizeof(int)); | ||
|
||
for (int i = 0; i < n; ++i) | ||
{ | ||
start[i] = i; | ||
} | ||
|
||
cudaMemcpy(d_start, start, n * sizeof(unsigned), cudaMemcpyHostToDevice); | ||
|
||
testDependency<<<1, 1>>>(d_start, d_results, n); | ||
|
||
cudaMemcpy(results, d_results, n * sizeof(int), cudaMemcpyDeviceToHost); | ||
|
||
cudaFree(d_results); | ||
|
||
for (int i = 0; i < n / 1024; ++i) | ||
{ | ||
std::cout << "Result[" << i << "]: " << results[i] << std::endl; | ||
} | ||
|
||
return 0; | ||
} |