mirror of
https://github.com/andreinechaev/nvcc4jupyter.git
synced 2026-06-13 18:50:47 +05:30
Create separate files for blur kernel and the error handling macro to make the main function more readable
This commit is contained in:
@@ -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 <opencv2/core.hpp>\n",
|
||||
"#include <opencv2/imgcodecs.hpp>\n",
|
||||
"\n",
|
||||
"#include <iostream>\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 <iostream>\n",
|
||||
"\n",
|
||||
"#include <opencv2/core.hpp>\n",
|
||||
"#include <opencv2/imgcodecs.hpp>\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",
|
||||
|
||||
Reference in New Issue
Block a user