Skip to content

Commit

Permalink
sw: Adding placeholder for hero libomptarget-device library
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilKoe committed Dec 12, 2023
1 parent 38ed00c commit fd4a705
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 0 deletions.
1 change: 1 addition & 0 deletions target/sim/sw/device/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Add user applications to APPS variable
APPS = blas/axpy
APPS += blas/gemm
APPS += libomptarget_device

TARGET ?= all

Expand Down
3 changes: 3 additions & 0 deletions target/sim/sw/device/apps/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ $(BUILDDIR):
$(DEP): $(SRCS) | $(BUILDDIR)
$(RISCV_CC) $(RISCV_CFLAGS) -MM -MT '$(ELF)' $< > $@

$(BUILDDIR)/%.o: $(SRC_DIR)/%.c | $(BUILDDIR)
$(RISCV_CC) $(RISCV_CFLAGS) -c $< -o $@

$(ELF): $(DEP) $(LD_SRCS) | $(BUILDDIR)
$(RISCV_CC) $(RISCV_CFLAGS) $(RISCV_LDFLAGS) $(SRCS) -o $@

Expand Down
30 changes: 30 additions & 0 deletions target/sim/sw/device/apps/libomptarget_device/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Cyril Koenig <[email protected]>

# Usage of absolute paths is required to externally include this Makefile
MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR := $(realpath $(MK_DIR)/src)

APP ?= omptarget_device
SRCS ?= $(SRC_DIR)/main.c
INCDIRS += $(SRC_DIR)

.PHONY: clean
clean:

include ../common.mk

OBJS := $(subst $(SRC_DIR), $(BUILDDIR), $(SRCS:.c=.o))
LIB := $(BUILDDIR)/libomptarget_device.a

$(BUILDDIR)/origin.ld: | $(BUILDDIR)
echo "L3_ORIGIN = 0x80000000;" > $(BUILDDIR)/origin.ld

$(LIB): $(OBJS) | $(BUILDDIR)
$(RISCV_AR) $(RISCV_ARFLAGS) $@ $^

# For this target, only build the library
all: $(LIB)
181 changes: 181 additions & 0 deletions target/sim/sw/device/apps/libomptarget_device/link.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
OUTPUT_ARCH(riscv)

Check failure on line 1 in target/sim/sw/device/apps/libomptarget_device/link.ld

View workflow job for this annotation

GitHub Actions / Check License headers

FAILED: File does not start with comment
ENTRY( _start )
MEMORY
{
LOCAL : ORIGIN = 0x70010000, LENGTH = 0x70000
L2 : ORIGIN = 0x80000000, LENGTH = 0x0fffffff
}



SECTIONS
{
.init :
{
. = ALIGN(4);
KEEP( *(.init) )
} > LOCAL


.fini :
{
. = ALIGN(4);
KEEP( *(.fini) )
} > LOCAL

.preinit_array : {
. = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} > LOCAL

.init_array : {
. = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(.ctors.start))
KEEP(*(.ctors))
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array ))
LONG(0)
__CTOR_END__ = .;
PROVIDE_HIDDEN (__init_array_end = .);
} > LOCAL

.fini_array : {
. = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .);
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
KEEP(*(.dtors.start))
KEEP(*(.dtors))
LONG(0)
__DTOR_END__ = .;
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array ))
PROVIDE_HIDDEN (__fini_array_end = .);
} > LOCAL

.boot : {
. = ALIGN(4);
*(.boot)
*(.boot.data)
} > LOCAL

.rodata : {
. = ALIGN(4);
*(.rodata);
*(.rodata.*)
*(.srodata);
*(.srodata.*)
*(.eh_frame*)
} > LOCAL

.shbss : {
. = ALIGN(4);
*(.shbss)
} > LOCAL

.talias : {
} > LOCAL

.gnu.offload_funcs : {
. = ALIGN(4);
KEEP(*(.gnu.offload_funcs))
} > LOCAL

.gnu.offload_vars : {
. = ALIGN(4);
KEEP(*(.gnu.offload_vars))
} > LOCAL

.stack : {
. = ALIGN(4);
. = ALIGN(16);
stack_start = .;
. = . + 0x1000;
stack = .;
} > LOCAL

.data : {
. = ALIGN(4);
sdata = .;
_sdata = .;
*(.data_fc)
*(.data_fc.*)
*(.data);
*(.data.*)
*(.sdata);
*(.sdata.*)
*(.heapl2ram)
*(.fcTcdm)
*(.fcTcdm.*)
*(.fcTcdm_g)
*(.fcTcdm_g.*)
. = ALIGN(4);
edata = .;
_edata = .;
} > LOCAL

.bss : {
. = ALIGN(8);
_bss_start = .;
*(.bss)
*(.bss.*)
*(.sbss)
*(.sbss.*)
*(COMMON)
. = ALIGN(4);
_bss_end = .;
} > LOCAL

__l2_priv0_end = ALIGN(4);

/*
* LOCAL PRIVATE BANK1
*
* Contains FC code
*/

.vectors MAX(0x60010000,ALIGN(256)) :
{
__irq_vector_base = .;
KEEP(*(.vectors))
} > LOCAL

.text :
{
. = ALIGN(4);
_stext = .;
*(.text)
*(.text.*)
_etext = .;
*(.lit)
*(.shdata)
_endtext = .;
. = ALIGN(4);
} > LOCAL

__l2_priv1_end = ALIGN(4);

/*
* L2 SHARED BANKS
*
* Contains other data such as peripheral data and cluster code and data
*/

.l2_data :
{
. = ALIGN(4);
*(.l2_data)
*(.l2_data.*)
*(.data_fc_shared)
*(.data_fc_shared.*)
. = ALIGN(4);
} > L2

__l2_shared_end = ALIGN(4);

}
4 changes: 4 additions & 0 deletions target/sim/sw/device/apps/libomptarget_device/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Check failure on line 1 in target/sim/sw/device/apps/libomptarget_device/src/main.c

View workflow job for this annotation

GitHub Actions / Check License headers

FAILED: File does not start with comment
int main() {
return 0;
}
Binary file not shown.

0 comments on commit fd4a705

Please sign in to comment.