<commit_before>/*
Team: Packers
PID: 5642858
Class: CDA4101   Section: U02
Affirmation:
"I affirm that this program is entirely
my own work and none of it is the work
of any other person."
*/

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include "bmplib.h"

int img_pix[100000][100000][3] = {{{0}}};


//cuda function
__global__ void compressor(PIXEL * orig, int row, int col){
    // int n = blockIdx.x * blockDim.x + threadIdx.x;
    // int k = blockIdx.y * blockDim.y + threadIdx.y;
    int rows, cols;
    for(rows = 0; rows < row; rows++){
            for(cols = 0; cols < col; cols++){
                    PIXEL * test = orig + rows + cols;
                    img_pix[blockIdx.x][threadIdx.x][0] = (int)test -> r;
                    img_pix[blockIdx.x][threadIdx.x][1] = (int)test -> g;
                    img_pix[blockIdx.x][threadIdx.x][2] = (int)test -> b;
                    //img_pix[n][k][3] =;
                    printf("%d, %d, %d\n", img_pix[n][k][0], img_pix[n][k][1], img_pix[n][k][2]);
                    printf("rows: %d, cols: %d\n", rows, cols);

            }
        }

}
// middleware to handle gpu core and thread usage
void middleware(PIXEL* original, int rows, int cols, PIXEL* newImg){
    int numThreads = 1024;
    int numCores = (rows * cols) /  numThreads + 1;

    PIXEL* gpuAllocation;

    cudaMalloc(&gpuAllocation, (rows * cols));
    cudaMemcpy(gpuAllocation, original, (rows * cols), cudaMemcpyHostToDevice);
    compressor<<<numCores, numThreads>>>(original, rows, cols);
    cudaMemcpy(newImg, gpuAllocation, (rows * cols), cudaMemcpyDeviceToHost);
    cudaFree(&gpuAllocation);
}
int main (int agrc, char **agrv){
    FILE *inputfile;
    inputfile = fopen("image_list.txt", "r");
    char image_name[256];
    fgets(image_name, 256, (FILE*)inputfile);
    while(!feof(inputfile)){
        int row, col;
        PIXEL *uncompressed, *compressed;
        readFile("example.bmp", &row, &col, &uncompressed);
        middleware(uncompressed, row, col, compressed);

        fgets(image_name, 256, (FILE*)inputfile);
    }
}<commit_msg>made changes to kernel function in mian.cu<commit_after>/*
Team: Packers
PID: 5642858
Class: CDA4101   Section: U02
Affirmation:
"I affirm that this program is entirely
my own work and none of it is the work
of any other person."
*/

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include "bmplib.h"

int img_pix[100000][100000] = {{0}};


//cuda function
__global__ void compressor(PIXEL * orig, int row, int col, int img_pix[][]){
    // int n = blockIdx.x * blockDim.x + threadIdx.x;
    // int k = blockIdx.y * blockDim.y + threadIdx.y;
    int rows, cols;
    int gpu_pix [3] = {};
    for(rows = 0; rows < row; rows++){
            for(cols = 0; cols < col; cols++){
                    PIXEL * test = orig + rows + cols;
                    gpu_pix[0] = (int)test -> r;
                    gpu_pix[1] = (int)test -> g;
                    gpu_pix[2] = (int)test -> b;
                    img_pix[blockIdx.x][threadIdx.x] = gpu_pix;
                    //img_pix[n][k][3] =;
                    printf("%d, %d, %d\n", img_pix[blockIdx.x][threadIdx.x][0], img_pix[blockIdx.x][threadIdx.x][1], img_pix[blockIdx.x][threadIdx.x][2]);
                    printf("rows: %d, cols: %d\n", rows, cols);

            }
        }

}
// middleware to handle gpu core and thread usage
void middleware(PIXEL* original, int rows, int cols, PIXEL* newImg){
    int numThreads = 1024;
    int numCores = (rows * cols) /  numThreads + 1;

    PIXEL* gpuAllocation;

    cudaMalloc(&gpuAllocation, (rows * cols));
    cudaMemcpy(gpuAllocation, original, (rows * cols), cudaMemcpyHostToDevice);
    compressor<<<numCores, numThreads>>>(original, rows, cols, img_pix);
    cudaMemcpy(newImg, gpuAllocation, (rows * cols), cudaMemcpyDeviceToHost);
    cudaFree(&gpuAllocation);
}
int main (int agrc, char **agrv){
    FILE *inputfile;
    inputfile = fopen("image_list.txt", "r");
    char image_name[256];
    fgets(image_name, 256, (FILE*)inputfile);
    while(!feof(inputfile)){
        int row, col;
        PIXEL *uncompressed, *compressed;
        readFile("example.bmp", &row, &col, &uncompressed);
        middleware(uncompressed, row, col, compressed);

        fgets(image_name, 256, (FILE*)inputfile);
    }
}
{'fraction_non_alphanumeric': 0.1542528735632184, 'fraction_numerical': 0.022988505747126436, 'mean_word_length': 2.7411865864144453, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '25536', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1544, 'n_words': 382}