Restructure
This commit is contained in:
BIN
kernel/.DS_Store
vendored
Normal file
BIN
kernel/.DS_Store
vendored
Normal file
Binary file not shown.
21
kernel/Makefile
Normal file
21
kernel/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
COMP = /opt/riscv/bin/riscv32-unknown-elf-gcc
|
||||
CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib
|
||||
|
||||
DMP = /opt/riscv/bin/riscv32-unknown-elf-objdump
|
||||
CPY = /opt/riscv/bin/riscv32-unknown-elf-objcopy
|
||||
|
||||
VX_LIB = ./vx_os/vx_back/vx_back.s ./vx_os/vx_back/vx_back.c ./vx_os/vx_util/queue.s
|
||||
VX_IO = ./vx_os/vx_io/vx_io.s ./vx_os/vx_io/vx_io.c
|
||||
VX_FR = ./vx_include/vx_front.c
|
||||
|
||||
all: HEX DUMP ELF
|
||||
|
||||
DUMP: ELF
|
||||
$(DMP) -D vortex_test.elf > vortex_test.dump
|
||||
|
||||
HEX: ELF
|
||||
$(CPY) -O ihex vortex_test.elf vortex_test.hex
|
||||
|
||||
ELF:
|
||||
$(COMP) $(CC_FLAGS) $(VX_LIB) $(VX_IO) $(VX_FR) vx_main.c -o vortex_test.elf
|
||||
48
kernel/linker.ld
Normal file
48
kernel/linker.ld
Normal file
@@ -0,0 +1,48 @@
|
||||
/* ---- Original Script: /opt/riscv32i/riscv32-unknown-elf/lib/ldscripts/elf32lriscv.x ---- */
|
||||
/* Default linker script, for normal executables */
|
||||
/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
||||
Copying and distribution of this script, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. */
|
||||
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
|
||||
"elf32-littleriscv")
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x80000000;
|
||||
.text :
|
||||
{
|
||||
*(.text)
|
||||
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
||||
*(.text.exit .text.exit.*)
|
||||
*(.text.startup .text.startup.*)
|
||||
*(.text.hot .text.hot.*)
|
||||
*(.stub .text.* .gnu.linkonce.t.*)
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
}
|
||||
.init :
|
||||
{
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
}
|
||||
.plt : { *(.plt) }
|
||||
.iplt : { *(.iplt) }
|
||||
.fini :
|
||||
{
|
||||
KEEP (*(SORT_NONE(.fini)))
|
||||
}
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
PROVIDE (_edata = .);
|
||||
PROVIDE (_end = .);
|
||||
PROVIDE (__global_pointer$ = .);
|
||||
|
||||
. = 0x81000000;
|
||||
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
|
||||
.rodata1 : { *(.rodata1) }
|
||||
. = 0x82000000;
|
||||
.comment : { *(.comment) }
|
||||
|
||||
}
|
||||
2067
kernel/vortex_test.dump
Normal file
2067
kernel/vortex_test.dump
Normal file
File diff suppressed because it is too large
Load Diff
BIN
kernel/vortex_test.elf
Executable file
BIN
kernel/vortex_test.elf
Executable file
Binary file not shown.
438
kernel/vortex_test.hex
Normal file
438
kernel/vortex_test.hex
Normal file
@@ -0,0 +1,438 @@
|
||||
:0200000480007A
|
||||
:1000000013054000731005021305800073101502DC
|
||||
:10001000731040F17310103037F1FF7FEF0080193B
|
||||
:10002000EF10C06D73000000938B0600130D0700E6
|
||||
:10003000130F01009303050013051000635C7500A6
|
||||
:1000400013010180130305006B5003001305150015
|
||||
:100050006FF0DFFE13010F0013050000930F060081
|
||||
:10006000938D0300EBE0BF01170500001305051B8E
|
||||
:100070006B40050017030000130343FB6B000300F4
|
||||
:1000800067800000170200011302022623200200ED
|
||||
:100090002322120023242200232632002328420098
|
||||
:1000A000232A5200232C6200232E72002320820276
|
||||
:1000B000232292022324A2022326B2022328C20270
|
||||
:1000C000232AD202232CE202232EF202232002054D
|
||||
:1000D0002322120523242205232632052328420544
|
||||
:1000E000232A5205232C6205232E72052320820722
|
||||
:1000F000232292072324A2072326B2072328C2071C
|
||||
:10010000232AD207232CE207232EF2071302100022
|
||||
:1001100067800000170200011302021D0320020085
|
||||
:1001200083204200032182008321C20003220201B6
|
||||
:1001300083224201032382018323C201032402029A
|
||||
:1001400083244202032582028325C202032602037E
|
||||
:1001500083264203032782038327C2030328020462
|
||||
:1001600083284204032982048329C204032A020546
|
||||
:10017000832A4205032B8205832BC205032C02062A
|
||||
:10018000832C4206032D8206832DC206032E02070E
|
||||
:10019000832E4207032F8207832FC207130200001A
|
||||
:1001A000678000007325000267800000732510023D
|
||||
:1001B00067800000130101FE232E1100232C810013
|
||||
:1001C00013040102232604FE6F0000030327C4FE6C
|
||||
:1001D0009307404C3307F702B707008193874736F0
|
||||
:1001E000B307F70013850700EF0040408327C4FEE4
|
||||
:1001F000938717002326F4FE0327C4FE930770009D
|
||||
:10020000E3D6E7FC130000008320C1010324810131
|
||||
:100210001301010267800000130101FD2326110272
|
||||
:10022000232481022322A1031304010313070D00D9
|
||||
:100230009307404C3307F702B7070081938747368F
|
||||
:10024000B307F70013850700EF00804B9307050005
|
||||
:10025000638A070213070D00B707008113172700F1
|
||||
:100260009387472CB307F7001307100023A0E7007C
|
||||
:1002700093070D0063960700EFF0DFE96F0080053C
|
||||
:100280007300000013070D009307404C3307F7027B
|
||||
:10029000B707008193874736B307F700130784FD3C
|
||||
:1002A0009305070013850700EF00003D832704FE38
|
||||
:1002B000138107008327C4FD832584FD032644FEA4
|
||||
:1002C000832684FE0327C4FE13850700EFF0DFD5E5
|
||||
:1002D000730000008320C10203248102032D410228
|
||||
:1002E0001301010367800000130101FB23261104A1
|
||||
:1002F0002324810413040105EFF0DFEA2324A4FE84
|
||||
:1003000093090100930710002326F4FE6F004008B4
|
||||
:100310000327C4FE9307404C3307F702B707008159
|
||||
:1003200093874736B307F70013850700EF00403D7A
|
||||
:1003300093070500639807040327C4FE9307404C06
|
||||
:100340003307F702B707008193874736B307F700F3
|
||||
:10035000130704FD9305070013850700EF00C03164
|
||||
:10036000832784FD13810700832744FD832504FD33
|
||||
:100370000326C4FD832604FE032744FE13850700DD
|
||||
:10038000EFF05FCF8327C4FE938717002326F4FE88
|
||||
:100390008327C4FE032784FEE3ECE7F613810900FC
|
||||
:1003A000EFF05FCE9307020063880704B707008170
|
||||
:1003B00013854736EF00C03493070500639E07029C
|
||||
:1003C000930784FB93850700B707008113854736A1
|
||||
:1003D000EF00802A832704FC138107008327C4FBD6
|
||||
:1003E000832584FB032644FC832684FC0327C4FC6A
|
||||
:1003F00013850700EFF05FC3130000008320C104E2
|
||||
:10040000032481041301010567800000130101FB2F
|
||||
:10041000232611042324810413040105232EA4FAA6
|
||||
:10042000232CB4FA232AC4FA2328D4FAEFF09FD855
|
||||
:10043000EFF05FD72322A4FE13090100232604FE58
|
||||
:10044000232404FE6F00C008B709FFFF3301310108
|
||||
:10045000832784FE2326F4FC832784FB2328F4FCD3
|
||||
:1004600093070100232AF4FC832744FB232CF4FC8C
|
||||
:10047000832704FB232EF4FC8327C4FE2320F4FEF1
|
||||
:100480000327C4FE9307404C3307F702B7070081E8
|
||||
:1004900093874736B307F7001307C4FC930507009B
|
||||
:1004A00013850700EF00C0168327C4FE938717004B
|
||||
:1004B0002326F4FE8327C4FE032744FE63E4E700FB
|
||||
:1004C000232604FE832784FE938717002324F4FE4B
|
||||
:1004D000032784FE8327C4FBE368F7F613010900B2
|
||||
:1004E000EFF09FE0130000008320C1040324810487
|
||||
:1004F0001301010567800000130101FD232611028D
|
||||
:100500002324810213040103232EA4FCEFF09FC9CE
|
||||
:100510002320A4FE232604FE6F004005232604FEAC
|
||||
:10052000232404FE6F00C003B7070081032784FE65
|
||||
:10053000131727009387472CB307F70003A707007B
|
||||
:10054000930710006318F7008327C4FE93871700F2
|
||||
:100550002326F4FE832784FE938717002324F4FECA
|
||||
:10056000832784FE032704FEE3E0E7FC0327C4FEA1
|
||||
:100570008327C4FDE314F7FA232204FE6F008002F0
|
||||
:10058000B7070081032744FE131727009387472CE2
|
||||
:10059000B307F70023A00700832744FE93871700C3
|
||||
:1005A0002322F4FE832744FE032704FEE3EAE7FC4C
|
||||
:1005B000130000008320C102032481021301010300
|
||||
:1005C00067800000130101FF2326810023247101AD
|
||||
:1005D0001304010193870B00138507000324C10056
|
||||
:1005E000832B810013010101678000009302050045
|
||||
:1005F000130300009303700023A0620023A2620093
|
||||
:1006000023A4620023A6720023A862006780000072
|
||||
:100610009302050003A382001303130023A46200C6
|
||||
:100620001383420183AE420093935E003303730051
|
||||
:1006300003AE05002320C30103AE45002322C301FE
|
||||
:1006400003AE85002324C30103AEC5002326C301E6
|
||||
:1006500003AE05012328C30103AE4501232AC301CC
|
||||
:10066000938E1E00130F20036394EE01930E00007F
|
||||
:1006700023A2D201678000009302050003A3820039
|
||||
:100680001303F3FF23A462001383420183AE02002D
|
||||
:10069000930F2003138F0E00130F1F006314FF012D
|
||||
:1006A000130F000023A0E20193935E003303730055
|
||||
:1006B000032E030023A0C501032E430023A2C5017E
|
||||
:1006C000032E830023A4C501032EC30023A6C50166
|
||||
:1006D000032E030123A8C501032E430123AAC5014C
|
||||
:1006E000678000009302050003A382001305000049
|
||||
:1006F000130E200363146E001305150067800000BD
|
||||
:100700009302050003A3820013050000130E0000EE
|
||||
:1007100063146E0013051500678000009302050046
|
||||
:1007200003A3C20083A3020133B563006780000006
|
||||
:10073000130141FF232011002322B100834505004E
|
||||
:1007400063880500EF00C001130515006FF01FFF5F
|
||||
:1007500083200100832541001301C1006780000050
|
||||
:10076000B708010023A0B80067800000130101FD55
|
||||
:10077000232611022324810213040103232EA4FC47
|
||||
:100780000327C4FD9307F00063E4E702B707008185
|
||||
:100790000327C4FD1317270093874720B307F700EB
|
||||
:1007A00083A7070013850700EFF09FF86F0040074D
|
||||
:1007B000930700022326F4FEA30504FE8327C4FE4C
|
||||
:1007C0009387C7FF0327C4FDB357F70093F7F700DC
|
||||
:1007D0002322F4FE832744FE63860700930710005C
|
||||
:1007E000A305F4FE8347B4FE63820702B7070081C6
|
||||
:1007F000032744FE1317270093874720B307F7000A
|
||||
:1008000083A7070013850700EFF09FF28327C4FE3C
|
||||
:100810009387C7FF2326F4FE8327C4FEE340F0FA44
|
||||
:100820008320C102032481021301010367800000B9
|
||||
:10083000130101FE232E1100232C81001304010259
|
||||
:100840002326A4FE2324B4FE0325C4FEEFF05FEEAE
|
||||
:10085000032584FEEFF09FF1B70700811385070899
|
||||
:10086000EFF01FED130000008320C101032481017C
|
||||
:100870001301010267800000130101FD232611020C
|
||||
:100880002324810213040103232EA4FC232CB4FC93
|
||||
:10089000232AC4FC2328D4FCB73700810327C4FDD6
|
||||
:1008A00023A2E79AB73700819387479A032784FDED
|
||||
:1008B00023A2E700B73700819387479A032744FDB7
|
||||
:1008C00023A4E700B73700819387479A032704FDE5
|
||||
:1008D00023A6E700EFF09F8D2324A4FE032704FD49
|
||||
:1008E000832784FEB357F7022326F4FE032704FD73
|
||||
:1008F000832784FEB377F702638807008327C4FE4B
|
||||
:10090000938717002326F4FE8325C4FEB7070081D2
|
||||
:100910001385470CEFF0DFF1B73700819387479AD3
|
||||
:100920000327C4FE23A8E700032704FD832784FED2
|
||||
:100930006362F702B73700819386479AB717008042
|
||||
:100940001386C79A832584FE032504FDEFF01FACB0
|
||||
:100950006F000002B73700819386479AB71700806F
|
||||
:100960001386C79A832504FD032504FDEFF01FAA13
|
||||
:10097000EFF05F832322A4FE032704FD832744FEB8
|
||||
:1009800063F8E700032544FEEFF01FB76F00C000D7
|
||||
:10099000032504FDEFF05FB6130000008320C102C1
|
||||
:1009A000032481021301010367800000130101FA8F
|
||||
:1009B000232E1104232C8104130401062326A4FAF8
|
||||
:1009C0002324B4FAEFF01FC0232CA4FC832784FD5A
|
||||
:1009D00083A70700232AF4FC832784FD83A747000D
|
||||
:1009E0002328F4FC832784FD83A787002326F4FCB7
|
||||
:1009F000832784FD83A707012326F4FE0327C4FE73
|
||||
:100A00008327C4FAB307F7022324F4FE8327C4FE26
|
||||
:100A1000639A0700930710002326F4FE8327C4FA85
|
||||
:100A20002324F4FE832784FD83A7C7002324F4FC3A
|
||||
:100A3000232204FE6F004012232004FE232E04FC18
|
||||
:100A40006F008007032784FA832784FCB307F7022B
|
||||
:100A50000327C4FDB307F7002322F4FC032784FC1B
|
||||
:100A60008327C4FDB307F702032784FEB307F7000B
|
||||
:100A70002320F4FC832744FC93972700032744FD9D
|
||||
:100A8000B307F70003A70700832704FC9397270009
|
||||
:100A9000832604FDB387F60083A70700B307F70298
|
||||
:100AA000032704FEB307F7002320F4FE8327C4FDC9
|
||||
:100AB00093871700232EF4FC0327C4FD832784FCAF
|
||||
:100AC000E362F7F8032784FA832784FC3307F702ED
|
||||
:100AD000832784FEB307F700232EF4FA032784FE4E
|
||||
:100AE000832784FCB337F70093F7F70F232CF4FA2E
|
||||
:100AF000832784FB93B71700A30BF4FA834774FB97
|
||||
:100B0000138F0700B7170080938F47B46B200F0037
|
||||
:100B10007B70FF018327C4FB939727000327C4FC46
|
||||
:100B2000B307F700032704FE23A0E700832784FE12
|
||||
:100B3000938717002324F4FEB7170080138E87B421
|
||||
:100B400067000E00130000006B300000832744FE96
|
||||
:100B5000938717002322F4FE832744FE0327C4FE55
|
||||
:100B6000E3ECE7EC130000008320C10503248105BA
|
||||
:100B70001301010667800000130101FC232E1102FE
|
||||
:100B8000232C810213040104232EA4FC232CB4FC87
|
||||
:100B9000232AC4FC2328D4FC2326E4FCB737008195
|
||||
:100BA0000327C4FD23ACE79AB73700819387879B5F
|
||||
:100BB000032784FD23A2E700B73700819387879B33
|
||||
:100BC000032744FD23A4E700B73700819387879B61
|
||||
:100BD0000327C4FC23A6E700B73700819387879BD0
|
||||
:100BE000032704FD23A8E700EFF04FDC2324A4FE35
|
||||
:100BF0000327C4FC832784FEB357F7022326F4FEA1
|
||||
:100C00000327C4FC832784FEB377F70263880700B9
|
||||
:100C10008327C4FE938717002326F4FEB73700818D
|
||||
:100C20009387879B0327C4FE23AAE7000327C4FCFE
|
||||
:100C3000832784FE6362F702B73700819386879B20
|
||||
:100C4000B7170080138607CB832584FE032504FD98
|
||||
:100C5000EFF0CFFB6F000002B73700819386879BD0
|
||||
:100C6000B7170080138607CB8325C4FC032504FD3A
|
||||
:100C7000EFF0CFF9EFF00FD32322A4FE032704FDFA
|
||||
:100C8000832744FE63F8E700032544FEEFF0DF8688
|
||||
:100C90006F00C000032504FDEFF01F861300000065
|
||||
:100CA0008320C10303248103130101046780000032
|
||||
:100CB000130101FB232611042324810413040105DD
|
||||
:100CC000232EA4FA232CB4FAEFF0DF8F2320A4FE06
|
||||
:100CD000832704FE83A70700232EF4FC832704FE4A
|
||||
:100CE00083A74700232CF4FC832704FE83A78700F7
|
||||
:100CF000232AF4FC832704FE83A747012326F4FE5E
|
||||
:100D00000327C4FE8327C4FBB307F7022324F4FEA2
|
||||
:100D10008327C4FE639A0700930710002326F4FE7E
|
||||
:100D20008327C4FB2324F4FE832704FE83A7C70084
|
||||
:100D30002328F4FC232204FE6F00000C032784FB0D
|
||||
:100D4000832704FD3307F702832784FEB307F700E8
|
||||
:100D50002326F4FC032784FE832704FDB337F70022
|
||||
:100D600093F7F70F2324F4FC832784FC93B7170031
|
||||
:100D7000A303F4FC834774FC138F0700B7170080AC
|
||||
:100D8000938F47DE6B200F007B70FF018327C4FC2D
|
||||
:100D9000939727000327C4FDB307F70083A6070036
|
||||
:100DA0008327C4FC93972700032784FDB307F7002C
|
||||
:100DB00003A707008327C4FC93972700032644FD5D
|
||||
:100DC000B307F6003387E60023A0E700832784FEFD
|
||||
:100DD000938717002324F4FEB7170080138E87DE55
|
||||
:100DE00067000E00130000006B300000832744FEF4
|
||||
:100DF000938717002322F4FE832744FE0327C4FEB3
|
||||
:100E0000E3EEE7F2130000008320C1040324810411
|
||||
:100E10001301010567800000130101FC232E11025C
|
||||
:100E2000232C810213040104232EA4FC232CB4FCE4
|
||||
:100E3000232AC4FC2328D4FC2326E4FCB7370081F2
|
||||
:100E40000327C4FD23ACE79AB73700819387879BBC
|
||||
:100E5000032784FD23A2E700B73700819387879B90
|
||||
:100E6000032744FD23A4E700B73700819387879BBE
|
||||
:100E70000327C4FC23A6E700B73700819387879B2D
|
||||
:100E8000032704FD23A8E700EFF04FB22324A4FEBC
|
||||
:100E90000327C4FC832784FEB357F7022326F4FEFE
|
||||
:100EA0000327C4FC832784FEB377F7026388070017
|
||||
:100EB0008327C4FE938717002326F4FEB7370081EB
|
||||
:100EC0009387879B0327C4FE23AAE7000327C4FC5C
|
||||
:100ED000832784FE6362F702B73700819386879B7E
|
||||
:100EE000B7170080138607F5832584FE032504FDCC
|
||||
:100EF000EFF0CFD16F000002B73700819386879B58
|
||||
:100F0000B7170080138607F58325C4FC032504FD6D
|
||||
:100F1000EFF0CFCFEFF00FA92322A4FE032704FDAB
|
||||
:100F2000832744FE63F8E700032544FEEFF0CFDC9F
|
||||
:100F30006F00C000032504FDEFF00FDC130000007C
|
||||
:100F40008320C1030324810313010104678000008F
|
||||
:100F5000130101FB2326110423248104130401053A
|
||||
:100F6000232EA4FA232CB4FAEFF0CFE52320A4FE1D
|
||||
:100F7000832704FE83A70700232EF4FC832704FEA7
|
||||
:100F800083A74700232CF4FC832704FE83A7870054
|
||||
:100F9000232AF4FC832704FE83A747012326F4FEBB
|
||||
:100FA0000327C4FE8327C4FBB307F7022324F4FE00
|
||||
:100FB0008327C4FE639A0700930710002326F4FEDC
|
||||
:100FC0008327C4FB2324F4FE832704FE83A7C700E2
|
||||
:100FD0002328F4FC232204FE6F00000C032784FB6B
|
||||
:100FE000832704FD3307F702832784FEB307F70046
|
||||
:100FF0002326F4FC032784FE832704FDB337F70080
|
||||
:1010000093F7F70F2324F4FC832784FC93B717008E
|
||||
:10101000A303F4FC834774FC138F0700B717008009
|
||||
:10102000938F47086B200F007B70FF018327C4FC60
|
||||
:10103000939727000327C4FDB307F70083A6070093
|
||||
:101040008327C4FC93972700032784FDB307F70089
|
||||
:1010500003A707008327C4FC93972700032644FDBA
|
||||
:10106000B307F6003387E64023A0E700832784FE1A
|
||||
:10107000938717002324F4FEB7170080138E870888
|
||||
:1010800067000E00130000006B300000832744FE51
|
||||
:10109000938717002322F4FE832744FE0327C4FE10
|
||||
:1010A000E3EEE7F2130000008320C104032481046F
|
||||
:1010B0001301010567800000130101FC232E1102BA
|
||||
:1010C000232C810213040104232EA4FC232CB4FC42
|
||||
:1010D000232AC4FC2328D4FC2326E4FCB737008150
|
||||
:1010E0000327C4FD23A8E79CB73700819387079D9A
|
||||
:1010F000032784FD23A2E700B73700819387079D6C
|
||||
:10110000032744FD23A4E700B73700819387079D99
|
||||
:101110000327C4FC23A6E700B73700819387079D08
|
||||
:10112000032704FD23A8E700EFF04F882324A4FE43
|
||||
:101130000327C4FC832784FEB357F7022326F4FE5B
|
||||
:101140000327C4FC832784FEB377F7026388070074
|
||||
:101150008327C4FE938717002326F4FEB737008148
|
||||
:101160009387079D0327C4FE23AAE7000327C4FC37
|
||||
:10117000832784FE6362F702B73700819386079D59
|
||||
:10118000B71700801386071F832584FE032504FDFF
|
||||
:10119000EFF0CFA76F000002B73700819386079D5D
|
||||
:1011A000B71700801386071F8325C4FC032504FDA1
|
||||
:1011B000EFF0CFA5EFE01FFF2322A4FE032704FDDD
|
||||
:1011C000832744FE63F8E700032544FEEFF0CFB227
|
||||
:1011D0006F00C000032504FDEFF00FB21300000004
|
||||
:1011E0008320C103032481031301010467800000ED
|
||||
:1011F000130101FB23261104232481041304010598
|
||||
:10120000232EA4FA232CB4FAEFF0CFBB2320A4FEA4
|
||||
:10121000832704FE83A70700232EF4FC832704FE04
|
||||
:1012200083A7470083A70700232CF4FC832704FE31
|
||||
:1012300083A78700232AF4FC832704FE83A74701A2
|
||||
:101240002326F4FE0327C4FE8327C4FBB307F7025B
|
||||
:101250002324F4FE8327C4FE639A0700930710003B
|
||||
:101260002326F4FE8327C4FB2324F4FE832704FEF5
|
||||
:1012700083A7C7002328F4FC232204FE6F00000B81
|
||||
:10128000032784FB832704FD3307F702832784FEAB
|
||||
:10129000B307F7002326F4FC032784FE832704FD0D
|
||||
:1012A000B337F70093F7F70F2324F4FC832784FC6C
|
||||
:1012B00093B71700A303F4FC834774FC138F070054
|
||||
:1012C000B7170080938F87316B200F007B70FF0171
|
||||
:1012D0008327C4FC939727000327C4FDB307F700B7
|
||||
:1012E00083A607008327C4FC93972700032744FDA8
|
||||
:1012F000B307F700032784FD3387E60023A0E70048
|
||||
:10130000832784FE938717002324F4FEB7170080F9
|
||||
:10131000138EC73167000E00130000006B30000011
|
||||
:10132000832744FE938717002322F4FE832744FE7D
|
||||
:101330000327C4FEE3E6E7F4130000008320C104A2
|
||||
:10134000032481041301010567800000130101FCDF
|
||||
:10135000232E1102232C810213040104232EA4FC4A
|
||||
:10136000232CB4FC232AC4FC2328D4FC2326E4FC2D
|
||||
:10137000B73700810327C4FD23A8E79CB737008156
|
||||
:101380009387079D032784FD23A2E700B7370081D9
|
||||
:101390009387079D032744FD23A4E700B737008107
|
||||
:1013A0009387079D0327C4FC23A6E700B737008176
|
||||
:1013B0009387079D032704FD23A8E700EFE01FDFC5
|
||||
:1013C0002324A4FE0327C4FC832784FEB357F7021B
|
||||
:1013D0002326F4FE0327C4FC832784FEB377F70299
|
||||
:1013E000638807008327C4FE938717002326F4FE33
|
||||
:1013F000B73700819387079D0327C4FE23AAE70020
|
||||
:101400000327C4FC832784FE6362F702B737008199
|
||||
:101410009386079DB717008013864748832584FE6F
|
||||
:10142000032504FDEFE09FFE6F000002B737008147
|
||||
:101430009386079DB7170080138647488325C4FC11
|
||||
:10144000032504FDEFE09FFCEFE0DFD52322A4FE9F
|
||||
:10145000032704FD832744FE63F8E700032544FEC9
|
||||
:10146000EFF08F896F00C000032504FDEFF0CF88F7
|
||||
:10147000130000008320C10303248103130101042E
|
||||
:1014800067800000130101FB23261104232481043B
|
||||
:1014900013040105232EA4FA232CB4FAEFF08F9243
|
||||
:1014A0002320A4FE832704FE83A70700232EF4FC39
|
||||
:1014B000832704FE83A7470083A70700232CF4FC9F
|
||||
:1014C000832704FE83A78700232AF4FC832704FED6
|
||||
:1014D00083A747012326F4FE0327C4FE8327C4FB0A
|
||||
:1014E000B307F7022324F4FE8327C4FE639A0700A0
|
||||
:1014F000930710002326F4FE8327C4FB2324F4FE65
|
||||
:10150000832704FE83A7C7002328F4FC232204FEBC
|
||||
:101510006F00000B032784FB832704FD3307F702CA
|
||||
:10152000832784FEB307F7002326F4FC032784FEF9
|
||||
:10153000832704FDB337F70093F7F70F2324F4FC58
|
||||
:10154000832784FC93B71700A303F4FC834774FC40
|
||||
:10155000138F0700B7170080938FC75A6B200F00B7
|
||||
:101560007B70FF018327C4FC939727000327C4FDEA
|
||||
:10157000B307F70083A607008327C4FC93972700CF
|
||||
:10158000032744FDB307F700032784FD3387E602F2
|
||||
:1015900023A0E700832784FE938717002324F4FE0B
|
||||
:1015A000B7170080138E075B67000E001300000062
|
||||
:1015B0006B300000832744FE938717002322F4FE3C
|
||||
:1015C000832744FE0327C4FEE3E6E7F4130000008C
|
||||
:1015D0008320C104032481041301010567800000F6
|
||||
:1015E000130101FE232E810013040102232604FEB1
|
||||
:1015F0006F008004B73700810327C4FE131727004C
|
||||
:101600009387879EB307F7001307300023A0E700F6
|
||||
:10161000B74700810327C4FE131727009387879ECF
|
||||
:10162000B307F7001307200023A0E7008327C4FEB9
|
||||
:10163000938717002326F4FE0327C4FE9307F00FB9
|
||||
:10164000E3DAE7FA130000000324C10113010102E9
|
||||
:1016500067800000130101FD23261102232481026B
|
||||
:1016600013040103232EA4FCB7070081138507117F
|
||||
:10167000EFF00F8C232604FE6F0080058327C4FE45
|
||||
:10168000638E07008327C4FE93F7F7006398070073
|
||||
:10169000B707008113854713EFF08F898327C4FEB6
|
||||
:1016A000939727000327C4FDB307F70083A707001C
|
||||
:1016B00013850700EFF08F8BB70700811385871321
|
||||
:1016C000EFF00F878327C4FE938717002326F4FECD
|
||||
:1016D0000327C4FE9307F00FE3D2E7FAB7070081B0
|
||||
:1016E0001385C713EFF0CF84130000008320C102DD
|
||||
:1016F000032481021301010367800000130101FE2E
|
||||
:10170000232E1100232C810013040102EFF05FED62
|
||||
:1017100093060001B75700811386879EB747008163
|
||||
:101720009385879EB73700811385879EEFF0CF940E
|
||||
:10173000B707008113850716EFE09FFFB7570081B9
|
||||
:101740001385879EEFF01FF1130700019306000138
|
||||
:10175000B75700811386879EB74700819385879E80
|
||||
:10176000B73700811385879EEFF00FC1B70700815F
|
||||
:101770001385C717EFE0DFFBB75700811385879EFE
|
||||
:10178000EFF05FED1307000193060001B7570081EA
|
||||
:101790001386879EB74700819385879EB737008160
|
||||
:1017A0001385879EEFF04FE7B70700811385071970
|
||||
:1017B000EFE01FF8B75700811385879EEFF09FE990
|
||||
:1017C000930730002326F4FE9305C4FE130700019F
|
||||
:1017D00093060001B75700811386879EB757008193
|
||||
:1017E0001385879EEFF05F8DB70700811385871AF9
|
||||
:1017F000EFE01FF4B75700811385879EEFF09FE558
|
||||
:101800009305C4FE1307000193060001B75700813A
|
||||
:101810001386879EB75700811385879EEFF01FB30D
|
||||
:10182000B70700811385871AEFE09FF0B757008153
|
||||
:101830001385879EEFF01FE29307000013850700D2
|
||||
:101840008320C1010324810113010102678000008C
|
||||
:02000004810079
|
||||
:10000000300000003100000032000000330000002A
|
||||
:10001000340000003500000036000000370000000A
|
||||
:10002000380000003900000061000000620000009C
|
||||
:10003000630000006400000065000000660000002E
|
||||
:1000400030000000310000003200000033000000EA
|
||||
:1000500034000000350000003600000037000000CA
|
||||
:10006000380000003900000061000000620000005C
|
||||
:1000700063000000640000006500000066000000EE
|
||||
:100080000A000000300000003100000032000000D3
|
||||
:10009000330000003400000035000000360000008E
|
||||
:1000A0003700000038000000390000006100000047
|
||||
:1000B00062000000630000006400000065000000B2
|
||||
:1000C000660000004F66667365743A200000000009
|
||||
:1000D000300000003100000032000000330000005A
|
||||
:1000E000340000003500000036000000370000003A
|
||||
:1000F00038000000390000006100000062000000CC
|
||||
:10010000630000006400000065000000660000005D
|
||||
:100110002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0F
|
||||
:100120002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0A22
|
||||
:10013000000000000A000000200000000A2D2D2D04
|
||||
:100140002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DDF
|
||||
:100150002D2D2D2D2D2D2D2D2D2D2D2D0A00000079
|
||||
:100160000A0A4D6174726978206D756C7469706CDF
|
||||
:1001700069636174696F6E0A000000000A0A4D61CC
|
||||
:1001800074726978204164646974696F6E0A000052
|
||||
:100190000A0A4D61747269782053756274726163E2
|
||||
:1001A00074696F6E0A0000000A0A4D617472697802
|
||||
:1001B00020456C656D656E74204164646974696F77
|
||||
:0301C0006E0A00C4
|
||||
:1001C4000000008104000081080000810C0000810F
|
||||
:1001D4001000008114000081180000811C000081BF
|
||||
:1001E4002000008124000081280000812C0000816F
|
||||
:1001F4003000008134000081380000813C0000811F
|
||||
:100204004000008144000081480000814C000081CE
|
||||
:100214005000008154000081580000815C0000817E
|
||||
:100224006000008164000081680000816C0000812E
|
||||
:100234007000008174000081780000817C000081DE
|
||||
:1002440084000081880000818C000081900000817E
|
||||
:1002540094000081980000819C000081A00000812E
|
||||
:10026400A4000081A8000081AC000081B0000081DE
|
||||
:10027400B4000081B8000081BC000081C00000818E
|
||||
:10028400D0000081D4000081D8000081DC0000810E
|
||||
:10029400E0000081E4000081E8000081EC000081BE
|
||||
:1002A400F0000081F4000081F8000081FC0000816E
|
||||
:1002B4000001008104010081080100810C0100811A
|
||||
:040000058000000077
|
||||
:00000001FF
|
||||
BIN
kernel/vx_include/.DS_Store
vendored
Normal file
BIN
kernel/vx_include/.DS_Store
vendored
Normal file
Binary file not shown.
439
kernel/vx_include/vx_front.c
Normal file
439
kernel/vx_include/vx_front.c
Normal file
@@ -0,0 +1,439 @@
|
||||
|
||||
#include "vx_front.h"
|
||||
#include "../vx_os/vx_back/vx_back.h"
|
||||
|
||||
// -------------------------- Matrix Multiplication --------------------------
|
||||
|
||||
static mat_mult_arg_t mat_mult_args;
|
||||
|
||||
void _vx_mat_mult(unsigned, unsigned);
|
||||
void vx_sq_mat_mult(void * x, void * y, void * z, unsigned mat_dim)
|
||||
{
|
||||
mat_mult_args.x = x;
|
||||
mat_mult_args.y = y;
|
||||
mat_mult_args.z = z;
|
||||
mat_mult_args.mat_dim = mat_dim;
|
||||
|
||||
unsigned num_avail_threads = vx_available_threads();
|
||||
|
||||
unsigned off = (mat_dim/num_avail_threads);
|
||||
|
||||
if ((mat_dim%num_avail_threads) != 0)
|
||||
{
|
||||
off += 1;
|
||||
}
|
||||
|
||||
vx_printf("Offset: ", off);
|
||||
|
||||
|
||||
mat_mult_args.offset = off;
|
||||
|
||||
if (mat_dim >= num_avail_threads)
|
||||
{
|
||||
vx_spawnWarps(mat_dim, num_avail_threads, _vx_mat_mult, (void *) (&mat_mult_args));
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_spawnWarps(mat_dim, mat_dim, _vx_mat_mult, (void *) (&mat_mult_args));
|
||||
}
|
||||
|
||||
unsigned num_avail_warps = vx_available_warps();
|
||||
|
||||
if (mat_dim > num_avail_warps)
|
||||
{
|
||||
vx_wait_for_warps(num_avail_warps);
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_wait_for_warps(mat_dim);
|
||||
}
|
||||
}
|
||||
|
||||
void _vx_mat_mult(unsigned tid, unsigned wid)
|
||||
{
|
||||
mat_mult_arg_t * args = (mat_mult_arg_t *) vx_get_arg_struct();
|
||||
|
||||
unsigned * x_ptr = args->x;
|
||||
unsigned * y_ptr = args->y;
|
||||
unsigned * z_ptr = args->z;
|
||||
|
||||
unsigned off = args->offset;
|
||||
|
||||
unsigned i_index = off * tid;
|
||||
|
||||
if (off == 0)
|
||||
{
|
||||
off = 1;
|
||||
i_index = tid;
|
||||
}
|
||||
|
||||
unsigned mat_dim = args->mat_dim;
|
||||
|
||||
for (int iter = 0; iter < off; ++iter)
|
||||
{
|
||||
unsigned total = 0;
|
||||
for (unsigned place = 0; place < mat_dim; ++place)
|
||||
{
|
||||
unsigned x_i = (wid * mat_dim) + place;
|
||||
unsigned y_i = (mat_dim * place) + i_index;
|
||||
|
||||
total += (x_ptr[x_i] * y_ptr[y_i]);
|
||||
}
|
||||
|
||||
int final_i = (wid * mat_dim) + i_index;
|
||||
unsigned cond = i_index < mat_dim;
|
||||
__if(cond)
|
||||
{
|
||||
z_ptr[final_i] = total;
|
||||
i_index++;
|
||||
}
|
||||
__else
|
||||
__end_if
|
||||
}
|
||||
|
||||
// for (int z = 0; z < ((1000 * wid) + 1000); z++);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static mat_r_arg_t mat_r_args;
|
||||
// -------------------------- Matrix Addition --------------------------
|
||||
void _vx_mat_add(unsigned, unsigned);
|
||||
void vx_mat_add(void * x, void * y, void * z, unsigned num_rows, unsigned num_cols)
|
||||
{
|
||||
mat_r_args.x = x;
|
||||
mat_r_args.y = y;
|
||||
mat_r_args.z = z;
|
||||
mat_r_args.num_cols = num_cols;
|
||||
mat_r_args.num_rows = num_rows;
|
||||
|
||||
|
||||
unsigned num_avail_threads = vx_available_threads();
|
||||
|
||||
unsigned off = (num_cols/num_avail_threads);
|
||||
|
||||
if ((num_cols%num_avail_threads) != 0)
|
||||
{
|
||||
off += 1;
|
||||
}
|
||||
|
||||
|
||||
mat_r_args.offset = off;
|
||||
|
||||
if (num_cols >= num_avail_threads)
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_avail_threads, _vx_mat_add, (void *) (&mat_r_args));
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_cols, _vx_mat_add, (void *) (&mat_r_args));
|
||||
}
|
||||
|
||||
unsigned num_avail_warps = vx_available_warps();
|
||||
|
||||
if (num_rows > num_avail_warps)
|
||||
{
|
||||
vx_wait_for_warps(num_avail_warps);
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_wait_for_warps(num_rows);
|
||||
}
|
||||
}
|
||||
|
||||
void _vx_mat_add(unsigned tid, unsigned wid)
|
||||
{
|
||||
// vx_print_str("*");
|
||||
// for (int z = 0; z < ((wid * 1000) + 1000); z++);
|
||||
|
||||
mat_r_arg_t * args = (mat_r_arg_t *) vx_get_arg_struct();
|
||||
|
||||
unsigned * x_ptr = args->x;
|
||||
unsigned * y_ptr = args->y;
|
||||
unsigned * z_ptr = args->z;
|
||||
|
||||
unsigned off = args->offset;
|
||||
|
||||
unsigned i_index = off * tid;
|
||||
|
||||
if (off == 0)
|
||||
{
|
||||
off = 1;
|
||||
i_index = tid;
|
||||
}
|
||||
|
||||
unsigned num_cols = args->num_cols;
|
||||
|
||||
for (int iter = 0; iter < off; ++iter)
|
||||
{
|
||||
int final_i = (wid * num_cols) + i_index;
|
||||
unsigned cond = i_index < num_cols;
|
||||
__if(cond)
|
||||
{
|
||||
z_ptr[final_i] = x_ptr[final_i] + y_ptr[final_i];
|
||||
i_index++;
|
||||
}
|
||||
__else
|
||||
__end_if
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------- Matrix Subtraction --------------------------
|
||||
void _vx_mat_sub(unsigned, unsigned);
|
||||
void vx_mat_sub(void * x, void * y, void * z, unsigned num_rows, unsigned num_cols)
|
||||
{
|
||||
mat_r_args.x = x;
|
||||
mat_r_args.y = y;
|
||||
mat_r_args.z = z;
|
||||
mat_r_args.num_cols = num_cols;
|
||||
mat_r_args.num_rows = num_rows;
|
||||
|
||||
unsigned num_avail_threads = vx_available_threads();
|
||||
|
||||
unsigned off = (num_cols/num_avail_threads);
|
||||
|
||||
if ((num_cols%num_avail_threads) != 0)
|
||||
{
|
||||
off += 1;
|
||||
}
|
||||
|
||||
|
||||
mat_r_args.offset = off;
|
||||
|
||||
if (num_cols >= num_avail_threads)
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_avail_threads, _vx_mat_sub, (void *) (&mat_r_args));
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_cols, _vx_mat_sub, (void *) (&mat_r_args));
|
||||
}
|
||||
|
||||
unsigned num_avail_warps = vx_available_warps();
|
||||
|
||||
if (num_rows > num_avail_warps)
|
||||
{
|
||||
vx_wait_for_warps(num_avail_warps);
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_wait_for_warps(num_rows);
|
||||
}
|
||||
}
|
||||
|
||||
void _vx_mat_sub(unsigned tid, unsigned wid)
|
||||
{
|
||||
// vx_print_str("*");
|
||||
// for (int z = 0; z < ((wid * 1000) + 1000); z++);
|
||||
|
||||
mat_r_arg_t * args = (mat_r_arg_t *) vx_get_arg_struct();
|
||||
|
||||
unsigned * x_ptr = args->x;
|
||||
unsigned * y_ptr = args->y;
|
||||
unsigned * z_ptr = args->z;
|
||||
|
||||
unsigned off = args->offset;
|
||||
|
||||
unsigned i_index = off * tid;
|
||||
|
||||
if (off == 0)
|
||||
{
|
||||
off = 1;
|
||||
i_index = tid;
|
||||
}
|
||||
|
||||
unsigned num_cols = args->num_cols;
|
||||
|
||||
for (int iter = 0; iter < off; ++iter)
|
||||
{
|
||||
int final_i = (wid * num_cols) + i_index;
|
||||
unsigned cond = i_index < num_cols;
|
||||
__if(cond)
|
||||
{
|
||||
z_ptr[final_i] = x_ptr[final_i] - y_ptr[final_i];
|
||||
i_index++;
|
||||
}
|
||||
__else
|
||||
__end_if
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static mat_e_arg_t mat_e_args;
|
||||
// --------------------------------------------------------------
|
||||
|
||||
void _vx_e_mat_add(unsigned, unsigned);
|
||||
void vx_e_mat_add(void * x, void * scal, void * z, unsigned num_rows, unsigned num_cols)
|
||||
{
|
||||
mat_e_args.x = x;
|
||||
mat_e_args.scal = scal;
|
||||
mat_e_args.z = z;
|
||||
mat_e_args.num_cols = num_cols;
|
||||
mat_e_args.num_rows = num_rows;
|
||||
|
||||
|
||||
unsigned num_avail_threads = vx_available_threads();
|
||||
|
||||
unsigned off = (num_cols/num_avail_threads);
|
||||
|
||||
if ((num_cols%num_avail_threads) != 0)
|
||||
{
|
||||
off += 1;
|
||||
}
|
||||
|
||||
mat_e_args.offset = off;
|
||||
|
||||
if (num_cols >= num_avail_threads)
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_avail_threads, _vx_e_mat_add, (void *) (&mat_e_args));
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_cols, _vx_e_mat_add, (void *) (&mat_e_args));
|
||||
}
|
||||
|
||||
unsigned num_avail_warps = vx_available_warps();
|
||||
|
||||
if (num_rows > num_avail_warps)
|
||||
{
|
||||
vx_wait_for_warps(num_avail_warps);
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_wait_for_warps(num_rows);
|
||||
}
|
||||
}
|
||||
|
||||
void _vx_e_mat_add(unsigned tid, unsigned wid)
|
||||
{
|
||||
// vx_print_str("*");
|
||||
// for (int z = 0; z < ((wid * 1000) + 1000); z++);
|
||||
|
||||
mat_e_arg_t * args = (mat_e_arg_t *) vx_get_arg_struct();
|
||||
|
||||
unsigned * x_ptr = args->x;
|
||||
unsigned scal = *((unsigned *) args->scal);
|
||||
|
||||
unsigned * z_ptr = args->z;
|
||||
|
||||
unsigned off = args->offset;
|
||||
|
||||
unsigned i_index = off * tid;
|
||||
|
||||
if (off == 0)
|
||||
{
|
||||
off = 1;
|
||||
i_index = tid;
|
||||
}
|
||||
|
||||
unsigned num_cols = args->num_cols;
|
||||
|
||||
for (int iter = 0; iter < off; ++iter)
|
||||
{
|
||||
int final_i = (wid * num_cols) + i_index;
|
||||
unsigned cond = i_index < num_cols;
|
||||
__if(cond)
|
||||
{
|
||||
z_ptr[final_i] = x_ptr[final_i] + scal;
|
||||
i_index++;
|
||||
}
|
||||
__else
|
||||
__end_if
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void _vx_e_mat_mult(unsigned, unsigned);
|
||||
void vx_e_mat_mult(void * x, void * scal, void * z, unsigned num_rows, unsigned num_cols)
|
||||
{
|
||||
mat_e_args.x = x;
|
||||
mat_e_args.scal = scal;
|
||||
mat_e_args.z = z;
|
||||
mat_e_args.num_cols = num_cols;
|
||||
mat_e_args.num_rows = num_rows;
|
||||
|
||||
|
||||
unsigned num_avail_threads = vx_available_threads();
|
||||
|
||||
unsigned off = (num_cols/num_avail_threads);
|
||||
|
||||
if ((num_cols%num_avail_threads) != 0)
|
||||
{
|
||||
off += 1;
|
||||
}
|
||||
|
||||
mat_e_args.offset = off;
|
||||
|
||||
if (num_cols >= num_avail_threads)
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_avail_threads, _vx_e_mat_mult, (void *) (&mat_e_args));
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_spawnWarps(num_rows, num_cols, _vx_e_mat_mult, (void *) (&mat_e_args));
|
||||
}
|
||||
|
||||
unsigned num_avail_warps = vx_available_warps();
|
||||
|
||||
if (num_rows > num_avail_warps)
|
||||
{
|
||||
vx_wait_for_warps(num_avail_warps);
|
||||
}
|
||||
else
|
||||
{
|
||||
vx_wait_for_warps(num_rows);
|
||||
}
|
||||
}
|
||||
|
||||
void _vx_e_mat_mult(unsigned tid, unsigned wid)
|
||||
{
|
||||
// vx_print_str("*");
|
||||
// for (int z = 0; z < ((wid * 1000) + 1000); z++);
|
||||
|
||||
mat_e_arg_t * args = (mat_e_arg_t *) vx_get_arg_struct();
|
||||
|
||||
unsigned * x_ptr = args->x;
|
||||
unsigned scal = *((unsigned *) args->scal);
|
||||
|
||||
unsigned * z_ptr = args->z;
|
||||
|
||||
unsigned off = args->offset;
|
||||
|
||||
unsigned i_index = off * tid;
|
||||
|
||||
if (off == 0)
|
||||
{
|
||||
off = 1;
|
||||
i_index = tid;
|
||||
}
|
||||
|
||||
unsigned num_cols = args->num_cols;
|
||||
|
||||
for (int iter = 0; iter < off; ++iter)
|
||||
{
|
||||
int final_i = (wid * num_cols) + i_index;
|
||||
unsigned cond = i_index < num_cols;
|
||||
__if(cond)
|
||||
{
|
||||
z_ptr[final_i] = x_ptr[final_i] * scal;
|
||||
i_index++;
|
||||
}
|
||||
__else
|
||||
__end_if
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
55
kernel/vx_include/vx_front.h
Normal file
55
kernel/vx_include/vx_front.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "../vx_os/vx_back/vx_back.h"
|
||||
#include "../vx_os/vx_io/vx_io.h"
|
||||
|
||||
|
||||
// -------------------------- Matrix Multiplication --------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * x;
|
||||
void * y;
|
||||
void * z;
|
||||
unsigned mat_dim;
|
||||
unsigned offset;
|
||||
|
||||
} mat_mult_arg_t;
|
||||
void vx_sq_mat_mult(void *, void *, void *, unsigned);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * x;
|
||||
void * y;
|
||||
void * z;
|
||||
unsigned num_cols;
|
||||
unsigned num_rows;
|
||||
unsigned offset;
|
||||
|
||||
} mat_r_arg_t;
|
||||
// -------------------------- Matrix Addition -----------------------------
|
||||
void vx_mat_add(void *, void *, void *, unsigned, unsigned);
|
||||
|
||||
// -------------------------- Matrix Subtraction --------------------------
|
||||
void vx_mat_sub(void *, void *, void *, unsigned, unsigned);
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
void * x;
|
||||
void * scal;
|
||||
void * z;
|
||||
unsigned num_cols;
|
||||
unsigned num_rows;
|
||||
unsigned offset;
|
||||
|
||||
} mat_e_arg_t;
|
||||
|
||||
// -------------------------- Matrix element Addition ------------------
|
||||
void vx_e_mat_add(void *, void *, void *, unsigned, unsigned);
|
||||
|
||||
// -------------------------- Matrix element Addition ------------------
|
||||
void vx_e_mat_mult(void *, void *, void *, unsigned, unsigned);
|
||||
70
kernel/vx_main.c
Normal file
70
kernel/vx_main.c
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
#include "./vx_include/vx_front.h"
|
||||
|
||||
unsigned x[1024] = {0};
|
||||
unsigned y[1024] = {0};
|
||||
unsigned z[1024] = {0};
|
||||
|
||||
#define MAT_DIM 16
|
||||
|
||||
#define NUM_COLS 16
|
||||
#define NUM_ROWS 16
|
||||
|
||||
void initialize_mats()
|
||||
{
|
||||
for (int i = 0; i < (MAT_DIM * MAT_DIM); i++)
|
||||
{
|
||||
x[i] = 3;
|
||||
y[i] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void print_matrix(unsigned * z)
|
||||
{
|
||||
vx_print_str("-------------------------------\n");
|
||||
for (int j = 0; j < (MAT_DIM * MAT_DIM); j++)
|
||||
{
|
||||
if (j!=0) if ((j % MAT_DIM) == 0) vx_print_str("\n");
|
||||
vx_print_hex(z[j]);
|
||||
vx_print_str(" ");
|
||||
}
|
||||
vx_print_str("\n-------------------------------\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
initialize_mats();
|
||||
|
||||
// matrix multiplication
|
||||
vx_sq_mat_mult(x, y, z, MAT_DIM);
|
||||
vx_print_str("\n\nMatrix multiplication\n");
|
||||
print_matrix(z);
|
||||
|
||||
|
||||
// matrix addition
|
||||
vx_mat_add(x, y, z, NUM_ROWS, NUM_COLS);
|
||||
vx_print_str("\n\nMatrix Addition\n");
|
||||
print_matrix(z);
|
||||
|
||||
|
||||
// matrix sub
|
||||
vx_mat_sub(x, y, z, NUM_ROWS, NUM_COLS);
|
||||
vx_print_str("\n\nMatrix Subtraction\n");
|
||||
print_matrix(z);
|
||||
|
||||
unsigned scal = 3;
|
||||
|
||||
// matrix element add
|
||||
vx_e_mat_add(z, &scal, z, NUM_ROWS, NUM_COLS);
|
||||
vx_print_str("\n\nMatrix Element Addition\n");
|
||||
print_matrix(z);
|
||||
|
||||
// matrix element add
|
||||
vx_e_mat_mult(z, &scal, z, NUM_ROWS, NUM_COLS);
|
||||
vx_print_str("\n\nMatrix Element Addition\n");
|
||||
print_matrix(z);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
kernel/vx_os/.DS_Store
vendored
Normal file
BIN
kernel/vx_os/.DS_Store
vendored
Normal file
Binary file not shown.
150
kernel/vx_os/vx_back/vx_back.c
Normal file
150
kernel/vx_os/vx_back/vx_back.c
Normal file
@@ -0,0 +1,150 @@
|
||||
|
||||
#include "vx_back.h"
|
||||
#include "../vx_io/vx_io.h"
|
||||
|
||||
|
||||
void vx_before_main()
|
||||
{
|
||||
// unsigned num_available_warps = vx_available_warps();
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
queue_initialize(q + i);
|
||||
}
|
||||
}
|
||||
|
||||
void vx_reschedule_warps()
|
||||
{
|
||||
|
||||
|
||||
register unsigned curr_warp asm("s10");
|
||||
// vx_printf("Reschedule: ", curr_warp);
|
||||
|
||||
if (queue_isEmpty(q+curr_warp))
|
||||
{
|
||||
// vx_printf("Done: ", curr_warp);
|
||||
done[curr_warp] = 1;
|
||||
if (curr_warp == 0)
|
||||
{
|
||||
vx_load_context();
|
||||
return;
|
||||
}
|
||||
ECALL;
|
||||
}
|
||||
|
||||
Job j;
|
||||
queue_dequeue(q+curr_warp,&j);
|
||||
|
||||
// vx_printf("Reschedule -> ", j.wid);
|
||||
asm __volatile__("mv sp,%0"::"r" (j.base_sp):);
|
||||
vx_createThreads(j.n_threads, j.wid, j.func_ptr, j.args, j.assigned_warp);
|
||||
|
||||
ECALL;
|
||||
|
||||
}
|
||||
|
||||
void vx_schedule_warps()
|
||||
{
|
||||
|
||||
unsigned num_available_warps = vx_available_warps();
|
||||
|
||||
asm __volatile__("mv s3, sp");
|
||||
|
||||
for (int curr_warp = 1; curr_warp < num_available_warps; ++curr_warp)
|
||||
{
|
||||
if (!queue_isEmpty(q+curr_warp))
|
||||
{
|
||||
Job j;
|
||||
queue_dequeue(q+curr_warp,&j);
|
||||
asm __volatile__("mv sp,%0"::"r" (j.base_sp):);
|
||||
vx_wspawn(j.n_threads, j.wid, j.func_ptr, j.args, j.assigned_warp);
|
||||
}
|
||||
}
|
||||
|
||||
asm __volatile__("mv sp, s3");
|
||||
|
||||
|
||||
vx_save_context();
|
||||
|
||||
// vx_print_str("saved context\n");
|
||||
|
||||
register unsigned val asm("tp");
|
||||
if (val)
|
||||
{
|
||||
if (!queue_isEmpty(q))
|
||||
{
|
||||
// vx_print_str("found something for w0\n");
|
||||
Job j;
|
||||
queue_dequeue(q,&j);
|
||||
// vx_printf("num_threads: ", j.n_threads);
|
||||
asm __volatile__("mv sp,%0"::"r" (j.base_sp):);
|
||||
vx_createThreads(j.n_threads, j.wid, j.func_ptr, j.args, j.assigned_warp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void vx_spawnWarps(unsigned num_Warps, unsigned num_threads, FUNC, void * args)
|
||||
{
|
||||
vx_before_main();
|
||||
|
||||
unsigned num_available_warps = vx_available_warps();
|
||||
// vx_printf("Num available warps: ", num_available_warps);
|
||||
|
||||
asm __volatile__("addi s2, sp, 0");
|
||||
int warp = 0;
|
||||
for (unsigned i = 0; i < num_Warps; i++)
|
||||
{
|
||||
asm __volatile__("lui s3, 0xFFFF0");
|
||||
asm __volatile__("add sp, sp, s3");
|
||||
register unsigned stack_ptr asm("sp");
|
||||
|
||||
Job j;
|
||||
j.wid = i;
|
||||
j.n_threads = num_threads;
|
||||
j.base_sp = stack_ptr;
|
||||
j.func_ptr = (unsigned) func;
|
||||
j.args = args;
|
||||
j.assigned_warp = warp;
|
||||
|
||||
queue_enqueue(q + warp,&j);
|
||||
++warp;
|
||||
if (warp >= num_available_warps) warp = 0;
|
||||
}
|
||||
asm __volatile__("addi sp, s2, 0");
|
||||
|
||||
|
||||
vx_schedule_warps();
|
||||
|
||||
}
|
||||
|
||||
void vx_wait_for_warps(unsigned num_wait)
|
||||
{
|
||||
// vx_printf("wait for: ", num_wait);
|
||||
unsigned num_available_warps = vx_available_warps();
|
||||
unsigned num = 0;
|
||||
while (num != num_wait)
|
||||
{
|
||||
num = 0;
|
||||
for (int i = 0; i < num_available_warps; i++)
|
||||
{
|
||||
if (done[i] == 1)
|
||||
{
|
||||
num += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vx_printf("num found: ", num);
|
||||
for (int i = 0; i < num_available_warps; i++) done[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
void * vx_get_arg_struct(void)
|
||||
{
|
||||
register void *ret asm("s7");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
55
kernel/vx_os/vx_back/vx_back.h
Normal file
55
kernel/vx_os/vx_back/vx_back.h
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../vx_util/queue.h"
|
||||
|
||||
#define WSPAWN asm __volatile__(".word 0x3006b"::);
|
||||
#define CLONE asm __volatile__(".word 0x3506b":::);
|
||||
#define JALRS asm __volatile__(".word 0x1bfe0eb":::"s10");
|
||||
#define ECALL asm __volatile__(".word 0x00000073");
|
||||
#define JMPRT asm __volatile__(".word 0x5406b");
|
||||
#define SPLIT asm __volatile__(".word 0xf206b");
|
||||
#define P_JUMP asm __volatile__(".word 0x1ff707b");
|
||||
#define JOIN asm __volatile__(".word 0x306b");
|
||||
|
||||
|
||||
#define __if(val) bool temp = !val; \
|
||||
register unsigned p asm("t5") = temp; \
|
||||
register void * e asm("t6") = &&ELSE; \
|
||||
SPLIT; \
|
||||
P_JUMP; \
|
||||
|
||||
|
||||
#define __else register void * w asm("t3") = &&AFTER; \
|
||||
asm __volatile__("jr t3"); \
|
||||
ELSE: asm __volatile__("nop");
|
||||
|
||||
#define __end_if AFTER:\
|
||||
JOIN;
|
||||
|
||||
static int done[] = {0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
static int main_sp[1];
|
||||
|
||||
unsigned context[32];
|
||||
void vx_save_context(void);
|
||||
void vx_load_context(void);
|
||||
|
||||
|
||||
#define FUNC void (func)(unsigned, unsigned)
|
||||
|
||||
unsigned vx_available_warps(void);
|
||||
unsigned vx_available_threads(void);
|
||||
|
||||
|
||||
void vx_createThreads(unsigned, unsigned, unsigned, void *, unsigned);
|
||||
void vx_wspawn(unsigned, unsigned, unsigned, void *, unsigned);
|
||||
void vx_spawnWarps(unsigned num_Warps, unsigned num_threads, FUNC, void *);
|
||||
void vx_schedule_warps(void);
|
||||
void vx_reschedule_warps(void);
|
||||
void vx_wait_for_warps(unsigned);
|
||||
void * vx_get_arg_struct(void);
|
||||
|
||||
|
||||
151
kernel/vx_os/vx_back/vx_back.s
Normal file
151
kernel/vx_os/vx_back/vx_back.s
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
|
||||
|
||||
.section .text
|
||||
|
||||
.type _start, @function
|
||||
.global _start
|
||||
_start:
|
||||
li a0, 4 # Num Warps
|
||||
csrw 0x20, a0 # Setting the number of available warps
|
||||
li a0, 8 # Num Threads
|
||||
csrw 0x21, a0 # Setting the number of available threads
|
||||
csrw mhartid,zero
|
||||
csrw misa,zero
|
||||
lui sp, 0x7ffff
|
||||
jal vx_before_main
|
||||
jal main
|
||||
ecall
|
||||
|
||||
.type vx_createThreads, @function
|
||||
.global vx_createThreads
|
||||
vx_createThreads:
|
||||
mv s7 ,a3 # Moving args to s7
|
||||
mv s10,a4 # Moving assigned_warp to s10
|
||||
mv t5 ,sp # Saving the current stack pointer to t5
|
||||
mv t2 , a0 # t2 = num_threads
|
||||
loop_init:
|
||||
li a0,1 # i = 0
|
||||
loop_cond:
|
||||
bge a0, t2, loop_done # i < num_threads
|
||||
loop_body:
|
||||
addi sp,sp,-2048 # Allocate 2k stack for new thread
|
||||
mv t1, a0 # #lane = i
|
||||
.word 0x3506b # clone register state
|
||||
loop_inc:
|
||||
addi a0, a0, 1
|
||||
j loop_cond
|
||||
loop_done:
|
||||
mv sp,t5 # Restoring the stack
|
||||
li a0,0 # setting tid = 0 for main thread
|
||||
mv t6,a2 # setting func_addr
|
||||
mv s11,t2 # setting num_threads to spawn
|
||||
.word 0x1bfe0eb
|
||||
la a0, vx_reschedule_warps
|
||||
.word 0x5406b
|
||||
|
||||
|
||||
.type vx_wspawn, @function
|
||||
.global vx_wspawn
|
||||
vx_wspawn:
|
||||
la t1, vx_createThreads
|
||||
.word 0x3006b # WSPAWN instruction
|
||||
ret
|
||||
|
||||
.global context
|
||||
|
||||
.type vx_save_context, @function
|
||||
.global vx_save_context
|
||||
vx_save_context:
|
||||
la tp, context
|
||||
sw x0 , 0 (tp)
|
||||
sw x1 , 4 (tp)
|
||||
sw x2 , 8 (tp)
|
||||
sw x3 , 12(tp)
|
||||
sw x4 , 16(tp)
|
||||
sw x5 , 20(tp)
|
||||
sw x6 , 24(tp)
|
||||
sw x7 , 28(tp)
|
||||
sw x8 , 32(tp)
|
||||
sw x9 , 36(tp)
|
||||
sw x10, 40(tp)
|
||||
sw x11, 44(tp)
|
||||
sw x12, 48(tp)
|
||||
sw x13, 52(tp)
|
||||
sw x14, 56(tp)
|
||||
sw x15, 60(tp)
|
||||
sw x16, 64(tp)
|
||||
sw x17, 68(tp)
|
||||
sw x18, 72(tp)
|
||||
sw x19, 76(tp)
|
||||
sw x20, 80(tp)
|
||||
sw x21, 84(tp)
|
||||
sw x22, 88(tp)
|
||||
sw x23, 92(tp)
|
||||
sw x24, 96(tp)
|
||||
sw x25, 100(tp)
|
||||
sw x26, 104(tp)
|
||||
sw x27, 108(tp)
|
||||
sw x28, 112(tp)
|
||||
sw x29, 116(tp)
|
||||
sw x30, 120(tp)
|
||||
sw x31, 124(tp)
|
||||
li tp, 1
|
||||
ret
|
||||
|
||||
|
||||
.type vx_load_context, @function
|
||||
.global vx_load_context
|
||||
vx_load_context:
|
||||
la tp, context
|
||||
lw x0 , 0 (tp)
|
||||
lw x1 , 4 (tp)
|
||||
lw x2 , 8 (tp)
|
||||
lw x3 , 12(tp)
|
||||
lw x4 , 16(tp)
|
||||
lw x5 , 20(tp)
|
||||
lw x6 , 24(tp)
|
||||
lw x7 , 28(tp)
|
||||
lw x8 , 32(tp)
|
||||
lw x9 , 36(tp)
|
||||
lw x10, 40(tp)
|
||||
lw x11, 44(tp)
|
||||
lw x12, 48(tp)
|
||||
lw x13, 52(tp)
|
||||
lw x14, 56(tp)
|
||||
lw x15, 60(tp)
|
||||
lw x16, 64(tp)
|
||||
lw x17, 68(tp)
|
||||
lw x18, 72(tp)
|
||||
lw x19, 76(tp)
|
||||
lw x20, 80(tp)
|
||||
lw x21, 84(tp)
|
||||
lw x22, 88(tp)
|
||||
lw x23, 92(tp)
|
||||
lw x24, 96(tp)
|
||||
lw x25, 100(tp)
|
||||
lw x26, 104(tp)
|
||||
lw x27, 108(tp)
|
||||
lw x28, 112(tp)
|
||||
lw x29, 116(tp)
|
||||
lw x30, 120(tp)
|
||||
lw x31, 124(tp)
|
||||
li tp, 0
|
||||
ret
|
||||
|
||||
.type vx_available_warps, @function
|
||||
.global vx_available_warps
|
||||
vx_available_warps:
|
||||
csrr a0, 0x20
|
||||
ret
|
||||
|
||||
.type vx_available_threads, @function
|
||||
.global vx_available_threads
|
||||
vx_available_threads:
|
||||
csrr a0, 0x21
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
kernel/vx_os/vx_io/.DS_Store
vendored
Normal file
BIN
kernel/vx_os/vx_io/.DS_Store
vendored
Normal file
Binary file not shown.
29
kernel/vx_os/vx_io/vx_io.c
Normal file
29
kernel/vx_os/vx_io/vx_io.c
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
#include "vx_io.h"
|
||||
|
||||
void vx_print_hex(unsigned f)
|
||||
{
|
||||
if (f < 16)
|
||||
{
|
||||
vx_print_str(hextoa[f]);
|
||||
return;
|
||||
}
|
||||
int temp;
|
||||
int sf = 32;
|
||||
bool start = false;
|
||||
do
|
||||
{
|
||||
temp = (f >> (sf - 4)) & 0xf;
|
||||
if (temp != 0) start = true;
|
||||
if (start) vx_print_str(hextoa[temp]);
|
||||
sf -= 4;
|
||||
} while(sf > 0);
|
||||
}
|
||||
|
||||
|
||||
void vx_printf(char * c, unsigned f)
|
||||
{
|
||||
vx_print_str(c);
|
||||
vx_print_hex(f);
|
||||
vx_print_str("\n");
|
||||
}
|
||||
9
kernel/vx_os/vx_io/vx_io.h
Normal file
9
kernel/vx_os/vx_io/vx_io.h
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
static char * hextoa[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
|
||||
void vx_print_hex(unsigned);
|
||||
void vx_print_str(char *);
|
||||
void vx_printf(char *, unsigned);
|
||||
30
kernel/vx_os/vx_io/vx_io.s
Normal file
30
kernel/vx_os/vx_io/vx_io.s
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
.type vx_print_str, @function
|
||||
.global vx_print_str
|
||||
vx_print_str:
|
||||
addi sp, sp, -12
|
||||
sw ra, 0(sp)
|
||||
sw a1, 4(sp)
|
||||
bl:
|
||||
lbu a1,0(a0)
|
||||
beqz a1,be
|
||||
jal vx_printc
|
||||
addi a0, a0, 1
|
||||
j bl
|
||||
be:
|
||||
lw ra, 0(sp)
|
||||
lw a1, 4(sp)
|
||||
addi sp, sp, 12
|
||||
ret
|
||||
|
||||
|
||||
.type vx_printc, @function
|
||||
.global vx_printc
|
||||
vx_printc:
|
||||
la a7, 0x00010000
|
||||
sw a1, 0(a7)
|
||||
ret
|
||||
|
||||
|
||||
|
||||
BIN
kernel/vx_os/vx_util/.DS_Store
vendored
Normal file
BIN
kernel/vx_os/vx_util/.DS_Store
vendored
Normal file
Binary file not shown.
49
kernel/vx_os/vx_util/queue.h
Normal file
49
kernel/vx_os/vx_util/queue.h
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
#ifndef __QUEUE__
|
||||
|
||||
#define __QUEUE__
|
||||
|
||||
|
||||
|
||||
#define SIZE 50
|
||||
#define WARPS 7
|
||||
|
||||
|
||||
typedef struct Job_t
|
||||
{
|
||||
unsigned wid;
|
||||
unsigned n_threads;
|
||||
unsigned base_sp;
|
||||
unsigned func_ptr;
|
||||
void * args;
|
||||
unsigned assigned_warp;
|
||||
|
||||
} Job;
|
||||
|
||||
typedef struct Queue_t
|
||||
{
|
||||
unsigned start_i;
|
||||
unsigned end_i;
|
||||
unsigned num_j;
|
||||
unsigned total_warps;
|
||||
unsigned active_warps;
|
||||
struct Job_t jobs[SIZE];
|
||||
|
||||
} Queue;
|
||||
|
||||
Queue q[8];
|
||||
|
||||
void queue_initialize(Queue *);
|
||||
|
||||
void queue_enqueue(Queue *, Job *);
|
||||
|
||||
void queue_dequeue(Queue *, Job *);
|
||||
|
||||
int queue_isFull(Queue *);
|
||||
int queue_isEmpty(Queue *);
|
||||
int queue_availableWarps(Queue *);
|
||||
|
||||
|
||||
void func();
|
||||
|
||||
#endif
|
||||
123
kernel/vx_os/vx_util/queue.s
Normal file
123
kernel/vx_os/vx_util/queue.s
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
.equ A_WARPS, 7
|
||||
.equ SIZE, 50
|
||||
|
||||
.section .text
|
||||
|
||||
.type queue_initialize, @function
|
||||
.global queue_initialize
|
||||
queue_initialize:
|
||||
mv t0, a0 # loading base address of q
|
||||
li t1, 0 # to initialize variables
|
||||
li t2, A_WARPS # Num of available warps
|
||||
sw t1, 0 (t0) # start_i
|
||||
sw t1, 4 (t0) # end_i
|
||||
sw t1, 8 (t0) # num_j
|
||||
sw t2, 12(t0) # total_warps
|
||||
sw t1, 16(t0) # active_warps
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
.type queue_enqueue, @function
|
||||
.global queue_enqueue
|
||||
queue_enqueue:
|
||||
mv t0, a0 # loding base address of q
|
||||
lw t1, 8 (t0) # t1 = num_j
|
||||
addi t1, t1, 1 # ++t1
|
||||
sw t1, 8 (t0) # num_j = t1
|
||||
addi t1, t0, 20 # t1 = jobs_addr
|
||||
lw t4, 4 (t0) # t4 = end_i
|
||||
slli t2, t4, 5 # index * 32 [log(sizeof(job))]
|
||||
add t1, t1, t2 # jobs + index
|
||||
lw t3, 0 (a1) # wid
|
||||
sw t3, 0 (t1) #
|
||||
lw t3, 4 (a1) # n_threads
|
||||
sw t3, 4 (t1) #
|
||||
lw t3, 8 (a1) # base_sp
|
||||
sw t3, 8 (t1) #
|
||||
lw t3, 12(a1) # func_ptr
|
||||
sw t3, 12(t1) #
|
||||
lw t3, 16(a1) # args
|
||||
sw t3, 16(t1) #
|
||||
lw t3, 20(a1) # assigned_warp
|
||||
sw t3, 20(t1) #
|
||||
addi t4, t4, 1 # end_i++
|
||||
li t5, SIZE # size
|
||||
bne t4, t5, ec # if ((q.end_i + 1) == SIZE)
|
||||
mv t4, zero
|
||||
ec:
|
||||
sw t4, 4 (t0) # end_i
|
||||
ret
|
||||
|
||||
|
||||
.type queue_dequeue, @function
|
||||
.global queue_dequeue
|
||||
|
||||
queue_dequeue:
|
||||
mv t0, a0 # loading base address of q
|
||||
lw t1, 8 (t0) # t1 = num_j
|
||||
addi t1, t1, -1 # --t1
|
||||
sw t1, 8 (t0) # num_j = t1
|
||||
addi t1, t0, 20 # t1 = jobs_addr
|
||||
lw t4, 0 (t0) # t4 = start_i
|
||||
li t6, SIZE # size
|
||||
mv t5, t4 # t5 = start_i
|
||||
addi t5, t5, 1 # t5++
|
||||
bne t5, t6, dc # if ((q.start_i + 1) == SIZE)
|
||||
mv t5, zero
|
||||
dc:
|
||||
sw t5, 0(t0) # storing start_i
|
||||
slli t2, t4, 5 # index * 32 [log(sizeof(job))]
|
||||
add t1, t1, t2 # jobs + index
|
||||
lw t3, 0 (t1) # wid
|
||||
sw t3, 0 (a1) #
|
||||
lw t3, 4 (t1) # n_threads
|
||||
sw t3, 4 (a1) #
|
||||
lw t3, 8 (t1) # base_sp
|
||||
sw t3, 8 (a1) #
|
||||
lw t3, 12(t1) # func_ptr
|
||||
sw t3, 12(a1) #
|
||||
lw t3, 16(t1) # args
|
||||
sw t3, 16(a1) #
|
||||
lw t3, 20(t1) # assigned_warp
|
||||
sw t3, 20(a1) #
|
||||
ret
|
||||
|
||||
|
||||
.type queue_isFull, @function
|
||||
.global queue_isFull
|
||||
queue_isFull:
|
||||
mv t0, a0 # loading base address of q
|
||||
lw t1, 8 (t0) # t1 = num_j
|
||||
mv a0, zero # ret_val = 0
|
||||
li t3, SIZE # t3 = SIZE
|
||||
bne t3, t1, qf # if (num_j == 1)
|
||||
addi a0, a0, 1 # ret_val = 1;
|
||||
qf:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
.type queue_isEmpty, @function
|
||||
.global queue_isEmpty
|
||||
queue_isEmpty:
|
||||
mv t0, a0 # loading base address of q
|
||||
lw t1, 8 (t0) # t1 = num_j
|
||||
mv a0, zero # ret_val = 0
|
||||
mv t3, zero # t3 = 0
|
||||
bne t3, t1, qe # if (num_j == 0)
|
||||
addi a0, a0, 1 # ret_val = 1;
|
||||
qe:
|
||||
ret
|
||||
|
||||
|
||||
.type queue_availableWarps, @function
|
||||
.global queue_availableWarps
|
||||
queue_availableWarps:
|
||||
mv t0, a0 # loading base address of q
|
||||
lw t1, 12(t0) # t1 = total_warps
|
||||
lw t2, 16(t0) # t2 = active_warps
|
||||
sltu a0, t2, t1
|
||||
ret
|
||||
Reference in New Issue
Block a user