Skip to content

Commit

Permalink
Merge pull request #189 from pgleeson/ow-0.9.4
Browse files Browse the repository at this point in the history
Ow 0.9.4 - Passing tests building sibernetic using Intel and AMD drivers
  • Loading branch information
pgleeson authored Nov 17, 2023
2 parents 7e6dfd3 + 0e7f82a commit 6aeb352
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 67 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/ci-build-intel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build using Intel drivers

on:
push:
branches: [ master, dev*, ow* ]
pull_request:
branches: [ master, dev, ow* ]

jobs:

build:

runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [ ubuntu-latest, ubuntu-20.04 ]

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3

- name: Install Intel OpenCL libraries needed for Sibernetic
run: |
lscpu
echo "Installing OpenCL Drivers"
# Based on: https://github.com/openworm/OpenWorm/blob/master/Dockerfile
mkdir intel-opencl-tmp
cd intel-opencl-tmp
mkdir intel-opencl
wget https://github.com/openworm/OpenWorm/raw/dev_inte/SRB5.0_linux64.zip
unzip SRB5.0_linux64.zip
tar -C intel-opencl -Jxf intel-opencl-r5.0-63503.x86_64.tar.xz
tar -C intel-opencl -Jxf intel-opencl-devel-r5.0-63503.x86_64.tar.xz
tar -C intel-opencl -Jxf intel-opencl-cpu-r5.0-63503.x86_64.tar.xz
sudo cp -R intel-opencl/* /
sudo ldconfig
cd ..
sudo rm -r intel-opencl-tmp
sudo cp -R /opt/intel/opencl/include/CL /usr/include/
sudo apt install -y ocl-icd-opencl-dev vim
echo "OpenCL Driver Installation Complete"
- name: Build Sibernetic
run: |
sudo apt install -y python3-dev freeglut3-dev libglu1-mesa-dev
#sudo apt install -y --allow-downgrades libc-bin=2.27-3ubuntu1.5 # Fails with 2.27-3ubuntu1.6 for some reason...
python -V
ls -alt /usr/bin/python*
ls -alt
make clean
make
- name: Print info on executable
run: |
ldd ./Release/Sibernetic
echo "NOTE: not running Sibernetic on GitHub actions test with Intel drivers. Seg faults."
###./Release/Sibernetic -no_g timelimit=0.001
- name: Final version info
run: |
python -V
pip list
67 changes: 43 additions & 24 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Sibernetic
name: Build using AMD drivers

on:
push:
Expand All @@ -14,36 +14,55 @@ jobs:
strategy:
fail-fast: false
matrix:
runs-on: [ ubuntu-latest ]
runs-on: [ ubuntu-latest, ubuntu-20.04 ]

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Intel OpenCL libraries needed for Sibernetic
- name: Install AMD OpenCL libraries needed for Sibernetic
run: |
# Based on: https://github.com/openworm/OpenWorm/blob/master/Dockerfile
lscpu
mkdir intel-opencl-tmp
cd intel-opencl-tmp
mkdir intel-opencl
wget https://github.com/openworm/OpenWorm/raw/dev_inte/SRB5.0_linux64.zip
unzip SRB5.0_linux64.zip
tar -C intel-opencl -Jxf intel-opencl-r5.0-63503.x86_64.tar.xz
tar -C intel-opencl -Jxf intel-opencl-devel-r5.0-63503.x86_64.tar.xz
tar -C intel-opencl -Jxf intel-opencl-cpu-r5.0-63503.x86_64.tar.xz
sudo cp -R intel-opencl/* /
sudo ldconfig
cd ..
sudo rm -r intel-opencl-tmp
sudo cp -R /opt/intel/opencl/include/CL /usr/include/
sudo apt install -y ocl-icd-opencl-dev vim
echo "Installing OpenCL Drivers"
# Legacy install of Intel's OpenCL Drivers:
# Based on: https://github.com/openworm/OpenWorm/blob/master/Dockerfile
# mkdir intel-opencl-tmp
# cd intel-opencl-tmp
# mkdir intel-opencl
# wget https://github.com/openworm/OpenWorm/raw/dev_inte/SRB5.0_linux64.zip
# unzip SRB5.0_linux64.zip
# tar -C intel-opencl -Jxf intel-opencl-r5.0-63503.x86_64.tar.xz
# tar -C intel-opencl -Jxf intel-opencl-devel-r5.0-63503.x86_64.tar.xz
# tar -C intel-opencl -Jxf intel-opencl-cpu-r5.0-63503.x86_64.tar.xz
# sudo cp -R intel-opencl/* /
# sudo ldconfig
# cd ..
# sudo rm -r intel-opencl-tmp
# sudo cp -R /opt/intel/opencl/include/CL /usr/include/
# sudo apt install -y ocl-icd-opencl-dev vim
# Install AMD's OpenCL Drivers (AMD-APP-SDK 3.0):
wget https://master.dl.sourceforge.net/project/nicehashsgminerv5viptools/APP%20SDK%20A%20Complete%20Development%20Platform/AMD%20APP%20SDK%203.0%20for%2064-bit%20Linux/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
tar -xf AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
printf 'Y\n\n' | sudo ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh
sudo ln -s /opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libOpenCL.so.1 /usr/lib/libOpenCL.so.1
sudo ln -s /opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libamdocl64.so /usr/lib/libamdocl64.so
sudo apt install -y ocl-icd-opencl-dev
echo "OpenCL Driver Installation Complete"
echo "CLINFO:"
clinfo
- name: Build Sibernetic
run: |
Expand Down
2 changes: 1 addition & 1 deletion sibernetic_c302.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pprint
pp = pprint.PrettyPrinter(indent=4)

script_version = '0.1.4' # This will change at different rate to C++ code...
script_version = '0.1.5' # This will change at different rate to C++ code...

DEFAULTS = {'duration': 2.0,
'dt': 0.005,
Expand Down
9 changes: 2 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool load_to = false;
bool skip_display_particles = false;
bool skip_display_membranes = false;
bool skip_display_connections = false;
std::string version = "0.0.6";
std::string version = "0.0.7";

int usage() {
std::cout
Expand Down Expand Up @@ -103,13 +103,11 @@ int usage() {
}

int main(int argc, char **argv) {
int exitStatus;
std::cout << "S1\n";
int exitStatus = -1;
if (argc == 1) {
std::cout << "Sibernetic: no arguments specified, run method executing\n";
exitStatus = run(argc, argv);
} else {
std::cout << "S1e\n";
bool graph = true;
bool run_tests = false;

Expand All @@ -135,7 +133,6 @@ int main(int argc, char **argv) {
0) { // run load config from file mode
graph = true;
load_from_file = true;
std::cout << "S1f\n";
}
if (std::string("-skip_display_particles").compare(argv[i]) == 0) {
skip_display_particles = true;
Expand All @@ -154,9 +151,7 @@ int main(int argc, char **argv) {
test_energy_conservation(argc, argv);
} else

std::cout << "S1r\n";
exitStatus = run(argc, argv, graph);
}
std::cout << "S1n\n";
return exitStatus;
}
26 changes: 10 additions & 16 deletions src/owOpenCLSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@ owOpenCLSolver::owOpenCLSolver(const float *position_cpp,
const int *membraneData_cpp,
const int *particleMembranesList_cpp) {
try {
std::cout << "owC1\n";
initializeOpenCL(config);
std::cout << "owC10\n";
// Create OpenCL buffers
initializeBuffers(position_cpp, velocity_cpp, config,
elasticConnectionsData_cpp, membraneData_cpp,
particleMembranesList_cpp);
std::cout << "owC1a\n";
// Create OpenCL kernels
create_ocl_kernel("clearBuffers", clearBuffers);
create_ocl_kernel("findNeighbors", findNeighbors);
Expand All @@ -91,14 +88,13 @@ owOpenCLSolver::owOpenCLSolver(const float *position_cpp,
pcisph_computeElasticForces);
// membrane handling kernels

std::cout << "owC1b\n";
create_ocl_kernel("clearMembraneBuffers", clearMembraneBuffers);
create_ocl_kernel("computeInteractionWithMembranes",
computeInteractionWithMembranes);
create_ocl_kernel("computeInteractionWithMembranes_finalize",
computeInteractionWithMembranes_finalize);
} catch (std::runtime_error &ex) {
std::cout << "errrr\n";
std::cout << "Error in owOpenCLSolver.cpp!!\n";
destroy();
throw;
}
Expand Down Expand Up @@ -239,18 +235,14 @@ void owOpenCLSolver::initializeBuffers(const float *position_cpp,
* Contain information about simulating configuration
*/
void owOpenCLSolver::initializeOpenCL(owConfigProperty *config) {
std::cout << "owCi1\n";
cl_int err;
std::vector<cl::Platform> platformList;
std::cout << "owCi1a\n";
err = cl::Platform::get(
&platformList); // TODO make check that returned value isn't error
std::cout << "owCi1b\n";
if (platformList.size() < 1 || err != CL_SUCCESS) {
std::cout << "No OpenCL platforms found, error code: "<< err<< " \n";
throw std::runtime_error("No OpenCL platforms found");
}
std::cout << "owCi2\n";
char cBuffer[1024];
cl_platform_id cl_pl_id[10];
cl_uint n_pl;
Expand All @@ -262,12 +254,12 @@ void owOpenCLSolver::initializeOpenCL(owConfigProperty *config) {
ciErrNum = clGetPlatformInfo(cl_pl_id[i], CL_PLATFORM_VERSION,
sz = sizeof(cBuffer), cBuffer, nullptr);
if (ciErrNum == CL_SUCCESS) {
printf(" CL_PLATFORM_VERSION [%d]: \t%s\n", i, cBuffer);
printf(" CL_PLATFORM_VERSION [%d]: \t%s", i, cBuffer);
std::cout << std::endl;
} else {
printf(" Error %i in clGetPlatformInfo Call !!!\n\n", ciErrNum);
}
}
std::cout << "owCi2\n";
// 0-CPU, 1-GPU // depends on the time order of system OpenCL drivers
// installation on your local machine
// CL_DEVICE_TYPE
Expand All @@ -287,6 +279,7 @@ void owOpenCLSolver::initializeOpenCL(owConfigProperty *config) {
cl_uint device_coumpute_unit_num;
cl_uint device_coumpute_unit_num_current = 0;
unsigned int deviceNum = 0;

// Selection of more appropriate device
while (!findDevice) {
for (int clSelectedPlatformID = 0; clSelectedPlatformID < (int)n_pl;
Expand All @@ -297,8 +290,9 @@ void owOpenCLSolver::initializeOpenCL(owConfigProperty *config) {
device_type[config->getDeviceType()], 0, nullptr,
&ciDeviceCount);
if ((devices_t = static_cast<cl_device_id *>(
malloc(sizeof(cl_device_id) * ciDeviceCount))) == nullptr)
malloc(sizeof(cl_device_id) * ciDeviceCount))) == nullptr) {
bPassed = false;
}
if (bPassed) {
result = clGetDeviceIDs(cl_pl_id[clSelectedPlatformID],
device_type[config->getDeviceType()],
Expand Down Expand Up @@ -335,12 +329,13 @@ void owOpenCLSolver::initializeOpenCL(owConfigProperty *config) {
std::cout << "Unfortunately OpenCL couldn't find device "
<< deviceTypeName << std::endl;
std::cout << "OpenCL try to init existing device " << std::endl;
if (config->getDeviceType() != ALL)
if (config->getDeviceType() != ALL) {
config->setDeviceType(ALL);
else
} else {
throw std::runtime_error("Sibernetic can't find any OpenCL devices. "
"Please check you're environment "
"configuration.");
}
}
}
cl_context_properties cprops[3] = {
Expand All @@ -357,8 +352,7 @@ void owOpenCLSolver::initializeOpenCL(owConfigProperty *config) {
&cBuffer); // CL_INVALID_VALUE = -30;
if (result == CL_SUCCESS) {
std::cout << "CL_CONTEXT_PLATFORM [" << plList << "]: CL_DEVICE_NAME ["
<< deviceNum << "]:\t" << cBuffer << "\n"
<< std::endl;
<< deviceNum << "]:\t" << cBuffer << std::endl << std::endl;
}
if (strlen(cBuffer) < 1000) {
config->setDeviceName(cBuffer);
Expand Down
4 changes: 0 additions & 4 deletions src/owPhysicsFluidSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ owPhysicsFluidSimulator::owPhysicsFluidSimulator(owHelper *helper, int argc,
membraneData_cpp, particleMembranesList_cpp,
config); // Load configuration from file to buffer

std::cout << "owP1\n";
this->helper = helper;
std::cout << "owP1a\n";
if (config->numOfElasticP != 0) {
std::cout << "owP1b\n";
ocl_solver = new owOpenCLSolver(
position_cpp, velocity_cpp, config, elasticConnectionsData_cpp,
membraneData_cpp,
Expand All @@ -114,7 +111,6 @@ owPhysicsFluidSimulator::owPhysicsFluidSimulator(owHelper *helper, int argc,
throw;
}

std::cout << "owP2\n";
}
/** Reset simulation
*
Expand Down
1 change: 0 additions & 1 deletion src/owSignalSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ std::vector<float> SignalSimulator::run() {
// Call a method of the class
// pValue = PyObject_CallMethod(pInstance, "rrun
// un", nullptr);
std::cout << "S1s\n";
pValue = PyObject_CallMethod(pInstance, const_cast<char *>("run"), nullptr);
if (PyErr_Occurred()) {
PyErr_Print();
Expand Down
Loading

0 comments on commit 6aeb352

Please sign in to comment.