From 1b238ff1076edf5004e18a28560497647ea7bdb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosmin=20=C8=98tefan=20Ciocan?= <57830279+cosminc98@users.noreply.github.com> Date: Sun, 2 Jun 2024 09:13:56 +0000 Subject: [PATCH] Create separate files for blur kernel and the error handling macro to make the main function more readable --- .../compiling-with-external-libraries.ipynb | 64 +++++++++++++------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/notebooks/compiling-with-external-libraries.ipynb b/notebooks/compiling-with-external-libraries.ipynb index 635a8f2..a1295d0 100644 --- a/notebooks/compiling-with-external-libraries.ipynb +++ b/notebooks/compiling-with-external-libraries.ipynb @@ -187,26 +187,10 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "hhkNS3HJlFlC", - "outputId": "bb0b3fad-f132-4a26-e247-32bf5e29c1a4" - }, + "metadata": {}, "outputs": [], "source": [ - "%%cuda --compiler-args \"$COMPILER_ARGS\"\n", - "\n", - "#include \n", - "#include \n", - "\n", - "#include \n", - "\n", - "#define BLUR_SIZE 5\n", - "#define R 0\n", - "#define G 1\n", - "#define B 2\n", + "%%cuda_group_save -n \"error_handling.h\" -g \"shared\"\n", "\n", "// error checking macro\n", "#define cudaCheckErrors(msg) \\\n", @@ -219,7 +203,18 @@ " fprintf(stderr, \"*** FAILED - ABORTING\\n\"); \\\n", " exit(1); \\\n", " } \\\n", - " } while (0)\n", + " } while (0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%cuda_group_save -n \"blur_kernel.h\" -g \"shared\"\n", + "\n", + "#define BLUR_SIZE 5\n", "\n", "// kernel taken from https://stackoverflow.com/a/65973288\n", "__global__ void blurKernel(\n", @@ -249,7 +244,34 @@ " }\n", " out[row * width * num_channel + col * num_channel + channel] = (unsigned char)(pixVal/pixels);\n", " }\n", - "}\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "hhkNS3HJlFlC", + "outputId": "bb0b3fad-f132-4a26-e247-32bf5e29c1a4" + }, + "outputs": [], + "source": [ + "%%cuda --compiler-args \"$COMPILER_ARGS\"\n", + "\n", + "#include \n", + "\n", + "#include \n", + "#include \n", + "\n", + "#include \"error_handling.h\"\n", + "#include \"blur_kernel.h\"\n", + "\n", + "#define R 0\n", + "#define G 1\n", + "#define B 2\n", "\n", "int main()\n", "{\n", @@ -354,7 +376,7 @@ "kaggle": { "accelerator": "nvidiaTeslaT4", "dataSources": [], - "dockerImageVersionId": 30699, + "dockerImageVersionId": 30716, "isGpuEnabled": true, "isInternetEnabled": true, "language": "python",