Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build/
*.pb.h
makefile.config
etc/config
sysroot/debian-buster
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
include makefile.config

ifdef SYSROOT
SYSROOT_FLAGS:=--sysroot=${SYSROOT} -L/usr/lib/aarch64-linux-gnu -L/usr/lib/aarch64-linux-gnu/blas
SYSROOT_RPATH:=:/usr/lib/aarch64-linux-gnu/blas:/usr/lib/aarch64-linux-gnu/lapack
else
SYSROOT_FLAGS:=
SYSROOT_RPATH:=
endif

export CROSS_COMPILE SYSROOT SYSROOT_FLAGS SYSROOT_RPATH

MAKEBUILD=$(shell pwd)/scripts/makefile.build

BUILD_DIR=$(shell pwd)/build
Expand Down Expand Up @@ -48,10 +58,9 @@ install: $(SUB_DIRS)

$(APP_SUB_DIRS): $(LIB_SUB_DIRS)

$(SUB_DIRS):
$(SUB_DIRS): ${SYSROOT}
@$(MAKE) -C $@ BUILD_DIR=$(BUILD_DIR)/$@ $(MAKECMDGOALS)


distclean:
find . -name $(BUILD_DIR) | xargs rm -rf
find . -name $(INSTALL_DIR) | xargs rm -rf
Expand Down
15 changes: 7 additions & 8 deletions core/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
CC=gcc -std=gnu99
CXX=g++ -std=c++11
LD=g++

CC=${CROSS_COMPILE}gcc -std=gnu99 ${SYSROOT_FLAGS}
CXX=${CROSS_COMPILE}g++ -std=c++11 ${SYSROOT_FLAGS}
LD=${CROSS_COMPILE}g++ ${SYSROOT_FLAGS}

BUILD_DIR?=$(shell pwd)/build
INSTALL_DIR?=$(shell pwd)/install
MAKEBUILD?=$(shell pwd)/makefile.build

export CC CXX CFLAGS LD LDFLAGS CXXFLAGS COMMON_CFLAGS
export CC CXX CFLAGS LD LDFLAGS CXXFLAGS COMMON_CFLAGS

INC_DIR+=-I$(shell pwd)/../include -I$(shell pwd)/include -I$(shell pwd)/include
#INC_DIR+=-I$(shell pwd)/../operator/include


CXXFLAGS+=
CXXFLAGS+=

COMMON_CFLAGS+= -Wall -g -I$(shell pwd)/include -fPIC $(INC_DIR)
COMMON_CFLAGS+= -Wall -g -I$(shell pwd)/include -fPIC $(INC_DIR)

libsubdir_list=lib

Expand Down Expand Up @@ -54,7 +53,7 @@ $(BIN_OBJS): $(binsubdir_list)

build: default install

LDFLAGS+=-rdynamic
LDFLAGS+=-rdynamic ${SYSROOT_FLAGS}

#$(TENGINE_OBJS): $(libsubdir_list)
#$(BIN_OBJS):$(binsubdir_list)
Expand Down
1 change: 1 addition & 0 deletions core/include/notify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <string>
#include <vector>
#include <iostream>
#include <functional>

#include "any.hpp"

Expand Down
12 changes: 6 additions & 6 deletions driver/Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
CC=gcc -std=gnu99
CXX=g++ -std=c++11
LD=g++
CC=${CROSS_COMPILE}gcc -std=gnu99 ${SYSROOT_FLAGS}
CXX=${CROSS_COMPILE}g++ -std=c++11 ${SYSROOT_FLAGS}
LD=${CROSS_COMPILE}g++ ${SYSROOT_FLAGS}


BUILD_DIR?=$(shell pwd)/build
INSTALL_DIR?=$(shell pwd)/install
MAKEBUILD?=$(shell pwd)/makefile.build

export CC CXX CFLAGS LD LDFLAGS CXXFLAGS COMMON_CFLAGS
export CC CXX CFLAGS LD LDFLAGS CXXFLAGS COMMON_CFLAGS

INC_DIR+=-I$(shell pwd)/include
INC_DIR+=-I$(shell pwd)/../include
INC_DIR+=-I$(shell pwd)/../core/include
INC_DIR+=-I$(shell pwd)/../operator/include
INC_DIR+=-I$(shell pwd)/../executor/include

MODULE_DIR=rk3399 hikey960 plugin
MODULE_DIR=rk3399 hikey960 apq8096 plugin
MODULE_NAME=libdriver.so

CXXFLAGS+=

COMMON_CFLAGS+= -Wall -g -fPIC $(INC_DIR)
COMMON_CFLAGS+= -Wall -g -fPIC $(INC_DIR)
ifeq ($(CONFIG_CAFFE_REF),y)
COMMON_CFLAGS+= -DCONFIG_CAFFE_REF=1
endif
Expand Down
7 changes: 7 additions & 0 deletions driver/apq8096/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
obj-y+=apq8096_driver.o
obj-y+=apq8096_executor.o

apq8096_driver_CXXFLAGS+=-I.
apq8096_executor_CXXFLAGS+=-I.


209 changes: 209 additions & 0 deletions driver/apq8096/apq8096_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

/*
* Copyright (c) 2018, Open AI Lab
* Copyright (c) 2018, Linaro Ltd
* Author: haitao@openailab.com
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
* Author: Mark Charlebois <mark.charlebois@linaro.org>
*/

#include <sched.h>
#include <chrono>
#include <functional>

#include "tensor_mem.hpp"
#include "apq8096_driver.hpp"
#include "apq8096_executor.hpp"
#include "logger.hpp"


namespace TEngine {


APQ8096Driver::APQ8096Driver(void)
{
SetName("APQ8096");

id_table_.push_back("cpu.apq8096.kryo.all");
id_table_.push_back("cpu.apq8096.c0.all");
id_table_.push_back("cpu.apq8096.c1.all");
id_table_.push_back("cpu.apq8096.kryo.0");
id_table_.push_back("cpu.apq8096.kryo.2");
}


int APQ8096Driver::ProbeDevice(void)
{
int number=0;

for(unsigned int i=0; i<id_table_.size();i++)
{
const dev_id_t& dev_id=id_table_[i];
if(ProbeDevice(dev_id))
number++;
}
return number;
}

bool APQ8096Driver::ProbeDevice(const dev_id_t& dev_id)
{
if(dev_id==std::string("cpu.apq8096.kryo.all"))
{
CPUDevice * dev=new APQ8096Device();
dev->SetName(dev_id);
InitializeDevice(dev);
device_table_[dev->GetName()]=dev;
return true;
}
else if (dev_id == "cpu.apq8096.c0.all")
{
CPUDevice * dev=new KryoClusterDevice(0);
dev->SetName(dev_id);
InitializeDevice(dev);
device_table_[dev->GetName()]=dev;
return true;
}
else if(dev_id == "cpu.apq8096.c1.all")
{
CPUDevice * dev=new KryoClusterDevice(1);
dev->SetName(dev_id);
InitializeDevice(dev);
device_table_[dev->GetName()]=dev;
return true;
}
else if(dev_id == std::string("cpu.apq8096.kryo.0"))
{
CPUDevice * dev=new SingleKryoDevice(0);
dev->SetName(dev_id);
InitializeDevice(dev);
device_table_[dev->GetName()]=dev;
return true;

}
else if(dev_id == std::string("cpu.apq8096.kryo.2"))
{
CPUDevice * dev=new SingleKryoDevice(1);
dev->SetName(dev_id);
InitializeDevice(dev);
device_table_[dev->GetName()]=dev;
return true;
}
return false;
}

int APQ8096Driver::DestroyDevice(void)
{
auto ir=device_table_.begin();
auto end=device_table_.end();

int count=0;

while(ir!=end)
{
if(DestroyDevice(ir->second)) {
count++;
}
else {
ir++;
}
}

return count;
}

bool APQ8096Driver::DestroyDevice(Device * device)
{
CPUDevice * cpu_dev=reinterpret_cast<CPUDevice *>(device);

if(GetDeviceStatus(cpu_dev)!=kDevStopped) {
return false;
}

ReleaseDevice(cpu_dev);

device_table_.erase(cpu_dev->GetName());

delete cpu_dev;

return true;
}

int APQ8096Driver::GetDeviceNum(void)
{
return device_table_.size();
}

Device * APQ8096Driver::GetDevice(int idx)
{
auto ir=device_table_.begin();
auto end=device_table_.end();

int i;

for(i=0;i<idx && ir!=end;i++,ir++);

if(ir==end) {
return nullptr;
}

return ir->second;
}

Device * APQ8096Driver::GetDevice(const std::string& name)
{
if(device_table_.count(name)==0) {
return nullptr;
}
return device_table_[name];
}



int APQ8096Driver::GetDevIDTableSize()
{
return id_table_.size();
}

const dev_id_t& APQ8096Driver::GetDevIDbyIdx(int idx)
{
return id_table_[idx];
}

bool APQ8096Driver::GetWorkload(Device * dev, DevWorkload& load)
{
//TO BE IMPLEMENTED
return false;
}

bool APQ8096Driver::GetPerf(Device * dev, Subgraph * graph,int policy,GraphPerf& perf)
{
//TO BE IMPLEMENTED
return false;
}

float APQ8096Driver::GetFops(Device * dev, Subgraph * graph)
{
//TO BE IMPLEMENTED
return false;
}


} //namespace TEngine
Loading