Skip to content

Commit

Permalink
Merge branch 'develop' into feat/pointer_copies
Browse files Browse the repository at this point in the history
  • Loading branch information
mairooni committed Jun 26, 2024
2 parents dd45e60 + 469765f commit f84aa53
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 107 deletions.
60 changes: 35 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,59 @@ Please follow the instructions below for your Pull Requests (PRs).

## How to submit your changes

1. **Fork** the repository in GitHub
2. **Clone** the project
3. **Create a new branch from the `develop` branch**
4. **Commit your changes**
5. **Push** your work to your repository
6. Create a **Pull Request** to the `develop` branch.

Please, ensure that your changes are merged with the latest changes in the `develop` branch, and the code follows the
code conventions (see below).

Be aware we are a very small team.
Thus, depending on the PR, it might take some time for us to review it since we check on many OCL/SPIR-V/PTX platforms and different drivers.
1. **Fork** the repository in GitHub.
2. **Clone** the project.
3. **Create a new branch from the `develop` branch**:
```bash
$ git checkout -b fix/my/branch
```
4. **Commit your changes**:
```bash
$ git add <yourFiles>
$ git commit -a -m "My new feature/fix"
```
5. **Push** your work to your repository:
```bash
$ git push -u myRepo feat/my/branch
```
6. Create a **Pull Request** (PR) to the `develop` branch.
7. When you open PR, there are a few GitHub actions. One of them is the checker for the **Contributor License Agreement**, [CLA](https://cla-assistant.io/beehive-lab/TornadoVM), if you haven't signed before, you will be prompted with the link to sign the CLA. Use the same email as you commit email.
Please, ensure that your changes are merged with the latest changes in the `develop` branch, and the code follows the code conventions (see below).
### What's next?

We check the PR and test it internally. Be aware we are a very small team. Thus, depending on the PR, it might take some time for us to review it since we check the PR with our regression tests and benchmarks for all backends (OCL/SPIR-V/PTX platforms) as well as with different drivers and Operating Systems.

## Code of Conduct

For the PR process as well as any issues and discussions we follow this [CODE_OF_CONDUCT](https://github.com/beehive-lab/TornadoVM/blob/master/CODE_OF_CONDUCT.md).


## What happens after you open the PR?
## How is the review process?

We have a few GitHub actions, such as code formatter, documentation rendering and checks for the CLA (Contributor License Agreement).
If you haven't signed the CLA yet, you will be redirected to the TornadoVM CLA webpage, where you can read and review it.
1. We have a few GitHub actions, such as code formatter, documentation rendering and checks for the CLA (Contributor License Agreement).
2. As mentioned earlier, if you haven't signed the CLA yet, you will be redirected to the TornadoVM CLA webpage, where you can read and review it.
If you agree with the terms, then you will sign it.
After that, the TornadoVM team can process your PR to be able to merge it into the TornadoVM's codebase.

At least two researchers/engineers from the TornadoVM team will review your PR.
Expect a few comments, questions and possible changes.
3. After that, the TornadoVM team can process your PR to be able to merge it into the TornadoVM's codebase.
4. At least two researchers/engineers from the TornadoVM team will review your PR.
**Expect a few comments, questions and possible changes.**
This is a totally normal process, and it tries not to introduce untested code for specific devices, better documentation, etc.
Thus, we work together to improve TornadoVM.
We are proud to say that TornadoVM is 10+ years of active development, with many different researchers and developers. Thus, we prioritize code maintainability and reproducibility, and we will work together to guarantee this as much as possible.


## Coding Conventions

We use the auto-formatter for **Eclipse** and **IntelliJ**.
Please, ensure that your code follows the formatter rules before the pull request.
The auto-formatter is set automatically by running the following script:
We use the auto-formatter for **Eclipse** and **IntelliJ**. You can use any IDE you like, but keep in mind the whole TornadoVM team uses IntelliJ. Please, ensure that your code follows the formatter rules before the pull request. The auto-formatter is set automatically by running the following script:


#### Using Eclipse:
### Using Eclipse:
```bash
## For Eclipse, use the following script
$ python3 scripts/eclipseSetup.py
```

#### Using IntelliJ:
### Using IntelliJ:

For IntelliJ, import the XML auto-formatter. Steps [here](https://tornadovm.readthedocs.io/en/latest/installation.html#ide-code-formatter). Additionally, be sure that
IntelliJ uses a single class import:
Expand Down
23 changes: 7 additions & 16 deletions tornado-assembly/src/bin/tornado-test
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,21 @@ __TEST_THE_WORLD__ = [

## Tests for Virtual Devices
TestEntry(testName="uk.ac.manchester.tornado.unittests.virtual.TestVirtualDeviceKernel",
testMethods=["testVirtualDeviceKernelGPU"],
testMethods=["testVirtualDeviceKernel"],
testParameters=[
"-Dtornado.device.desc=" + os.environ["TORNADO_SDK"] + "/examples/virtual-device-GPU.json",
"-Dtornado.print.kernel=True", "-Dtornado.virtual.device=True",
"-Dtornado.print.kernel.dir=" + os.environ["TORNADO_SDK"] + "/virtualKernelOut.out"]),
TestEntry(testName="uk.ac.manchester.tornado.unittests.virtual.TestVirtualDeviceKernel",
testMethods=["testVirtualDeviceKernelCPU"],
testParameters=[
"-Dtornado.device.desc=" + os.environ["TORNADO_SDK"] + "/examples/virtual-device-CPU.json",
"-Dtornado.print.kernel=True", "-Dtornado.virtual.device=True",
"-Dtornado.print.kernel=True",
"-Dtornado.virtual.device=True",
"-Dtornado.print.kernel.dir=" + os.environ["TORNADO_SDK"] + "/virtualKernelOut.out"]),
TestEntry(testName="uk.ac.manchester.tornado.unittests.virtual.TestVirtualDeviceFeatureExtraction",
testMethods=["testVirtualDeviceFeaturesGPU"],
testMethods=["testVirtualDeviceFeatures"],
testParameters=[
"-Dtornado.device.desc=" + os.environ["TORNADO_SDK"] + "/examples/virtual-device-GPU.json",
"-Dtornado.virtual.device=True", "-Dtornado.feature.extraction=True",
"-Dtornado.features.dump.dir=" + os.environ["TORNADO_SDK"] + "/virtualFeaturesOut.out"]),
TestEntry(testName="uk.ac.manchester.tornado.unittests.virtual.TestVirtualDeviceFeatureExtraction",
testMethods=["testVirtualDeviceFeaturesCPU"],
testParameters=[
"-Dtornado.device.desc=" + os.environ["TORNADO_SDK"] + "/examples/virtual-device-CPU.json",
"-Dtornado.virtual.device=True", "-Dtornado.feature.extraction=True",
"-Dtornado.virtual.device=True",
"-Dtornado.feature.extraction=True",
"-Dtornado.features.dump.dir=" + os.environ["TORNADO_SDK"] + "/virtualFeaturesOut.out"]),

## Tests for Multi-Thread and Memory
TestEntry(testName="uk.ac.manchester.tornado.unittests.multithreaded.TestMultiThreadedExecutionPlans",
testParameters=["-Dtornado.device.memory=4GB"]),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public List<Integer> enqueueWrite(long executionPlanId, final Object value, long

listEvents.add(headerEvent);
listEvents.add(returnEvent);
return useDeps ? listEvents : null;
return listEvents;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public List<Integer> enqueueWrite(long executionPlanId, Object reference, long b
}
returnEvents.add(internalEvent);
onDevice = true;
return useDeps ? returnEvents : null;
return returnEvents;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public List<Integer> enqueueWrite(long executionPlanId, final Object value, long
}
final int returnEvent = enqueueWriteArrayData(executionPlanId, toBuffer(), bufferOffset, bufferSize, array, hostOffset, (useDeps) ? events : null);
listEvents.add(returnEvent);
return useDeps ? listEvents : null;
return listEvents;
}

private int enqueueWriteArrayData(long executionPlanId, long bufferId, long offset, long bytes, Object value, long hostOffset, int[] waitEvents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public List<Integer> enqueueWrite(long executionPlanId, Object ref, long batchSi
eventList.addAll(field.enqueueWrite(executionPlanId, ref, (useDeps) ? events : null, useDeps));
}
}
return useDeps ? eventList : null;
return eventList;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
public class OCLTornadoDevice implements TornadoXPUDevice {

private static OCLBackendImpl driver = null;
private static boolean BENCHMARKING_MODE = Boolean.parseBoolean(System.getProperties().getProperty("tornado.benchmarking", "False"));
private static final Pattern NAME_PATTERN = Pattern.compile("^OpenCL (\\d)\\.(\\d).*");
private final OCLTargetDevice device;
private final int deviceIndex;
Expand Down Expand Up @@ -630,10 +629,11 @@ public synchronized long deallocate(DeviceBufferState deviceBufferState) {

@Override
public List<Integer> ensurePresent(long executionPlanId, Object object, DeviceBufferState state, int[] events, long batchSize, long offset) {
if (!state.hasContent() || BENCHMARKING_MODE) {
if (!state.hasContent()) {
state.setContents(true);
return state.getXPUBuffer().enqueueWrite(executionPlanId, object, batchSize, offset, events, events == null);
}
// return a NULL list
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void read(long executionPlanId, final Object reference) {

private MemorySegment getSegmentWithHeader(final Object reference) {
return switch (reference) {

case TornadoNativeArray tornadoNativeArray -> tornadoNativeArray.getSegmentWithHeader();
case TornadoCollectionInterface<?> tornadoCollectionInterface -> tornadoCollectionInterface.getSegmentWithHeader();
case TornadoImagesInterface<?> imagesInterface -> imagesInterface.getSegmentWithHeader();
Expand Down Expand Up @@ -168,7 +167,7 @@ public List<Integer> enqueueWrite(long executionPlanId, Object reference, long b
(useDeps) ? events : null);
}
returnEvents.add(internalEvent);
return useDeps ? returnEvents : null;
return returnEvents;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public List<Integer> enqueueWrite(long executionPlanId, final Object value, long
}
final int returnEvent = enqueueWriteArrayData(executionPlanId, toBuffer(), bufferSize, array, hostOffset, (useDeps) ? events : null);
listEvents.add(returnEvent);
return useDeps ? listEvents : null;
return listEvents;
}

private int enqueueWriteArrayData(long executionPlanId, long address, long bytes, Object value, long hostOffset, int[] waitEvents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@

public class PTXTornadoDevice implements TornadoXPUDevice {

private static final boolean BENCHMARKING_MODE = Boolean.parseBoolean(System.getProperties().getProperty("tornado.benchmarking", "False"));
private static PTXBackendImpl driver = null;
private final PTXDevice device;
private final int deviceIndex;
Expand Down Expand Up @@ -398,7 +397,7 @@ private XPUBuffer createMultiArrayWrapper(Class<?> componentType, Class<?> type,
*/
@Override
public List<Integer> ensurePresent(long executionPlanId, Object object, DeviceBufferState objectState, int[] events, long batchSize, long hostOffset) {
if (!objectState.hasContent() || BENCHMARKING_MODE) {
if (!objectState.hasContent()) {
objectState.setContents(true);
return objectState.getXPUBuffer().enqueueWrite(executionPlanId, object, batchSize, hostOffset, events, events != null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ private SPIRVByteBuffer buildArrayHeaderBatch(final long arraySize) {
return header;
}

// FIXME <REFACTOR> <S>
@Override
public List<Integer> enqueueWrite(long executionPlanId, Object reference, long batchSize, long hostOffset, int[] events, boolean useDeps) {
final T array = cast(reference);
Expand All @@ -227,20 +226,17 @@ public List<Integer> enqueueWrite(long executionPlanId, Object reference, long b

listEvents.add(headerEvent);
listEvents.add(returnEvent);
return useDeps ? listEvents : null;
return listEvents;
}

// FIXME <REFACTOR> <S>
private long sizeOf(final T array) {
return (long) arrayHeaderSize + ((long) Array.getLength(array) * (long) kind.getByteCount());
}

// FIXME <REFACTOR> <S>
private long sizeOfBatch(long batchSize) {
return (long) arrayHeaderSize + batchSize;
}

// FIXME <REFACTOR> <S>
@Override
public void allocate(Object objectReference, long batchSize) {
final T hostArray = cast(objectReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public List<Integer> enqueueWrite(long executionPlanId, Object reference, long b

}
returnEvents.add(internalEvent);
return useDeps ? returnEvents : null;
return returnEvents;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public List<Integer> enqueueWrite(long executionPlanId, Object ref, long batchSi
eventList.addAll(field.enqueueWrite(executionPlanId, ref, (useDeps) ? events : null, useDeps));
}
}
return useDeps ? eventList : null;
return eventList;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public List<Integer> enqueueWrite(long executionPlanId, final Object value, long
}
final int returnEvent = enqueueWriteArrayData(executionPlanId, toBuffer(), bufferOffset, bufferSize, array, hostOffset, (useDeps) ? events : null);
listEvents.add(returnEvent);
return useDeps ? listEvents : null;
return listEvents;
}

private int enqueueWriteArrayData(long executionPlanId, long bufferId, long offset, long bytes, Object value, long hostOffset, int[] waitEvents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
*/
public class SPIRVTornadoDevice implements TornadoXPUDevice {

private static final boolean BENCHMARKING_MODE = Boolean.parseBoolean(System.getProperties().getProperty("tornado.benchmarking", "False"));
private static SPIRVBackendImpl driver = null;
private final SPIRVDevice device;
private final int deviceIndex;
Expand Down Expand Up @@ -406,7 +405,7 @@ public synchronized long deallocate(DeviceBufferState deviceBufferState) {
*/
@Override
public List<Integer> ensurePresent(long executionPlanId, Object object, DeviceBufferState objectState, int[] events, long batchSize, long offset) {
if (!objectState.hasContent() || BENCHMARKING_MODE) {
if (!objectState.hasContent()) {
objectState.setContents(true);
return objectState.getXPUBuffer().enqueueWrite(executionPlanId, object, batchSize, offset, events, events == null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class XPUDeviceBufferState implements DeviceBufferState {
private XPUBuffer xpuBuffer;
private boolean atomicRegionPresent;

private boolean contents;
private boolean bufferHasContent;
private boolean lockBuffer;
private long partialSize;

Expand Down Expand Up @@ -68,12 +68,12 @@ public void setLockBuffer(boolean lockBuffer) {

@Override
public boolean hasContent() {
return contents;
return bufferHasContent;
}

@Override
public void setContents(boolean value) {
contents = value;
public void setContents(boolean content) {
bufferHasContent = content;
}

@Override
Expand Down
Loading

0 comments on commit f84aa53

Please sign in to comment.