Skip to content

Commit

Permalink
Android build in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mfep committed Aug 22, 2023
1 parent cc06703 commit f15a4e4
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 23 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
run: $GITHUB_WORKSPACE/scripts/check-format.sh origin/${{ needs.get-branch.outputs.branch }} --binary clang-format

linux:
if: false
runs-on: ubuntu-latest
needs: format
strategy:
Expand Down Expand Up @@ -371,3 +372,43 @@ jobs:
- name: Run Ruby Samples
run: rake test
working-directory: ruby

android:
runs-on: ubuntu-latest
needs: format
strategy:
matrix:
ABI:
- arm64-v8a
- x86_64
API_LEVEL:
- android-29
- android-33
CONFIG:
- Debug
- Release
env:
CFLAGS: -Wall -Wextra -pedantic -Werror -Wno-error=gnu-statement-expression
CXXFLAGS: -Wall -Wextra -pedantic -Werror -Wno-error=missing-field-initializers
steps:
- name: Checkout OpenCL-SDK
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

- name: Configure
shell: bash
run: cmake
-G "Unix Makefiles"
-D CMAKE_BUILD_TYPE=${{matrix.CONFIG}}
-D CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake
-D ANDROID_ABI=${{matrix.ABI}}
-D ANDROID_PLATFORM=${{matrix.API_LEVEL}}
-D OPENCL_SDK_BUILD_OPENGL_SAMPLES=OFF
-S $GITHUB_WORKSPACE
-B $GITHUB_WORKSPACE/build

- name: Build
shell: bash
run: cmake --build $GITHUB_WORKSPACE/build --parallel `nproc`
3 changes: 2 additions & 1 deletion cmake/Modules/FindStb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ find_path (Stb_INCLUDE_PATH stb_image.h
PATH_SUFFIXES
include
include/stb
)
NO_CMAKE_FIND_ROOT_PATH
)

# handle the QUIETLY and REQUIRED arguments and set Stb_FOUND to
# TRUE if all listed variables are TRUE
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/FindTCLAP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ find_path (TCLAP_INCLUDE_PATH tclap/CmdLine.h
PATHS
${CMAKE_SOURCE_DIR}/include
${CMAKE_INSTALL_PREFIX}/include
NO_CMAKE_FIND_ROOT_PATH
)

# handle the QUIETLY and REQUIRED arguments and set TCLAP_FOUND to
Expand Down
2 changes: 1 addition & 1 deletion lib/include/CL/Utils/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ UTILS_EXPORT
cl_ulong cl_util_get_event_duration(const cl_event event,
const cl_profiling_info start,
const cl_profiling_info end,
cl_int* const error);
cl_int* const error);
5 changes: 0 additions & 5 deletions lib/src/Extensions/src/openclext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@

#include <vector>

static inline cl_platform_id _get_platform(cl_platform_id platform)
{
return platform;
}

static inline cl_platform_id _get_platform(cl_device_id device)
{
if (device == nullptr) return nullptr;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/SDK/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ namespace sdk {
data + im.width * im.height * im.pixel_size);

if (im.width && im.height && im.pixel_size
&& im.pixels.size() == im.width * im.height * im.pixel_size)
&& im.pixels.size()
== static_cast<size_t>(im.width * im.height * im.pixel_size))
err = CL_SUCCESS;
else
cl::util::detail::errHandler(CL_INVALID_ARG_VALUE, &err,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Utils/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ cl_int cl::util::write_binaries(const cl::Program::Binaries& binaries,
{
try
{
for (auto i = 0; i < binaries.size(); ++i)
for (auto i = 0ull; i < binaries.size(); ++i)
{
string binary_name = string(program_file_name) + "-"
+ devices.at(i).getInfo<CL_DEVICE_NAME>() + ".bin";
Expand Down
2 changes: 1 addition & 1 deletion samples/core/binaries/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int main(int argc, char *argv[])
cl_platform_id platform;
cl_device_id device;
cl_context context;
cl_command_queue queue;
cl_command_queue queue = NULL;

cl_program program;

Expand Down
4 changes: 2 additions & 2 deletions samples/core/blur/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ void BlurCppExample::finalize_blur()
// restore image type if needed
if (input_image.pixel_size != output_image.pixel_size)
{
const auto pixels = input_image.width * input_image.height,
pixel_size = output_image.pixel_size;
const size_t pixels = input_image.width * input_image.height,
pixel_size = output_image.pixel_size;
for (size_t i = 1; i < pixels; ++i)
memcpy(output_image.pixels.data() + pixel_size * i,
output_image.pixels.data() + 4 * i, pixel_size);
Expand Down
2 changes: 1 addition & 1 deletion samples/core/blur/blur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class BlurCppExample {
public:
BlurCppExample(int argc, char* argv[])
: gauss_kernel(nullptr), origin({ 0, 0 })
: origin({ 0, 0 }), gauss_kernel(nullptr)
{
parse_command_line(argc, argv);
}
Expand Down
6 changes: 3 additions & 3 deletions samples/core/copybuffer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ int main(int argc, char** argv)
}
else
{
for (size_t i = 1; i < argc; i++)
for (size_t i = 1; i < static_cast<size_t>(argc); i++)
{
if (!strcmp(argv[i], "-d"))
{
++i;
if (i < argc)
if (i < static_cast<size_t>(argc))
{
deviceIndex = strtoul(argv[i], NULL, 10);
}
}
else if (!strcmp(argv[i], "-p"))
{
++i;
if (i < argc)
if (i < static_cast<size_t>(argc))
{
platformIndex = strtoul(argv[i], NULL, 10);
}
Expand Down
6 changes: 3 additions & 3 deletions samples/core/copybufferkernel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ int main(int argc, char** argv)
}
else
{
for (size_t i = 1; i < argc; i++)
for (size_t i = 1; i < static_cast<size_t>(argc); i++)
{
if (!strcmp(argv[i], "-d"))
{
++i;
if (i < argc)
if (i < static_cast<size_t>(argc))
{
deviceIndex = strtoul(argv[i], NULL, 10);
}
}
else if (!strcmp(argv[i], "-p"))
{
++i;
if (i < argc)
if (i < static_cast<size_t>(argc))
{
platformIndex = strtoul(argv[i], NULL, 10);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/core/enumopencl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static cl_int PrintDeviceInfoSummary(cl_device_id* devices, cl_uint numDevices)
return errorCode;
}

int main(int argc, char** argv)
int main(void)
{
cl_uint numPlatforms = 0;
clGetPlatformIDs(0, NULL, &numPlatforms);
Expand Down
2 changes: 1 addition & 1 deletion samples/core/enumopencl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static cl_int PrintDeviceInfoSummary(const std::vector<cl::Device> devices)
return CL_SUCCESS;
}

int main(int argc, char** argv)
int main()
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
Expand Down
4 changes: 2 additions & 2 deletions samples/core/reduce/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ cl_int accumulate(cl_int *arr, size_t len, cl_int zero_elem,
cl_ulong new_size(const cl_ulong actual, const cl_ulong factor)
{
return actual / factor + (actual % factor == 0 ? 0 : 1);
};
}
// NOTE: because one work-group produces one output
// new_size == number_of_work_groups
size_t global(const size_t actual, const cl_ulong factor, const size_t wgs)
{
return new_size(actual, factor) * wgs;
};
}

// Random number generator state
pcg32_random_t rng;
Expand Down

0 comments on commit f15a4e4

Please sign in to comment.