This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
RC v1.2.0 #10
Open
alessandrocapotondi
wants to merge
2
commits into
master
Choose a base branch
from
rel-v1.2.0
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
RC v1.2.0 #10
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
*build/ | ||
*.o | ||
*~ | ||
*testsuite | ||
*__pycache__ | ||
*junit-reports | ||
|
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 |
---|---|---|
|
@@ -96,3 +96,27 @@ hero_rt_core_id(void) | |
{ | ||
return omp_get_thread_num(); | ||
} | ||
|
||
void | ||
hero_rt_start_cycle_cnt() | ||
{ | ||
return; | ||
} | ||
|
||
void | ||
hero_rt_reset_cycle_cnt() | ||
{ | ||
return; | ||
} | ||
|
||
void | ||
hero_rt_stop_cycle_cnt() | ||
{ | ||
return; | ||
} | ||
|
||
int | ||
hero_rt_get_cycles() | ||
{ | ||
return 0x0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline |
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 |
---|---|---|
|
@@ -58,7 +58,8 @@ hero_dma_memcpy_async(void *dst, void *src, int size) | |
int ext2loc; | ||
unsigned int ext_addr_tmp, ext_addr, loc_addr; | ||
int size_tmp = size; | ||
hero_dma_job_t dma = 0; | ||
hero_dma_job_t dma_job = plp_dma_counter_alloc(); | ||
uin32_t dma_cmd; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: |
||
|
||
// get direction | ||
if ((unsigned int) dst < ARCHI_CLUSTER_GLOBAL_ADDR(0) || | ||
|
@@ -100,15 +101,17 @@ hero_dma_memcpy_async(void *dst, void *src, int size) | |
pulp_tryread((unsigned *)ext_addr_tmp); | ||
pulp_tryread((unsigned *)((ext_addr + size_tmp - 1) & 0xFFFFFFFC)); | ||
|
||
// just wait for the last one... | ||
dma = (hero_dma_job_t)plp_dma_memcpy_priv(ext_addr,loc_addr,size_tmp,ext2loc); | ||
//dma_job = (hero_dma_job_t)plp_dma_memcpy_priv(ext_addr,loc_addr,size_tmp,ext2loc); | ||
dma_cmd = plp_dma_getCmd(ext2loc, size, PLP_DMA_1D, PLP_DMA_TRIG_EVT, PLP_DMA_NO_TRIG_IRQ, PLP_DMA_PRIV); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will test it as soon as my other DMA and compiler issues are resolved. This way I won't have to create a custom test case. |
||
__asm__ __volatile__ ("" : : : "memory"); | ||
plp_dma_cmd_push(dma_cmd, loc_addr, ext_addr); | ||
|
||
size -= size_tmp; | ||
ext_addr += size_tmp; | ||
loc_addr += size_tmp; | ||
} | ||
|
||
return dma; | ||
return dma_job; | ||
} | ||
|
||
void | ||
|
@@ -152,3 +155,27 @@ hero_rt_core_id(void) | |
{ | ||
return rt_core_id(); | ||
} | ||
|
||
void | ||
hero_rt_start_cycle_cnt() | ||
{ | ||
start_timer(); | ||
} | ||
|
||
void | ||
hero_rt_reset_cycle_cnt() | ||
{ | ||
reset_timer(); | ||
} | ||
|
||
void | ||
hero_rt_stop_cycle_cnt() | ||
{ | ||
stop_timer(); | ||
} | ||
|
||
int | ||
hero_rt_get_cycles() | ||
{ | ||
return get_time(); | ||
} |
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,12 @@ | ||
from plptest import * | ||
|
||
TestConfig = c = {} | ||
|
||
tests = Testset( | ||
name = 'libhero-target', | ||
files = [ | ||
'testsuite/timers/testset.cfg', | ||
] | ||
) | ||
|
||
c['testsets'] = [ tests ] |
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,3 @@ | ||
CSRCS = main.c | ||
|
||
-include ${HERO_OMP_EXAMPLES_DIR}/common/default.mk |
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,79 @@ | ||
/* | ||
* HERO HelloWorld Example Application | ||
* | ||
* Copyright 2018 ETH Zurich, University of Bologna | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <omp.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <time.h> | ||
#include <hero-target.h> | ||
|
||
struct timespec start, stop; | ||
double start_ns, stop_ns, exe_time; | ||
|
||
#pragma omp declare target | ||
void test(int *ret, int *aux) | ||
{ | ||
int cycles1=0x0; | ||
int cycles2=0x0; | ||
|
||
hero_rt_reset_cycle_cnt(); | ||
hero_rt_start_cycle_cnt(); | ||
|
||
for(int i=0; i<1000; i++) | ||
*aux+=hero_rt_get_cycles(); | ||
|
||
hero_rt_stop_cycle_cnt(); | ||
cycles1=hero_rt_get_cycles(); | ||
|
||
if(cycles1<=0x0) | ||
*ret=1; | ||
if(cycles1<1000) | ||
*ret=2; | ||
|
||
cycles2=hero_rt_get_cycles(); | ||
if(cycles1!=cycles2) | ||
*ret=3; | ||
|
||
hero_rt_start_cycle_cnt(); | ||
for(int i=0; i<1000; i++) | ||
*aux+=hero_rt_get_cycles(); | ||
hero_rt_stop_cycle_cnt(); | ||
cycles1=hero_rt_get_cycles(); | ||
if(cycles1==cycles2) | ||
*ret=4; | ||
|
||
hero_rt_reset_cycle_cnt(); | ||
cycles1=hero_rt_get_cycles(); | ||
if(cycles1!=0x0) | ||
*ret=5; | ||
} | ||
#pragma omp end declare target | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int ret=0; | ||
int aux=0; | ||
|
||
omp_set_default_device(BIGPULP_MEMCPY); | ||
|
||
#pragma omp target map(tofrom:ret,aux) | ||
test(&ret,&aux); | ||
|
||
return ret; | ||
} |
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,8 @@ | ||
from plptest import * | ||
TestConfig = c = {} | ||
def check_output(config, output): | ||
return(output.find("make: *** [run] Error") == -1, None) | ||
|
||
c['tests'] = [ | ||
Test(name = 'timers', commands = [ Shell('clean', 'make clean'), Shell('build', 'make all'), Shell('run', 'make run'), Check('check', check_output) ], timeout=1000000), | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be a corresponding timer implementation for the host side as well? I think this would be useful when doing profiling and comparing host vs. accelerator execution. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PULP timer returns the number passed of clock cycles. How would you implement this on the host while staying consistent with the unit (clock cycles)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two options:
You are using functions like
clock_gettime()
on the host which gives you the time in seconds and nanoseconds. You can then convert this into accelerator clock cycles or host clock cycles depending on what comparison you want to do. The frequencies of these two clocks you can get from thepulp
struct defined and set up by libpulp (see hero-support), namelypulp->pulp_clk_freq_mhz
andpulp->host_clk_freq_mhz
. Alternatively, you can also get the host clock frequency from sysfs.Despite executing on the host, you can still use the timer inside the accelerator directly. How to do this is illustrated here:
https://github.com/pulp-platform/hero-support/blob/6762d055953089eea215c60a58ad3a62c6b717e2/libpulp/src/pulp.c#L503
You just need to be careful that the accelerator is not manipulating the timer simultaneously.
Best regards,
Pirmin