Commit f43c9199 authored by Marc's avatar Marc
Browse files

changes in the test software to include assembler instructions for the custom ISA extension

parent 7a9d3dcc
...@@ -3,112 +3,25 @@ XCC=sparc-gaisler-elf-gcc #$(XINC) ...@@ -3,112 +3,25 @@ XCC=sparc-gaisler-elf-gcc #$(XINC)
XCFLAGS=-O2 -g -msoft-float -mcpu=v8 -fno-inline XCFLAGS=-O2 -g -msoft-float -mcpu=v8 -fno-inline
XCFLAGS0=-O0 -g -msoft-float -mcpu=v8 XCFLAGS0=-O0 -g -msoft-float -mcpu=v8
%.o: %.c #include leon3_tests/Makefile
$(XCC) $(XCFLAGS) -c $< systest hello:
$(MAKE) -C leon3_tests $@
%.o: %.S simd_%:
$(XCC) $(XCFLAGS) -c $< $(MAKE) -C module_tests $@
bin_change: mat_mu%:
g++ -o bin_change bin_change.cc $(MAKE) -C matrix_multiplication $@
g++ -o bin_change2 bin_change2.cc
make.x:
g++ -o make.x make_simd_op.cc
systest:
cp systest.srec $(CURRENT_DIR)/test.srec
hello: hello.o gray%:
$(XCC) $(XCFLAGS) hello.o -o hello.exe $(MAKE) -C image_manipulation $@
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 hello.exe hello.srec
cp hello.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d hello.o > hello.dump
simd_test: simd_test.c bin_change clean:
$(XCC) $(XCFLAGS0) -c simd_test.c $(MAKE) -C leon3_tests $@
$(XCC) $(XCFLAGS0) simd_test.o -o simd_test.exe $(MAKE) -C module_tests $@
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 simd_test.exe tmp.simd_test.srec $(MAKE) -C matrix_multiplication $@
./bin_change tmp.simd_test.srec simd_test.list simd_test.srec 83288001 $(MAKE) -C image_manipulation $@
cp simd_test.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d simd_test.o > simd_test.dump
simd_swizling: simd_swizling.c bin_change
$(XCC) $(XCFLAGS0) -c simd_swizling.c
$(XCC) $(XCFLAGS0) simd_swizling.o -o simd_swizling.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 simd_swizling.exe tmp.simd_swizling.srec
./bin_change tmp.simd_swizling.srec simd_swizling.list simd_swizling.srec 83288001
cp simd_swizling.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d simd_swizling.o > simd_swizling.dump
simd_imm: simd_imm.c bin_change
$(XCC) $(XCFLAGS0) -c simd_imm.c
$(XCC) $(XCFLAGS0) simd_imm.o -o simd_imm.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 simd_imm.exe tmp.simd_imm.srec
./bin_change tmp.simd_imm.srec simd_imm.list simd_imm.srec 83288001
cp simd_imm.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d simd_imm.o > simd_imm.dump
simd_mask: simd_mask_test.c bin_change
$(XCC) $(XCFLAGS0) -c simd_mask_test.c
$(XCC) $(XCFLAGS0) simd_mask_test.o -o simd_mask_test.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 simd_mask_test.exe tmp.simd_mask_test.srec
./bin_change tmp.simd_mask_test.srec simd_mask_test.list simd_mask_test.srec 83288001
cp simd_mask_test.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d simd_mask_test.o > simd_mask_test.dump
mat_mul: mat_mul.c
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) mat_mul.o -o mat_mul.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul.exe mat_mul.srec
cp mat_mul.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul.o > mat_mul.dump
grayscale: grayscale.c arrays.h image256.h image32.h
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) grayscale.o -o grayscale.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 grayscale.exe grayscale.srec
cp grayscale.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d grayscale.o > grayscale.dump
grayscale_simd: grayscale_simd.c arrays.h image256.h image32.h
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) grayscale_simd.o -o grayscale_simd.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 grayscale_simd.exe tmp.grayscale_simd.srec
./bin_change2 tmp.grayscale_simd.srec grayscale_simd.list grayscale_simd.srec 83386002
cp grayscale_simd.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d grayscale_simd.o > grayscale_simd.dump
mat_mul_int: mat_mul_int.c
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) mat_mul_int.o -o mat_mul_int.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_int.exe mat_mul_int.srec
cp mat_mul_int.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_int.o > mat_mul_int.dump
mat_mul_simd: mat_mul_simd.c bin_change
$(XCC) $(XCFLAGS) -D N=$(par1) -c mat_mul_simd.c
$(XCC) $(XCFLAGS) mat_mul_simd.o -o mat_mul_simd.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd.exe tmp.mat_mul_simd.srec
./bin_change tmp.mat_mul_simd.srec mat_mul_simd.list tmp2.mat_mul_simd.srec 925A0009
./bin_change tmp2.mat_mul_simd.srec mat_mul_simd32.list3 mat_mul_simd.srec 92020009
cp mat_mul_simd.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd.o > mat_mul_simd.dump
mat_mul_simd4: mat_mul_simd4.o bin_change
$(XCC) $(XCFLAGS) mat_mul_simd4.o -o mat_mul_simd4.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd4.exe tmp.mat_mul_simd4.srec
./bin_change tmp.mat_mul_simd4.srec mat_mul_simd4.list mat_mul_simd4.srec 925A0009
cp mat_mul_simd4.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd4.o > mat_mul_simd4.dump
mat_mul_simd32: mat_mul_simd32.o bin_change
$(XCC) $(XCFLAGS) mat_mul_simd32.o -o mat_mul_simd32.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd32.exe tmp.mat_mul_simd32.srec
./bin_change tmp.mat_mul_simd32.srec mat_mul_simd32.list tmp2.mat_mul_simd32.srec 925A0009
./bin_change tmp2.mat_mul_simd32.srec mat_mul_simd32.list2 tmp3.mat_mul_simd32.srec 84784001
./bin_change tmp3.mat_mul_simd32.srec mat_mul_simd32.list3 mat_mul_simd32.srec 92020009
cp mat_mul_simd32.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd32.o > mat_mul_simd32.dump
clean:
rm -f *.exe *.o *.dump bin_change2 bin_change make.x tmp*.*
Directory containing the testing utilities for the leon3mp design Directory containing the testing utilities for the leon3 design
The executed program, must be found in test.srec file in the .srec format The executed program, must be found in test.srec file in the .srec format
A makefile is provided with the commands to generate this srec file A makefile is provided with the commands to generate this srec file
execute "make _test_name" to generate all the necessary files execute "make _test_name" to generate all the necessary files
To use instructions not included in the compiler the bin_change and make_simd_op All tests are grouped in directories with similar testing goals:
programs are included. Use make_sim_op (whose executable is make.x) to
generate the hex codification for the simd instructions.
--TODO-- allow input to be operation name
Include a list of all the new instructions, just the ones not included in the module_tests/ -> Contains tests to verify the correct behaviour of the
compiler, in the corresponding order. This list must be in _test_name.list module.
matrix_multiplication/ -> contains tests with different aproaches for
When calling bin_change pass this list together with the output file, usually matrix multiplication, both including the
test.srec, and the dummy instruction used in the C code to compile. use of the AI module and not.
For existing test all this mechanisms are included when executing "make _test_name"
image_manipulation/ -> Tests regarding the manipulation of image files
also included tests with no use of the module for
performance comparison.
This diff is collapsed.
This diff is collapsed.
XCC=sparc-gaisler-elf-gcc #$(XINC)
XCFLAGS=-O2 -g -msoft-float -mcpu=v8 -fno-inline
XCFLAGS0=-O0 -g -msoft-float -mcpu=v8
grayscale: grayscale.c arrays.h image256.h image32.h
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) grayscale.o -o grayscale.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 grayscale.exe grayscale.srec
cp grayscale.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d grayscale.o > grayscale.dump
grayscale_simd: grayscale_simd.c arrays.h image256.h image32.h
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) grayscale_simd.o -o grayscale_simd.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 grayscale_simd.exe grayscale_simd.srec
cp grayscale_simd.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d grayscale_simd.o > grayscale_simd.dump
clean:
rm -f *.exe *.o *.dump *.srec
#include <stdio.h>
#include <stdlib.h>
#include "arrays.h"
#ifndef N
#define N 2
#endif
//void init(unsigned char a[N][N][4]){
// for (int i = 0; i<N; i++)
// for (int j = 0; j<N; j++){
// a[i][j][0] = rand()%255;
// a[i][j][1] = rand()%255;
// a[i][j][2] = rand()%255;
// a[i][j][3] = 255;
// }
//}
unsigned char shift_and_add(unsigned char r, unsigned char g, unsigned char b){
unsigned char ret;
ret = (r>>2) + (g>>2) + (b>>2);
return ret;
}
//__attribute__((optimize("unroll-loops")))
void grayscale(unsigned char src[N][N][4], unsigned char dst[N][N]){
unsigned char color;
asm("nop");
asm("srl %i0, %o1, %g2");
asm("nop");
for (int i = 0; i<N; i++)
for (int j = 0; j<N; j+=4){
dst[i][j] = (src[i][j][0]>>2) + (src[i][j][1]>>2) + (src[i][j][2]>>2);
dst[i][j+1] = (src[i][j+1][0]>>2) + (src[i][j+1][1]>>2) + (src[i][j+1][2]>>2);
dst[i][j+2] = (src[i][j+2][0]>>2) + (src[i][j+2][1]>>2) + (src[i][j+2][2]>>2);
dst[i][j+3] = (src[i][j+3][0]>>2) + (src[i][j+3][1]>>2) + (src[i][j+3][2]>>2);
// dst[i][j] = shift_and_add(src[i][j][0], src[i][j][1], src[i][j][2]);
}
asm("nop");
asm("srl %i0, %o1, %g2");
asm("nop");
}
void print(unsigned char src[N][N]) {
printf("P3\n%d %d\n255\n",N,N);
for (int i = 0; i<N; i++){
for (int j = 0; j<N; j++){
printf("%d %d %d ", src[i][j], src[i][j], src[i][j]);
}
printf("\n");
}
}
int main(){
unsigned char source[N][N][4] = {IMAGE_ARRAY};
unsigned char dest[N][N];
//init(source);
grayscale(source, dest);
print(dest);
}
#include <stdio.h>
#include <stdlib.h>
#include "arrays.h"
#ifndef N
#define N 2
#endif
//void init(unsigned char a[N][N][4]){
// for (int i = 0; i<N; i++)
// for (int j = 0; j<N; j++){
// a[i][j][0] = rand()%255;
// a[i][j][1] = rand()%255;
// a[i][j][2] = rand()%255;
// a[i][j][3] = 255;
// }
//}
int b = 0xfcfcfc7f;
//int shift_and_add(int a){
//int r;
//asm("srl %1, %0, %0"
// : "=r"(r)
// : "r"(a), "0"(b));
//return r;
//}
int shift_and_add(int a);
asm("shift_and_add:");
asm("retl");
asm("shft_sum %o0, %g4, %o0");
//__attribute__((optimize("unroll-loops")))
void grayscale(unsigned char src[N][N][4], unsigned char dst[N][N]){
asm("set 0xfcfcfc00, %o5");
asm("nop");
asm("srl %i0, %o1, %g2");
asm("nop");
register int c0 asm("%o0");
register int c1 asm("%o1");
register int c2 asm("%o2");
register int c3 asm("%o3");
for (int i = 0; i<N; i++)
for (int j = 0; j<N; j+=4){
c0 = *((int *) &src[i][j][0]);
c1 = *((int *) &src[i][j+1][0]);
c2 = *((int *) &src[i][j+2][0]);
c3 = *((int *) &src[i][j+3][0]);
asm("shft_sum %o0, %o5, %o0");
asm("shft_sum %o1, %o5, %o1");
asm("shft_sum %o2, %o5, %o2");
asm("shft_sum %o3, %o5, %o3");
dst[i][j]= c0;
dst[i][j+1]= c1;
dst[i][j+2]= c2;
dst[i][j+3]= c3;
}
asm("nop");
asm("srl %i0, %o1, %g2");
asm("nop");
}
void print(unsigned char src[N][N]) {
printf("P3\n%d %d\n255\n",N,N);
for (int i = 0; i<N; i++){
for (int j = 0; j<N; j++){
printf("%d %d %d ", src[i][j], src[i][j], src[i][j]);
}
printf("\n");
}
}
int main(){
unsigned char source[N][N][4] = {IMAGE_ARRAY};
unsigned char dest[N][N];
//init(source);
grayscale(source, dest);
print(dest);
}
XCC=sparc-gaisler-elf-gcc #$(XINC)
XCFLAGS=-O2 -g -msoft-float -mcpu=v8 -fno-inline
systest:
cp systest.srec $(CURRENT_DIR)/test.srec
hello: hello.c
$(XCC) $(XCFLAGS) hello.c -o hello.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 hello.exe hello.srec
cp hello.srec $(CURRENT_DIR)/test.srec
clean:
rm -f *.exe *.o *.dump hello.srec
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
puts("Hello World\n");
puts("END OF TEST");
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
XCC=sparc-gaisler-elf-gcc #$(XINC)
XCFLAGS=-O2 -g -msoft-float -mcpu=v8 -fno-inline
mat_mul: mat_mul.c
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) mat_mul.o -o mat_mul.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul.exe mat_mul.srec
cp mat_mul.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul.o > mat_mul.dump
mat_mul_int: mat_mul_int.c
$(XCC) $(XCFLAGS) -D N=$(par1) -c $<
$(XCC) $(XCFLAGS) mat_mul_int.o -o mat_mul_int.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_int.exe mat_mul_int.srec
cp mat_mul_int.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_int.o > mat_mul_int.dump
mat_mul_simd: mat_mul_simd.c
$(XCC) $(XCFLAGS) -D N=$(par1) -c mat_mul_simd.c
$(XCC) $(XCFLAGS) mat_mul_simd.o -o mat_mul_simd.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd.exe mat_mul_simd.srec
cp mat_mul_simd.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd.o > mat_mul_simd.dump
mat_mul_simd4: mat_mul_simd4.c
$(XCC) $(XCFLAGS) -c mat_mul_simd4.c
$(XCC) $(XCFLAGS) mat_mul_simd4.o -o mat_mul_simd4.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd4.exe mat_mul_simd4.srec
cp mat_mul_simd4.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd4.o > mat_mul_simd4.dump
mat_mul_simd32: mat_mul_simd32.c
$(XCC) $(XCFLAGS) -c mat_mul_simd32.c
$(XCC) $(XCFLAGS) mat_mul_simd32.o -o mat_mul_simd32.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd32.exe mat_mul_simd32.srec
cp mat_mul_simd32.srec $(CURRENT_DIR)/test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd32.o > mat_mul_simd32.dump
clean:
rm -f *.exe *.o *.dump *.srec
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment