Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert homogentable to array/vector/matrix #4

Merged
merged 47 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
08352ab
1. convert homogenTable to array/vector/matrix
minmingzhu Apr 17, 2022
a88614f
update ConvertHomogenTableSuite.scala
minmingzhu Apr 17, 2022
aaca1ea
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 17, 2022
5aa8430
update test.sh
minmingzhu Apr 17, 2022
44e00c5
Update build-jni.sh
minmingzhu Apr 17, 2022
244d33d
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 22, 2022
711ba0c
update
minmingzhu Apr 22, 2022
1dfc511
update ColumnAccessorImpl.cpp RowAccessorImpl.cpp
minmingzhu Apr 24, 2022
77a46a9
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 25, 2022
08c70e2
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 25, 2022
ba99cb6
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 28, 2022
7843ca3
Merge remote-tracking branch 'origin/convert_homogentable' into conve…
minmingzhu Apr 28, 2022
e0b782f
Update ci-local-dpc-test.sh
minmingzhu Apr 28, 2022
6c32fca
merge make_homogen_table
minmingzhu May 9, 2022
f3a72e5
rollback to edb9f3d
minmingzhu May 9, 2022
cc5352c
update
minmingzhu May 9, 2022
884c0b4
Merge remote-tracking branch 'origin/convert_homogentable' into conve…
minmingzhu May 9, 2022
c3b214e
1. convert homogenTable to array/vector/matrix
minmingzhu Apr 17, 2022
47a7171
update ConvertHomogenTableSuite.scala
minmingzhu Apr 17, 2022
4556a5d
update ColumnAccessorImpl.cpp RowAccessorImpl.cpp
minmingzhu Apr 24, 2022
7f9a768
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 25, 2022
0ea2448
update
minmingzhu May 9, 2022
35af201
update
minmingzhu May 9, 2022
065d0d3
Merge remote-tracking branch 'origin/convert_homogentable' into conve…
minmingzhu May 9, 2022
8ab660d
update
minmingzhu May 9, 2022
0cb1f19
1. convert homogenTable to array/vector/matrix
minmingzhu Apr 17, 2022
354d4a9
update ConvertHomogenTableSuite.scala
minmingzhu Apr 17, 2022
f6c228b
update ColumnAccessorImpl.cpp RowAccessorImpl.cpp
minmingzhu Apr 24, 2022
e1cba0d
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 25, 2022
fcf8314
rollback to edb9f3d
minmingzhu May 9, 2022
0c4bd73
update
minmingzhu May 9, 2022
2226da9
1. convert homogenTable to array/vector/matrix
minmingzhu Apr 17, 2022
73f99fa
update ColumnAccessorImpl.cpp RowAccessorImpl.cpp
minmingzhu Apr 24, 2022
800845b
Merge branch 'make_homogen_table' into convert_homogentable
minmingzhu Apr 25, 2022
e13e27a
update
minmingzhu May 9, 2022
177e486
update
minmingzhu May 9, 2022
e4778fe
Merge remote-tracking branch 'origin/convert_homogentable' into conve…
minmingzhu May 9, 2022
7114c7c
update
minmingzhu May 9, 2022
ef2a7d7
update cpp style
minmingzhu May 9, 2022
45bf666
Update build.sh
minmingzhu May 10, 2022
5b86e6c
fix comments
minmingzhu May 10, 2022
8f31387
Merge remote-tracking branch 'origin/convert_homogentable' into conve…
minmingzhu May 10, 2022
f060188
update code style
minmingzhu May 10, 2022
d853874
fix comments
minmingzhu May 16, 2022
d84ab04
update
minmingzhu May 16, 2022
961f55f
update
minmingzhu May 16, 2022
9e694f2
update
minmingzhu May 16, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.intel.oneapi.dal.table;

public class ColumnAccessor {
private long cObject;

public ColumnAccessor(long cObject) {
this.cObject = cObject;
}

public double[] pullDouble(long columnIndex, Common.ComputeDevice device){
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
return this.cPullDouble(this.cObject, columnIndex, 0, -1, device.ordinal());
}

public double[] pullDouble(long columnIndex, long rowStartIndex, long rowEndIndex, Common.ComputeDevice device){
return this.cPullDouble(this.cObject, columnIndex, rowStartIndex, rowEndIndex, device.ordinal());
}

private native double[] cPullDouble(long cObject, long cColumnIndex,
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
long cRowStartIndex, long cRowEndIndex, int computeDeviceIndex);

public float[] pullFloat(long columnIndex, Common.ComputeDevice device){
return this.cPullFloat(this.cObject, columnIndex, 0, -1, device.ordinal());
}

public float[] pullFloat(long columnIndex, long rowStartIndex, long rowEndIndex, Common.ComputeDevice device){
return this.cPullFloat(this.cObject, columnIndex, rowStartIndex, rowEndIndex, device.ordinal());
}

private native float[] cPullFloat(long cObject, long cColumnIndex, long cRowStartIndex,
long cRowEndIndex, int computeDeviceIndex);

public int[] pullInt(long columnIndex, Common.ComputeDevice device){
return this.cPullInt(this.cObject, columnIndex, 0, -1, device.ordinal());
}

public int[] pullInt(long columnIndex, long rowStartIndex, long rowEndIndex, Common.ComputeDevice device){
return this.cPullInt(this.cObject, columnIndex, rowStartIndex, rowEndIndex, device.ordinal());
}

private native int[] cPullInt(long cObject, long cColumnIndex, long cRowStartIndex,
long cRowEndIndex, int computeDeviceIndex);

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum ComputeDevice {
public static ComputeDevice get(int ordinal) {
return values[ordinal];
}
public static int getOrdinalByName(String key){
public static ComputeDevice getOrdinalByName(String key){
ComputeDevice device = null;
switch (key.toUpperCase()){
case "HOST":
Expand All @@ -43,7 +43,7 @@ public static int getOrdinalByName(String key){
device = GPU;
break;
}
return device.ordinal();
return device;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ public HomogenTable(long cTable){
public HomogenTable(long rowCount,
long colCount,
int[] data,
int deviceIndex){
Common.ComputeDevice device){
super();
// default
Common.DataLayout dataLayout = Common.DataLayout.ROW_MAJOR;
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

public HomogenTable(long rowCount,
long colCount,
int[] data,
int layoutindex,
int deviceIndex){
Common.DataLayout dataLayout,
Common.ComputeDevice device){
super();
Common.DataLayout dataLayout = Common.DataLayout.get(layoutindex);
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);

Expand All @@ -36,75 +33,65 @@ public HomogenTable(long rowCount,
public HomogenTable(long rowCount,
long colCount,
long[] data,
int deviceIndex){
Common.ComputeDevice device){
super();
// default
Common.DataLayout dataLayout = Common.DataLayout.ROW_MAJOR;
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

public HomogenTable(long rowCount,
long colCount,
long[] data,
int layoutIndex,
int deviceIndex){
Common.DataLayout dataLayout,
Common.ComputeDevice device){
super();
Common.DataLayout dataLayout = Common.DataLayout.get(layoutIndex);
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

public HomogenTable(long rowCount,
long colCount,
float[] data,
int deviceIndex){
Common.ComputeDevice device){
super();
// default
Common.DataLayout dataLayout = Common.DataLayout.ROW_MAJOR;
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

public HomogenTable(long rowCount,
long colCount,
float[] data,
int layoutIndex,
int deviceIndex){
Common.DataLayout dataLayout,
Common.ComputeDevice device){
super();
Common.DataLayout dataLayout = Common.DataLayout.get(layoutIndex);
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

public HomogenTable(long rowCount,
long colCount,
double[] data,
int deviceIndex){
Common.ComputeDevice device){
super();
// default
Common.DataLayout dataLayout = Common.DataLayout.ROW_MAJOR;
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

public HomogenTable(long rowCount,
long colCount,
double[] data,
int layoutIndex,
int deviceIndex){
Common.DataLayout dataLayout,
Common.ComputeDevice device){
super();
Common.DataLayout dataLayout = Common.DataLayout.get(layoutIndex);
Common.ComputeDevice device = Common.ComputeDevice.get(deviceIndex);
impl = new HomogenTableImpl(rowCount, colCount, data,
dataLayout, device);
}

@Override
public Long getColumnCount() {
return impl.getColumnCount();
Expand Down Expand Up @@ -150,4 +137,8 @@ public long[] getLongData() {
public double[] getDoubleData() {
return impl.getDoubleData();
}

public long getcObejct() {
return impl.getcObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class HomogenTableImpl implements HomogenTableIface {
e.printStackTrace();
}
}
private transient long cObject;
private long cObject;
private TableMetadata metadata;

protected HomogenTableImpl() {
Expand Down Expand Up @@ -130,8 +130,10 @@ public long getPullRowsIface() {
private native long cGetPullRowsIface(long cObject);

@Override
public long getPullColumnIface() {
return 0;
public ColumnAccessor getPullColumnIface() {
ColumnAccessor accessor = new ColumnAccessor(cGetPullColumnIface(this.cObject));

return accessor;
}

private native long cGetPullColumnIface(long cObject);
Expand Down Expand Up @@ -177,4 +179,8 @@ public double[] getDoubleData() {
}

private native double[] cGetDoubleData(long cObject);

public long getcObject(){
return this.cObject;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.intel.oneapi.dal.table;

public class RowAccessor {
private transient long cObject;

public RowAccessor(long cObject) {
this.cObject = cObject;
}

public double[] pullDouble(Common.ComputeDevice device){
return this.cPullDouble(this.cObject, 0, -1, device.ordinal());
}

public double[] pullDouble(long rowStartIndex, long rowEndIndex, Common.ComputeDevice device){
return this.cPullDouble(this.cObject, rowStartIndex, rowEndIndex, device.ordinal());
}

private native double[] cPullDouble(long cObject, long cRowStartIndex,
long cRowEndIndex, int computeDeviceIndex);

public float[] pullFloat(Common.ComputeDevice device){
return this.cPullFloat(this.cObject, 0, -1, device.ordinal());
}

public float[] pullFloat(long rowStartIndex, long rowEndIndex, Common.ComputeDevice device){
return this.cPullFloat(this.cObject, rowStartIndex, rowEndIndex, device.ordinal());
}

private native float[] cPullFloat(long cObject, long cRowStartIndex,
long cRowEndIndex, int computeDeviceIndex);

public int[] pullInt(Common.ComputeDevice device){
return this.cPullInt(this.cObject, 0, -1, device.ordinal());
}

public int[] pullInt(long rowStartIndex, long rowEndIndex, Common.ComputeDevice device){
return this.cPullInt(this.cObject, rowStartIndex, rowEndIndex, device.ordinal());
}

private native int[] cPullInt(long cObject, long cRowStartIndex,
long cRowEndIndex, int computeDeviceIndex);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.ArrayList;

public class SimpleMetadataImpl implements TableMetadataImpl{
private transient long cObject;
private long cObject;
private ArrayList dtypes;
private ArrayList ftypes;
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.Serializable;

public abstract class Table implements Serializable {
public abstract class Table {
public Table() {}
protected abstract Long getColumnCount();
protected abstract Long getRowCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface TableIface {
Common.DataLayout getDataLayout();
TableMetadata getMetaData();
long getPullRowsIface();
long getPullColumnIface();
ColumnAccessor getPullColumnIface();
long getPullCSRBlockIface();
boolean hasData();
}
39 changes: 20 additions & 19 deletions mllib-dal/src/main/native/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@

static std::mutex mtx;
static std::vector<std::shared_ptr<sycl::queue>> cVector;
sycl::queue *getQue() {

static void setVector(std::shared_ptr<sycl::queue> *ptr) {
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
mtx.lock();
cVector.push_back(*ptr);
mtx.unlock();
}

static sycl::queue *getQue(const sycl::device device) {
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
mtx.lock();
if (!cVector.empty()) {
return cVector[0].get();
} else {
sycl::queue *queue = new sycl::queue(device);
std::shared_ptr<sycl::queue> *queuePtr =
new std::shared_ptr<sycl::queue>(queue);
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
setVector(queuePtr);
return cVector[0].get();
}
return NULL;
mtx.unlock();
minmingzhu marked this conversation as resolved.
Show resolved Hide resolved
}

static std::vector<sycl::device> get_gpus() {
Expand Down Expand Up @@ -72,35 +86,22 @@ sycl::device getAssignedGPU(ccl::communicator &comm, int size, int rankId,
return rank_gpu;
}

static void setVector(std::shared_ptr<sycl::queue> *ptr) {
mtx.lock();
cVector.push_back(*ptr);
mtx.unlock();
}

sycl::queue *getQueue(const compute_device device) {
std::cout << "Get Queue" << std::endl;
std::shared_ptr<sycl::queue> *queuePtr;
sycl::queue *queue;

switch (device) {
case compute_device::gpu: {
std::cout << "selector GPU" << std::endl;
auto device_gpu = sycl::gpu_selector{}.select_device();
queue = new sycl::queue(device_gpu);
queuePtr = new std::shared_ptr<sycl::queue>(queue);
setVector(queuePtr);
return getQue();
return getQue(device_gpu);
}
case compute_device::cpu: {
std::cout << "selector CPU" << std::endl;
auto device_cpu = sycl::cpu_selector{}.select_device();
queue = new sycl::queue(device_cpu);
queuePtr = new std::shared_ptr<sycl::queue>(queue);
setVector(queuePtr);
return getQue();
return getQue(device_cpu);
}
default: {
return getQue();
return NULL;
}
}
}
10 changes: 6 additions & 4 deletions mllib-dal/src/main/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ LIBS_COMMON := -L$(CCL_ROOT)/lib/cpu_gpu_dpcpp -lccl \
-L$(TBBROOT)/lib/intel64/gcc4.8 -ltbb -ltbbmalloc \
-L$(I_MPI_ROOT)


ifeq ($(PLATFORM_PROFILE),CPU_ONLY_PROFILE)
LIBS := $(LIBS_COMMON)
else ifeq ($(PLATFORM_PROFILE),CPU_GPU_PROFILE)
Expand All @@ -78,7 +77,9 @@ CPP_SRCS += \
./CorrelationDALImpl.cpp \
./SummarizerDALImpl.cpp \
./oneapi/dal/HomogenTableImpl.cpp \
./oneapi/dal/SimpleMetadataImpl.cpp
./oneapi/dal/SimpleMetadataImpl.cpp \
./oneapi/dal/ColumnAccessorImpl.cpp \
./oneapi/dal/RowAccessorImpl.cpp


OBJS += \
Expand All @@ -91,8 +92,9 @@ OBJS += \
./CorrelationDALImpl.o \
./SummarizerDALImpl.o \
./oneapi/dal/HomogenTableImpl.o \
./oneapi/dal/SimpleMetadataImpl.o

./oneapi/dal/SimpleMetadataImpl.o \
./oneapi/dal/ColumnAccessorImpl.o \
./oneapi/dal/RowAccessorImpl.o

DEFINES=-D$(PLATFORM_PROFILE)

Expand Down
6 changes: 4 additions & 2 deletions mllib-dal/src/main/native/build-jni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ javah -d $WORK_DIR/javah -classpath "$WORK_DIR/../../../target/classes:$DAAL_JAR
com.intel.oap.mllib.stat.CorrelationDALImpl \
com.intel.oap.mllib.stat.SummarizerDALImpl \
com.intel.oneapi.dal.table.HomogenTableImpl \
com.intel.oneapi.dal.table.SimpleMetadataImpl

com.intel.oneapi.dal.table.SimpleMetadataImpl \
com.intel.oneapi.dal.table.ColumnAccessor \
com.intel.oneapi.dal.table.RowAccessor

Loading