-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from mn416/explicit-vpm
Support explicit VPM and DMA
- Loading branch information
Showing
30 changed files
with
1,247 additions
and
594 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "QPULib.h" | ||
|
||
using namespace QPULib; | ||
|
||
void dma(Ptr<Int> p) | ||
{ | ||
// Setup load of 16 vectors into VPM, starting at word address 0 | ||
dmaSetReadPitch(64); | ||
dmaSetupRead(HORIZ, 16, 0); | ||
// Start loading from memory at address 'p' | ||
dmaStartRead(p); | ||
// Wait until load complete | ||
dmaWaitRead(); | ||
|
||
// Setup load of 16 vectors from VPM, starting at vector address 0 | ||
vpmSetupRead(HORIZ, 16, 0); | ||
// Setup store to VPM, starting at vector address 16 | ||
vpmSetupWrite(HORIZ, 16); | ||
|
||
// Read each vector, increment it, and write it back | ||
for (int i = 0; i < 16; i++) | ||
vpmPut(vpmGetInt() + 1); | ||
|
||
// Setup store of 16 vectors into VPM, starting at word address 256 | ||
dmaSetupWrite(HORIZ, 16, 256); | ||
// Start writing to memory at address 'p' | ||
dmaStartWrite(p); | ||
// Wait until store complete | ||
dmaWaitWrite(); | ||
} | ||
|
||
int main() | ||
{ | ||
// Construct kernel | ||
auto k = compile(dma); | ||
|
||
// Allocate and initialise array shared between ARM and GPU | ||
SharedArray<int> array(256); | ||
for (int i = 0; i < 256; i++) | ||
array[i] = i; | ||
|
||
// Invoke the kernel and display the result | ||
k(&array); | ||
for (int i = 0; i < 16; i++) { | ||
for (int j = 0; j < 16; j++) | ||
printf("%i ", array[16*i + j]); | ||
printf("\n"); | ||
} | ||
|
||
return 0; | ||
} |
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,21 @@ | ||
#ifndef _QUEUE_H_ | ||
#define _QUEUE_H_ | ||
|
||
namespace QPULib { | ||
|
||
// Very simple queue containing N elements of type T | ||
template <int N, typename T> struct Queue { | ||
T elems[N+1]; | ||
int front; | ||
int back; | ||
Queue() { front = back = 0; } | ||
bool isEmpty() { return front == back; } | ||
bool isFull() { return ((back+1)%(N+1)) == front; } | ||
void enq(T elem) { elems[back] = elem; back = (back+1)%(N+1); } | ||
T* first() { return &elems[front]; } | ||
void deq() { front = (front+1)%(N+1); } | ||
}; | ||
|
||
} | ||
|
||
#endif |
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
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
Oops, something went wrong.